FrmBaseAddAsk.cs 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788
  1. using Core.Mes.Client.Comm.Control;
  2. using Core.Mes.Client.Comm.Format;
  3. using Core.Mes.Client.Comm.Server;
  4. using Core.Mes.Client.Comm.Tool;
  5. using Core.StlMes.Client.Qcm.model;
  6. using CoreFS.CA06;
  7. using Infragistics.Win.UltraWinEditors;
  8. using Infragistics.Win.UltraWinGrid;
  9. using System;
  10. using System.Collections;
  11. using System.Collections.Generic;
  12. using System.Data;
  13. using System.Windows.Forms;
  14. namespace Core.StlMes.Client.Qcm
  15. {
  16. public partial class FrmBaseAddAsk : FrmBase
  17. {
  18. private bool isEx = false;
  19. private string askItemNo = "";
  20. private string errMessage = "";
  21. private int isSelect = 0;
  22. public FrmBaseAddAsk()
  23. {
  24. InitializeComponent();
  25. this.IsLoadUserView = true;
  26. }
  27. private void InitCom()
  28. {
  29. UltraComboEditor uce = new UltraComboEditor();
  30. this.Controls.Add(uce);
  31. uce.Visible = false;
  32. UltraGridBand ugb = ultraGrid1.DisplayLayout.Bands[0];
  33. //所有工序
  34. QcmBaseCommon.InitDrop(uce, "com.steering.pss.qcm.ComBaseQuery.geComBaseProcessAll2", "BASENAME", "BASECODE", true, this.ob);
  35. ugb.Columns["STATION_CODE"].EditorComponent = uce;
  36. ugb.Columns["STATION_CODE"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList;
  37. //UltraComboEditor uceIsAllowEdit = new UltraComboEditor();
  38. //this.Controls.Add(uceIsAllowEdit);
  39. //uceIsAllowEdit.Visible = false;
  40. //uceIsAllowEdit.Items.Add("1", "是");
  41. //uceIsAllowEdit.Items.Add("0", "否");
  42. //UltraGridBand ugb1 = ultraGrid1.DisplayLayout.Bands[1];
  43. //ugb1.Columns["IS_ALLOW_EDIT"].EditorComponent = uceIsAllowEdit;
  44. //ugb1.Columns["IS_ALLOW_EDIT"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList;
  45. }
  46. private void InitIsAdd()
  47. {
  48. //UltraComboEditor uce = new UltraComboEditor();
  49. //this.Controls.Add(uce);
  50. //uce.Visible = false;
  51. //UltraGridBand ugb = ultraGrid1.DisplayLayout.Bands[1];
  52. //uce.Items.Add("1", "是");
  53. //uce.Items.Add("0", "否");
  54. //ugb.Columns["IS_ADD"].EditorComponent = uce;
  55. //ugb.Columns["IS_ADD"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList;
  56. }
  57. private void FrmBaseAddAsk_Load(object sender, EventArgs e)
  58. {
  59. InitCom();
  60. InitIsAdd();
  61. ultraGrid2.Enabled = false;
  62. DoQuery(true);
  63. }
  64. public override void ToolBar_Click(object sender, string ToolbarKey)
  65. {
  66. switch (ToolbarKey)
  67. {
  68. case "Query":
  69. DoQuery(true);
  70. break;
  71. case "Query1":
  72. DoQuery(false);
  73. break;
  74. case "Save":
  75. DoSave();
  76. break;
  77. case "Delete":
  78. DoDeleteOrResume(true);
  79. break;
  80. case "Resume":
  81. DoDeleteOrResume(false);
  82. break;
  83. case "DeleteData":
  84. DeleteData();
  85. break;
  86. case "Refresh":
  87. InitCom();
  88. break;
  89. case "Close":
  90. this.Close();
  91. break;
  92. }
  93. }
  94. /// <summary>
  95. /// 查询
  96. /// </summary>
  97. private void DoQuery(bool flag)
  98. {
  99. dataTable2.Rows.Clear();
  100. dataTable1.Rows.Clear();
  101. DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreBaseAddAsk.queryAddAskItem", new Object[] { flag }, this.ob);
  102. GridHelper.CopyDataToDatatable(ref dt, ref this.dataTable1, true);
  103. DataTable dt1 = ServerHelper.GetData("com.steering.pss.qcm.CoreBaseAddAsk.queryAddAskSub", new Object[] { flag }, this.ob);
  104. GridHelper.CopyDataToDatatable(ref dt1, ref this.dataTable2, true);
  105. QcmBaseCommon.DistinguishColor(ultraGrid1, "VALIDFLAG", "有效");
  106. QcmBaseCommon.SetUltraGridNoEdit(ultraGrid1);
  107. UltraGridRow[] rows1 = GridHelper.GetRowsWithKey(ultraGrid1, new string[] { "ASK_ITEM_NO" }, new string[] { askItemNo });
  108. if (rows1.Length > 0)
  109. {
  110. rows1[0].Activate();
  111. if (isEx)
  112. rows1[0].ExpandAll();
  113. }
  114. isEx = false;
  115. askItemNo = "";
  116. }
  117. /// <summary>
  118. /// 删除
  119. /// </summary>
  120. private void DoDelete()
  121. {
  122. ultraGrid1.UpdateData();
  123. }
  124. private void DoSave()
  125. {
  126. ultraGrid1.UpdateData();
  127. ultraGrid2.UpdateData();
  128. if (isSelect == 0)
  129. {
  130. MessageBox.Show("请选择记录!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  131. return;
  132. }
  133. ArrayList listOne = new ArrayList();
  134. ArrayList listTwo = new ArrayList();
  135. ArrayList listThree = new ArrayList();
  136. for (int i = 0; i < ultraGrid1.Rows.Count; i++)
  137. {
  138. UltraGridRow ugr = ultraGrid1.Rows[i];
  139. //主表行
  140. if (Convert.ToBoolean(ugr.Cells["CHC"].Value))
  141. {
  142. BaseAddAskObject com = Qcm.objectData.GetObjectData.GetAddAskData(ugr);
  143. if (!CheckBaseAddAsk(com))
  144. {
  145. MessageBox.Show(errMessage, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  146. return;
  147. }
  148. com.CreateName = UserInfo.GetUserName();
  149. listOne.Add(JSONFormat.Format(com));
  150. askItemNo = com.AskItemNo;
  151. }
  152. //从表行
  153. if (ugr.HasChild())
  154. {
  155. if (ugr.Cells["VALIDFLAG"].Value.ToString().Equals("") && !Convert.ToBoolean(ugr.Cells["CHC"].Value))
  156. {
  157. MessageBox.Show("请选择主记录", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  158. return;
  159. }
  160. for (int j = 0; j < ugr.ChildBands[0].Rows.Count; j++)
  161. {
  162. UltraGridRow ugrC = ugr.ChildBands[0].Rows[j];
  163. if (Convert.ToBoolean(ugrC.Cells["CHC"].Value))
  164. {
  165. BaseAddAskObject comC = Qcm.objectData.GetObjectData.GetAddAskData(ugrC);
  166. if (!CheckBaseAddAsk(comC))
  167. {
  168. MessageBox.Show(errMessage, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  169. return;
  170. }
  171. comC.CreateName = UserInfo.GetUserName();
  172. listTwo.Add(JSONFormat.Format(comC));
  173. askItemNo = ugr.Cells["ASK_ITEM_NO"].Value.ToString();
  174. isEx = true;
  175. }
  176. }
  177. }
  178. }
  179. for (int i = 0; i < ultraGrid2.Rows.Count; i++)
  180. {
  181. UltraGridRow ugr = ultraGrid2.Rows[i];
  182. if (Convert.ToBoolean(ugr.Cells["CHC"].Value))
  183. {
  184. BaseAddAskObject com = Qcm.objectData.GetObjectData.GetAddAskData(ugr);
  185. if (!CheckBaseAddAsk(com))
  186. {
  187. MessageBox.Show(errMessage, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  188. return;
  189. }
  190. com.CreateName = UserInfo.GetUserName();
  191. listThree.Add(JSONFormat.Format(com));
  192. }
  193. }
  194. if (MessageBox.Show("是否保存选择记录?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
  195. {
  196. return;
  197. }
  198. if (listOne.Count > 0 || listTwo.Count > 0 || listThree.Count > 0)
  199. {
  200. int count = ServerHelper.SetData("com.steering.pss.qcm.CoreBaseAddAsk.saveAddAsk",
  201. new Object[] { listOne, listTwo, listThree }, this.ob);
  202. if (count > 0)
  203. {
  204. MessageBox.Show("保存成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  205. DoQuery(true);
  206. }
  207. }
  208. }
  209. private void ultraGrid1_AfterRowInsert(object sender, RowEventArgs e)
  210. {
  211. UltraGridRow ugr = ultraGrid1.DisplayLayout.ActiveRow;
  212. string style = "1210";
  213. if (!ugr.HasParent()) //主表自动填充主键(成分索引号)
  214. {
  215. string askItemNo = "";
  216. int temp = 0;
  217. for (int i = 0; i < ultraGrid1.Rows.Count - 1; i++)
  218. {
  219. string str = ultraGrid1.Rows[i].Cells["ASK_ITEM_NO"].Value.ToString().Substring(4, 2);
  220. if (Convert.ToInt32(str) > temp)
  221. temp = Convert.ToInt32(str);
  222. }
  223. askItemNo = style + string.Format("{0:00}", temp + 1);
  224. ugr.Cells["ASK_ITEM_NO"].Value = askItemNo;
  225. }
  226. //从表自动填充序号
  227. if (ugr.HasParent())
  228. {
  229. int index = 0;
  230. string askItemNo = ugr.Cells["ASK_P_ITEM_NO"].Value.ToString();
  231. foreach (UltraGridRow ug in ultraGrid1.Rows)
  232. {
  233. if (ug.Cells["ASK_ITEM_NO"].Value.ToString().Equals(askItemNo))
  234. {
  235. for (int i = 0; i < ug.ChildBands[0].Rows.Count - 1; i++)
  236. {
  237. string str = ug.ChildBands[0].Rows[i].Cells["ASK_ITEM_NO"].Value.ToString();
  238. int indexSeq = Convert.ToInt32(ug.ChildBands[0].Rows[i].Cells["ASK_ITEM_NO"].Value.ToString().Substring(6, 2));
  239. if (indexSeq > index)
  240. index = indexSeq;
  241. }
  242. }
  243. }
  244. ugr.Cells["ASK_ITEM_NO"].Value = askItemNo + string.Format("{0:00}", index + 1);
  245. ugr.Cells["STATION_CODE"].Value = ugr.ParentRow.Cells["STATION_CODE"].Value.ToString();
  246. ugr.Cells["STATION_DESC"].Value = ugr.ParentRow.Cells["STATION_DESC"].Value.ToString();
  247. ugr.Cells["IS_ADD"].Value = "1";
  248. }
  249. //增加行如果没有勾选则不可编辑
  250. if (!Convert.ToBoolean(ugr.Cells["CHC"].Value))
  251. {
  252. for (int i = 0; i < ugr.Cells.Count; i++)
  253. {
  254. if (!ugr.Cells[i].Column.Key.Equals("CHC"))
  255. ugr.Cells[i].Activation = Activation.ActivateOnly;
  256. }
  257. }
  258. }
  259. private void ultraGrid2_AfterRowInsert(object sender, RowEventArgs e)
  260. {
  261. UltraGridRow ugr = ultraGrid2.DisplayLayout.ActiveRow;
  262. string askItemNo = "";
  263. int temp = 0;
  264. for (int i = 0; i < ultraGrid2.Rows.Count - 1; i++)
  265. {
  266. string str1 = ultraGrid2.Rows[i].Cells["ASK_ITEM_NO"].Value.ToString();
  267. string str = ultraGrid2.Rows[i].Cells["ASK_ITEM_NO"].Value.ToString().Substring(8, 3);
  268. if (Convert.ToInt32(str) > temp)
  269. temp = Convert.ToInt32(str);
  270. }
  271. UltraGridRow ugrItem = ultraGrid1.DisplayLayout.ActiveRow;
  272. if (ugrItem == null)
  273. return;
  274. ugr.Cells["ASK_ITEM_NOONE"].Value = ugrItem.ParentRow.Cells["ASK_ITEM_DESC"].Value.ToString();
  275. ugr.Cells["ASK_ITEM_NOTWO"].Value = ugrItem.Cells["ASK_ITEM_DESC"].Value.ToString();
  276. ugr.Cells["ASK_P_ITEM_NO"].Value = ugrItem.Cells["ASK_ITEM_NO"].Value.ToString();
  277. ugr.Cells["STATION_CODE"].Value = ugrItem.ParentRow.Cells["STATION_CODE"].Value.ToString();
  278. ugr.Cells["STATION_DESC"].Value = ugrItem.ParentRow.Cells["STATION_DESC"].Value.ToString();
  279. askItemNo = ugr.Cells["ASK_P_ITEM_NO"].Value.ToString() + string.Format("{0:000}", temp + 1);
  280. ugr.Cells["ASK_ITEM_NO"].Value = askItemNo;
  281. }
  282. private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
  283. {
  284. try
  285. {
  286. this.Cursor = Cursors.WaitCursor;
  287. UltraGridRow ugrItem = ultraGrid1.DisplayLayout.ActiveRow;
  288. if (ugrItem.HasParent())
  289. {
  290. if (ugrItem.Cells["VALIDFLAG"].Value.Equals("无效"))
  291. {
  292. dataTable3.Rows.Clear();
  293. ultraGrid2.Enabled = false;
  294. }
  295. else if (ugrItem.Cells["VALIDFLAG"].Value.Equals(""))
  296. {
  297. ultraGrid2.Enabled = true;
  298. }
  299. else
  300. {
  301. ultraGrid2.Enabled = true;
  302. DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreBaseAddAsk.queryAddAskStan", new Object[] { ugrItem.Cells["ASK_ITEM_NO"].Value.ToString() }, this.ob);
  303. GridHelper.CopyDataToDatatable(ref dt, ref this.dataTable3, true);
  304. QcmBaseCommon.DistinguishColor(ultraGrid2, "VALIDFLAG", "有效");
  305. UltraGridBand ugb = this.ultraGrid2.DisplayLayout.Bands[0];
  306. UltraGridColumn[] col = new UltraGridColumn[] { ugb.Columns["ASK_ITEM_DESC"], ugb.Columns["STATION_DESC"],
  307. ugb.Columns["PIC"],ugb.Columns["ASK_ITEM_NOONE"],ugb.Columns["ASK_ITEM_NOTWO"]};
  308. GridHelper.RefreshAndAutoSizeExceptColumns(ultraGrid2, col);
  309. QcmBaseCommon.SetUltraGridNoEdit(ultraGrid2);
  310. foreach (UltraGridRow row in ultraGrid2.Rows)
  311. {
  312. ControlAskItemDesc(row);
  313. }
  314. }
  315. }
  316. else
  317. {
  318. for (int i = 0; i < ultraGrid2.Rows.Count; i++)
  319. {
  320. ultraGrid2.Rows[i].Cells["CHC"].Value = false;
  321. }
  322. this.dataTable3.Rows.Clear();
  323. this.ultraGrid2.Enabled = false;
  324. }
  325. }
  326. finally
  327. {
  328. this.Cursor = Cursors.Default;
  329. }
  330. }
  331. /// <summary>
  332. /// 控制标准说明是否可以编辑
  333. /// </summary>
  334. /// <param name="row"></param>
  335. private void ControlAskItemDesc(UltraGridRow row)
  336. {
  337. if (row.GetValue("VALIDFLAG") != "")
  338. {
  339. row.Cells["ASK_ITEM_DESC"].Activation = Activation.ActivateOnly;
  340. }
  341. }
  342. private void ultraGrid1_CellChange(object sender, CellEventArgs e)
  343. {
  344. ultraGrid1.UpdateData();
  345. UltraGridRow ugr = ultraGrid1.ActiveRow;
  346. if (e.Cell.Column.Key.Equals("STATION_CODE"))
  347. {
  348. ugr.Cells["STATION_DESC"].Value = ugr.Cells["STATION_CODE"].Text;
  349. if (ugr.HasChild())
  350. {
  351. foreach (UltraGridRow ugrC in ugr.ChildBands[0].Rows)
  352. {
  353. ugrC.Cells["STATION_CODE"].Value = ugr.Cells["STATION_CODE"].Value.ToString();
  354. ugrC.Cells["STATION_DESC"].Value = ugr.Cells["STATION_DESC"].Value.ToString();
  355. }
  356. }
  357. }
  358. if (e.Cell.Column.Key.Equals("CHC")) //
  359. {
  360. Activation activation = Activation.ActivateOnly;
  361. if (Convert.ToBoolean(e.Cell.Value))
  362. {
  363. activation = Activation.AllowEdit;
  364. isSelect += 1;
  365. }
  366. else
  367. isSelect -= 1;
  368. CellsCollection cells = e.Cell.Row.Cells;
  369. for (int i = 0; i < cells.Count; i++)
  370. {
  371. if (!cells[i].Column.Key.Equals("CHC"))
  372. {
  373. e.Cell.Row.Cells[i].Activation = activation;
  374. }
  375. }
  376. if (Convert.ToBoolean(e.Cell.Value))
  377. {
  378. if (e.Cell.Row.HasParent())
  379. {
  380. string code = e.Cell.Row.Cells["ASK_ITEM_NO"].Value.ToString();
  381. DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreBaseAddAsk.isLinkStd", new Object[] { code }, this.ob);
  382. if (dt != null && dt.Rows.Count > 0)
  383. {
  384. for (int i = 0; i < e.Cell.Row.Cells.Count; i++)
  385. {
  386. if (!e.Cell.Row.Cells[i].Column.Key.Equals("CHC") && !e.Cell.Row.Cells[i].Column.Key.Equals("IS_ADD")
  387. && !e.Cell.Row.Cells[i].Column.Key.Equals("IS_ALLOW_EDIT"))
  388. e.Cell.Row.Cells[i].Activation = Activation.ActivateOnly;
  389. }
  390. }
  391. else
  392. {
  393. for (int i = 0; i < e.Cell.Row.Cells.Count; i++)
  394. {
  395. if (!e.Cell.Row.Cells[i].Column.Key.Equals("CHC"))
  396. e.Cell.Row.Cells[i].Activation = Activation.AllowEdit;
  397. }
  398. }
  399. }
  400. else
  401. {
  402. string code = e.Cell.Row.Cells["ASK_ITEM_NO"].Value.ToString();
  403. DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreBaseAddAsk.isLinkStd1", new Object[] { code }, this.ob);
  404. if (dt != null && dt.Rows.Count > 0)
  405. {
  406. for (int i = 0; i < e.Cell.Row.Cells.Count; i++)
  407. {
  408. if (!e.Cell.Row.Cells[i].Column.Key.Equals("CHC"))
  409. e.Cell.Row.Cells[i].Activation = Activation.ActivateOnly;
  410. }
  411. }
  412. else
  413. {
  414. for (int i = 0; i < e.Cell.Row.Cells.Count; i++)
  415. {
  416. if (!e.Cell.Row.Cells[i].Column.Key.Equals("CHC"))
  417. e.Cell.Row.Cells[i].Activation = Activation.AllowEdit;
  418. }
  419. }
  420. }
  421. }
  422. }
  423. if (ugr.HasChild())
  424. {
  425. return;
  426. }
  427. else
  428. {
  429. CreateSequence();
  430. }
  431. }
  432. private void CreateSequence()
  433. {
  434. UltraGridRow ugrItem = ultraGrid1.ActiveRow;
  435. for (int i = 0; i < ultraGrid2.Rows.Count; i++)
  436. {
  437. UltraGridRow ugrStand = ultraGrid2.Rows[i];
  438. ugrStand.Cells["ASK_ITEM_NOONE"].Value = ugrItem.ParentRow.Cells["ASK_ITEM_DESC"].Value.ToString().Trim();
  439. ugrStand.Cells["ASK_ITEM_NOTWO"].Value = ugrItem.Cells["ASK_ITEM_DESC"].Value.ToString().Trim();
  440. ugrStand.Cells["ASK_P_ITEM_NO"].Value = ugrItem.Cells["ASK_ITEM_NO"].Value.ToString().Trim();
  441. ugrStand.Cells["STATION_DESC"].Value = ugrItem.ParentRow.Cells["STATION_DESC"].Value.ToString().Trim();
  442. ugrStand.Cells["STATION_CODE"].Value = ugrItem.ParentRow.Cells["STATION_CODE"].Value.ToString();
  443. if (!ugrStand.Cells["ASK_P_ITEM_NO"].Value.Equals(""))
  444. {
  445. ugrStand.Cells["ASK_ITEM_NO"].Value = ugrItem.Cells["ASK_ITEM_NO"].Value.ToString() + ugrStand.Cells["ASK_ITEM_NO"].Value.ToString().Substring(8, 3);
  446. }
  447. }
  448. }
  449. private void ultraGrid2_CellChange(object sender, CellEventArgs e)
  450. {
  451. ultraGrid2.UpdateData();
  452. if (e.Cell.Column.Key.Equals("CHC")) //
  453. {
  454. Activation activation = Activation.ActivateOnly;
  455. if (Convert.ToBoolean(e.Cell.Value))
  456. {
  457. activation = Activation.AllowEdit;
  458. isSelect += 1;
  459. UltraGridRow ugr1 = ultraGrid1.ActiveRow;
  460. UltraGridRow ugr2 = ultraGrid2.ActiveRow;
  461. string station = ugr1.ParentRow.Cells["STATION_CODE"].Text;
  462. string item = ugr1.ParentRow.Cells["ASK_ITEM_DESC"].Value.ToString();
  463. string subitem = ugr1.Cells["ASK_ITEM_DESC"].Value.ToString();
  464. if (ugr2.Cells["STATION_DESC"].Value.ToString() != station)
  465. {
  466. ugr2.Cells["STATION_DESC"].Value = station;
  467. }
  468. if (ugr2.Cells["ASK_ITEM_NOONE"].Value.ToString() != item)
  469. {
  470. ugr2.Cells["ASK_ITEM_NOONE"].Value = item;
  471. }
  472. if (ugr2.Cells["ASK_ITEM_NOTWO"].Value.ToString() != subitem)
  473. {
  474. ugr2.Cells["ASK_ITEM_NOTWO"].Value = subitem;
  475. }
  476. }
  477. else
  478. isSelect -= 1;
  479. CellsCollection cells = e.Cell.Row.Cells;
  480. for (int i = 0; i < cells.Count; i++)
  481. {
  482. if (!cells[i].Column.Key.Equals("CHC"))
  483. {
  484. e.Cell.Row.Cells[i].Activation = activation;
  485. }
  486. }
  487. if (Convert.ToBoolean(e.Cell.Value))
  488. {
  489. string code = e.Cell.Row.Cells["ASK_ITEM_NO"].Value.ToString();
  490. DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreBaseAddAsk.isLinkStd2", new Object[] { code }, this.ob);
  491. if (dt != null && dt.Rows.Count > 0)
  492. {
  493. for (int i = 0; i < e.Cell.Row.Cells.Count; i++)
  494. {
  495. if (!e.Cell.Row.Cells[i].Column.Key.Equals("CHC") && !e.Cell.Row.Cells[i].Column.Key.Equals("STDFLAG"))
  496. e.Cell.Row.Cells[i].Activation = Activation.ActivateOnly;
  497. }
  498. }
  499. else
  500. {
  501. for (int i = 0; i < e.Cell.Row.Cells.Count; i++)
  502. {
  503. if (!e.Cell.Row.Cells[i].Column.Key.Equals("CHC") && !e.Cell.Row.Cells[i].Column.Key.Equals("STDFLAG"))
  504. e.Cell.Row.Cells[i].Activation = Activation.AllowEdit;
  505. }
  506. }
  507. }
  508. }
  509. ControlAskItemDesc(e.Cell.Row);
  510. }
  511. private bool CheckBaseAddAsk(BaseAddAskObject com)
  512. {
  513. if (com.Validflag.Equals("无效"))
  514. {
  515. errMessage = "无效记录不能保存操作";
  516. return false;
  517. }
  518. string askItemDesc = com.AskItemDesc;
  519. string askItemCode = com.AskItemNo;
  520. if (askItemDesc.Equals(""))
  521. {
  522. errMessage = "项目、分项或者标准说明不能为空";
  523. return false;
  524. }
  525. //if (com.Validflag.Equals(""))
  526. //{
  527. // DataTable dt = ServerHelper.GetData("", new Object[] { askItemDesc, askItemCode }, this.ob);
  528. // if (dt != null && dt.Rows.Count > 0)
  529. // {
  530. // errMessage = askItemDesc + "重复,请重新输入";
  531. // return false;
  532. // }
  533. //}
  534. //else
  535. //{
  536. // DataTable dt = ServerHelper.GetData("", new Object[] { askItemDesc, askItemCode }, this.ob);
  537. // if (dt != null && dt.Rows.Count > 0)
  538. // {
  539. // errMessage = askItemDesc + "重复,请重新输入";
  540. // return false;
  541. // }
  542. //}
  543. return true;
  544. }
  545. private void DeleteData()
  546. {
  547. ultraGrid1.UpdateData();
  548. ultraGrid2.UpdateData();
  549. if (ultraGrid1.ActiveRow == null && !ultraGrid1.ActiveRow.HasParent())
  550. {
  551. MessageUtil.ShowWarning("请选择需要删除的检验分项!");
  552. return;
  553. }
  554. if (MessageUtil.ShowYesNoAndQuestion("是否确认删除?") == DialogResult.No)
  555. {
  556. return;
  557. }
  558. ServerHelper.SetData("com.steering.pss.qcm.CoreBaseAddAsk.deleteData", new object[] {
  559. ultraGrid1.ActiveRow.GetValue("ASK_ITEM_NO") }, ob);
  560. MessageUtil.ShowTips("操作成功!");
  561. }
  562. private void DoDeleteOrResume(bool flag)
  563. {
  564. ultraGrid1.UpdateData();
  565. ultraGrid2.UpdateData();
  566. if (isSelect == 0)
  567. {
  568. MessageBox.Show("请选择记录!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  569. return;
  570. }
  571. ArrayList listData = new ArrayList();
  572. foreach (UltraGridRow ugr in ultraGrid1.Rows)
  573. {
  574. if (Convert.ToBoolean(ugr.Cells["CHC"].Value))
  575. {
  576. BaseAddAskObject com = Qcm.objectData.GetObjectData.GetAddAskData(ugr);
  577. if (!CheckData(com, flag))
  578. {
  579. MessageBox.Show(errMessage, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  580. ugr.Activate();
  581. return;
  582. }
  583. if (flag && ugr.HasChild())
  584. {
  585. foreach (UltraGridRow ugrC in ugr.ChildBands[0].Rows)
  586. {
  587. if (!Convert.ToBoolean(ugrC.Cells["CHC"].Value) && ugrC.Cells["VALIDFLAG"].Value.Equals("有效"))
  588. {
  589. MessageBox.Show("请先作废对应子记录", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  590. return;
  591. }
  592. }
  593. }
  594. com.DeleteName = UserInfo.GetUserName();
  595. listData.Add(JSONFormat.Format(com));
  596. askItemNo = com.AskItemNo;
  597. }
  598. if (ugr.HasChild())
  599. {
  600. foreach (UltraGridRow ugrC in ugr.ChildBands[0].Rows)
  601. {
  602. if (Convert.ToBoolean(ugrC.Cells["CHC"].Value))
  603. {
  604. BaseAddAskObject com = Qcm.objectData.GetObjectData.GetAddAskData(ugrC);
  605. if (!CheckData(com, flag))
  606. {
  607. MessageBox.Show(errMessage, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  608. ugrC.Activate();
  609. return;
  610. }
  611. if (flag)
  612. {
  613. foreach (UltraGridRow ugrC2 in ultraGrid2.Rows)
  614. {
  615. if (!Convert.ToBoolean(ugrC2.Cells["CHC"].Value) && ugrC2.Cells["VALIDFLAG"].Value.Equals("有效"))
  616. {
  617. MessageBox.Show("请先作废对应的子项标准说明记录", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  618. ugrC2.Activate();
  619. return;
  620. }
  621. }
  622. }
  623. else
  624. {
  625. if (!Convert.ToBoolean(ugr.Cells["CHC"].Value) && ugr.Cells["VALIDFLAG"].Value.Equals("无效"))
  626. {
  627. MessageBox.Show("请先恢复对应主记录", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  628. ugr.Activate();
  629. return;
  630. }
  631. }
  632. listData.Add(JSONFormat.Format(com));
  633. askItemNo = ugr.Cells["ASK_ITEM_NO"].Value.ToString();
  634. isEx = true;
  635. }
  636. }
  637. }
  638. }
  639. foreach (UltraGridRow ugr in ultraGrid2.Rows)
  640. {
  641. if (Convert.ToBoolean(ugr.Cells["CHC"].Value))
  642. {
  643. BaseAddAskObject com = Qcm.objectData.GetObjectData.GetAddAskData(ugr);
  644. if (!CheckData(com, flag))
  645. {
  646. MessageBox.Show(errMessage, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  647. return;
  648. }
  649. listData.Add(JSONFormat.Format(com));
  650. }
  651. }
  652. if (MessageBox.Show("是否" + (flag ? "作废" : "恢复") + "选择记录", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
  653. {
  654. return;
  655. }
  656. if (listData.Count > 0)
  657. {
  658. int count = ServerHelper.SetData("com.steering.pss.qcm.CoreBaseAddAsk.deleteOrResume", new Object[] { listData, flag }, this.ob);
  659. if (count > 0)
  660. {
  661. MessageBox.Show((flag ? "作废" : "恢复") + "成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Question);
  662. DoQuery(false);
  663. }
  664. }
  665. }
  666. private bool CheckData(BaseAddAskObject com, bool flag)
  667. {
  668. if (com.Validflag.Equals("无效") && flag)
  669. {
  670. errMessage = "无效记录不能删除";
  671. return false;
  672. }
  673. if (com.Validflag.Equals("有效") && !flag)
  674. {
  675. errMessage = "有效记录不能恢复";
  676. return false;
  677. }
  678. return true;
  679. }
  680. private void ultraGrid1_BeforeRowInsert(object sender, BeforeRowInsertEventArgs e)
  681. {
  682. if (e.Band.Header.Caption.Equals("Table1"))
  683. {
  684. return;
  685. }
  686. if (e.ParentRow.Cells["VALIDFLAG"].Value.ToString().Equals("无效"))
  687. e.Cancel = true;
  688. }
  689. private void ultraGrid2_ClickCellButton(object sender, CellEventArgs e)
  690. {
  691. UltraGridRow ugr = ultraGrid2.ActiveRow;
  692. string path = "";
  693. if (e.Cell.Column.Key.Equals("PIC") && e.Cell.Row.Cells["CHC"].Value.ToString().ToUpper() == "TRUE"
  694. && e.Cell.Row.Cells["VALIDFLAG"].Value.ToString().Equals("有效"))
  695. {
  696. ArrayList list = FileUpLoad("PIC");
  697. if (list != null && list.Count > 0)
  698. {
  699. for (int i = 0; i < list.Count; i++)
  700. {
  701. if (path == "")
  702. path = list[i].ToString();
  703. else
  704. path = path + "," + list[i];
  705. }
  706. ugr.Cells["PIC"].Value = path;
  707. }
  708. }
  709. }
  710. private ArrayList FileUpLoad(string sFileName)
  711. {
  712. List<FileBean> list = new List<FileBean>();
  713. ArrayList pathList = new ArrayList();
  714. FileBean bean = new FileBean();
  715. OpenFileDialog file = new OpenFileDialog();
  716. file.Multiselect = true;
  717. if (file.ShowDialog() == DialogResult.OK)
  718. {
  719. foreach (string fileName in file.FileNames)
  720. {
  721. bean = new FileBean();
  722. string filena = System.IO.Path.GetFileName(fileName);
  723. bean.setFileName(filena);
  724. bean.setPathName(sFileName);
  725. bean.setFile(FileHelper.FileToArray(fileName));
  726. list.Add(bean);
  727. pathList.Add(sFileName + "/" + filena);
  728. }
  729. bool isSuccess = Core.Mes.Client.Comm.Server.FileHelper.Upload(list);
  730. if (isSuccess)
  731. {
  732. MessageBox.Show("上传成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  733. return pathList;
  734. }
  735. }
  736. return null;
  737. }
  738. private void ultraGrid2_MouseUp(object sender, MouseEventArgs e)
  739. {
  740. foreach (UltraGridRow row in ultraGrid2.Rows)
  741. {
  742. if (row.Selected)
  743. {
  744. row.Cells["CHC"].Value = true;
  745. }
  746. }
  747. ultraGrid2.UpdateData();
  748. }
  749. }
  750. }