FrmILBaseInfo.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458
  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 FrmILBaseInfo :Core.Mes.Client.Common.frmStyleBase
  14. {
  15. private bool bOK = false;
  16. private string strInitID = "";
  17. #region "================================Add on 2009-07-28=============================="
  18. #endregion
  19. public string strInitiD = "";
  20. public FrmILBaseInfo(OpeBase oba)
  21. {
  22. InitializeComponent();
  23. this.strInitID = strInitiD;
  24. ob=oba;
  25. }
  26. private void FrmILBaseInfo_Load(object sender, EventArgs e)
  27. {
  28. proc_GetID(strInitID);
  29. bOK = true;
  30. cbbID_SelectedIndexChanged(null, null);
  31. }
  32. private void cbbID_SelectedIndexChanged(object sender, EventArgs e)
  33. {
  34. if (!bOK)
  35. return;
  36. if (ucmeID.Items.Count == 0)
  37. return;
  38. string strID = ucmeID.Text.Trim();
  39. proc_GetInfo(strID);
  40. }
  41. private void proc_ResetEditArea(bool bFlag)
  42. {
  43. try
  44. {
  45. if (bFlag)
  46. ucmeID.Text = "";
  47. txtCurrStatus.Text = "系统默认";
  48. txtAgeTS.Clear();
  49. tbAgeBG.Clear();
  50. txtMemo.Clear();
  51. }
  52. catch { }
  53. }
  54. /// <summary>
  55. /// 加载铁包信息
  56. /// </summary>
  57. /// <param 铁包编号="strID"></param>
  58. private void proc_GetInfo(string strID)
  59. {
  60. try
  61. {
  62. string strErr = "";
  63. ArrayList arry = new ArrayList();
  64. arry.Add("FrmILBaseInfo_Query1");
  65. arry.Add(ucmeID.Text.Trim());
  66. CommonClientToServer ccs = new CommonClientToServer();
  67. ccs.ob = this.ob;
  68. DataSet ds = ccs.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBQuery", "doSimpleQuery", arry, out strErr);
  69. if (strErr == "" && ds != null && ds.Tables.Count > 0)
  70. {
  71. proc_ResetEditArea(false);
  72. if (ds.Tables[0].Rows.Count > 0)
  73. {
  74. txtCurrStatus.Text = ds.Tables[0].Rows[0]["当前状态"].ToString(); //当前状态
  75. txtAgeTS.Text = ds.Tables[0].Rows[0]["铁水包龄"].ToString(); //铁水包龄
  76. tbAgeBG.Text = ds.Tables[0].Rows[0]["半钢包龄"].ToString(); //半钢包龄
  77. txtMemo.Text = ds.Tables[0].Rows[0]["备注"].ToString();//备注
  78. txtProduct.Text = ds.Tables[0].Rows[0]["MANUFACTURERS"].ToString();//生产厂家
  79. txtTraeWeight.Text = ds.Tables[0].Rows[0]["TAREWEIGHT"].ToString();//生产厂家
  80. }
  81. }
  82. else
  83. {
  84. MessageBox.Show("铁包信息查询出错!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  85. }
  86. }
  87. catch (Exception ex)
  88. {
  89. MessageBox.Show("铁包信息查询出错!\r\n" + ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  90. }
  91. }
  92. /// <summary>
  93. /// 加载铁包编号
  94. /// </summary>
  95. /// <param 铁包编号="strID"></param>
  96. private void proc_GetID(string strID)
  97. {
  98. try
  99. {
  100. string strErr = "";
  101. ArrayList arry = new ArrayList();
  102. arry.Add("FrmILBaseInfo_Query2");
  103. CommonClientToServer ccs = new CommonClientToServer();
  104. ccs.ob = this.ob;
  105. DataSet ds = ccs.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBQuery", "doSimpleQuery", arry, out strErr);
  106. if (strErr == "" && ds != null && ds.Tables.Count > 0)
  107. {
  108. this.ucmeID.Items.Clear();
  109. for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
  110. {
  111. ucmeID.Items.Add(ds.Tables[0].Rows[i]["铁包编号"]);
  112. }
  113. if (ds.Tables[0].Rows.Count == 0)
  114. {
  115. proc_ResetEditArea(true);
  116. return;
  117. }
  118. if (strID.Length > 0)
  119. ucmeID.Text = strID;
  120. cbbID_SelectedIndexChanged(null, null);
  121. }
  122. else
  123. {
  124. MessageBox.Show("铁包包号信息查询出错!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  125. }
  126. }
  127. catch (Exception ex)
  128. {
  129. MessageBox.Show("铁包包号信息查询出错!\r\n" + ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  130. }
  131. }
  132. private void TextBoxNumberEditor_KeyPress(object sender, KeyPressEventArgs e)
  133. {
  134. try
  135. {
  136. if (!(Char.IsNumber(e.KeyChar) || e.KeyChar == '\b' || e.KeyChar == '.'))
  137. e.Handled = true;
  138. }
  139. catch { }
  140. }
  141. /// <summary>
  142. /// 铁包基础信息新增
  143. /// </summary>
  144. private void IronLadle_Add()
  145. {
  146. try
  147. {
  148. if (ucmeID.Text.Trim().Length == 0)
  149. {
  150. MessageBox.Show("请输入铁包编号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  151. ucmeID.Focus();
  152. return;
  153. }
  154. string strErr = "";
  155. ArrayList arry = new ArrayList();
  156. arry.Add("FrmILBaseInfo_Query3");
  157. arry.Add(ucmeID.Text.Trim());
  158. CommonClientToServer ccs = new CommonClientToServer();
  159. ccs.ob = this.ob;
  160. DataSet ds = ccs.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBQuery", "doSimpleQuery", arry, out strErr);
  161. if (!(strErr == "" && ds != null && ds.Tables.Count > 0))
  162. {
  163. MessageBox.Show("铁包[" + ucmeID.Text.Trim() + "]新增失败,请重试!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  164. return;
  165. }
  166. if (ds.Tables[0].Rows.Count > 0)
  167. {
  168. MessageBox.Show("铁包编号[" + ucmeID.Text.Trim() + "]已经存在,请重新指定!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  169. ucmeID.Focus();
  170. return;
  171. }
  172. string strmaxid = "";
  173. strErr = "";
  174. arry.Clear();
  175. ds = null;
  176. arry.Add("QueryIronMaxID");
  177. ccs.ob = this.ob;
  178. ds = ccs.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBQuery", "doSimpleQuery", arry, out strErr);
  179. if (strErr == "" && ds != null && ds.Tables.Count > 0)
  180. {
  181. strmaxid=ds.Tables[0].Rows[0]["maxid"].ToString();
  182. }
  183. string strReturn = "";
  184. strErr = "";
  185. arry.Clear();
  186. arry.Add("FrmILBaseInfo_Add");
  187. arry.Add(Convert.ToInt32(strmaxid));
  188. arry.Add(ucmeID.Text.Trim());
  189. arry.Add(txtAgeTS.Text.Trim() == "" ? "0" : txtAgeTS.Text.Trim());
  190. arry.Add(tbAgeBG.Text.Trim() == "" ? "0" : tbAgeBG.Text.Trim());
  191. arry.Add(txtMemo.Text.Trim());
  192. arry.Add(txtProduct.Text.Trim());
  193. arry.Add(txtTraeWeight.Text.Trim());
  194. ccs.ob = this.ob;
  195. strReturn = ccs.NoQueryFunctions("Core.LgMes.Server.Common.ComDBSave", "doSimpleSave", arry, out strErr);
  196. if (strErr == "")
  197. {
  198. proc_GetID(ucmeID.Text.Trim());
  199. FrmIronLadleManage frm = (FrmIronLadleManage)this.Tag;
  200. if (!frm._bAutoRefresh)
  201. {
  202. frm.GetID();
  203. frm.GetAndSetData();
  204. }
  205. MessageBox.Show("铁包[" + ucmeID.Text.Trim() + "]新增成功!", "提示");
  206. }
  207. else
  208. {
  209. MessageBox.Show("铁包[" + ucmeID.Text.Trim() + "]新增失败!\n" + strErr, "错误!", MessageBoxButtons.OK, MessageBoxIcon.Error);
  210. }
  211. }
  212. catch (Exception ex)
  213. {
  214. MessageBox.Show("铁包[" + ucmeID.Text.Trim() + "]新增失败!\n" + ex.Message, "错误!", MessageBoxButtons.OK, MessageBoxIcon.Error);
  215. }
  216. }
  217. /// <summary>
  218. /// 铁包基础信息修改
  219. /// </summary>
  220. private void IronLadle_Edit()
  221. {
  222. try
  223. {
  224. if (ucmeID.Items.Count == 0) return;
  225. if (ucmeID.Text.Trim().Length == 0)
  226. {
  227. MessageBox.Show("请选择需要修改的铁包编号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  228. ucmeID.Focus();
  229. return;
  230. }
  231. string strErr = "";
  232. ArrayList arry = new ArrayList();
  233. arry.Add("FrmILBaseInfo_Query4");
  234. arry.Add(ucmeID.Text.Trim());
  235. CommonClientToServer ccs = new CommonClientToServer();
  236. ccs.ob = this.ob;
  237. DataSet ds = ccs.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBQuery", "doSimpleQuery", arry, out strErr);
  238. if (!(strErr == "" && ds != null && ds.Tables.Count > 0))
  239. {
  240. MessageBox.Show("铁包[" + ucmeID.Text.Trim() + "]信息修改失败,请重试!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  241. return;
  242. }
  243. if (ds.Tables[0].Rows.Count == 0)
  244. {
  245. MessageBox.Show("铁包编号[" + ucmeID.Text.Trim() + "]不存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  246. proc_GetID("");
  247. ucmeID.Focus();
  248. return;
  249. }
  250. string strOldAgeTS = Convert.ToString(ds.Tables[0].Rows[0]["铁水包龄"]);
  251. string strOldAgeBG = Convert.ToString(ds.Tables[0].Rows[0]["半钢包龄"]);
  252. string strOldStatus = Convert.ToString(ds.Tables[0].Rows[0]["当前状态"]);
  253. string strCurAgeTS = (txtAgeTS.Text.Trim() == "" ? "0" : txtAgeTS.Text.Trim());
  254. string strCurAgeBG = (tbAgeBG.Text.Trim() == "" ? "0" : tbAgeBG.Text.Trim());
  255. string strMemo = txtMemo.Text.Trim();
  256. string strMturers = txtProduct.Text.Trim();
  257. string strTWeight = txtTraeWeight.Text.Trim();
  258. if (strOldStatus == "使用" && (strOldAgeTS != strCurAgeTS || strOldAgeBG != strCurAgeBG))
  259. {
  260. MessageBox.Show("铁包[" + ucmeID.Text.Trim() + "]正在使用,不能修改铁水包龄!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  261. if (strOldAgeTS != strCurAgeTS)
  262. txtAgeTS.Focus();
  263. else
  264. tbAgeBG.Focus();
  265. return;
  266. }
  267. string strReturn = "";
  268. strErr = "";
  269. arry.Clear();
  270. arry.Add("FrmILBaseInfo_Edit");
  271. arry.Add(strCurAgeTS);
  272. arry.Add(strCurAgeBG);
  273. arry.Add(strMemo);
  274. arry.Add(strMturers);
  275. arry.Add(strTWeight);
  276. arry.Add(ucmeID.Text.Trim());
  277. strReturn = ccs.NoQueryFunctions("Core.LgMes.Server.Common.ComDBSave", "doSimpleSave", arry, out strErr);
  278. if (strErr == "")
  279. {
  280. proc_GetID(ucmeID.Text.Trim());
  281. FrmIronLadleManage frm = (FrmIronLadleManage)this.Tag;
  282. if (!frm._bAutoRefresh)
  283. {
  284. frm.GetID();
  285. frm.GetAndSetData();
  286. }
  287. MessageBox.Show("铁包[" + ucmeID.Text.Trim() + "]信息修改成功!", "提示");
  288. }
  289. else
  290. {
  291. MessageBox.Show("铁包[" + ucmeID.Text.Trim() + "]信息修改失败!\n" + strErr, "错误!", MessageBoxButtons.OK, MessageBoxIcon.Error);
  292. }
  293. }
  294. catch (Exception ex)
  295. {
  296. MessageBox.Show("铁包[" + ucmeID.Text.Trim() + "]信息修改失败!\n" + ex.Message, "错误!", MessageBoxButtons.OK, MessageBoxIcon.Error);
  297. }
  298. }
  299. /// <summary>
  300. /// 基础信息删除
  301. /// </summary>
  302. private void IronLadle_Del()
  303. {
  304. try
  305. {
  306. if (ucmeID.Items.Count == 0) return;
  307. if (ucmeID.Text.Trim().Length == 0)
  308. {
  309. MessageBox.Show("请选择需要删除的铁包编号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  310. ucmeID.Focus();
  311. return;
  312. }
  313. string strErr = "";
  314. ArrayList arry = new ArrayList();
  315. arry.Add("FrmILBaseInfo_Query5");
  316. arry.Add(ucmeID.Text.Trim());
  317. CommonClientToServer ccs = new CommonClientToServer();
  318. ccs.ob = this.ob;
  319. DataSet ds = ccs.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBQuery", "doSimpleQuery", arry, out strErr);
  320. if (!(strErr == "" && ds != null && ds.Tables.Count > 0))
  321. {
  322. MessageBox.Show("铁包[" + ucmeID.Text.Trim() + "]信息删除失败,请重试!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  323. return;
  324. }
  325. if (ds.Tables[0].Rows.Count == 0)
  326. {
  327. MessageBox.Show("铁包编号[" + ucmeID.Text.Trim() + "]不存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  328. proc_GetID("");
  329. ucmeID.Focus();
  330. return;
  331. }
  332. if (MessageBox.Show("确定要删除铁包[" + ucmeID.Text.Trim() + "]信息吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
  333. return;
  334. strErr = "";
  335. ds = null;
  336. arry.Clear();
  337. ccs.ob = ob;
  338. arry.Add("FrmILBaseInfo_Query6");
  339. arry.Add(ucmeID.Text.Trim());
  340. arry.Add(ucmeID.Text.Trim());
  341. arry.Add(ucmeID.Text.Trim());
  342. ds = ccs.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBQuery", "doSimpleQuery", arry, out strErr);
  343. if (!(strErr == "" && ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0))
  344. {
  345. MessageBox.Show("铁包[" + ucmeID.Text.Trim() + "]信息删除失败,请重试!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  346. return;
  347. }
  348. int iCount = Convert.ToInt16(ds.Tables[0].Rows[0][0]);
  349. if (iCount > 0)
  350. {
  351. MessageBox.Show("铁包[" + ucmeID.Text.Trim() + "]存在使用记录、维修记录或烘烤记录,不能删除!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  352. return;
  353. }
  354. string strReturn = "";
  355. strErr = "";
  356. arry.Clear();
  357. arry.Add("FrmILBaseInfo_Delect");
  358. arry.Add(ucmeID.Text.Trim());
  359. strReturn = ccs.NoQueryFunctions("Core.LgMes.Server.Common.ComDBSave", "doSimpleSave", arry, out strErr);
  360. if (strErr == "")
  361. {
  362. proc_GetID("");
  363. FrmIronLadleManage frm = (FrmIronLadleManage)this.Tag;
  364. if (!frm._bAutoRefresh)
  365. {
  366. frm.GetID();
  367. frm.GetAndSetData();
  368. }
  369. MessageBox.Show("铁包[" + ucmeID.Text.Trim() + "]信息删除成功!", "提示");
  370. }
  371. else
  372. {
  373. MessageBox.Show("铁包[" + ucmeID.Text.Trim() + "]信息删除失败!\n" + strErr, "错误!", MessageBoxButtons.OK, MessageBoxIcon.Error);
  374. }
  375. }
  376. catch (Exception ex)
  377. {
  378. MessageBox.Show("铁包[" + ucmeID.Text.Trim() + "]信息删除失败!\n" + ex.Message, "错误!", MessageBoxButtons.OK, MessageBoxIcon.Error);
  379. }
  380. }
  381. private void btnClose_Click(object sender, EventArgs e)
  382. {
  383. this.Close();
  384. }
  385. private void toolStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
  386. {
  387. switch (e.ClickedItem.Name)
  388. {
  389. case "ADD":
  390. {
  391. IronLadle_Add();
  392. break;
  393. }
  394. case "EDIT":
  395. {
  396. IronLadle_Edit();
  397. break;
  398. }
  399. case "DEL":
  400. {
  401. IronLadle_Del();
  402. break;
  403. }
  404. case "CLOSE":
  405. {
  406. this.Close();
  407. break;
  408. }
  409. default:
  410. break;
  411. }
  412. }
  413. }
  414. }