FrmZEROCL.cs 14 KB

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