FrmTD.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  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 CoreFS.CA06;
  9. using System.Collections;
  10. using Core.Mes.Client.Common;
  11. namespace Core.LgMes.Client.LgDeviceManager
  12. {
  13. public partial class FrmTD : FrmLgDevFunctions
  14. {
  15. public string strID = ""; //ID
  16. public string strNO = ""; //中间包编号
  17. public string strCCM = ""; //铸机号
  18. public string strPOS = ""; //工位
  19. public string strSTATUS = ""; //当前状态
  20. public FrmTD(OpeBase oba)
  21. {
  22. InitializeComponent();
  23. ob = oba;
  24. }
  25. private void FrmTD_Load(object sender, EventArgs e)
  26. {
  27. this.ultraGroupBox1.Text = "[" + this.strCCM + "]-中间包[" + this.strNO + "]";
  28. txtCurrPos.Text = ucmePos.Text = this.strPOS;
  29. txtCurrStatus.Text = ucmeStatus.Text = this.strSTATUS;
  30. cmbCCM.Text = strCCM;
  31. }
  32. private void btnclose_Click(object sender, EventArgs e)
  33. {
  34. this.Close();
  35. }
  36. private string proc_CodeNameExchangeStatus(bool bCodetoName, string str)
  37. {
  38. if (bCodetoName) //代码->名称
  39. {
  40. switch (str)
  41. {
  42. case "0":
  43. return "下线";
  44. case "1":
  45. return "等待位";
  46. case "2":
  47. return "浇铸位";
  48. case "3":
  49. return "备用";
  50. default:
  51. return "";
  52. }
  53. }
  54. else
  55. {
  56. switch (str)
  57. {
  58. case "下线":
  59. return "0";
  60. case "等待位":
  61. return "1";
  62. case "浇铸位":
  63. return "2";
  64. case "备用":
  65. return "3";
  66. default:
  67. return "";
  68. }
  69. }
  70. }
  71. private string proc_CodeNameExchangePosition(bool bCodetoName, string str)
  72. {
  73. if (bCodetoName) //代码->名称
  74. {
  75. switch (str)
  76. {
  77. case "1":
  78. return "南";
  79. case "2":
  80. return "北";
  81. default:
  82. return "";
  83. }
  84. }
  85. else
  86. {
  87. switch (str)
  88. {
  89. case "南":
  90. return "1";
  91. case "北":
  92. return "2";
  93. default:
  94. return "";
  95. }
  96. }
  97. }
  98. private void proc_OK()
  99. {
  100. try
  101. {
  102. if ((strCCM == "1#连铸机" || strCCM == "2#连铸机") && cmbCCM.Text.Trim() == "3#连铸机")
  103. {
  104. MessageBox.Show("1#机、2#机不能与3#机共用同一个中间包!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  105. return;
  106. }
  107. if (strCCM == "3#连铸机" && (cmbCCM.Text.Trim() == "1#连铸机" || cmbCCM.Text.Trim() == "2#连铸机"))
  108. {
  109. MessageBox.Show("3#机不能与1#、2#机共用同一个中间包!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  110. return;
  111. }
  112. string strErr = "";
  113. string strSql = "select count(1) from DEV_ZJB_BASE_INFO where ID = '" + this.strID + "'";
  114. DataSet ds = QueryFixedFunions(strSql, ob);
  115. if (strErr != "" || !(ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0))
  116. {
  117. MessageBox.Show("[" + this.strCCM + "]中间包[" + this.strNO + "]设置失败!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  118. return;
  119. }
  120. int iCnt = Convert.ToInt32(ds.Tables[0].Rows[0][0]);
  121. if (iCnt == 0)
  122. {
  123. MessageBox.Show("[" + this.strCCM + "]不存在中间包[" + this.strNO + "],请录入基础信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  124. return;
  125. }
  126. string strPos = proc_CodeNameExchangePosition(false, ucmePos.Text.Trim());
  127. string strStatus = proc_CodeNameExchangeStatus(false, ucmeStatus.Text.Trim());
  128. if (strStatus == "")
  129. {
  130. MessageBox.Show("请选择状态!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
  131. ucmeStatus.Focus();
  132. return;
  133. }
  134. if (strStatus == "1" && strPos == "")
  135. {
  136. MessageBox.Show("请选择工位!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
  137. ucmePos.Focus();
  138. return;
  139. }
  140. ds = null;
  141. strErr = "";
  142. strSql = "select STATUS, POSITIONID from DEV_ZJB_BASE_INFO where ID = '" + this.strID + "'";
  143. ds = QueryFixedFunions(strSql, ob);
  144. if (strErr != "" || !(ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0))
  145. {
  146. MessageBox.Show("[" + this.strCCM + "]中间包[" + this.strNO + "]设置失败!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  147. return;
  148. }
  149. this.strPOS = Convert.ToString(ds.Tables[0].Rows[0]["POSITIONID"]); //原始状态
  150. this.strSTATUS = Convert.ToString(ds.Tables[0].Rows[0]["STATUS"]);
  151. txtCurrPos.Text = proc_CodeNameExchangePosition(true, this.strPOS);
  152. txtCurrStatus.Text = proc_CodeNameExchangeStatus(true, this.strSTATUS);
  153. if (this.strSTATUS == "")
  154. {
  155. MessageBox.Show("[" + this.strCCM + "]中间包[" + this.strNO + "]当前状态不明确,无法设置!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  156. return;
  157. }
  158. if ((this.strSTATUS == "0" && strStatus == "0") ||
  159. (this.strSTATUS == "2" && strStatus == "2") ||
  160. (this.strSTATUS == "3" && strStatus == "3") ||
  161. ((this.strSTATUS == "1" && strStatus == "1") && (this.strPOS == strPos)))
  162. {
  163. MessageBox.Show("操作无意义!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  164. ucmeStatus.Focus();
  165. return;
  166. }
  167. if (this.strSTATUS == "0" && (strStatus == "1" || strStatus == "2"))
  168. {
  169. MessageBox.Show("不能将[" + this.strCCM + "]中间包[" + this.strNO + "]从[下线]状态发至[等待位]或[浇铸位]!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  170. ucmeStatus.Focus();
  171. return;
  172. }
  173. if ((this.strSTATUS == "1" || this.strSTATUS == "2") && strStatus == "3")
  174. {
  175. MessageBox.Show("不能将[" + this.strCCM + "]中间包[" + this.strNO + "]从[等待位]或[浇铸位]改为[备用]状态!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  176. ucmeStatus.Focus();
  177. return;
  178. }
  179. if ((this.strSTATUS == "1" || this.strSTATUS == "2") && strStatus == "0")
  180. {
  181. if (MessageBox.Show("确定[" + this.strCCM + "]中间包[" + this.strNO + "]从" + (this.strSTATUS == "1" ? "[" + ucmePos.Text.Trim() + "]工位[等待位]" : "[浇铸位]") + "[下线]吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
  182. {
  183. ucmeStatus.Focus();
  184. return;
  185. }
  186. }
  187. if (strStatus == "1" || strStatus == "2")
  188. {
  189. ds = null;
  190. strErr = "";
  191. if (strStatus == "2")
  192. strSql = "select * from DEV_ZJB_BASE_INFO where CCM_ID = '" + this.strCCM + "' and ID <> '" + this.strID + "' and STATUS = '" + strStatus + "'";
  193. else
  194. strSql = "select * from DEV_ZJB_BASE_INFO where CCM_ID = '" + this.strCCM + "' and ID <> '" + this.strID + "' and STATUS = '" + strStatus + "' and POSITIONID = '" + strPos + "'";
  195. ds = QueryFixedFunions(strSql, ob);
  196. if (strErr != "")
  197. {
  198. MessageBox.Show("[" + this.strCCM + "]中间包[" + this.strNO + "]设置失败!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  199. return;
  200. }
  201. if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
  202. {
  203. string str = Convert.ToString(ds.Tables[0].Rows[0]["TUNDISHID"]);
  204. string strMsg = "";
  205. if (strStatus == "1")
  206. strMsg = "当前[" + this.strCCM + "]中间包[" + str + "]处于[" + ucmePos.Text.Trim() + "][" + ucmeStatus.Text.Trim() + "],你要替换为中间包[" + this.strNO + "]吗?";
  207. else if (strStatus == "2")
  208. strMsg = "当前[" + this.strCCM + "]中间包[" + str + "]处于[" + ucmeStatus.Text.Trim() + "],你要替换为中间包[" + this.strNO + "]吗?";
  209. if (MessageBox.Show(strMsg, "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
  210. return;
  211. }
  212. }
  213. string[] strParams = new string[3] { this.strID, strPos, strStatus };
  214. strErr = "";
  215. string msg = "";
  216. ProcedureZ("Core.LgMes.Server.DEV.Methods.DEVPublicMethods", "procedure", new object[] { "RES_LG_TOOLMANAGE.ZJBSTATUS_CHANGE", strParams },ob, out strErr, out msg);
  217. if (Convert.ToInt32(strErr) > 0)
  218. {
  219. FrmTundishManage frm = (FrmTundishManage)this.Tag;
  220. frm.QueryZJBData(this.strCCM, this.strNO);
  221. MessageBox.Show(msg, "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  222. //修改中间包铸机号
  223. ZJBCcmNo_Edit();
  224. this.Close();
  225. }
  226. else
  227. MessageBox.Show(msg, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  228. }
  229. catch (Exception ex)
  230. {
  231. MessageBox.Show(ex.Message);
  232. }
  233. }
  234. /// <summary>
  235. /// 修改中间包对应的铸机号
  236. /// </summary>
  237. public void ZJBCcmNo_Edit()
  238. {
  239. string strErr = "";
  240. ArrayList arry = new ArrayList();
  241. arry.Add("FrmZJB_CCMNO.Edit");
  242. arry.Add(this.cmbCCM.Text);
  243. arry.Add(strNO);
  244. arry.Add(strID);
  245. CommonClientToServer cctos = new CommonClientToServer();
  246. cctos.ob = this.ob;
  247. DataSet ds = cctos.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBSave",
  248. "doSimpleSave", arry, out strErr);
  249. if (strErr != "" && ds != null)
  250. {
  251. MessageBox.Show(strErr);
  252. }
  253. FrmTundishManage frm = (FrmTundishManage)this.Tag;
  254. frm.QueryZJBData(this.strCCM, this.strNO);
  255. }
  256. private void btnOK_Click(object sender, EventArgs e)
  257. {
  258. this.proc_OK();
  259. }
  260. }
  261. }