FrmVTHot.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462
  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 Core.Mes.Client.Common;
  10. using System.Collections;
  11. namespace Core.LgMes.Client.LgDeviceManager
  12. {
  13. public partial class FrmVTHot : Core.Mes.Client.Common.frmStyleBase
  14. {
  15. bool bOK = false; //是否响应槽车号选择改变事件
  16. public string strNo = "", strRHS = "";
  17. public FrmVTHot(OpeBase oba)
  18. {
  19. InitializeComponent();
  20. ob=oba;
  21. }
  22. private void FrmVTHot_Load(object sender, EventArgs e)
  23. {
  24. if (strRHS.Length > 0)
  25. {
  26. cmbRHS.Text = strRHS;
  27. this.cbbCCM_SelectedIndexChanged(this, null);
  28. if (strNo.Length > 0)
  29. {
  30. cmbID.Text = strNo;
  31. bOK = true;
  32. this.cbbID_SelectedIndexChanged(this, null);
  33. }
  34. }
  35. else
  36. {
  37. bOK = true;
  38. proc_ResetControl();
  39. btnBegin.Enabled = btnEnd.Enabled = false;
  40. }
  41. }
  42. /// <summary>
  43. /// 槽车号加载
  44. /// </summary>
  45. /// <param name="strRHS"></param>
  46. private void proc_GetID(string strRHS)
  47. {
  48. try
  49. {
  50. if (strRHS.Length == 0)
  51. return;
  52. string strErr = "";
  53. ArrayList arry = new ArrayList();
  54. arry.Add("FrmVTHot_Query3");
  55. arry.Add(strRHS);
  56. CommonClientToServer ccs = new CommonClientToServer();
  57. ccs.ob = this.ob;
  58. DataSet ds = ccs.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBQuery", "doSimpleQuery", arry, out strErr);
  59. if (strErr != "" || !(ds != null && ds.Tables.Count > 0))
  60. {
  61. MessageBox.Show("槽车号加载失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  62. if (MessageBox.Show("是否重新加载槽车号?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
  63. proc_GetID(strRHS);
  64. return;
  65. }
  66. cmbID.DataSource = ds.Tables[0];
  67. cmbID.DisplayMember = "TANKCARID";
  68. if (ds.Tables[0].Rows.Count == 0)
  69. {
  70. proc_ResetControl();
  71. btnBegin.Enabled = btnEnd.Enabled = false;
  72. }
  73. }
  74. catch (Exception ex)
  75. {
  76. MessageBox.Show(ex.Message);
  77. }
  78. }
  79. private void proc_ResetControl()
  80. {
  81. try
  82. {
  83. cmbID.Text = "";
  84. txtID1.Clear();
  85. txtID2.Clear();
  86. txtID3.Clear();
  87. txtCS1.Clear();
  88. txtCS2.Clear();
  89. txtCS3.Clear();
  90. udteStart.Text = "";
  91. udteEnd.Text = "";
  92. txtPeriod.Clear();
  93. txtMemo.Clear();
  94. }
  95. catch (Exception ex)
  96. {
  97. MessageBox.Show(ex.Message);
  98. }
  99. }
  100. /// <summary>
  101. /// 烘烤开始
  102. /// </summary>
  103. private void proc_Begin()
  104. {
  105. try
  106. {
  107. if (cmbID.Items.Count == 0)
  108. return;
  109. string strRhs = cmbRHS.Text.Trim();
  110. string strID = cmbID.Text.Trim();
  111. if (strID.Length == 0)
  112. {
  113. MessageBox.Show("请选择需要烘烤的槽车编号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  114. cmbID.Focus();
  115. return;
  116. }
  117. if (udteStart.Text.Trim().Length == 0)
  118. udteStart.DateTime = DateTime.Now;
  119. if (MessageBox.Show("确定要烘烤[" + strRhs + "]的槽车[" + strID + "]吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
  120. {
  121. proc_GetID(strRhs);
  122. return;
  123. }
  124. string strErr = "";
  125. ArrayList arry = new ArrayList();
  126. arry.Add("FrmVTHot_Query4");
  127. arry.Add(strRhs);
  128. arry.Add(strID);
  129. CommonClientToServer ccs = new CommonClientToServer();
  130. ccs.ob = this.ob;
  131. DataSet ds = ccs.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBQuery", "doSimpleQuery", arry, out strErr);
  132. if (strErr != "" || !(ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0))
  133. {
  134. MessageBox.Show("[" + strRhs + "]槽车[" + strID + "]烘烤信息保存失败!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  135. return;
  136. }
  137. int iCnt = Convert.ToInt32(ds.Tables[0].Rows[0][0]);
  138. if (iCnt == 0)
  139. {
  140. MessageBox.Show("[" + strRhs + "]不存在槽车[" + strID + "]信息,无法烘烤!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  141. proc_GetID(strRhs);
  142. cmbID.Focus();
  143. return;
  144. }
  145. iCnt = 0;
  146. ds = null;
  147. strErr = "";
  148. arry.Clear();
  149. ccs.ob = this.ob;
  150. arry.Add("FrmVTHot_Query5");
  151. arry.Add(strRhs);
  152. arry.Add(strID);
  153. ds = ccs.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBQuery", "doSimpleQuery", arry, out strErr);
  154. if (strErr != "" || !(ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0))
  155. {
  156. MessageBox.Show("[" + strRhs + "]槽车[" + strID + "]烘烤信息保存失败!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  157. return;
  158. }
  159. if (Convert.ToString(ds.Tables[0].Rows[0]["NOWSTATUS"].ToString().Trim()) != "下线")
  160. {
  161. MessageBox.Show("[" + strRhs + "]槽车[" + strID + "]当前状态[" + Convert.ToString(ds.Tables[0].Rows[0]["NOWSTATUS"]) + "],只有在[下线]状态才能烘烤!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  162. cmbID.Focus();
  163. return;
  164. }
  165. string strReturn = "";
  166. strErr = "";
  167. arry.Clear();
  168. ccs.ob = ob;
  169. arry.Add("FrmVTHot_Add.1");
  170. arry.Add(strID);
  171. arry.Add(strRhs);
  172. arry.Add(udteStart.DateTime.ToString("yyyy-MM-dd HH:mm:ss"));
  173. arry.Add(txtMemo.Text.Trim());
  174. strReturn = ccs.NoQueryFunctions("Core.LgMes.Server.Common.ComDBSave", "doSimpleSave", arry, out strErr);
  175. if (!(strErr == null || strErr == ""))
  176. {
  177. MessageBox.Show("[" + strRhs + "]槽车[" + strID + "]烘烤信息保存失败!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  178. return;
  179. }
  180. strErr = "";
  181. arry.Clear();
  182. ccs.ob = ob;
  183. arry.Add("FrmVTHot_Update.1");
  184. arry.Add(strRhs);
  185. arry.Add(strID);
  186. strReturn = ccs.NoQueryFunctions("Core.LgMes.Server.Common.ComDBSave", "doSimpleSave", arry, out strErr);
  187. if (!(strErr == null || strErr == ""))
  188. {
  189. MessageBox.Show("[" + strRhs + "]槽车[" + strID + "]烘烤信息保存失败!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  190. return;
  191. }
  192. FrmVacuumTankManage frm = (FrmVacuumTankManage)this.Tag;
  193. frm.proc_GetBaseInfo(strRhs, strID);
  194. proc_GetID(strRhs);
  195. MessageBox.Show("[" + strRhs + "]槽车[" + strID + "]烘烤信息保存成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  196. return;
  197. }
  198. catch (Exception ex)
  199. {
  200. MessageBox.Show(ex.Message);
  201. }
  202. }
  203. /// <summary>
  204. /// 烘烤结束
  205. /// </summary>
  206. private void proc_End()
  207. {
  208. try
  209. {
  210. if (cmbID.Items.Count == 0)
  211. return;
  212. string strRhs = cmbRHS.Text.Trim();
  213. string strID = cmbID.Text.Trim();
  214. if (strID.Length == 0)
  215. {
  216. MessageBox.Show("请选择烘烤中的槽车编号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  217. cmbID.Focus();
  218. return;
  219. }
  220. if (udteEnd.Text.Trim().Length == 0)
  221. udteEnd.DateTime = DateTime.Now;
  222. if (udteStart.DateTime > udteEnd.DateTime)
  223. {
  224. MessageBox.Show("烘烤开始时刻不能大于烘烤结束时刻!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
  225. udteEnd.Focus();
  226. return;
  227. }
  228. if (MessageBox.Show("确定[" + strRhs + "]槽车[" + strID + "]烘烤结束吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
  229. {
  230. proc_GetID(strRhs);
  231. return;
  232. }
  233. string strErr = "";
  234. ArrayList arry = new ArrayList();
  235. arry.Add("FrmVTHot_Query6");
  236. arry.Add(strRhs);
  237. arry.Add(strID);
  238. CommonClientToServer ccs = new CommonClientToServer();
  239. ccs.ob = this.ob;
  240. DataSet ds = ccs.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBQuery", "doSimpleQuery", arry, out strErr);
  241. if (strErr != "" || !(ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0))
  242. {
  243. MessageBox.Show("[" + strRhs + "]槽车[" + strID + "]烘烤信息保存失败!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  244. return;
  245. }
  246. int iCnt = Convert.ToInt32(ds.Tables[0].Rows[0][0]);
  247. if (iCnt == 0)
  248. {
  249. MessageBox.Show("[" + strRhs + "]槽车[" + strID + "]信息不存在,无法保存烘烤信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  250. proc_GetID(strRhs);
  251. cmbID.Focus();
  252. return;
  253. }
  254. iCnt = 0;
  255. ds = null;
  256. strErr = "";
  257. arry.Clear();
  258. ccs.ob = ob;
  259. arry.Add("FrmVTHot_Query7");
  260. arry.Add(strRhs);
  261. arry.Add(strID);
  262. ds = ccs.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBQuery", "doSimpleQuery", arry, out strErr);
  263. if (strErr != "" || !(ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0))
  264. {
  265. MessageBox.Show("[" + strRhs + "]槽车[" + strID + "]烘烤信息保存失败!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  266. return;
  267. }
  268. if (Convert.ToString(ds.Tables[0].Rows[0]["NOWSTATUS"].ToString().Trim()) != "烘烤")
  269. {
  270. MessageBox.Show("[" + strRhs + "]槽车[" + strID + "]当前状态[" + Convert.ToString(ds.Tables[0].Rows[0]["NOWSTATUS"]) + "],只有在[烘烤]状态才能结束烘烤!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  271. cmbID.Focus();
  272. return;
  273. }
  274. string strReturn = "";
  275. strErr = "";
  276. arry.Clear();
  277. ccs.ob = ob;
  278. arry.Add("FrmVTHot_Update.2");
  279. arry.Add(udteStart.DateTime.ToString("yyyy-MM-dd HH:mm:ss"));
  280. arry.Add(udteEnd.DateTime.ToString("yyyy-MM-dd HH:mm:ss"));
  281. arry.Add(txtMemo.Text.Trim());
  282. arry.Add(strID);
  283. arry.Add(strRhs);
  284. strReturn = ccs.NoQueryFunctions("Core.LgMes.Server.Common.ComDBSave", "doSimpleSave", arry, out strErr);
  285. if (!(strErr == null || strErr == ""))
  286. {
  287. MessageBox.Show("[" + strRhs + "]槽车[" + strID + "]烘烤信息保存失败!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  288. return;
  289. }
  290. strErr = "";
  291. arry.Clear();
  292. ccs.ob = ob;
  293. arry.Add("FrmVTHot_Update.3");
  294. arry.Add(strRhs);
  295. arry.Add(strID);
  296. strReturn = ccs.NoQueryFunctions("Core.LgMes.Server.Common.ComDBSave", "doSimpleSave", arry, out strErr);
  297. if (!(strErr == null || strErr == ""))
  298. {
  299. MessageBox.Show("[" + strRhs + "]槽车[" + strID + "]烘烤信息保存失败!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  300. return;
  301. }
  302. FrmVacuumTankManage frm = (FrmVacuumTankManage)this.Tag;
  303. frm.proc_GetBaseInfo(strRhs, strID);
  304. proc_GetID(strRhs);
  305. MessageBox.Show("[" + strRhs + "]槽车[" + strID + "]烘烤信息保存成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  306. return;
  307. }
  308. catch (Exception ex)
  309. {
  310. MessageBox.Show(ex.Message);
  311. }
  312. }
  313. /// <summary>
  314. /// 烘烤开始
  315. /// </summary>
  316. /// <param name="sender"></param>
  317. /// <param name="e"></param>
  318. private void btnBegin_Click(object sender, EventArgs e)
  319. {
  320. proc_Begin();
  321. }
  322. /// <summary>
  323. /// 烘烤结束
  324. /// </summary>
  325. /// <param name="sender"></param>
  326. /// <param name="e"></param>
  327. private void btnEnd_Click(object sender, EventArgs e)
  328. {
  329. proc_End();
  330. }
  331. private void cbbCCM_SelectedIndexChanged(object sender, EventArgs e)
  332. {
  333. if (cmbRHS.Text.Length > 0)
  334. proc_GetID(cmbRHS.Text);
  335. }
  336. /// <summary>
  337. /// 烘烤信息
  338. /// </summary>
  339. /// <param name="sender"></param>
  340. /// <param name="e"></param>
  341. private void cbbID_SelectedIndexChanged(object sender, EventArgs e)
  342. {
  343. try
  344. {
  345. if (!bOK)
  346. return;
  347. string strRhs = cmbRHS.Text.Trim();
  348. string strID = cmbID.Text.Trim();
  349. if (strID.Length == 0)
  350. {
  351. txtID1.Clear();
  352. txtID2.Clear();
  353. txtID3.Clear();
  354. txtCS1.Clear();
  355. txtCS2.Clear();
  356. txtCS3.Clear();
  357. udteStart.Text = "";
  358. udteEnd.Text = "";
  359. txtPeriod.Clear();
  360. txtMemo.Clear();
  361. txtMemo.Clear();
  362. btnBegin.Enabled = btnEnd.Enabled = false;
  363. return;
  364. }
  365. string strErr = "";
  366. ArrayList arry = new ArrayList();
  367. arry.Add("FrmVTHot_Query1");
  368. arry.Add(strID);
  369. arry.Add(strRhs);
  370. CommonClientToServer ccs = new CommonClientToServer();
  371. ccs.ob = this.ob;
  372. DataSet ds = ccs.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBQuery", "doSimpleQuery", arry, out strErr);
  373. if (strErr != "" || !(ds != null && ds.Tables.Count > 0))
  374. {
  375. MessageBox.Show("[" + strRhs + "]槽车[" + strID + "]烘烤信息查询失败!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  376. return;
  377. }
  378. if (ds.Tables[0].Rows.Count > 0)
  379. {
  380. udteStart.DateTime = Convert.ToDateTime(ds.Tables[0].Rows[0]["BEGINTIME"]);
  381. udteEnd.Text = "";
  382. txtPeriod.Text = Convert.ToString(ds.Tables[0].Rows[0]["PERIOD"]);
  383. txtMemo.Text = Convert.ToString(ds.Tables[0].Rows[0]["MEMO"]);
  384. btnBegin.Enabled = false;
  385. }
  386. else
  387. {
  388. udteStart.Text = "";
  389. udteEnd.Text = "";
  390. txtPeriod.Clear();
  391. txtMemo.Clear();
  392. btnBegin.Enabled = true;
  393. }
  394. btnEnd.Enabled = !btnBegin.Enabled;
  395. strErr = "";
  396. arry.Clear();
  397. ds = null;
  398. ccs.ob = this.ob;
  399. arry.Add("FrmVTHot_Query2");
  400. arry.Add(strID);
  401. arry.Add(strRhs);
  402. ds = ccs.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBQuery", "doSimpleQuery", arry, out strErr);
  403. if (strErr != "" || !(ds != null && ds.Tables.Count > 0))
  404. {
  405. MessageBox.Show("[" + strRhs + "]槽车[" + strID + "]基本信息查询失败!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  406. return;
  407. }
  408. if (ds.Tables[0].Rows.Count > 0)
  409. {
  410. txtID1.Text = Convert.ToString(ds.Tables[0].Rows[0]["ID1"]);
  411. txtID2.Text = Convert.ToString(ds.Tables[0].Rows[0]["ID2"]);
  412. txtID3.Text = Convert.ToString(ds.Tables[0].Rows[0]["ID3"]);
  413. txtCS1.Text = Convert.ToString(ds.Tables[0].Rows[0]["CS1"]);
  414. txtCS2.Text = Convert.ToString(ds.Tables[0].Rows[0]["CS2"]);
  415. txtCS3.Text = Convert.ToString(ds.Tables[0].Rows[0]["CS3"]);
  416. }
  417. }
  418. catch (Exception ex)
  419. {
  420. MessageBox.Show(ex.Message, "提示");
  421. }
  422. }
  423. }
  424. }