FrmTDBaseInfo.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410
  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 FrmTDBaseInfo : FrmLgDevFunctions
  14. {
  15. bool bOK = false; //是否响应中间包号选择改变事件
  16. public string strBH = "", strCCM = "",strPID="";
  17. public FrmTDBaseInfo(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 FrmTDBaseInfo_Load(object sender, EventArgs e)
  30. {
  31. if (strCCM.Length > 0)
  32. {
  33. ucmeCCM.Text = strCCM;
  34. this.cbbCCM_SelectedIndexChanged(this, null);//铸机号查询
  35. if (strBH.Length > 0)
  36. {
  37. ucmeID.Text = strBH;
  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("Proc_GetIDByOneTWOCCM");
  60. }
  61. else
  62. {
  63. arry.Add("proc_GetID.Query");
  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. ucmeID.Items.Clear();
  77. for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
  78. {
  79. ucmeID.Items.Add(ds.Tables[0].Rows[i][0]);
  80. }
  81. if (ds.Tables[0].Rows.Count == 0)
  82. proc_ResetControl();
  83. }
  84. catch (Exception ex)
  85. {
  86. MessageBox.Show(ex.Message);
  87. }
  88. }
  89. private void proc_ResetControl()
  90. {
  91. try
  92. {
  93. ucmeID.Text = "";
  94. txtStatus.Clear();
  95. txtAge.Clear();
  96. udtePTime.DateTime = DateTime.Now;
  97. udteBuyTime.DateTime = DateTime.Now;
  98. txtMemo.Clear();
  99. }
  100. catch (Exception ex)
  101. {
  102. MessageBox.Show(ex.Message);
  103. }
  104. }
  105. private void proc_Add()
  106. {
  107. try
  108. {
  109. string strErr = "";
  110. string msg = "";
  111. string strCcm = ucmeCCM.Text.Trim();
  112. string strID = ucmeID.Text.Trim();
  113. string tbAge = this.txtAge.Text.Trim();
  114. string tionDateTime = Convert.ToDateTime(udtePTime.Value.ToString()).ToString("yyyy-MM-dd");
  115. string BuyDateTime = Convert.ToDateTime(udteBuyTime.Value.ToString()).ToString("yyyy-MM-dd");
  116. string tbMemo = this.txtMemo.Text.Trim();
  117. CoreClientParam ccp = new CoreClientParam();
  118. ccp.ServerName = "Core.LgMes.Server.LgDeviceManager.LadleManager";
  119. ccp.MethodName = "proc_Add";
  120. string[] a = new string[] { strCcm, strID, tbAge, tionDateTime, BuyDateTime, tbMemo };
  121. ccp.ServerParams = new Object[] { "LG_DEV_ZJB_BaseInfo_add", a };
  122. ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  123. System.Collections.ArrayList al = (System.Collections.ArrayList)ccp.ReturnObject;
  124. strErr = al[0].ToString();
  125. msg = al[1].ToString();
  126. if (strErr == "1")
  127. {
  128. FrmTundishManage frm = (FrmTundishManage)this.Tag;
  129. frm.QueryZJBData(strCcm, strID);
  130. proc_GetID(strCcm);
  131. MessageBox.Show(msg, "提示", MessageBoxButtons.OK);
  132. return;
  133. }
  134. else
  135. {
  136. MessageBox.Show(msg, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  137. return;
  138. }
  139. }
  140. catch (Exception ex)
  141. {
  142. MessageBox.Show(ex.Message);
  143. }
  144. }
  145. private void proc_Edit()
  146. {
  147. try
  148. {
  149. if (ucmeID.Items.Count == 0)
  150. return;
  151. string strCcm = ucmeCCM.Text.Trim();
  152. string strID = ucmeID.Text.Trim();
  153. if (strID.Length == 0)
  154. {
  155. MessageBox.Show("请选择需要修改的中间包编号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  156. ucmeID.Focus();
  157. return;
  158. }
  159. if (MessageBox.Show("确定要修改[" + strCcm + "]的中间包[" + strID + "]信息吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
  160. return;
  161. string strErr = "";
  162. string strSql = "select count(1) from DEV_ZJB_BASE_INFO where CCM_ID = '" + strCcm + "' and TUNDISHID = '" + strID + "'";
  163. CoreClientParam ccp = new CoreClientParam();
  164. ccp.ServerName = "Core.LgMes.Server.DEV.Methods.DEVPublicMethods";
  165. ccp.MethodName = "QueryMethods";
  166. ccp.ServerParams = new Object[] { strSql };
  167. DataTable dt = new DataTable();
  168. ccp.SourceDataTable = dt;
  169. ob.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal);
  170. DataSet ds = new DataSet();
  171. ds.Tables.Add(dt);
  172. if (strErr != "" || !(ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0))
  173. {
  174. MessageBox.Show("[" + strCcm + "]中间包[" + strID + "]信息修改失败!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  175. return;
  176. }
  177. strErr = "";
  178. strSql = "update DEV_ZJB_BASE_INFO set "
  179. + "CCM_ID = '" + strCcm + "',"
  180. + "AGE = '" + (txtAge.Text.Trim() == "" ? "0" : txtAge.Text.Trim()) + "',"
  181. + "CREATIVEDATE = to_date('" + udtePTime.DateTime.ToString("yyyy-MM-dd") + "','yyyy-MM-dd'),"
  182. + "BUYDATE = to_date('" + udteBuyTime.DateTime.ToString("yyyy-MM-dd") + "','yyyy-MM-dd'),"
  183. + "MEMO = '" + txtMemo.Text.Trim() + "' "
  184. + "where TUNDISHID = '" + strID + "' and ID='" + strPID + "'";
  185. CoreClientParam ccp_up = new CoreClientParam();
  186. ccp_up.ServerName = "Core.LgMes.Server.DEV.Methods.DEVPublicMethods";
  187. ccp_up.MethodName = "UpdateMethods";
  188. ccp_up.ServerParams = new Object[] { strSql };
  189. ob.ExecuteNonQuery(ccp_up, CoreInvokeType.Internal);
  190. FrmTundishManage frm = (FrmTundishManage)this.Tag;
  191. frm.QueryZJBData(strCcm, strID);
  192. proc_GetID(strCcm);
  193. MessageBox.Show("[" + strCcm + "]中间包[" + strID + "]信息修改成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  194. this.Close();
  195. return;
  196. }
  197. catch (Exception ex)
  198. {
  199. MessageBox.Show(ex.Message);
  200. }
  201. }
  202. private void proc_Del()
  203. {
  204. try
  205. {
  206. if (ucmeID.Items.Count == 0)
  207. return;
  208. string strCcm = ucmeCCM.Text.Trim();
  209. string strID = ucmeID.Text.Trim();
  210. if (strID.Length == 0)
  211. {
  212. MessageBox.Show("请选择需要删除的中间包编号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  213. ucmeID.Focus();
  214. return;
  215. }
  216. if (MessageBox.Show("确定要删除[" + strCcm + "]中间包[" + strID + "]的信息吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
  217. return;
  218. string strErr = "";
  219. string strSql = "select count(1) from DEV_ZJB_BASE_INFO where CCM_ID = '" + strCcm + "' and TUNDISHID = '" + strID + "'";
  220. CoreClientParam ccp = new CoreClientParam();
  221. ccp.ServerName = "Core.LgMes.Server.DEV.Methods.DEVPublicMethods";
  222. ccp.MethodName = "QueryMethods";
  223. ccp.ServerParams = new Object[] { strSql };
  224. DataTable dt = new DataTable();
  225. ccp.SourceDataTable = dt;
  226. ob.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal);
  227. DataSet ds = new DataSet();
  228. ds.Tables.Add(dt);
  229. if (strErr != "" || !(ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0))
  230. {
  231. MessageBox.Show("[" + strCcm + "]中间包[" + strID + "]信息删除失败!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  232. return;
  233. }
  234. int iCnt = Convert.ToInt32(ds.Tables[0].Rows[0][0]);
  235. if (iCnt == 0)
  236. {
  237. MessageBox.Show("[" + strCcm + "]不存在中间包[" + strID + "]信息,无法删除!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  238. ucmeID.Focus();
  239. return;
  240. }
  241. iCnt = 0;
  242. ds = null;
  243. strErr = "";
  244. strSql = "select count(1) from DEV_ZJB_USE_DETAIL where TUNDISHID = (select ID from DEV_ZJB_BASE_INFO where CCM_ID = '" + strCcm + "' and TUNDISHID = '" + strID + "')";
  245. CoreClientParam ccp_up = new CoreClientParam();
  246. ccp_up.ServerName = "Core.LgMes.Server.DEV.Methods.DEVPublicMethods";
  247. ccp_up.MethodName = "QueryMethods";
  248. ccp_up.ServerParams = new Object[] { strSql };
  249. DataTable dtt = new DataTable();
  250. ccp_up.SourceDataTable = dtt;
  251. ob.ExecuteQueryToDataTable(ccp_up, CoreInvokeType.Internal);
  252. DataSet dss = new DataSet();
  253. dss.Tables.Add(dtt);
  254. if (strErr != "" || !(dss != null && dss.Tables.Count > 0 && dss.Tables[0].Rows.Count > 0))
  255. {
  256. MessageBox.Show("[" + strCcm + "]中间包[" + strID + "]信息删除失败!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  257. return;
  258. }
  259. iCnt = Convert.ToInt32(dss.Tables[0].Rows[0][0]);
  260. if (iCnt > 0)
  261. {
  262. MessageBox.Show("[" + strCcm + "]中间包[" + strID + "]存在使用记录,不能删除!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  263. ucmeID.Focus();
  264. return;
  265. }
  266. strErr = "";
  267. strSql = "delete from DEV_ZJB_BASE_INFO where CCM_ID = '" + strCcm + "' and TUNDISHID = '" + strID + "'";
  268. CoreClientParam ccp_del = new CoreClientParam();
  269. ccp_del.ServerName = "Core.LgMes.Server.DEV.Methods.DEVPublicMethods";
  270. ccp_del.MethodName = "UpdateMethods";
  271. ccp_del.ServerParams = new Object[] { strSql };
  272. ob.ExecuteNonQuery(ccp_del, CoreInvokeType.Internal);
  273. if (!(strErr == null || strErr == ""))
  274. {
  275. MessageBox.Show("[" + strCcm + "]中间包[" + strID + "]信息删除失败!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  276. return;
  277. }
  278. FrmTundishManage frm = (FrmTundishManage)this.Tag;
  279. frm.QueryZJBData(strCcm, "");
  280. proc_GetID(strCcm);
  281. MessageBox.Show("[" + strCcm + "]中间包[" + strID + "]信息删除成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  282. return;
  283. }
  284. catch (Exception ex)
  285. {
  286. MessageBox.Show(ex.Message);
  287. }
  288. }
  289. private void toolStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
  290. {
  291. switch (e.ClickedItem.Name)
  292. {
  293. case "ADD":
  294. {
  295. this.proc_Add();
  296. break;
  297. }
  298. case "EDIT":
  299. {
  300. this.proc_Edit();
  301. break;
  302. }
  303. case "DEL":
  304. {
  305. this.proc_Del();
  306. break;
  307. }
  308. case "CLOSE":
  309. {
  310. this.Close();
  311. break;
  312. }
  313. default:
  314. break;
  315. }
  316. }
  317. /// <summary>
  318. /// //铸机号查询
  319. /// </summary>
  320. /// <param name="sender"></param>
  321. /// <param name="e"></param>
  322. private void cbbCCM_SelectedIndexChanged(object sender, EventArgs e)
  323. {
  324. if (ucmeCCM.Text.Length > 0)
  325. proc_GetID(ucmeCCM.Text);
  326. }
  327. /// <summary>
  328. /// 中间包查询
  329. /// </summary>
  330. /// <param name="sender"></param>
  331. /// <param name="e"></param>
  332. private void cbbID_SelectedIndexChanged(object sender, EventArgs e)
  333. {
  334. try
  335. {
  336. if (!bOK)
  337. return;
  338. string strCCM = ucmeCCM.Text.Trim();
  339. string strID = ucmeID.Text.Trim();
  340. if (strID.Length == 0)
  341. return;
  342. string strErr = "";
  343. string strSql = "where TUNDISHID = '" + strID + "' and CCM_ID = '" + strCCM + "'";
  344. CoreClientParam ccp = new CoreClientParam();
  345. ccp.ServerName = "Core.LgMes.Server.LgDeviceManager.LadleManager";
  346. ccp.MethodName = "cbbID_SelectedIndexChanged";
  347. ccp.ServerParams = new Object[] { strSql };
  348. DataTable dt = new DataTable();
  349. ccp.SourceDataTable = dt;
  350. ob.ExecuteQueryToDataTable(ccp,CoreInvokeType.Internal);
  351. DataSet ds = new DataSet();
  352. ds.Tables.Add(dt);
  353. if (strErr != "" || !(ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0))
  354. {
  355. MessageBox.Show("中间包[" + strID + "]信息查询失败!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  356. return;
  357. }
  358. txtStatus.Text = Convert.ToString(ds.Tables[0].Rows[0]["STATUS"]);
  359. txtAge.Text = Convert.ToString(ds.Tables[0].Rows[0]["AGE"]);
  360. udtePTime.DateTime = Convert.ToDateTime(ds.Tables[0].Rows[0]["CREATIVEDATE"]);
  361. udteBuyTime.DateTime = Convert.ToDateTime(ds.Tables[0].Rows[0]["BUYDATE"]);
  362. txtMemo.Text = Convert.ToString(ds.Tables[0].Rows[0]["MEMO"]);
  363. }
  364. catch (Exception ex)
  365. {
  366. MessageBox.Show(ex.Message, "提示");
  367. }
  368. }
  369. }
  370. }