FrmCL.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Text;
  7. using System.Windows.Forms;
  8. using System.Collections;
  9. using CoreFS.CA06;
  10. using Core.Mes.Client.Common;
  11. namespace Core.LgMes.Client.LgDeviceManager
  12. {
  13. public partial class FrmCL : FrmLgDevFunctions
  14. {
  15. public string strFlag = ""; //标识调用窗口 0 代表方坯结晶器管理, 1 代表板坯结晶器管理
  16. public string strID = ""; //ID
  17. public string strNO = ""; //结晶器编号
  18. public string strCCM = ""; //铸机号
  19. public string strPOS = ""; //流号
  20. public string strSTATUS = ""; //当前状态
  21. public FrmCL(OpeBase oba)
  22. {
  23. InitializeComponent();
  24. ob = oba;
  25. }
  26. private void FrmCL_Load(object sender, EventArgs e)
  27. {
  28. cmbCCM.Text = strCCM;
  29. this.ultraGroupBox1.Text = "[" + this.strCCM + "]-结晶器[" + this.strNO + "]";
  30. tbCurrPos.Text = ucmbPos.Text = this.strPOS;
  31. tbCurrStatus.Text = ucmbStatus.Text = this.strSTATUS;
  32. }
  33. private void btnclose_Click(object sender, EventArgs e)
  34. {
  35. this.Close();
  36. }
  37. private string proc_CodeNameExchangeStatus(bool bCodetoName, string str)
  38. {
  39. if (bCodetoName) //代码->名称
  40. {
  41. switch (str)
  42. {
  43. case "0":
  44. return "下线";
  45. case "1":
  46. return "上线";
  47. case "2":
  48. return "维修";
  49. case "3":
  50. return "备用";
  51. default:
  52. return "";
  53. }
  54. }
  55. else
  56. {
  57. switch (str)
  58. {
  59. case "下线":
  60. return "0";
  61. case "上线":
  62. return "1";
  63. case "维修":
  64. return "2";
  65. case "备用":
  66. return "3";
  67. default:
  68. return "";
  69. }
  70. }
  71. }
  72. private void proc_OK()
  73. {
  74. string strPosText = ""; //显示流名
  75. try
  76. {
  77. if ((strCCM == "1#连铸机" || strCCM == "2#连铸机") && cmbCCM.Text.Trim() == "3#连铸机")
  78. {
  79. MessageBox.Show("1#机、2#机不能与3#机共用同一个结晶器!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  80. return;
  81. }
  82. if (strCCM == "3#连铸机" && (cmbCCM.Text.Trim() == "1#连铸机" || cmbCCM.Text.Trim() == "2#连铸机"))
  83. {
  84. MessageBox.Show("3#机不能与1#、2#机共用同一个结晶器!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  85. return;
  86. }
  87. string strErr = "";
  88. string strSql = "select count(1) from DEV_JJQ_BASE_INFO where ID = '" + this.strID + "'";
  89. DataSet ds = QueryFixedFunions(strSql, ob);
  90. if (strErr != "" || !(ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0))
  91. {
  92. MessageBox.Show("[" + this.strCCM + "]结晶器[" + this.strNO + "]设置失败!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  93. return;
  94. }
  95. int iCnt = Convert.ToInt32(ds.Tables[0].Rows[0][0]);
  96. if (iCnt == 0)
  97. {
  98. MessageBox.Show("[" + this.strCCM + "]不存在结晶器[" + this.strNO + "],请录入基础信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  99. return;
  100. }
  101. string strPos = ucmbPos.Text.Trim();
  102. string strStatus = proc_CodeNameExchangeStatus(false, ucmbStatus.Text.Trim());
  103. if (strStatus == "")
  104. {
  105. MessageBox.Show("请选择状态!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
  106. ucmbStatus.Focus();
  107. return;
  108. }
  109. if (strStatus == "1" && strPos == "")
  110. {
  111. MessageBox.Show("请选择流号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
  112. ucmbPos.Focus();
  113. return;
  114. }
  115. if (ucmbStatus.Text.Trim() == "上线")
  116. {
  117. if (this.tbDM.Text == "" && this.txtWidth.Text == "")
  118. {
  119. MessageBox.Show("请输入断面信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
  120. ucmbStatus.Focus();
  121. return;
  122. }
  123. if (this.tbDM.Text == "")
  124. {
  125. MessageBox.Show("请输入断面厚度!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
  126. ucmbStatus.Focus();
  127. return;
  128. }
  129. if (this.txtWidth.Text == "")
  130. {
  131. MessageBox.Show("请输入断面宽度!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
  132. ucmbStatus.Focus();
  133. return;
  134. }
  135. }
  136. ds = null;
  137. strErr = "";
  138. strSql = "select NOWSTATUS, CCM_S_ID from DEV_JJQ_BASE_INFO where ID = '" + this.strID + "'";
  139. ds = QueryFixedFunions(strSql, ob);
  140. if (strErr != "" || !(ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0))
  141. {
  142. MessageBox.Show("[" + this.strCCM + "]结晶器[" + this.strNO + "]设置失败!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  143. return;
  144. }
  145. this.strPOS = Convert.ToString(ds.Tables[0].Rows[0]["CCM_S_ID"]); //原始状态
  146. this.strSTATUS = Convert.ToString(ds.Tables[0].Rows[0]["NOWSTATUS"]);
  147. tbCurrPos.Text = this.strPOS;
  148. tbCurrStatus.Text = proc_CodeNameExchangeStatus(true, this.strSTATUS);
  149. if (this.strSTATUS == "")
  150. {
  151. MessageBox.Show("[" + this.strCCM + "]结晶器[" + this.strNO + "]当前状态不明确,无法设置!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  152. return;
  153. }
  154. if ((this.strSTATUS == "0" && strStatus == "0") ||
  155. (this.strSTATUS == "2" && strStatus == "2") ||
  156. (this.strSTATUS == "3" && strStatus == "3") ||
  157. ((this.strSTATUS == "1" && strStatus == "1") && (this.strPOS == strPos)))
  158. {
  159. MessageBox.Show("操作无意义!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  160. ucmbStatus.Focus();
  161. return;
  162. }
  163. if (this.strSTATUS == "0" && strStatus == "1")
  164. {
  165. MessageBox.Show("不能将[" + this.strCCM + "]结晶器[" + this.strNO + "]从[下线]改为[上线]状态!\r\n如有必要,请先设置为[备用]状态!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  166. ucmbStatus.Focus();
  167. return;
  168. }
  169. if (this.strSTATUS == "1" && (strStatus == "2" || strStatus == "3"))
  170. {
  171. MessageBox.Show("不能将[" + this.strCCM + "]结晶器[" + this.strNO + "]从[上线]改为[维修]或[备用]状态!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  172. ucmbStatus.Focus();
  173. return;
  174. }
  175. if (this.strSTATUS == "2" && (strStatus == "0" || strStatus == "1"))
  176. {
  177. MessageBox.Show("不能将[" + this.strCCM + "]结晶器[" + this.strNO + "]从[维修]改为[下线]或[上线]状态!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  178. ucmbStatus.Focus();
  179. return;
  180. }
  181. if (this.strSTATUS == "3" && strStatus == "2")
  182. {
  183. MessageBox.Show("不能将[" + this.strCCM + "]结晶器[" + this.strNO + "]从[备用]改为[维修]状态!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  184. ucmbStatus.Focus();
  185. return;
  186. }
  187. if (this.strSTATUS == "0" && strStatus == "2")
  188. {
  189. if (MessageBox.Show("确定[" + this.strCCM + "]结晶器[" + this.strNO + "]开始维修吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
  190. {
  191. ucmbStatus.Focus();
  192. return;
  193. }
  194. }
  195. if (this.strSTATUS == "1" && strStatus == "0")
  196. {
  197. if (MessageBox.Show("确定[" + this.strCCM + "]结晶器[" + this.strNO + "][下线]吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
  198. {
  199. ucmbStatus.Focus();
  200. return;
  201. }
  202. }
  203. if (this.strSTATUS == "2" && strStatus == "3")
  204. {
  205. if (MessageBox.Show("确定[" + this.strCCM + "]结晶器[" + this.strNO + "]结束维修吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
  206. {
  207. ucmbStatus.Focus();
  208. return;
  209. }
  210. }
  211. if (strStatus == "1")
  212. {
  213. ds = null;
  214. strErr = "";
  215. strPosText = strPos;
  216. strSql = "select CRYSTALLIZERID from DEV_JJQ_BASE_INFO where NOWSTATUS = '1' and CCM_S_ID = '" + strPos + "' and CCM_ID = '" + cmbCCM.Text.Trim() + "'";
  217. ds = QueryFixedFunions(strSql, ob);
  218. if (strErr != "" || !(ds != null && ds.Tables.Count > 0))
  219. {
  220. MessageBox.Show("[" + this.strCCM + "]结晶器[" + this.strNO + "]设置失败!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  221. return;
  222. }
  223. if (ds.Tables[0].Rows.Count > 0)
  224. {
  225. string str = Convert.ToString(ds.Tables[0].Rows[0]["CRYSTALLIZERID"]);
  226. if (MessageBox.Show("当前结晶器[" + str + "]处于[" + cmbCCM.Text.Trim() + "][" + strPosText + "],确定要替换为结晶器[" + this.strNO + "]吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
  227. {
  228. ucmbStatus.Focus();
  229. return;
  230. }
  231. }
  232. }
  233. string[] strParams = new string[6] { this.strID, strPos, strStatus, CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName(), tbDM.Text.Trim() + "X" + txtWidth.Text.Trim(),cmbCCM.Text.Trim() };
  234. string msg = "";
  235. strErr = "";
  236. ProcedureZ("Core.LgMes.Server.DEV.Methods.DEVPublicMethods", "procedure", new object[] { "RES_LG_TOOLMANAGE.JJQSTATUS_CHANGE", strParams }, ob, out strErr, out msg);
  237. if (Convert.ToInt32(strErr) > 0)
  238. {
  239. if (strFlag == "0")
  240. {
  241. FrmCrystallizerManage frm = (FrmCrystallizerManage)this.Tag;
  242. frm.proc_GetBaseInfo(this.strCCM, this.strNO);
  243. }
  244. else if (strFlag == "1")
  245. {
  246. FrmCrystallizerManageBP frm = (FrmCrystallizerManageBP)this.Tag;
  247. frm.proc_GetBaseInfo(this.strCCM, this.strNO);
  248. }
  249. MessageBox.Show(msg, "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  250. JJQCcmNo_Edit();
  251. FrmCrystallizerManageBP frmCL = (FrmCrystallizerManageBP)this.Tag;
  252. frmCL.proc_GetBaseInfo(this.strCCM, this.strNO);
  253. this.Close();
  254. }
  255. else
  256. MessageBox.Show(msg, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  257. }
  258. catch (Exception ex)
  259. {
  260. MessageBox.Show(ex.Message);
  261. }
  262. }
  263. /// <summary>
  264. /// 修改结晶器对应的铸机号
  265. /// </summary>
  266. public void JJQCcmNo_Edit()
  267. {
  268. string strErr = "";
  269. ArrayList arry = new ArrayList();
  270. arry.Add("FrmJJQ_CCMNO.Edit");
  271. arry.Add(this.cmbCCM.Text);
  272. arry.Add(strNO);
  273. arry.Add(strID);
  274. CommonClientToServer cctos = new CommonClientToServer();
  275. cctos.ob = this.ob;
  276. DataSet ds = cctos.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBSave",
  277. "doSimpleSave", arry, out strErr);
  278. if (strErr != "" && ds != null)
  279. {
  280. MessageBox.Show(strErr);
  281. }
  282. }
  283. private void btnOK_Click(object sender, EventArgs e)
  284. {
  285. this.proc_OK();
  286. }
  287. private void tbDM_KeyPress(object sender, KeyPressEventArgs e)
  288. {
  289. try
  290. {
  291. if (!(Char.IsNumber(e.KeyChar) || e.KeyChar == '\b' || e.KeyChar == '.'))
  292. e.Handled = true;
  293. }
  294. catch { }
  295. }
  296. private void txtWidth_KeyPress(object sender, KeyPressEventArgs e)
  297. {
  298. try
  299. {
  300. if (!(Char.IsNumber(e.KeyChar) || e.KeyChar == '\b' || e.KeyChar == '.'))
  301. e.Handled = true;
  302. }
  303. catch { }
  304. }
  305. }
  306. }