FrmProductCHEMBIAS.cs 47 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062
  1. using Core.Mes.Client.Comm.Control;
  2. using Core.Mes.Client.Comm.Server;
  3. using Core.Mes.Client.Comm.Tool;
  4. using CoreFS.CA06;
  5. using Infragistics.Win.UltraWinGrid;
  6. using System;
  7. using System.Collections;
  8. using System.Collections.Generic;
  9. using System.Data;
  10. using System.Drawing;
  11. using System.Windows.Forms;
  12. namespace Core.StlMes.Client.Qcm
  13. {
  14. public partial class FrmProductCHEMBIAS : FrmBase
  15. {
  16. int _cic = 1; //索引号
  17. bool isflag = false;
  18. int isselect = 0;
  19. private List<string> CicCode = new List<string>(); //做过操作的CIC
  20. public FrmProductCHEMBIAS()
  21. {
  22. InitializeComponent();
  23. }
  24. public FrmProductCHEMBIAS(string errMsg, OpeBase ob) : this()
  25. {
  26. this.ob = ob;
  27. ultraStatusBar1.Panels["ExMsg"].Text = errMsg;
  28. panel2.Visible = true;
  29. ultraStatusBar1.Visible = true;
  30. doQuery(isflag);
  31. }
  32. private void FrmProductCHEMBIAS_Load(object sender, EventArgs e)
  33. {
  34. BindcmbType();
  35. }
  36. private void InitSteel(string cic)
  37. {
  38. DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreProductCHEMBIAS.getSteel", new object[] { cic }, this.ob);
  39. GridHelper.CopyDataToDatatable(ref dt, ref dataTable3, true);
  40. }
  41. private void BindcmbType()
  42. {
  43. #region 下拉列表
  44. DataTable dt1 = new DataTable();
  45. dt1.Columns.Add("xiaid");
  46. DataRow dr1 = dt1.NewRow();
  47. dr1["xiaid"] = ">";
  48. dt1.Rows.Add(dr1);
  49. DataRow dr2 = dt1.NewRow();
  50. dr2["xiaid"] = ">=";
  51. dt1.Rows.Add(dr2);
  52. DataRow dr3 = dt1.NewRow();
  53. dr3["xiaid"] = "=";
  54. dt1.Rows.Add(dr3);
  55. DataRow dr4 = dt1.NewRow();
  56. dr4["xiaid"] = " ";
  57. dt1.Rows.Add(dr4);
  58. dt1.Columns["xiaid"].Caption = "符号";
  59. xiaxian.DataSource = dt1;
  60. xiaxian.ValueMember = "xiaid";
  61. DataTable dts1 = new DataTable();
  62. dts1.Columns.Add("xiaid");
  63. DataRow drs1 = dts1.NewRow();
  64. drs1["xiaid"] = "单一元素";
  65. dts1.Rows.Add(drs1);
  66. DataRow drs2 = dts1.NewRow();
  67. drs2["xiaid"] = "复合元素";
  68. dts1.Rows.Add(drs2);
  69. DataRow drs4 = dts1.NewRow();
  70. drs4["xiaid"] = " ";
  71. dts1.Rows.Add(drs4);
  72. dts1.Columns["xiaid"].Caption = "符号";
  73. cmbdanyi.DataSource = dts1;
  74. cmbdanyi.ValueMember = "xiaid";
  75. DataTable dt2 = new DataTable();
  76. dt2.Columns.Add("shangid");
  77. DataRow dr5 = dt2.NewRow();
  78. dr5["shangid"] = "<";
  79. dt2.Rows.Add(dr5);
  80. DataRow dr6 = dt2.NewRow();
  81. dr6["shangid"] = "<=";
  82. dt2.Rows.Add(dr6);
  83. DataRow dr7 = dt2.NewRow();
  84. dr7["shangid"] = " ";
  85. dt2.Rows.Add(dr7);
  86. dt2.Columns["shangid"].Caption = "符号";
  87. shangxian.DataSource = dt2;
  88. shangxian.ValueMember = "shangid";
  89. DataTable dt3 = ServerHelper.GetData("com.steering.pss.qcm.CoreDropList.GetSelectstd", new Object[] { }, this.ob);//标准表
  90. int num = dt3.Rows.Count;
  91. DataTable dt4 = new DataTable();
  92. dt4.Columns.Add("fenlei");
  93. dt4.Columns.Add("fenname");
  94. DataRow dr;
  95. for (int i = 0; i < num; i++)
  96. {
  97. dr = dt4.NewRow();
  98. dr["fenlei"] = dt3.Rows[i]["STD_NAME"];
  99. dr["fenname"] = dt3.Rows[i]["STD_CODE"];
  100. dt4.Rows.Add(dr);
  101. }
  102. dt4.Columns["fenlei"].Caption = "名字";
  103. dt4.Columns["fenname"].Caption = "代码";
  104. fenleinumber.DataSource = dt4;
  105. fenleinumber.ValueMember = "fenname";
  106. fenleinumber.DisplayMember = "fenlei";
  107. DataTable dt5 = ServerHelper.GetData("com.steering.pss.qcm.CoreDropList.GetSelectinfo", new Object[] { }, this.ob);
  108. int num1 = dt5.Rows.Count;
  109. DataTable dt6 = new DataTable();
  110. dt6.Columns.Add("id");
  111. dt6.Columns.Add("name");
  112. dr = dt6.NewRow();
  113. dr["id"] = "";
  114. dr["name"] = "";
  115. dt6.Rows.Add(dr);
  116. for (int i = 0; i < num1; i++)
  117. {
  118. dr = dt6.NewRow();
  119. dr["id"] = dt5.Rows[i]["BASECODE"];
  120. dr["name"] = dt5.Rows[i]["BASENAME"];
  121. dt6.Rows.Add(dr);
  122. }
  123. dt6.Columns["id"].Caption = "类型";
  124. dt6.Columns["name"].Caption = "名字";
  125. ClsBaseInfo.SetComboItemHeight(yuanfenlei);
  126. yuanfenlei.DataSource = dt6;
  127. yuanfenlei.DisplayMember = "name";
  128. yuanfenlei.ValueMember = "id";
  129. DataTable dt7 = ServerHelper.GetData("com.steering.pss.qcm.ComBaseQuery.getCombaseChemA", new Object[] { }, this.ob);
  130. int num2 = dt7.Rows.Count;
  131. DataTable dt8 = new DataTable();
  132. dt8.Columns.Add("id");
  133. dt8.Columns.Add("name");
  134. for (int i = 0; i < num2; i++)
  135. {
  136. dr = dt8.NewRow();
  137. dr["id"] = dt7.Rows[i]["CHEM_CODE"] + "," + dt7.Rows[i]["CHEM_TYPE"] + "," + dt7.Rows[i]["CHEM_FORMULA"];
  138. dr["name"] = dt7.Rows[i]["CHEM_NAME"];
  139. dt8.Rows.Add(dr);
  140. }
  141. dt8.Columns["id"].Caption = "类型";
  142. dt8.Columns["name"].Caption = "名字";
  143. cmbyuansu.DataSource = dt8;
  144. cmbyuansu.DisplayMember = "name";
  145. cmbyuansu.ValueMember = "id";
  146. #endregion
  147. }
  148. public override void ToolBar_Click(object sender, string ToolbarKey)
  149. {
  150. switch (ToolbarKey)
  151. {
  152. case "doQuery":
  153. doQuery(isflag);
  154. break;
  155. case "doSave":
  156. doSave();
  157. break;
  158. case "doDelete":
  159. this.doDeleteOrResume(true);
  160. break;
  161. case "doResume":
  162. this.doDeleteOrResume(false);
  163. break;
  164. case "doClose":
  165. this.Close();
  166. break;
  167. }
  168. }
  169. ArrayList parmPAdd = new ArrayList(); //主表新增
  170. ArrayList parmPUpdate = new ArrayList(); //主表修改
  171. ArrayList parmCAdd = new ArrayList(); //从表新增
  172. ArrayList parmCUpdate = new ArrayList(); //从表修改
  173. ArrayList Deletelist = new ArrayList(); //删除数据或恢复数据
  174. ArrayList DeletelistC = new ArrayList(); //删除数据或恢复数据
  175. ArrayList parmSteel = new ArrayList(); //勾选的钢级牌号信息
  176. string deleteCic = ""; //用于钢级删除的CIC码
  177. private void doQuery(Boolean flag)
  178. {
  179. string stdName = "%";
  180. if (ultraCheckEditor1.Checked)
  181. stdName = ultraTextEditor1.Text.Trim();
  182. dataTable3.Clear();
  183. DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreProductCHEMBIAS.doQuery", new Object[] { flag, stdName }, this.ob);
  184. dataTable2.Clear();
  185. GridHelper.CopyDataToDatatable(ref dt, ref this.dataTable1, true);
  186. //从表的记录也要查询出来。
  187. DataTable mindt = ServerHelper.GetData("com.steering.pss.qcm.CoreProductCHEMBIAS.doQueryC", new Object[] { flag, stdName }, this.ob);
  188. GridHelper.CopyDataToDatatable(ref mindt, ref this.dataTable2, true);
  189. for (int i = 0; i < ultraGrid2.Rows.Count; i++)
  190. {
  191. for (int j = 0; j < ultraGrid2.Rows[i].Cells.Count; j++)
  192. {
  193. if (j == 7) break;
  194. ultraGrid2.Rows[i].Cells[j].Activation = Infragistics.Win.UltraWinGrid.Activation.ActivateOnly;
  195. }
  196. if (ultraGrid2.Rows[i].ChildBands[0].Rows.Count > 0)
  197. {
  198. for (int j = 0; j < ultraGrid2.Rows[i].ChildBands[0].Rows.Count; j++)
  199. {
  200. for (int k = 0; k < ultraGrid2.Rows[i].ChildBands[0].Rows[j].Cells.Count; k++)
  201. {
  202. if (k == 16) break;
  203. ultraGrid2.Rows[i].ChildBands[0].Rows[j].Cells[k].Activation = Infragistics.Win.UltraWinGrid.Activation.ActivateOnly;
  204. }
  205. }
  206. }
  207. }
  208. //不同颜色区分是否有效数据
  209. Infragistics.Win.UltraWinGrid.UltraGridRow row = null;
  210. Infragistics.Win.UltraWinGrid.UltraGridRow minrow = null;
  211. for (int i = 0; i < ultraGrid2.Rows.Count; i++)
  212. {
  213. row = ultraGrid2.Rows[i];
  214. if (row.ChildBands[0].Rows.Count > 0)
  215. {
  216. for (int j = 0; j < row.ChildBands[0].Rows.Count; j++)
  217. {
  218. minrow = row.ChildBands[0].Rows[j];
  219. if (!minrow.Cells["VALIDFLAG"].Value.ToString().Equals("有效"))
  220. {
  221. minrow.Appearance.ForeColor = Color.Red;
  222. row.ExpandAll();
  223. }
  224. else
  225. {
  226. minrow.Appearance.ForeColor = Color.Black;
  227. }
  228. }
  229. }
  230. if (!row.Cells["VALIDFLAG"].Value.ToString().Equals("有效"))
  231. {
  232. row.Appearance.ForeColor = Color.Red;
  233. }
  234. else
  235. {
  236. row.Appearance.ForeColor = Color.Black;
  237. }
  238. }
  239. //UltraGridColumn[] col = new UltraGridColumn[] { };
  240. //GridHelper.RefreshAndAutoSizeExceptRows(ultraGrid2, col);
  241. }
  242. private void doSave()
  243. {
  244. ultraGrid2.UpdateData();
  245. if (GetGridData() == 0 && (parmPAdd.Count > 0 || parmPUpdate.Count > 0 || parmCAdd.Count > 0 || parmCUpdate.Count > 0))
  246. {
  247. if (isselect == 0)
  248. {
  249. MessageBox.Show("请选择记录", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  250. return;
  251. }
  252. if (MessageBox.Show("是否确认保存修改?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
  253. {
  254. return;
  255. }
  256. if (ultraGrid2.ActiveRow != null)
  257. deleteCic = ultraGrid2.ActiveRow.Cells["CIC"].Value.ToString();
  258. CoreClientParam ccp = new CoreClientParam(); //CoreClientParam是平台用来向服务端传递存放所有相关参数信息的。
  259. ccp.ServerName = "com.steering.pss.qcm.CoreProductCHEMBIAS"; //服务名指的是服务端的包名+类名
  260. ccp.MethodName = "doSave"; //方法名指的是服务名指定类里的方法
  261. ccp.ServerParams = new object[] { parmPAdd, parmPUpdate, parmCAdd, parmCUpdate, parmSteel, deleteCic };//服务端方法的参数
  262. //ExecuteNonQuery主要用来执行添加、修改、删除、存储过程的操作。
  263. ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  264. if (ccp.ReturnCode == -1)
  265. return;
  266. MessageBox.Show("保存成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  267. doQuery(isflag);
  268. ExpandRow();
  269. CicCode.Clear();
  270. }
  271. }
  272. /// <summary>
  273. /// 删除或恢复
  274. /// </summary>
  275. /// <param name="isDelete">true删除 false恢复</param>
  276. private void doDeleteOrResume(bool flag)
  277. {
  278. if (GetDeleteData(flag) == -1)
  279. {
  280. return;
  281. }
  282. if (isselect == 0)
  283. {
  284. MessageBox.Show("请选择需要操作的记录", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  285. return;
  286. }
  287. if (MessageBox.Show("是否确认" + (flag ? "作废" : "恢复") + "数据", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
  288. {
  289. return;
  290. }
  291. CoreClientParam ccp = new CoreClientParam(); //CoreClientParam是平台用来向服务端传递存放所有相关参数信息的。
  292. ccp.ServerName = "com.steering.pss.qcm.CoreProductCHEMBIAS"; //服务名指的是服务端的包名+类名
  293. ccp.MethodName = "doDelete"; //方法名指的是服务名指定类里的方法
  294. ccp.ServerParams = new object[] { Deletelist, DeletelistC, flag };//服务端方法的参数
  295. //ExecuteNonQuery主要用来执行添加、修改、删除、存储过程的操作。
  296. ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  297. if (ccp.ReturnCode == -1)
  298. return;
  299. MessageBox.Show("数据" + (flag ? "作废" : "恢复") + "成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  300. doQuery(isflag);
  301. ExpandRow();
  302. CicCode.Clear();
  303. }
  304. private void ultraGrid2_CellChange(object sender, CellEventArgs e)
  305. {
  306. this.ultraGrid2.UpdateData();
  307. if (e.Cell.Column.Key.Equals("MIN_SIGN"))
  308. {
  309. if (e.Cell.Value.ToString() == "=")
  310. {
  311. e.Cell.Row.Cells["MAX_SIGN"].Activation = Activation.ActivateOnly;
  312. e.Cell.Row.Cells["MAX_VAL"].Activation = Activation.ActivateOnly;
  313. }
  314. else
  315. {
  316. e.Cell.Row.Cells["MAX_SIGN"].Activation = Activation.AllowEdit;
  317. e.Cell.Row.Cells["MAX_VAL"].Activation = Activation.AllowEdit;
  318. }
  319. }
  320. else if (e.Cell.Column.Key.Equals("ASSORTMENT_NAME"))
  321. {
  322. e.Cell.Row.Cells["ASSORTMENT_CODE"].Value = e.Cell.Row.Cells["ASSORTMENT_NAME"].Value;
  323. }
  324. else if (e.Cell.Column.Key.Equals("STD_NAME"))
  325. {
  326. e.Cell.Row.Cells["STD_CODE"].Value = e.Cell.Row.Cells["STD_NAME"].Value;
  327. }
  328. else if (e.Cell.Column.Key.Equals("CHEM_NAME"))
  329. {
  330. String str = e.Cell.Row.Cells["CHEM_NAME"].Value.ToString();
  331. string[] str1 = str.Split(',');
  332. e.Cell.Row.Cells["CHEM_CODE"].Value = str1[0];
  333. e.Cell.Row.Cells["WHOLE_BACKLOG"].Value = str1[1];
  334. e.Cell.Row.Cells["CHEM_FORMULA"].Value = str1[2];
  335. }
  336. else if (e.Cell.Column.Key.Equals("cb"))
  337. {
  338. Activation activation = Activation.NoEdit;
  339. if (Convert.ToBoolean(e.Cell.Value))
  340. {
  341. activation = Activation.AllowEdit;
  342. }
  343. CellsCollection cells = e.Cell.Row.Cells;
  344. for (int i = 0; i < cells.Count; i++)
  345. {
  346. if (!cells[i].Column.Key.Equals("cb")) //i!=9
  347. {
  348. if (i == 6) break;
  349. e.Cell.Row.Cells[i].Activation = activation;
  350. }
  351. }
  352. // e.Cell.Value = !Convert.ToBoolean(e.Cell.Value);
  353. }
  354. else if (e.Cell.Column.Key.Equals("ck1"))
  355. {
  356. Activation activation = Activation.ActivateOnly;
  357. if (Convert.ToBoolean(e.Cell.Value))
  358. {
  359. activation = Activation.AllowEdit;
  360. }
  361. CellsCollection cells = e.Cell.Row.Cells;
  362. for (int i = 0; i < cells.Count; i++)
  363. {
  364. if (!cells[i].Column.Key.Equals("ck1")) //i!=9
  365. {
  366. if (i == 15) break;
  367. e.Cell.Row.Cells[i].Activation = activation;
  368. }
  369. }
  370. }
  371. SaveCic(e);
  372. ultraGrid2.UpdateData();
  373. }
  374. private void ultraGrid2_AfterRowInsert(object sender, RowEventArgs e)
  375. {
  376. ultraGrid2.UpdateData();
  377. UltraGridRow ugr = this.ultraGrid2.ActiveRow;
  378. if (ugr == null)
  379. return;
  380. if (!ugr.HasParent()) //主表
  381. {
  382. string cicStr = "";
  383. string cic = "";
  384. DataRow[] dr = dataTable1.Select("", "CIC DESC");
  385. if (dr.Length > 0)
  386. {
  387. cic = dr[0]["CIC"].ToString();
  388. }
  389. if (!cic.Equals(""))
  390. {
  391. int number = int.Parse(cic.Substring(3, 6));
  392. cicStr = "CIC" + string.Format("{0:000000}", number + 1);
  393. _cic = number + 1;
  394. }
  395. else
  396. {
  397. cicStr = "CIC" + string.Format("{0:000000}", _cic);
  398. _cic = _cic + 1;
  399. }
  400. //赋值理化索引号
  401. ugr.Cells["CIC"].Value = cicStr;
  402. // ugr.Cells["cb"].Value = false;
  403. if (!Convert.ToBoolean(ugr.Cells["cb"].Value))
  404. {
  405. for (int i = 0; i < ugr.Cells.Count; i++)
  406. {
  407. if (!ugr.Cells[i].Column.Key.Equals("cb"))
  408. ugr.Cells[i].Activation = Activation.ActivateOnly;
  409. }
  410. }
  411. }
  412. else
  413. {
  414. int indexSeq = 0;
  415. DataRow[] dr = dataTable2.Select("CIC='" + ugr.Cells["CIC"].Value.ToString() + "'", "INDEX_SEQ DESC");
  416. if (dr.Length > 0)
  417. {
  418. indexSeq = Convert.ToInt32(dr[0]["INDEX_SEQ"]);
  419. }
  420. indexSeq += 1;
  421. //赋值序号
  422. this.ultraGrid2.DisplayLayout.ActiveRow.Cells["INDEX_SEQ"].Value = indexSeq;
  423. if (!Convert.ToBoolean(ugr.Cells["ck1"].Value))
  424. {
  425. for (int i = 0; i < ugr.Cells.Count; i++)
  426. {
  427. if (!ugr.Cells[i].Column.Key.Equals("ck1"))
  428. ugr.Cells[i].Activation = Activation.ActivateOnly;
  429. }
  430. }
  431. }
  432. }
  433. private int GetGridData()
  434. {
  435. this.ultraGrid2.UpdateData();
  436. this.ultraGrid1.UpdateData();
  437. parmPAdd = new ArrayList();
  438. parmPUpdate = new ArrayList();
  439. parmCAdd = new ArrayList();
  440. parmCUpdate = new ArrayList();
  441. UltraGridRow ugr = ultraGrid2.ActiveRow;
  442. isselect = 0;
  443. foreach (UltraGridRow row in ultraGrid2.Rows)
  444. {
  445. if (row.Cells["cb"].Value.ToString().ToUpper() == "TRUE")
  446. {
  447. ArrayList plistAdd = new ArrayList();
  448. ArrayList plistUpdate = new ArrayList();
  449. isselect += 1;
  450. if (row.Cells["STD_NAME"].Value.ToString() == "")
  451. {
  452. MessageBox.Show("请选择标准名称", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  453. //row.Activate();
  454. return -1;
  455. }
  456. //if (row.Cells["ASSORTMENT_NAME"].Value.ToString() == "")
  457. //{
  458. // MessageBox.Show("请选择品种名称", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  459. // row.Activate();
  460. // return -1;
  461. //}
  462. string assortment = row.Cells["ASSORTMENT_NAME"].Value.ToString();
  463. UltraGridRow[] arrRow = GridHelper.GetRowsWithKey(ultraGrid1, new string[] { "CHK" }, new string[] { "True" });
  464. if (assortment != "" && arrRow.Length > 0)
  465. {
  466. MessageBox.Show("钢种分类和右边的钢级(牌号)不能同时存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  467. // row.Activate();
  468. return -1;
  469. }
  470. else if (assortment == "" && arrRow.Length <= 0)
  471. {
  472. MessageBox.Show("请选择钢种分类或者右边钢级(牌号)", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  473. row.Activate();
  474. return -1;
  475. }
  476. if (row.Cells["VALIDFLAG"].Value.ToString() == "") //新增
  477. {
  478. plistAdd.Add(row.Cells["CIC"].Value.ToString());
  479. plistAdd.Add(row.Cells["STD_CODE"].Value.ToString());
  480. plistAdd.Add(row.Cells["STD_NAME"].Text);
  481. plistAdd.Add(row.Cells["ASSORTMENT_CODE"].Value.ToString());
  482. plistAdd.Add(row.Cells["ASSORTMENT_NAME"].Text);
  483. plistAdd.Add(this.UserInfo.GetUserName());
  484. parmPAdd.Add(plistAdd);
  485. }
  486. else
  487. {
  488. plistUpdate.Add(row.Cells["CIC"].Value.ToString());
  489. plistUpdate.Add(row.Cells["STD_CODE"].Value.ToString());
  490. plistUpdate.Add(row.Cells["STD_NAME"].Text);
  491. plistUpdate.Add(row.Cells["ASSORTMENT_CODE"].Value.ToString());
  492. plistUpdate.Add(row.Cells["ASSORTMENT_NAME"].Text);
  493. plistUpdate.Add(this.UserInfo.GetUserName());
  494. parmPUpdate.Add(plistUpdate);
  495. }
  496. }
  497. if (row.Cells["VALIDFLAG"].Value.ToString() != "" || (row.Cells["VALIDFLAG"].Value.ToString() == "" && row.Cells["cb"].Value.ToString().ToUpper() == "TRUE"))
  498. {
  499. if (row.ChildBands[0].Rows.Count > 0)
  500. {
  501. foreach (UltraGridRow crow in row.ChildBands[0].Rows)
  502. {
  503. if (crow.Cells["ck1"].Value.ToString().ToUpper() == "TRUE")
  504. {
  505. UltraGridRow pRow = crow.ParentRow;
  506. string assortment = pRow.Cells["ASSORTMENT_NAME"].Text;
  507. UltraGridRow[] arrRow = GridHelper.GetRowsWithKey(ultraGrid1, new string[] { "CHK" }, new string[] { "True" });
  508. if (assortment != "" && arrRow.Length > 0)
  509. {
  510. MessageBox.Show("钢种分类和右边的钢级(牌号)不能同时存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  511. // row.Activate();
  512. return -1;
  513. }
  514. else if (assortment == "" && arrRow.Length <= 0)
  515. {
  516. MessageBox.Show("请选择钢种分类或者右边钢级(牌号)", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  517. row.Activate();
  518. return -1;
  519. }
  520. isselect += 1;
  521. if (crow.Cells["CHEM_NAME"].Value.ToString() == "")
  522. {
  523. MessageBox.Show("请选择化学元素描述", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  524. crow.Activate();
  525. return -1;
  526. }
  527. string chem_type = ""; //化学元素类型
  528. switch (crow.Cells["whole_backlog"].Value.ToString())
  529. {
  530. case "单一元素":
  531. chem_type = "A";
  532. break;
  533. case "复合元素":
  534. chem_type = "B";
  535. break;
  536. }
  537. string min_sign = crow.Cells["MIN_SIGN"].Text.Trim();
  538. string min_val = crow.Cells["MIN_VAL"].Value.ToString();
  539. string max_sign = crow.Cells["MAX_SIGN"].Text.Trim();
  540. string max_val = crow.Cells["MAX_VAL"].Value.ToString();
  541. //string std_min_sign = crow.Cells["STD_MIN_SIGN"].Text.Trim();
  542. string std_min_val = crow.Cells["STD_MIN_VAL"].Value.ToString();
  543. //string std_max_sign = crow.Cells["STD_MAX_SIGN"].Text.Trim();
  544. string std_max_val = crow.Cells["STD_MAX_VAL"].Value.ToString();
  545. if (min_sign == "" && max_sign == "")
  546. {
  547. MessageBox.Show("化学成分上限符号和下限符号请至少选择一项", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  548. crow.Activate();
  549. return -1;
  550. }
  551. if (min_sign != "" && min_val == "")
  552. {
  553. MessageBox.Show("请输入化学成分下限值", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  554. crow.Activate();
  555. return -1;
  556. }
  557. if (min_sign == "" && min_val != "")
  558. {
  559. MessageBox.Show("化学成分下限值不为空,请选择化学元素下限符号", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  560. crow.Activate();
  561. return -1;
  562. }
  563. if (max_sign != "" && max_val == "")
  564. {
  565. MessageBox.Show("请输入化学成分上限值", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  566. crow.Activate();
  567. return -1;
  568. }
  569. if (max_sign == "" && max_val != "")
  570. {
  571. MessageBox.Show("化学成分上限值不为空,请选择化学元素上限符号", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  572. crow.Activate();
  573. return -1;
  574. }
  575. if (min_sign != "=")
  576. {
  577. if (min_val != "" && !StringUtil.IsNumber(min_val))
  578. {
  579. MessageBox.Show("化学成分下限值:请输入数字!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  580. crow.Activate();
  581. return -1;
  582. }
  583. if (max_val != "" && !StringUtil.IsNumber(max_val))
  584. {
  585. MessageBox.Show("化学成分上限值:请输入数字!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  586. crow.Activate();
  587. return -1;
  588. }
  589. if (min_val != "" && max_val != "")
  590. {
  591. if (Convert.ToDouble(max_val) < Convert.ToDouble(min_val))
  592. {
  593. MessageBox.Show("化学成分上限值不能小于下限值", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  594. crow.Activate();
  595. return -1;
  596. }
  597. }
  598. }
  599. //if (min_sign != "" && max_sign == "")
  600. //{
  601. // exsitchem = 1; //下限
  602. //}
  603. //if (max_sign != "" && min_sign == "")
  604. // exsitchem = 2; //上限
  605. //if (min_sign != "" && max_sign != "")
  606. // exsitchem = 3; //上下限存在
  607. //if (std_min_sign != "" && std_min_val == "")
  608. //{
  609. // MessageBox.Show("请输入允许偏差下限值", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  610. // crow.Activate();
  611. // return -1;
  612. //}
  613. //if (std_min_sign == "" && std_min_val != "")
  614. //{
  615. // MessageBox.Show("允许偏差下限值存在,请选择下限符号", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  616. // crow.Activate();
  617. // return -1;
  618. //}
  619. //if (std_max_sign != "" && std_max_sign == "")
  620. //{
  621. // MessageBox.Show("请输入允许偏差上限值", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  622. // crow.Activate();
  623. // return -1;
  624. //}
  625. //if (std_max_sign == "" && std_max_val != "")
  626. //{
  627. // MessageBox.Show("允许偏差上限值存在,请选择上限符号", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  628. // crow.Activate();
  629. // return -1;
  630. //}
  631. //if (exsitchem == 1 && std_max_val != "")
  632. //{
  633. // MessageBox.Show("化学成分不存在上限值,允许偏差也不能存在上偏差", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  634. // crow.Activate();
  635. // return -1;
  636. //}
  637. //if (exsitchem == 2 && std_min_val != "")
  638. //{
  639. // MessageBox.Show("化学成分不存在下限值,允许偏差也不能存在下偏差", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  640. // crow.Activate();
  641. // return -1;
  642. //}
  643. if (std_min_val != "")
  644. {
  645. if (!StringUtil.IsNumber(std_min_val))
  646. {
  647. MessageBox.Show("允许偏差下偏差:请输入数字!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  648. crow.Activate();
  649. return -1;
  650. }
  651. }
  652. if (std_max_val != "")
  653. {
  654. if (!StringUtil.IsNumber(std_max_val))
  655. {
  656. MessageBox.Show("允许偏差上偏差:请输入数字!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  657. crow.Activate();
  658. return -1;
  659. }
  660. }
  661. //if (std_min_val != "" && std_max_val != "")
  662. //{
  663. // if (Convert.ToDouble(std_max_val) < Convert.ToDouble(std_min_val))
  664. // {
  665. // MessageBox.Show("允许偏差上限值不能小于下限值!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  666. // crow.Activate();
  667. // return -1;
  668. // }
  669. //}
  670. ArrayList clistAdd = new ArrayList();
  671. ArrayList clistUpdate = new ArrayList();
  672. if (crow.Cells["VALIDFLAG"].Value.ToString() == "")
  673. {
  674. clistAdd.Add(crow.Cells["CIC"].Value.ToString());
  675. clistAdd.Add(crow.Cells["INDEX_SEQ"].Value.ToString());
  676. clistAdd.Add(crow.Cells["CHEM_CODE"].Value.ToString());
  677. clistAdd.Add(crow.Cells["CHEM_NAME"].Text);
  678. clistAdd.Add(chem_type);
  679. clistAdd.Add(crow.Cells["CHEM_FORMULA"].Value.ToString());
  680. clistAdd.Add(min_sign);
  681. clistAdd.Add(min_val);
  682. clistAdd.Add(max_sign);
  683. clistAdd.Add(max_val);
  684. // clistAdd.Add(std_min_sign);
  685. clistAdd.Add(std_min_val);
  686. //clistAdd.Add(std_max_sign);
  687. clistAdd.Add(std_max_val);
  688. clistAdd.Add(this.UserInfo.GetUserName());
  689. parmCAdd.Add(clistAdd);
  690. }
  691. else
  692. {
  693. clistUpdate.Add(crow.Cells["CIC"].Value.ToString());
  694. clistUpdate.Add(crow.Cells["INDEX_SEQ"].Value.ToString());
  695. clistUpdate.Add(crow.Cells["CHEM_CODE"].Value.ToString());
  696. clistUpdate.Add(crow.Cells["CHEM_NAME"].Text);
  697. clistUpdate.Add(chem_type);
  698. clistUpdate.Add(crow.Cells["CHEM_FORMULA"].Value.ToString());
  699. clistUpdate.Add(min_sign);
  700. clistUpdate.Add(min_val);
  701. clistUpdate.Add(max_sign);
  702. clistUpdate.Add(max_val);
  703. //clistUpdate.Add(std_min_sign);
  704. clistUpdate.Add(std_min_val);
  705. //clistUpdate.Add(std_max_sign);
  706. clistUpdate.Add(std_max_val);
  707. clistUpdate.Add(this.UserInfo.GetUserName());
  708. parmCUpdate.Add(clistUpdate);
  709. }
  710. }
  711. }
  712. }
  713. }
  714. }
  715. if (GetGrid1Data() == -1)
  716. return -1;
  717. return 0;
  718. }
  719. private int GetGrid1Data()
  720. {
  721. ultraGrid1.UpdateData();
  722. ultraGrid2.UpdateData();
  723. parmSteel = new ArrayList();
  724. deleteCic = "";
  725. UltraGridRow ugr = ultraGrid2.ActiveRow;
  726. if (ugr == null)
  727. return -1;
  728. foreach (UltraGridRow row in ultraGrid1.Rows)
  729. {
  730. if (row.Cells["CHK"].Value.ToString().ToUpper() == "TRUE")
  731. {
  732. ArrayList tmpList = new ArrayList();
  733. tmpList.Add(ugr.Cells["CIC"].Value.ToString());
  734. tmpList.Add(row.Cells["STEELCODE"].Value);
  735. tmpList.Add(row.Cells["STEELNAME"].Value);
  736. tmpList.Add(this.UserInfo.GetUserName());
  737. parmSteel.Add(tmpList);
  738. }
  739. }
  740. return 0;
  741. }
  742. private void ultraCheckEditor1_CheckedChanged(object sender, EventArgs e)
  743. {
  744. if (this.ultraCheckEditor1.Checked)
  745. {
  746. this.ultraTextEditor1.ReadOnly = false;
  747. }
  748. else
  749. {
  750. this.ultraTextEditor1.ReadOnly = true;
  751. }
  752. }
  753. private void ultraCheckEditor4_CheckedChanged(object sender, EventArgs e)
  754. {
  755. if (this.ultraCheckEditor4.Checked)
  756. {
  757. isflag = true;
  758. }
  759. else
  760. {
  761. isflag = false;
  762. }
  763. }
  764. /// <summary>
  765. /// 得到删除或恢复的数据
  766. /// </summary>
  767. /// <param name="flag">true 删除 false 恢复</param>
  768. /// <returns></returns>
  769. private int GetDeleteData(bool flag)
  770. {
  771. isselect = 0;
  772. this.ultraGrid2.UpdateData();
  773. Deletelist = new ArrayList();
  774. DeletelistC = new ArrayList();
  775. foreach (UltraGridRow row in ultraGrid2.Rows)
  776. {
  777. if (row.Cells["cb"].Value.ToString().ToUpper() == "TRUE")
  778. {
  779. isselect += 1;
  780. if (flag) //删除
  781. {
  782. if (row.Cells["VALIDFLAG"].Value.ToString() != "有效")
  783. {
  784. MessageBox.Show("无效数据,无法删除", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  785. row.Activate();
  786. return -1;
  787. }
  788. ArrayList list = new ArrayList();
  789. list.Add(this.UserInfo.GetUserName());
  790. list.Add(row.Cells["CIC"].Value.ToString());
  791. Deletelist.Add(list);
  792. }
  793. else //恢复
  794. {
  795. if (row.Cells["VALIDFLAG"].Value.ToString() == "有效")
  796. {
  797. MessageBox.Show("有效数据,无法恢复", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  798. row.Activate();
  799. return -1;
  800. }
  801. Deletelist.Add(row.Cells["CIC"].Value.ToString());
  802. if (row.ChildBands[0].Rows.Count > 0)
  803. {
  804. foreach (UltraGridRow crow in row.ChildBands[0].Rows)
  805. {
  806. if (crow.Cells["VALIDFLAG"].Value.ToString() == "有效")
  807. {
  808. MessageBox.Show("有效数据,无法恢复", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  809. row.Activate();
  810. return -1;
  811. }
  812. if (crow.Cells["ck1"].Value.ToString().ToUpper() == "TRUE")
  813. {
  814. ArrayList plist = new ArrayList();
  815. plist.Add(crow.Cells["CIC"].Value.ToString());
  816. plist.Add(crow.Cells["INDEX_SEQ"].Value.ToString());
  817. DeletelistC.Add(plist);
  818. }
  819. }
  820. }
  821. }
  822. }
  823. else
  824. {
  825. if (row.ChildBands[0].Rows.Count > 0)
  826. {
  827. foreach (UltraGridRow crow in row.ChildBands[0].Rows)
  828. {
  829. if (crow.Cells["ck1"].Value.ToString().ToUpper() == "TRUE")
  830. {
  831. isselect += 1;
  832. if (flag)
  833. {
  834. if (crow.Cells["VALIDFLAG"].Value.ToString() != "有效")
  835. {
  836. MessageBox.Show("无效数据,无法作废", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  837. row.Activate();
  838. return -1;
  839. }
  840. ArrayList clist = new ArrayList();
  841. clist.Add(this.UserInfo.GetUserName());
  842. clist.Add(crow.Cells["CIC"].Value.ToString());
  843. clist.Add(crow.Cells["INDEX_SEQ"].Value.ToString());
  844. DeletelistC.Add(clist);
  845. }
  846. else
  847. {
  848. if (crow.Cells["VALIDFLAG"].Value.ToString() == "有效")
  849. {
  850. MessageBox.Show("有效数据,无法恢复", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  851. row.Activate();
  852. return -1;
  853. }
  854. if (row.Cells["cb"].Value.ToString().ToUpper() == "FALSE" && row.Cells["VALIDFLAG"].Value.ToString() != "有效")
  855. {
  856. MessageBox.Show("主记录无效,不能单独恢复从记录,\n请先恢复主记录或主从记录一起恢复", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  857. return -1;
  858. }
  859. ArrayList plist = new ArrayList();
  860. plist.Add(crow.Cells["CIC"].Value.ToString());
  861. plist.Add(crow.Cells["INDEX_SEQ"].Value.ToString());
  862. DeletelistC.Add(plist);
  863. }
  864. }
  865. }
  866. }
  867. }
  868. }
  869. return 0;
  870. }
  871. private void SaveCic(CellEventArgs e)
  872. {
  873. if (e.Cell.Row.HasParent())
  874. {
  875. if (e.Cell.Row.Cells["ck1"].Value.ToString().ToUpper() == "TRUE"
  876. && !CicCode.Contains(e.Cell.Row.Cells["CIC"].Value.ToString()))
  877. {
  878. CicCode.Add(e.Cell.Row.Cells["CIC"].Value.ToString());
  879. }
  880. else if (e.Cell.Row.Cells["ck1"].Value.ToString().ToUpper() != "TRUE"
  881. && CicCode.Contains(e.Cell.Row.Cells["CIC"].Value.ToString()))
  882. {
  883. CicCode.Remove(e.Cell.Row.Cells["CIC"].Value.ToString()); //取消按钮 则取消保存的理化标准码
  884. }
  885. }
  886. else if (e.Cell.Row.ChildBands[0].Rows.Count > 0)
  887. {
  888. if (e.Cell.Row.Cells["cb"].Value.ToString().ToUpper() == "TRUE"
  889. && !CicCode.Contains(e.Cell.Row.Cells["CIC"].Value.ToString()))
  890. {
  891. CicCode.Add(e.Cell.Row.Cells["CIC"].Value.ToString());
  892. }
  893. }
  894. }
  895. private void ExpandRow()
  896. {
  897. foreach (UltraGridRow row in ultraGrid2.Rows)
  898. {
  899. if (CicCode.Contains(row.Cells["CIC"].Value.ToString()))
  900. {
  901. row.ExpandAll();
  902. row.Activate();
  903. }
  904. }
  905. }
  906. UltraGridRow oldActiveRow = null; //之前激活的主记录行
  907. private void ultraGrid2_AfterRowActivate(object sender, EventArgs e)
  908. {
  909. try
  910. {
  911. this.Cursor = Cursors.WaitCursor;
  912. UltraGridRow ugr = ultraGrid2.ActiveRow; //当前激活行
  913. if (ugr == null)
  914. return;
  915. UltraGridRow parentActiveRow = null; //主记录行
  916. if (ugr.HasParent())
  917. {
  918. parentActiveRow = ugr.ParentRow;
  919. //parentActiveRow.Cells["cb"].Value = true;
  920. }
  921. else
  922. {
  923. // ugr.Cells["cb"].Value = true;
  924. parentActiveRow = ugr;
  925. }
  926. if (oldActiveRow != parentActiveRow)
  927. {
  928. if (oldActiveRow != null)
  929. {
  930. oldActiveRow.Cells["cb"].Value = false;
  931. for (int i = 0; i < oldActiveRow.ChildBands[0].Rows.Count; i++)
  932. {
  933. oldActiveRow.ChildBands[0].Rows[i].Cells["ck1"].Value = false;
  934. }
  935. }
  936. string cic = parentActiveRow.Cells["CIC"].Value.ToString(); //主记录 子记录都有CIC字段 且主从关系的值一样
  937. InitSteel(cic);
  938. ultraGrid2.UpdateData();
  939. }
  940. oldActiveRow = parentActiveRow;
  941. }
  942. finally
  943. {
  944. this.Cursor = Cursors.Default;
  945. }
  946. }
  947. private void ultraGrid2_InitializeRow(object sender, InitializeRowEventArgs e)
  948. {
  949. if (!e.Row.HasParent())
  950. {
  951. if (e.Row.Cells["cb"].Value.ToString().ToUpper() == "TRUE")
  952. {
  953. e.Row.Cells["STD_NAME"].Activation = Activation.AllowEdit;
  954. e.Row.Cells["ASSORTMENT_NAME"].Activation = Activation.AllowEdit;
  955. }
  956. }
  957. }
  958. private void ultraGrid1_CellChange(object sender, CellEventArgs e)
  959. {
  960. ultraGrid1.UpdateData();
  961. }
  962. private void ultraToolbarsManager1_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
  963. {
  964. switch (e.Tool.Key)
  965. {
  966. case "查询":
  967. doQuery(isflag);
  968. break;
  969. case "保存":
  970. doSave();
  971. break;
  972. case "确认":
  973. break;
  974. case "作废":
  975. doDeleteOrResume(true);
  976. break;
  977. case "恢复":
  978. doDeleteOrResume(false);
  979. break;
  980. case "关闭":
  981. this.Close();
  982. break;
  983. }
  984. }
  985. }
  986. }