FrmSGBaseInfo.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427
  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 FrmSGBaseInfo : Core.Mes.Client.Common.frmStyleBase//frmModelFormStyle
  14. {
  15. bool bOK = false; //是否响应扇形段号选择改变事件
  16. public string strNo = "", strCCM = "";
  17. public FrmSGBaseInfo(OpeBase oba)
  18. {
  19. InitializeComponent();
  20. ob = oba;
  21. }
  22. private void txtAge_KeyPress(object sender, KeyPressEventArgs e)
  23. {
  24. if (!(Char.IsNumber(e.KeyChar) || e.KeyChar == '\b'))
  25. {
  26. e.Handled = true;
  27. }
  28. }
  29. private void FrmSGBaseInfo_Load(object sender, EventArgs e)
  30. {
  31. if (strCCM.Length > 0)
  32. {
  33. cmbCCM.Text = strCCM;
  34. this.cbbCCM_SelectedIndexChanged(this, null);
  35. if (strNo.Length > 0)
  36. {
  37. cmbID.Text = strNo;
  38. bOK = true;
  39. this.cbbID_SelectedIndexChanged(this, null);
  40. }
  41. }
  42. else
  43. bOK = true;
  44. }
  45. /// <summary>
  46. /// 扇形段号加载
  47. /// </summary>
  48. /// <param name="strCCM"></param>
  49. private void proc_GetID(string strCCM)
  50. {
  51. try
  52. {
  53. if (strCCM.Length == 0)
  54. return;
  55. string strErr = "";
  56. ArrayList arry = new ArrayList();
  57. if (strCCM == "1#连铸机" || strCCM == "2#连铸机")
  58. {
  59. arry.Add("OneandTwoCCM_SG.select");
  60. }
  61. else
  62. {
  63. arry.Add("FrmSGBaseInfo_Query1");
  64. arry.Add(strCCM);
  65. }
  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. MessageBox.Show("扇形段号加载失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  72. if (MessageBox.Show("是否重新加载扇形段号?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
  73. proc_GetID(strCCM);
  74. return;
  75. }
  76. cmbID.DataSource = ds.Tables[0];
  77. cmbID.DisplayMember = "SEGMENTID";
  78. if (ds.Tables[0].Rows.Count == 0)
  79. proc_ResetControl();
  80. }
  81. catch (Exception ex)
  82. {
  83. MessageBox.Show(ex.Message);
  84. }
  85. }
  86. private void proc_ResetControl()
  87. {
  88. try
  89. {
  90. cmbID.Text = "";
  91. txtType.Clear();
  92. txtSYCS.Clear();
  93. txtStatus.Clear();
  94. txtPos.Clear();
  95. udteBuyTime.DateTime = DateTime.Today;
  96. txtMemo.Clear();
  97. }
  98. catch (Exception ex)
  99. {
  100. MessageBox.Show(ex.Message);
  101. }
  102. }
  103. /// <summary>
  104. /// 新增
  105. /// </summary>
  106. private void proc_Add()
  107. {
  108. try
  109. {
  110. string strCcm = cmbCCM.Text.Trim();
  111. string strID = cmbID.Text.Trim();
  112. if (strCcm.Length == 0)
  113. {
  114. MessageBox.Show("请选择铸机号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  115. cmbCCM.Focus();
  116. return;
  117. }
  118. if (strID.Length == 0)
  119. {
  120. MessageBox.Show("请输入扇形段编号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  121. cmbID.Focus();
  122. return;
  123. }
  124. string strType = "1"; //板坯扇形段
  125. string strErr = "";
  126. ArrayList arry = new ArrayList();
  127. arry.Add("FrmSGBaseInfo_Query3");
  128. arry.Add(strCcm);
  129. arry.Add(strID);
  130. CommonClientToServer ccs = new CommonClientToServer();
  131. ccs.ob = this.ob;
  132. DataSet ds = ccs.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBQuery", "doSimpleQuery", arry, out strErr);
  133. if (strErr != "" || !(ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0))
  134. {
  135. MessageBox.Show("新增[" + strCcm + "]扇形段[" + strID + "]失败!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  136. return;
  137. }
  138. int iCnt = Convert.ToInt32(ds.Tables[0].Rows[0][0]);
  139. if (iCnt > 0)
  140. {
  141. MessageBox.Show("[" + strCcm + "]已存在扇形段[" + strID + "],不能重复录入!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  142. cmbID.Focus();
  143. return;
  144. }
  145. string strReturn = "";
  146. strErr = "";
  147. arry.Clear();
  148. ccs.ob = ob;
  149. arry.Add("FrmSGBaseInfo_Add1");
  150. arry.Add(strID);
  151. arry.Add(strCcm);
  152. arry.Add(strType);
  153. arry.Add(txtSYCS.Text.Trim() == "" ? "0" : txtSYCS.Text.Trim());
  154. arry.Add(udteBuyTime.DateTime.ToString("yyyy-MM-dd"));
  155. arry.Add(txtMemo.Text.Trim());
  156. strReturn = ccs.NoQueryFunctions("Core.LgMes.Server.Common.ComDBSave", "doSimpleSave", arry, out strErr);
  157. if (!(strErr == null || strErr == ""))
  158. {
  159. MessageBox.Show("新增[" + strCcm + "]扇形段[" + strID + "]失败!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  160. return;
  161. }
  162. FrmSegMentManage frm = (FrmSegMentManage)this.Tag;
  163. frm.proc_GetBaseInfo(strCcm, strID);
  164. proc_GetID(strCcm);
  165. MessageBox.Show("新增[" + strCcm + "]扇形段[" + strID + "]成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  166. this.Close();
  167. return;
  168. }
  169. catch (Exception ex)
  170. {
  171. MessageBox.Show(ex.Message);
  172. }
  173. }
  174. /// <summary>
  175. /// 修改
  176. /// </summary>
  177. private void proc_Edit()
  178. {
  179. try
  180. {
  181. string strCcm = cmbCCM.Text.Trim();
  182. string strID = cmbID.Text.Trim();
  183. if (strID.Length == 0)
  184. {
  185. MessageBox.Show("请选择需要修改的扇形段编号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  186. cmbID.Focus();
  187. return;
  188. }
  189. if (MessageBox.Show("确定要修改[" + strCcm + "]的扇形段[" + strID + "]信息吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
  190. return;
  191. string strErr = "";
  192. ArrayList arry = new ArrayList();
  193. arry.Add("FrmSGBaseInfo_Query4");
  194. arry.Add(strCcm);
  195. arry.Add(strID);
  196. CommonClientToServer ccs = new CommonClientToServer();
  197. ccs.ob = this.ob;
  198. DataSet ds = ccs.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBQuery", "doSimpleQuery", arry, out strErr);
  199. if (strErr != "" || !(ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0))
  200. {
  201. MessageBox.Show("[" + strCcm + "]扇形段[" + strID + "]信息修改失败!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  202. return;
  203. }
  204. string strReturn = "";
  205. strErr = "";
  206. arry.Clear();
  207. arry.Add("FrmSGBaseInfo_Update1");
  208. arry.Add(strCcm);
  209. arry.Add(txtSYCS.Text.Trim() == "" ? "0" : txtSYCS.Text.Trim());
  210. arry.Add(udteBuyTime.DateTime.ToString("yyyy-MM-dd"));
  211. arry.Add(txtMemo.Text.Trim());
  212. arry.Add(strID);
  213. strReturn = ccs.NoQueryFunctions("Core.LgMes.Server.Common.ComDBSave", "doSimpleSave", arry, out strErr);
  214. if (!(strErr == null || strErr == ""))
  215. {
  216. MessageBox.Show("[" + strCcm + "]扇形段[" + strID + "]信息修改失败!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  217. return;
  218. }
  219. FrmSegMentManage frm = (FrmSegMentManage)this.Tag;
  220. frm.proc_GetBaseInfo(strCcm, strID);
  221. proc_GetID(strCcm);
  222. MessageBox.Show("[" + strCcm + "]扇形段[" + strID + "]信息修改成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  223. this.Close();
  224. return;
  225. }
  226. catch (Exception ex)
  227. {
  228. MessageBox.Show(ex.Message);
  229. }
  230. }
  231. /// <summary>
  232. /// 删除
  233. /// </summary>
  234. private void proc_Del()
  235. {
  236. try
  237. {
  238. string strCcm = cmbCCM.Text.Trim();
  239. string strID = cmbID.Text.Trim();
  240. if (strID.Length == 0)
  241. {
  242. MessageBox.Show("请选择需要删除的扇形段编号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  243. cmbID.Focus();
  244. return;
  245. }
  246. if (MessageBox.Show("确定要删除[" + strCcm + "]扇形段[" + strID + "]的信息吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
  247. return;
  248. string strErr = "";
  249. ArrayList arry = new ArrayList();
  250. arry.Add("FrmSGBaseInfo_Query5");
  251. arry.Add(strCcm);
  252. arry.Add(strID);
  253. CommonClientToServer ccs = new CommonClientToServer();
  254. ccs.ob = this.ob;
  255. DataSet ds = ccs.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBQuery", "doSimpleQuery", arry, out strErr);
  256. if (strErr != "" || !(ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0))
  257. {
  258. MessageBox.Show("[" + strCcm + "]扇形段[" + strID + "]信息删除失败!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  259. return;
  260. }
  261. ds = null;
  262. strErr = "";
  263. arry.Clear();
  264. ccs.ob = ob;
  265. arry.Add("FrmSGBaseInfo_Query6");
  266. arry.Add(strCcm);
  267. arry.Add(strID);
  268. ds = ccs.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBQuery", "doSimpleQuery", arry, out strErr);
  269. if (strErr != "" || !(ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0))
  270. {
  271. MessageBox.Show("[" + strCcm + "]扇形段[" + strID + "]信息删除失败!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  272. return;
  273. }
  274. ds = null;
  275. strErr = "";
  276. arry.Clear();
  277. ccs.ob = ob;
  278. arry.Add("FrmSGBaseInfo_Query7");
  279. arry.Add(strCcm);
  280. arry.Add(strID);
  281. ds = ccs.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBQuery", "doSimpleQuery", arry, out strErr);
  282. if (strErr != "" || !(ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0))
  283. {
  284. MessageBox.Show("[" + strCcm + "]扇形段[" + strID + "]信息删除失败!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  285. return;
  286. }
  287. string strReturn = "";
  288. strErr = "";
  289. arry.Clear();
  290. arry.Add("FrmSGBaseInfo_Del1");
  291. arry.Add(strCcm);
  292. arry.Add(strID);
  293. strReturn = ccs.NoQueryFunctions("Core.LgMes.Server.Common.ComDBSave", "doSimpleSave", arry, out strErr);
  294. if (!(strErr == null || strErr == ""))
  295. {
  296. MessageBox.Show("[" + strCcm + "]扇形段[" + strID + "]信息删除失败!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  297. return;
  298. }
  299. FrmSegMentManage frm = (FrmSegMentManage)this.Tag;
  300. frm.proc_GetBaseInfo(strCcm, "");
  301. proc_GetID(strCcm);
  302. MessageBox.Show("[" + strCcm + "]扇形段[" + strID + "]信息删除成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  303. this.Close();
  304. return;
  305. }
  306. catch (Exception ex)
  307. {
  308. MessageBox.Show(ex.Message);
  309. }
  310. }
  311. /// <summary>
  312. /// 菜单栏
  313. /// </summary>
  314. /// <param name="sender"></param>
  315. /// <param name="e"></param>
  316. private void toolStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
  317. {
  318. switch (e.ClickedItem.Name)
  319. {
  320. case "ADD":
  321. {
  322. this.proc_Add();
  323. break;
  324. }
  325. case "EDIT":
  326. {
  327. this.proc_Edit();
  328. break;
  329. }
  330. case "DEL":
  331. {
  332. this.proc_Del();
  333. break;
  334. }
  335. case "CLOSE":
  336. {
  337. this.Close();
  338. break;
  339. }
  340. default:
  341. break;
  342. }
  343. }
  344. private void cbbCCM_SelectedIndexChanged(object sender, EventArgs e)
  345. {
  346. if (cmbCCM.Text.Length > 0)
  347. proc_GetID(cmbCCM.Text);
  348. }
  349. /// <summary>
  350. /// 扇形段信息查询
  351. /// </summary>
  352. /// <param name="sender"></param>
  353. /// <param name="e"></param>
  354. private void cbbID_SelectedIndexChanged(object sender, EventArgs e)
  355. {
  356. try
  357. {
  358. if (!bOK)
  359. return;
  360. string strCCM = cmbCCM.Text.Trim();
  361. string strID = cmbID.Text.Trim();
  362. if (strID.Length == 0)
  363. return;
  364. string strErr = "";
  365. ArrayList arry = new ArrayList();
  366. arry.Add("FrmSGBaseInfo_Query2");
  367. arry.Add(strID);
  368. arry.Add(strCCM);
  369. CommonClientToServer ccs = new CommonClientToServer();
  370. ccs.ob = this.ob;
  371. DataSet ds = ccs.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBQuery", "doSimpleQuery", arry, out strErr);
  372. if (strErr != "" || !(ds != null && ds.Tables.Count > 0))
  373. {
  374. MessageBox.Show("扇形段[" + strID + "]信息查询失败!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  375. return;
  376. }
  377. if (ds.Tables[0].Rows.Count == 0) return;
  378. txtType.Text = Convert.ToString(ds.Tables[0].Rows[0]["TYPE"]);
  379. txtSYCS.Text = Convert.ToString(ds.Tables[0].Rows[0]["USETIMES"]);
  380. txtStatus.Text = Convert.ToString(ds.Tables[0].Rows[0]["NOWSTATUS"]);
  381. txtPos.Text = Convert.ToString(ds.Tables[0].Rows[0]["POSITION"]);
  382. udteBuyTime.DateTime = Convert.ToDateTime(ds.Tables[0].Rows[0]["BUYDATE"]);
  383. txtMemo.Text = Convert.ToString(ds.Tables[0].Rows[0]["MEMO"]);
  384. }
  385. catch (Exception ex)
  386. {
  387. MessageBox.Show(ex.Message, "提示");
  388. }
  389. }
  390. }
  391. }