FrmStandard1.cs 48 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166
  1. using Core.Mes.Client.Comm.Control;
  2. using Core.Mes.Client.Comm.Server;
  3. using CoreFS.CA06;
  4. using Infragistics.Win.UltraWinEditors;
  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. /// <summary>
  15. /// 产品规范管理
  16. /// </summary>
  17. public partial class FrmStandard1 : FrmBase
  18. {
  19. //提示信息
  20. private string errMessage = "";
  21. //动态生成科室
  22. private Dictionary<string, UltraComboEditor> departments = null;
  23. //定位标准基础
  24. private string _std = "";
  25. //定位产品规范
  26. private string _psc = "";
  27. //定位最终客户
  28. private string _cust = "";
  29. //判断是否勾选
  30. private int isSelectData = -1;
  31. private int distance = 0;
  32. private int disWidth = 0;
  33. private UltraComboEditor[] uces = new UltraComboEditor[7];
  34. public FrmStandard1()
  35. {
  36. IsLoadUserView = true;
  37. InitializeComponent();
  38. }
  39. /// <summary>
  40. /// 隐藏页面
  41. /// </summary>
  42. private void Distinguish()
  43. {
  44. if (this.CustomInfo == "1")
  45. {
  46. splitContainer1.Panel2Collapsed = true;
  47. ultraGrid2.Enabled = false;
  48. }
  49. if (this.CustomInfo == "2")
  50. {
  51. splitContainer1.Panel2Collapsed = true;
  52. splitContainer2.Panel2Collapsed = true;
  53. }
  54. if (this.CustomInfo == "3")
  55. {
  56. splitContainer2.Panel2Collapsed = true;
  57. this.ultraGrid1.DisplayLayout.Bands[0].Columns["DEPARTMENT_CODE"].CellAppearance.BackColor = Color.Empty;
  58. this.ultraGrid1.DisplayLayout.Bands[0].Columns["UNIT_CODE"].CellAppearance.BackColor = Color.Empty;
  59. // LightGray
  60. }
  61. }
  62. /// <summary>
  63. /// 重写基类方法
  64. /// </summary>
  65. /// <param name="sender"></param>
  66. /// <param name="ToolbarKey"></param>
  67. public override void ToolBar_Click(object sender, string ToolbarKey)
  68. {
  69. switch (ToolbarKey)
  70. {
  71. case "doQuery":
  72. DoQuery();
  73. break;
  74. case "doSave":
  75. DoSave();
  76. break;
  77. case "doDelete":
  78. this.DoDeleteOrResume(true);
  79. break;
  80. case "doResume":
  81. this.DoDeleteOrResume(false);
  82. break;
  83. case "Refresh":
  84. InitComBoEditor();
  85. break;
  86. case "Close":
  87. this.Close();
  88. break;
  89. }
  90. }
  91. /// <summary>
  92. /// 初始化
  93. /// </summary>
  94. /// <param name="sender"></param>
  95. /// <param name="e"></param>
  96. private void FrmStandard1_Load(object sender, EventArgs e)
  97. {
  98. Distinguish();
  99. InitComBoEditor();
  100. CreateDepartments();
  101. }
  102. /// <summary>
  103. /// 初始化下拉框
  104. /// </summary>
  105. private void InitComBoEditor()
  106. {
  107. for (int i = 0; i < uces.Length; i++)
  108. {
  109. uces[i] = new UltraComboEditor();
  110. Controls.Add(uces[i]);
  111. uces[i].Visible = false;
  112. }
  113. UltraGridBand ugb1 = ultraGrid1.DisplayLayout.Bands[0];
  114. UltraGridBand ugb2 = ultraGrid2.DisplayLayout.Bands[0];
  115. UltraGridBand ugb3 = ultraGrid3.DisplayLayout.Bands[0];
  116. //初始化标准类型
  117. QcmBaseQuery.NitializeStandardType(uces[0], false, this.ob);
  118. if (CustomInfo == "1")
  119. {
  120. ((DataTable)uces[0].DataSource).DefaultView.RowFilter = "CODE IN ('G', 'X')";
  121. }
  122. if (CustomInfo == "2")
  123. {
  124. ((DataTable)uces[0].DataSource).DefaultView.RowFilter = "CODE NOT IN ('G', 'X','K')";
  125. }
  126. if (CustomInfo == "3")
  127. {
  128. ((DataTable)uces[0].DataSource).DefaultView.RowFilter = "CODE IN ('K')";
  129. }
  130. QcmBaseQuery.BindColumn(uces[0], "STDSTYLE", ugb1);
  131. //初始化标准协会
  132. QcmBaseQuery.NitializeSociety(uces[1], true, this.ob);
  133. QcmBaseQuery.BindColumn(uces[1], "STD_STYLE", ugb1);
  134. //初始化管理部门
  135. QcmBaseQuery.NitializeDepartment(uces[2], false, this.ob);
  136. QcmBaseQuery.BindColumn(uces[2], "DEPARTMENT_CODE", ugb1);
  137. QcmBaseQuery.BindColumn(uces[2], "DEPARTMENT_CODE", ugb2);
  138. //品名描述
  139. QcmBaseQuery.NitializeProducName(uces[3], false, this.ob);
  140. QcmBaseQuery.BindColumn(uces[3], "PRODUCCODE", ugb2);
  141. //初始化标准类别
  142. QcmBaseQuery.NitializeStdStyle(uces[4], true, this.ob);
  143. QcmBaseQuery.BindColumn(uces[4], "STD_STYLE", ugb2);
  144. //初始化钢级牌号
  145. QcmBaseQuery.NitializeSteel(uces[5], true, this.ob);
  146. QcmBaseQuery.BindColumn(uces[5], "STEELCODE", ugb2);
  147. //初始化最终客户
  148. QcmBaseQuery.NitializeCustomer(uces[6], true, this.ob);
  149. QcmBaseQuery.BindColumn(uces[6], "CUST_CODE", ugb3);
  150. }
  151. /// <summary>
  152. /// 动态绑定数据源 管理科室
  153. /// </summary>
  154. private void BandDepartments(InitializeRowEventArgs e)
  155. {
  156. string pid = e.Row.Cells["DEPARTMENT_CODE"].Value.ToString();
  157. if (departments.ContainsKey(pid))
  158. {
  159. e.Row.Cells["UNIT_CODE"].EditorComponent = departments[pid];
  160. }
  161. else
  162. {
  163. e.Row.Cells["UNIT_CODE"].EditorComponent = departments["noValue"];
  164. }
  165. }
  166. /// <summary>
  167. /// 根据部门生成科室
  168. /// </summary>
  169. private void CreateDepartments()
  170. {
  171. int count = uces[2].Items.Count;
  172. departments = new Dictionary<string, UltraComboEditor>(count + 1);
  173. departments.Add("noValue", new UltraComboEditor());
  174. for (int i = 0; i < count; i++)
  175. {
  176. string pid = uces[2].Items[i].DataValue.ToString();
  177. DataTable dt = ServerHelper.GetData("com.steering.comm.data.ComBaseInfo.getSection", new object[] { }, this.ob);
  178. dt.DefaultView.RowFilter = "PID='" + pid + "'";
  179. UltraComboEditor uce = new UltraComboEditor();
  180. uce.DataSource = dt;
  181. uce.DisplayMember = "DEPARTNAME";
  182. uce.ValueMember = "DEPARTID";
  183. uce.Visible = false;
  184. departments.Add(pid, uce);
  185. Controls.Add(uce);
  186. }
  187. }
  188. /// <summary>
  189. /// 查询
  190. /// </summary>
  191. private void DoQuery()
  192. {
  193. //查询条件
  194. string valid = "1";
  195. if (ChcValid.Checked)
  196. valid = "0";
  197. string std = "";
  198. if (ChcStd.Checked)
  199. std = TextStd.Text.Trim();
  200. //CoreStandard标准基础表
  201. DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreStandard1.getComBaseStd", new Object[] { valid, std }, this.ob);
  202. if (CustomInfo == "1")
  203. {
  204. DataRow[] rows = dt.Select("STDSTYLE<>'订货标准' AND STDSTYLE<>'协议标准'");
  205. foreach (DataRow dr in rows)
  206. {
  207. dt.Rows.Remove(dr);
  208. }
  209. }
  210. else if (CustomInfo == "3")
  211. {
  212. DataRow[] rows = dt.Select("STDSTYLE<>'Alpha'");
  213. foreach (DataRow dr in rows)
  214. {
  215. dt.Rows.Remove(dr);
  216. }
  217. }
  218. else
  219. {
  220. DataRow[] rows = dt.Select("STDSTYLE='协议标准' or STDSTYLE='订货标准' or STDSTYLE='Alpha'");
  221. foreach (DataRow dr in rows)
  222. {
  223. dt.Rows.Remove(dr);
  224. }
  225. }
  226. GridHelper.CopyDataToDatatable(ref dt, ref this.dataTable1, true);
  227. //定位
  228. UltraGridRow[] rows1 = GridHelper.GetRowsWithKey(ultraGrid1, new string[] { "STD_NAME" }, new string[] { _std });
  229. if (rows1.Length > 0)
  230. rows1[0].Activate();
  231. UltraGridColumn[] col = new UltraGridColumn[] { this.ultraGrid1.DisplayLayout.Bands[0].Columns["MEMO"] };
  232. GridHelper.RefreshAndAutoSizeExceptRows(ultraGrid1, col);
  233. QcmBaseCommon.SetUltraGridNoEdit(ultraGrid1);
  234. isSelectData = -1;
  235. }
  236. /// <summary>
  237. /// 保存
  238. /// </summary>
  239. private void DoSave()
  240. {
  241. ultraGrid1.UpdateData();
  242. ultraGrid2.UpdateData();
  243. ultraGrid3.UpdateData();
  244. if (isSelectData == -1)
  245. {
  246. MessageBox.Show("请选择记录!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  247. return;
  248. }
  249. //标准基础
  250. UltraGridRow[] rows = GridHelper.GetRowsWithKey(ultraGrid1, new string[] { "CHC" }, new string[] { "True" });
  251. ArrayList stdAdd = new ArrayList();
  252. ArrayList stdUpdate = new ArrayList();
  253. if (rows.Length > 0)
  254. {
  255. foreach (UltraGridRow row in rows)
  256. {
  257. ArrayList stdList = GetStdData(row);
  258. if (stdList == null)
  259. {
  260. MessageBox.Show(errMessage, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  261. return;
  262. }
  263. //标准名称
  264. string stdName = row.Cells["STD_NAME"].Value.ToString().Trim();
  265. string stdType = row.Cells["STDSTYLE"].Value.ToString();
  266. _std = stdName;
  267. //标准代码
  268. string stdCode = row.Cells["STD_CODE"].Value.ToString().Trim();
  269. //如果创建人为空,则新增,否则修改
  270. if (row.Cells["CREATE_NAME"].Value.ToString().Equals(""))
  271. {
  272. UltraGridRow[] rows1 = GridHelper.GetRowsWithKey(ultraGrid1, new string[] { "STD_NAME", "STDSTYLE" }, new string[] { stdName, stdType });
  273. if (rows1.Length > 1)
  274. {
  275. MessageBox.Show("标准名称:" + stdName + " 已经存在,请重新输入!", "提示",
  276. MessageBoxButtons.OK, MessageBoxIcon.Information);
  277. return;
  278. }
  279. //验证标准名称是否重复
  280. DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreStandard1.checkStdName", new Object[] { stdName, stdType }, this.ob);
  281. if (dt != null && dt.Rows.Count > 0)
  282. {
  283. MessageBox.Show("标准名称:" + stdName + " 已经存在,请重新输入!", "提示",
  284. MessageBoxButtons.OK, MessageBoxIcon.Information);
  285. return;
  286. }
  287. stdAdd.Add(stdList);
  288. }
  289. else
  290. {
  291. //验证标准名称是否重复
  292. DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreStandard1.checkStdName",
  293. new Object[] { stdName, stdCode, stdType }, this.ob);
  294. if (dt != null && dt.Rows.Count > 0)
  295. {
  296. MessageBox.Show("标准名称:" + stdName + " 已经存在,请重新输入!", "提示",
  297. MessageBoxButtons.OK, MessageBoxIcon.Information);
  298. return;
  299. }
  300. stdList.Add(stdCode);
  301. stdUpdate.Add(stdList);
  302. }
  303. }
  304. }
  305. //产品规范
  306. ArrayList pscAdd = new ArrayList();
  307. ArrayList pscUpdate = new ArrayList();
  308. rows = GridHelper.GetRowsWithKey(ultraGrid2, new string[] { "CHC" }, new string[] { "True" });
  309. if (rows.Length > 0)
  310. {
  311. foreach (UltraGridRow row in rows)
  312. {
  313. string psc = row.Cells["PSC"].Value.ToString();
  314. string pscDesc = row.Cells["PSC_DESC"].Value.ToString();
  315. _psc = pscDesc;
  316. ArrayList pscList = GetPscData(row);
  317. if (pscList == null)
  318. {
  319. MessageBox.Show(errMessage, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  320. return;
  321. }
  322. if (row.Cells["CREATE_NAME"].Value.ToString().Equals(""))
  323. {
  324. UltraGridRow[] rows1 = GridHelper.GetRowsWithKey(ultraGrid2, new string[] { "PSC_DESC" }, new string[] { pscDesc });
  325. if (rows1.Length > 1)
  326. {
  327. MessageBox.Show("产品规范描述:" + pscDesc + " 已经存在,请重新组合!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  328. return;
  329. }
  330. //验证产品规范描述是否重复
  331. DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreStandard1.checkPSC", new Object[] { pscDesc }, this.ob);
  332. if (dt != null && dt.Rows.Count > 0)
  333. {
  334. MessageBox.Show("产品规范描述:" + pscDesc + " 已经存在,请重新组合!", "提示",
  335. MessageBoxButtons.OK, MessageBoxIcon.Information);
  336. return;
  337. }
  338. pscAdd.Add(pscList);
  339. }
  340. else
  341. {
  342. //验证产品规范描述是否重复
  343. DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreStandard1.checkPSC", new Object[] { pscDesc, psc }, this.ob);
  344. if (dt != null && dt.Rows.Count > 0)
  345. {
  346. MessageBox.Show("产品规范描述:" + pscDesc + " 已经存在,请重新组合!", "提示",
  347. MessageBoxButtons.OK, MessageBoxIcon.Information);
  348. return;
  349. }
  350. pscList.Add(psc);
  351. pscUpdate.Add(pscList);
  352. }
  353. }
  354. }
  355. //客户
  356. ArrayList custerAdd = new ArrayList();
  357. ArrayList custerUpdate = new ArrayList();
  358. rows = GridHelper.GetRowsWithKey(ultraGrid3, new string[] { "CHC" }, new string[] { "True" });
  359. if (rows.Length > 0)
  360. {
  361. foreach (UltraGridRow row in rows)
  362. {
  363. ArrayList custList = GetcustData(row);
  364. if (custList == null)
  365. {
  366. MessageBox.Show(errMessage, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  367. return;
  368. }
  369. string stdCode = row.Cells["STD_CODE"].Value.ToString();
  370. string custName = row.Cells["CUST_NAME"].Text.ToString();
  371. //用于定位客户
  372. _cust = custName;
  373. string custCode = row.Cells["CUST_CODE"].Value.ToString();
  374. if (row.Cells["CREATE_NAME"].Value.ToString().Equals(""))
  375. {
  376. UltraGridRow[] rows1 = GridHelper.GetRowsWithKey(ultraGrid3, new string[] { "CUST_CODE" }, new string[] { custCode });
  377. if (rows1.Length > 1)
  378. {
  379. MessageBox.Show("最终客户:" + custName + " 已经存在,请重新选择!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  380. return;
  381. }
  382. //验证最终客户是否重复
  383. DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreStandard1.checkCust", new Object[] { custCode, stdCode }, this.ob);
  384. if (dt != null && dt.Rows.Count > 0)
  385. {
  386. MessageBox.Show("最终客户:" + custName + " 已经存在,请重新选择!", "提示",
  387. MessageBoxButtons.OK, MessageBoxIcon.Information);
  388. return;
  389. }
  390. custerAdd.Add(custList);
  391. }
  392. else
  393. {
  394. //验证最终客户是否重复
  395. if (!custCode.Equals(row.Cells["OLD_CUST_CODE"].Value.ToString()))
  396. {
  397. DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreStandard1.checkCust1", new Object[] { custCode, stdCode }, this.ob);
  398. if (dt != null && dt.Rows.Count > 0)
  399. {
  400. MessageBox.Show("最终客户:" + custName + " 已经存在,请重新选择!", "提示",
  401. MessageBoxButtons.OK, MessageBoxIcon.Information);
  402. return;
  403. }
  404. }
  405. custList.Add(stdCode);
  406. custList.Add(custCode);
  407. custerUpdate.Add(custList);
  408. }
  409. }
  410. }
  411. if (MessageBox.Show("是否保存记录?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
  412. {
  413. return;
  414. }
  415. if (stdAdd.Count > 0 || pscAdd.Count > 0 || custerAdd.Count > 0 || stdUpdate.Count > 0 || pscUpdate.Count > 0 || custerUpdate.Count > 0)
  416. {
  417. int count = ServerHelper.SetData("com.steering.pss.qcm.CoreStandard1.saveCoreStandard1",
  418. new Object[] { stdAdd, stdUpdate, pscAdd, pscUpdate, custerAdd, custerUpdate }, this.ob);
  419. if (count > 0)
  420. {
  421. MessageBox.Show("保存成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  422. DoQuery();
  423. }
  424. }
  425. }
  426. /// <summary>
  427. /// 作废与恢复
  428. /// </summary>
  429. /// <param name="flag"></param>
  430. private void DoDeleteOrResume(Boolean flag)
  431. {
  432. if (isSelectData == -1)
  433. {
  434. MessageBox.Show("请选择记录!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  435. return;
  436. }
  437. //标准基础
  438. UltraGridRow[] rows = GridHelper.GetRowsWithKey(ultraGrid1, new string[] { "CHC" }, new string[] { "True" });
  439. ArrayList stdList = new ArrayList();
  440. ArrayList pscList = new ArrayList();
  441. ArrayList custList = new ArrayList();
  442. if (rows.Length > 0)
  443. {
  444. foreach (UltraGridRow row in rows)
  445. {
  446. ArrayList std = new ArrayList();
  447. //如果作废标准基础,就同时此标准基础下作废产品规范和客户
  448. if (flag)
  449. {
  450. std.Add(UserInfo.GetUserName());
  451. for (int i = 0; i < ultraGrid2.Rows.Count; i++)
  452. {
  453. ArrayList psc = new ArrayList();
  454. psc.Add(UserInfo.GetUserName());
  455. psc.Add(ultraGrid2.Rows[i].Cells["PSC"].Value.ToString());
  456. pscList.Add(psc);
  457. }
  458. for (int i = 0; i < ultraGrid3.Rows.Count; i++)
  459. {
  460. ArrayList cust = new ArrayList();
  461. cust.Add(UserInfo.GetUserName());
  462. cust.Add(ultraGrid3.Rows[i].Cells["STD_CODE"].Value.ToString());
  463. cust.Add(ultraGrid3.Rows[i].Cells["CUST_CODE"].Value.ToString());
  464. custList.Add(cust);
  465. }
  466. }
  467. else
  468. std.Add("");
  469. std.Add(row.Cells["STD_CODE"].Value.ToString());
  470. stdList.Add(std);
  471. //用于定位
  472. _std = row.Cells["STD_NAME"].Value.ToString();
  473. }
  474. }
  475. //产品规范
  476. rows = GridHelper.GetRowsWithKey(ultraGrid2, new string[] { "CHC" }, new string[] { "True" });
  477. if (rows.Length > 0)
  478. {
  479. foreach (UltraGridRow row in rows)
  480. {
  481. ArrayList psc = new ArrayList();
  482. if (flag)
  483. psc.Add(UserInfo.GetUserName());
  484. else
  485. psc.Add("");
  486. psc.Add(row.Cells["PSC"].Value.ToString());
  487. pscList.Add(psc);
  488. //用于定位
  489. _psc = row.Cells["PSC_DESC"].Value.ToString();
  490. }
  491. }
  492. //最终客户
  493. rows = GridHelper.GetRowsWithKey(ultraGrid3, new string[] { "CHC" }, new string[] { "True" });
  494. if (rows.Length > 0)
  495. {
  496. foreach (UltraGridRow row in rows)
  497. {
  498. ArrayList cust = new ArrayList();
  499. if (flag)
  500. cust.Add(UserInfo.GetUserName());
  501. else
  502. {
  503. //恢复客户,如果所对应的标准名称没有恢复,且不能恢复
  504. string stdName = row.Cells["STD_NAME"].Value.ToString();
  505. UltraGridRow[] rows1 = GridHelper.GetRowsWithKey(ultraGrid1, new string[] { "STD_NAME" }, new string[] { stdName });
  506. if (rows1.Length > 0 && rows1[0].Cells["VALIDFLAG"].Value.Equals("无效"))
  507. {
  508. MessageBox.Show("请先恢复标准名称:" + stdName, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  509. return;
  510. }
  511. cust.Add("");
  512. }
  513. cust.Add(row.Cells["STD_CODE"].Value.ToString());
  514. cust.Add(row.Cells["CUST_CODE"].Value.ToString());
  515. custList.Add(cust);
  516. _cust = row.Cells["CUST_NAME"].Value.ToString();
  517. }
  518. }
  519. if (flag)
  520. {
  521. if (MessageBox.Show("是否作废记录?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
  522. {
  523. return;
  524. }
  525. }
  526. else
  527. {
  528. if (MessageBox.Show("是否恢复记录?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
  529. {
  530. return;
  531. }
  532. }
  533. if (stdList.Count > 0 || pscList.Count > 0 || custList.Count > 0)
  534. {
  535. int count = ServerHelper.SetData("com.steering.pss.qcm.CoreStandard1.deleteOrResume",
  536. new Object[] { stdList, pscList, custList, flag }, this.ob);
  537. if (count > 0)
  538. {
  539. if (flag)
  540. MessageBox.Show("作废成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  541. else
  542. MessageBox.Show("恢复成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  543. DoQuery();
  544. }
  545. }
  546. }
  547. /// <summary>
  548. /// 查询区
  549. /// </summary>
  550. /// <param name="sender"></param>
  551. /// <param name="e"></param>
  552. private void ChcStd_CheckedChanged(object sender, EventArgs e)
  553. {
  554. if (ChcStd.Checked)
  555. TextStd.Enabled = true;
  556. else
  557. TextStd.Enabled = false;
  558. }
  559. /// <summary>
  560. /// 将ultraGrid2选择全部不勾选
  561. /// </summary>
  562. /// <param name="ug"></param>
  563. private void changeUltraGirdChc(UltraGrid ug)
  564. {
  565. for (int i = 0; i < ug.Rows.Count; i++)
  566. ug.Rows[i].Cells["CHC"].Value = false;
  567. }
  568. //--------------------------------ultraGrid1-------------------------------
  569. /// <summary>
  570. /// 标准行增加
  571. /// </summary>
  572. /// <param name="sender"></param>
  573. /// <param name="e"></param>
  574. private void ultraGrid1_AfterRowInsert(object sender, RowEventArgs e)
  575. {
  576. //增加一行,自动获取最大的标准代码,然后加1
  577. UltraGridRow ugr = ultraGrid1.DisplayLayout.ActiveRow;
  578. int stdCode = 0;
  579. DataRow[] rows = dataTable1.Select("", "STD_CODE DESC");
  580. if (rows.Length > 0)
  581. stdCode = Convert.ToInt32(rows[0]["STD_CODE"].ToString().Substring(3, 7));
  582. ugr.Cells["STD_CODE"].Value = "STD" + string.Format("{0:0000000}", (stdCode + 1));
  583. //增加行如果没有勾选则不可编辑
  584. if (!Convert.ToBoolean(ugr.Cells["CHC"].Value))
  585. {
  586. for (int i = 0; i < ugr.Cells.Count; i++)
  587. {
  588. if (!ugr.Cells[i].Column.Key.Equals("CHC"))
  589. ugr.Cells[i].Activation = Activation.ActivateOnly;
  590. }
  591. }
  592. }
  593. /// <summary>
  594. /// ultraGrid1
  595. /// </summary>
  596. /// <param name="sender"></param>
  597. /// <param name="e"></param>
  598. private void ultraGrid1_CellChange(object sender, CellEventArgs e)
  599. {
  600. ultraGrid1.UpdateData();
  601. UltraGridRow ugr = ultraGrid1.DisplayLayout.ActiveRow;
  602. if (e.Cell.Column.Key.Equals("STD_NAME")) //标准名称
  603. {
  604. for (int i = 0; i < ultraGrid2.Rows.Count; i++)
  605. { ultraGrid2.Rows[i].Cells["STD_NAME"].Value = ultraGrid1.DisplayLayout.ActiveRow.Cells["STD_NAME"].Value.ToString().Trim(); }
  606. for (int i = 0; i < ultraGrid3.Rows.Count; i++)
  607. { ultraGrid3.Rows[i].Cells["STD_NAME"].Value = ultraGrid1.DisplayLayout.ActiveRow.Cells["STD_NAME"].Value.ToString().Trim(); }
  608. }
  609. if (e.Cell.Column.Key.Equals("STDSTYLE")) //标准类型
  610. {
  611. string stdstyle = ugr.Cells["STDSTYLE"].Text;
  612. if (stdstyle.Equals("订货标准") || stdstyle.Equals("协议标准"))
  613. {
  614. ultraGrid2.Enabled = true;
  615. changeUltraGirdChc(ultraGrid3);
  616. ultraGrid3.Enabled = false;
  617. if (stdstyle.Equals("订货标准"))
  618. {
  619. ugr.Cells["DEPARTMENT_DESC"].Value = "制造部";
  620. ugr.Cells["DEPARTMENT_CODE"].Value = "141106165400";
  621. ugr.Cells["UNIT_DESC"].Value = "标准科";
  622. ugr.Cells["UNIT_CODE"].Value = "141223091224";
  623. ;
  624. }
  625. if (stdstyle.Equals("协议标准"))
  626. {
  627. ugr.Cells["DEPARTMENT_DESC"].Value = "制造部";
  628. ugr.Cells["DEPARTMENT_CODE"].Value = "141106165400";
  629. ugr.Cells["UNIT_DESC"].Value = "工艺科";
  630. ugr.Cells["UNIT_CODE"].Value = "141106174134";
  631. ;
  632. }
  633. }
  634. else if (stdstyle.Equals("Alpha"))
  635. {
  636. changeUltraGirdChc(ultraGrid2);
  637. ultraGrid2.Enabled = false;
  638. ultraGrid3.Enabled = true;
  639. }
  640. else
  641. {
  642. changeUltraGirdChc(ultraGrid2);
  643. changeUltraGirdChc(ultraGrid3);
  644. ultraGrid2.Enabled = false;
  645. ultraGrid3.Enabled = false;
  646. }
  647. }
  648. if (e.Cell.Column.Key.Equals("STD_STYLE")) //标准协会
  649. {
  650. ugr.Cells["STD_STYLE_NAME"].Value = ugr.Cells["STD_STYLE"].Text;
  651. }
  652. if (e.Cell.Column.Key.Equals("DEPARTMENT_CODE")) //部门管理
  653. {
  654. ugr.Cells["DEPARTMENT_DESC"].Value = ugr.Cells["DEPARTMENT_CODE"].Text;
  655. ugr.Cells["UNIT_DESC"].Value = "";
  656. ugr.Cells["UNIT_CODE"].Value = "";
  657. }
  658. if (e.Cell.Column.Key.Equals("UNIT_CODE")) //科室管理
  659. {
  660. ugr.Cells["UNIT_DESC"].Value = ugr.Cells["UNIT_CODE"].Value.ToString();
  661. }
  662. if (e.Cell.Column.Key.Equals("CHC"))//选择
  663. {
  664. Activation activation = Activation.ActivateOnly;
  665. if (Convert.ToBoolean(e.Cell.Value))
  666. {
  667. activation = Activation.AllowEdit;
  668. isSelectData += 1;
  669. }
  670. else
  671. isSelectData -= 1;
  672. CellsCollection cells = e.Cell.Row.Cells;
  673. for (int i = 0; i < cells.Count; i++)
  674. {
  675. if (!cells[i].Column.Key.Equals("CHC") && !cells[i].Column.Key.Equals("STD_NAME"))
  676. {
  677. e.Cell.Row.Cells[i].Activation = activation;
  678. }
  679. }
  680. if (!e.Cell.Row.Cells["CREATE_NAME"].Value.ToString().Equals(""))
  681. {
  682. if (ultraGrid2.Rows.Count > 0 || ultraGrid3.Rows.Count > 0)
  683. e.Cell.Row.Cells["STD_NAME"].Activation = Activation.ActivateOnly;
  684. else
  685. e.Cell.Row.Cells["STD_NAME"].Activation = activation;
  686. }
  687. else
  688. e.Cell.Row.Cells["STD_NAME"].Activation = activation;
  689. }
  690. }
  691. /// <summary>
  692. /// ultraGrid1
  693. /// </summary>
  694. /// <param name="sender"></param>
  695. /// <param name="e"></param>
  696. private void ultraGrid1_InitializeRow(object sender, InitializeRowEventArgs e)
  697. {
  698. BandDepartments(e);
  699. if (e.Row.Cells["VALIDFLAG"].Value.ToString().Equals("无效"))
  700. {
  701. e.Row.Appearance.ForeColor = Color.Red;
  702. }
  703. else
  704. {
  705. e.Row.Appearance.ForeColor = Color.Black;
  706. }
  707. }
  708. /// <summary>
  709. /// 行激活事件
  710. /// </summary>
  711. /// <param name="sender"></param>
  712. /// <param name="e"></param>
  713. private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
  714. {
  715. if (this.CustomInfo == "2")
  716. return;
  717. ultraGrid2.Enabled = true;
  718. ultraGrid3.Enabled = true;
  719. ultraGrid2.UpdateData();
  720. ultraGrid3.UpdateData();
  721. UltraGridRow ugr = ultraGrid1.DisplayLayout.ActiveRow;
  722. string stdName = ugr.Cells["STD_NAME"].Value.ToString();
  723. _std = stdName;
  724. string stdStyle = ugr.Cells["STDSTYLE"].Text.ToString();
  725. //国标 产品规范码
  726. if (stdStyle.Equals("订货标准") || stdStyle.Equals("协议标准"))
  727. {
  728. DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreStandard1.getComPsc", new Object[] { stdName }, this.ob);
  729. GridHelper.CopyDataToDatatable(ref dt, ref this.dataTable2, true);
  730. //激活操作的行
  731. UltraGridRow[] rows = GridHelper.GetRowsWithKey(ultraGrid2, new string[] { "PSC_DESC" }, new string[] { _psc });
  732. if (rows.Length > 0)
  733. rows[0].Activate();
  734. _psc = "";
  735. UltraGridColumn[] col = new UltraGridColumn[] { this.ultraGrid2.DisplayLayout.Bands[0].Columns["MEMO"] };
  736. GridHelper.RefreshAndAutoSizeExceptRows(ultraGrid2, col);
  737. dataTable3.Rows.Clear();
  738. ultraGrid3.Enabled = false;
  739. }
  740. //Alpha 客户
  741. else if (stdStyle.Equals("Alpha"))
  742. {
  743. DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreStandard1.getComBaseStdRCust", new Object[] { stdName }, this.ob);
  744. GridHelper.CopyDataToDatatable(ref dt, ref this.dataTable3, true);
  745. //激活操作的行
  746. UltraGridRow[] rows1 = GridHelper.GetRowsWithKey(ultraGrid3, new string[] { "CUST_NAME" }, new string[] { _cust });
  747. if (rows1.Length > 0)
  748. rows1[0].Activate();
  749. _cust = "";
  750. //UltraGridColumn[] col1 = new UltraGridColumn[] { this.ultraGrid2.DisplayLayout.Bands[0].Columns["CHC"] };
  751. GridHelper.RefreshAndAutoSizeExceptRows(ultraGrid3, null);
  752. dataTable2.Rows.Clear();
  753. ultraGrid2.Enabled = false;
  754. }
  755. else
  756. {
  757. dataTable3.Rows.Clear();
  758. dataTable2.Rows.Clear();
  759. ultraGrid2.Enabled = false;
  760. ultraGrid3.Enabled = false;
  761. }
  762. QcmBaseCommon.SetUltraGridNoEdit(ultraGrid2);
  763. QcmBaseCommon.SetUltraGridNoEdit(ultraGrid3);
  764. }
  765. //--------------------------------ultraGrid2-------------------------
  766. /// <summary>
  767. /// 行增加事件 ultraGrid2
  768. /// </summary>
  769. /// <param name="sender"></param>
  770. /// <param name="e"></param>
  771. private void ultraGrid2_AfterRowInsert(object sender, RowEventArgs e)
  772. {
  773. //增加一行,自动获取最大的最大产品规范码,然后加1
  774. UltraGridRow ugr = ultraGrid2.DisplayLayout.ActiveRow;
  775. int psc = 0;
  776. DataRow[] rows = dataTable2.Select("", "PSC DESC");
  777. if (rows.Length > 0)
  778. psc = Convert.ToInt32(rows[0]["PSC"].ToString().Substring(4, 6));
  779. ugr.Cells["PSC"].Value = "PSC" + string.Format("{0:0000000}", (psc + 1));
  780. ugr.Cells["STD_NAME"].Value = ultraGrid1.DisplayLayout.ActiveRow.Cells["STD_NAME"].Value.ToString().Trim();
  781. ugr.Cells["STD_CODE"].Value = ultraGrid1.DisplayLayout.ActiveRow.Cells["STD_CODE"].Value.ToString().Trim();
  782. ugr.Cells["DEPARTMENT_DESC"].Value = UserInfo.GetDepartment();
  783. ugr.Cells["DEPARTMENT_CODE"].Value = UserInfo.GetDeptid();
  784. //增加行如果没有勾选则不可编辑
  785. if (!Convert.ToBoolean(ugr.Cells["CHC"].Value))
  786. {
  787. for (int i = 0; i < ugr.Cells.Count; i++)
  788. {
  789. if (!ugr.Cells[i].Column.Key.Equals("CHC"))
  790. ugr.Cells[i].Activation = Activation.ActivateOnly;
  791. }
  792. }
  793. }
  794. /// <summary>
  795. /// ultraGrid2值变化事件
  796. /// </summary>
  797. /// <param name="sender"></param>
  798. /// <param name="e"></param>
  799. private void ultraGrid2_CellChange(object sender, CellEventArgs e)
  800. {
  801. ultraGrid2.UpdateData();
  802. UltraGridRow ugr = ultraGrid2.DisplayLayout.ActiveRow;
  803. if (e.Cell.Column.Key.Equals("PRODUCCODE")) //品名描述
  804. {
  805. ugr.Cells["PRODUCNAME"].Value = ugr.Cells["PRODUCCODE"].Text;
  806. }
  807. if (e.Cell.Column.Key.Equals("STEELCODE")) //钢级(牌号)名称
  808. {
  809. ugr.Cells["STEELNAME"].Value = ugr.Cells["STEELCODE"].Text;
  810. }
  811. if (e.Cell.Column.Key.Equals("STD_STYLE")) //标准类别描述(PSL1....)
  812. {
  813. ugr.Cells["STD_STYLE_DESC"].Value = ugr.Cells["STD_STYLE"].Text;
  814. }
  815. //产品规范描述组成 =品名+标准类型+钢级+ 标准类别
  816. ugr.Cells["PSC_DESC"].Value = ugr.Cells["PRODUCNAME"].Text + "," + ugr.Cells["STD_NAME"].Text + "," +
  817. ugr.Cells["STEELNAME"].Text;
  818. //标准类别
  819. string stdStyleDesc = ugr.Cells["STD_STYLE_DESC"].Text;
  820. if (stdStyleDesc != null && !stdStyleDesc.Equals(""))
  821. ugr.Cells["PSC_DESC"].Value = ugr.Cells["PRODUCNAME"].Text + "," + ugr.Cells["STD_NAME"].Text + "," +
  822. ugr.Cells["STEELNAME"].Text + "+" + ugr.Cells["STD_STYLE_DESC"].Text;
  823. if (e.Cell.Column.Key.Equals("DEPARTMENT_CODE")) //部门管理
  824. {
  825. ugr.Cells["DEPARTMENT_DESC"].Value = ugr.Cells["DEPARTMENT_DESC"].Text;
  826. //根据部门号查询管理科室
  827. }
  828. if (e.Cell.Column.Key.Equals("UNIT_CODE")) //科室管理
  829. {
  830. ugr.Cells["UNIT_DESC"].Value = ugr.Cells["UNIT_CODE"].Text;
  831. }
  832. if (e.Cell.Column.Key.Equals("CHC"))//选择
  833. {
  834. Activation activation = Activation.ActivateOnly;
  835. if (Convert.ToBoolean(e.Cell.Value))
  836. {
  837. activation = Activation.AllowEdit;
  838. isSelectData += 1;
  839. }
  840. else
  841. isSelectData -= 1;
  842. CellsCollection cells = e.Cell.Row.Cells;
  843. for (int i = 0; i < cells.Count; i++)
  844. {
  845. if (!cells[i].Column.Key.Equals("CHC"))
  846. {
  847. e.Cell.Row.Cells[i].Activation = activation;
  848. }
  849. }
  850. }
  851. }
  852. /// <summary>
  853. /// ultraGrid2
  854. /// </summary>
  855. /// <param name="sender"></param>
  856. /// <param name="e"></param>
  857. private void ultraGrid2_InitializeRow(object sender, InitializeRowEventArgs e)
  858. {
  859. BandDepartments(e);
  860. if (e.Row.Cells["VALIDFLAG"].Value.ToString().Equals("无效"))
  861. {
  862. e.Row.Appearance.ForeColor = Color.Red;
  863. }
  864. else
  865. {
  866. e.Row.Appearance.ForeColor = Color.Black;
  867. }
  868. }
  869. /// <summary>
  870. /// 获取标准类型数据
  871. /// </summary>
  872. /// <param name="ugr"></param>
  873. /// <returns></returns>
  874. private ArrayList GetStdData(UltraGridRow ugr)
  875. {
  876. ArrayList list = new ArrayList();
  877. string std_code = ugr.Cells["STD_CODE"].Value.ToString();
  878. string std_name = ugr.Cells["STD_NAME"].Value.ToString().Trim();
  879. if (std_name.Equals(""))
  880. {
  881. errMessage = "请输入标准名称";
  882. return null;
  883. }
  884. string stdstyle = ugr.Cells["STDSTYLE"].Value.ToString();
  885. string std_note = ugr.Cells["STD_NOTE"].Value.ToString();
  886. string std_style = ugr.Cells["STD_STYLE"].Value.ToString();
  887. string std_style_name = ugr.Cells["STD_STYLE_NAME"].Value.ToString();
  888. string std_version = ugr.Cells["STD_VERSION"].Value.ToString();
  889. string department_code = ugr.Cells["DEPARTMENT_CODE"].Value.ToString();
  890. string department_desc = ugr.Cells["DEPARTMENT_DESC"].Value.ToString();
  891. if (CustomInfo != "3" && department_desc.Equals(""))
  892. {
  893. errMessage = "请选择管理部门描述";
  894. return null;
  895. }
  896. string unit_code = ugr.Cells["UNIT_CODE"].Value.ToString();
  897. string unit_desc = ugr.Cells["UNIT_DESC"].Value.ToString();
  898. if (CustomInfo != "3" && unit_desc.Equals(""))
  899. {
  900. errMessage = "请选择管理科室描述";
  901. return null;
  902. }
  903. string userName = UserInfo.GetUserName();
  904. string validflag = ugr.Cells["VALIDFLAG"].Value.ToString();
  905. if (validflag.Equals("无效"))
  906. {
  907. errMessage = "无效记录不能保存";
  908. return null;
  909. }
  910. string memo = ugr.Cells["MEMO"].Value.ToString();
  911. list.Add(std_code);
  912. list.Add(std_name);
  913. list.Add(stdstyle);
  914. list.Add(std_note);
  915. list.Add(std_style);
  916. list.Add(std_style_name);
  917. list.Add(std_version);
  918. list.Add(department_code);
  919. list.Add(department_desc);
  920. list.Add(unit_code);
  921. list.Add(unit_desc);
  922. list.Add(userName);
  923. list.Add(memo);
  924. return list;
  925. }
  926. /// <summary>
  927. /// 获取产品规范数据
  928. /// </summary>
  929. /// <param name="ugr"></param>
  930. /// <returns></returns>
  931. private ArrayList GetPscData(UltraGridRow ugr)
  932. {
  933. ArrayList list = new ArrayList();
  934. string psc = ugr.Cells["PSC"].Value.ToString();
  935. string psc_desc = ugr.Cells["PSC_DESC"].Value.ToString();
  936. string produccode = ugr.Cells["PRODUCCODE"].Value.ToString();
  937. string producname = ugr.Cells["PRODUCNAME"].Value.ToString();
  938. if (producname.Equals(""))
  939. {
  940. errMessage = "请选择品名描述";
  941. return null;
  942. }
  943. string std_code = ugr.Cells["STD_CODE"].Value.ToString();
  944. string std_name = ugr.Cells["STD_NAME"].Value.ToString();
  945. string steelcode = ugr.Cells["STEELCODE"].Value.ToString();
  946. string steelname = ugr.Cells["STEELNAME"].Value.ToString();
  947. if (steelname.Equals(""))
  948. {
  949. errMessage = "请选择钢级牌号";
  950. return null;
  951. }
  952. string std_style = ugr.Cells["STD_STYLE"].Value.ToString();
  953. string std_style_desc = ugr.Cells["STD_STYLE_DESC"].Value.ToString();
  954. string new_proc_code = ugr.Cells["NEW_PROC_CODE"].Value.ToString();
  955. if (Convert.ToBoolean(new_proc_code))
  956. new_proc_code = "1";
  957. else
  958. new_proc_code = "0";
  959. string new_proc_desc = ugr.Cells["NEW_PROC_DESC"].Value.ToString();
  960. string department_code = ugr.Cells["DEPARTMENT_CODE"].Value.ToString();
  961. string department_desc = ugr.Cells["DEPARTMENT_DESC"].Value.ToString();
  962. if (department_desc.Equals(""))
  963. {
  964. errMessage = "请选择管理部门描述";
  965. return null;
  966. }
  967. string unit_code = ugr.Cells["UNIT_CODE"].Value.ToString();
  968. string autojudge = ugr.Cells["AUTOJUDGE"].Value.ToString();
  969. if (Convert.ToBoolean(autojudge))
  970. autojudge = "1";
  971. else
  972. autojudge = "0";
  973. string unit_desc = ugr.Cells["UNIT_DESC"].Value.ToString();
  974. string userName = UserInfo.GetUserName();
  975. string validflag = ugr.Cells["validflag"].Value.ToString();
  976. if (validflag.Equals("无效"))
  977. {
  978. errMessage = "无效记录不能保存";
  979. return null;
  980. }
  981. string memo = ugr.Cells["memo"].Value.ToString();
  982. //list.Add(psc);
  983. list.Add(psc_desc);
  984. list.Add(produccode);
  985. list.Add(producname);
  986. list.Add(std_code);
  987. list.Add(std_name);
  988. list.Add(steelcode);
  989. list.Add(steelname);
  990. list.Add(std_style);
  991. list.Add(std_style_desc);
  992. list.Add(new_proc_code);
  993. list.Add(new_proc_desc);
  994. list.Add(department_code);
  995. list.Add(department_desc);
  996. list.Add(unit_code);
  997. list.Add(autojudge);
  998. list.Add(unit_desc);
  999. list.Add(userName);
  1000. list.Add(memo);
  1001. return list;
  1002. }
  1003. /// <summary>
  1004. /// 获取客户数据
  1005. /// </summary>
  1006. /// <param name="ugr"></param>
  1007. /// <returns></returns>
  1008. private ArrayList GetcustData(UltraGridRow ugr)
  1009. {
  1010. ArrayList list = new ArrayList();
  1011. string std_code = ugr.Cells["STD_CODE"].Value.ToString();
  1012. string std_name = ugr.Cells["STD_NAME"].Value.ToString();
  1013. string cust_code = ugr.Cells["CUST_CODE"].Value.ToString();
  1014. string cust_name = ugr.Cells["CUST_NAME"].Value.ToString();
  1015. if (cust_name.Equals(""))
  1016. {
  1017. errMessage = "请选择最终客户";
  1018. }
  1019. string userName = UserInfo.GetUserName();
  1020. string validflag = ugr.Cells["VALIDFLAG"].Value.ToString();
  1021. if (validflag.Equals("无效"))
  1022. {
  1023. errMessage = "无效记录不能保存";
  1024. return null;
  1025. }
  1026. string memo = "";
  1027. list.Add(std_code);
  1028. list.Add(std_name);
  1029. list.Add(cust_code);
  1030. list.Add(cust_name);
  1031. list.Add(userName);
  1032. list.Add(memo);
  1033. return list;
  1034. }
  1035. //-----------------------------------------ultraGrid3
  1036. private void ultraGrid3_AfterRowInsert(object sender, RowEventArgs e)
  1037. {
  1038. UltraGridRow ugr = ultraGrid3.DisplayLayout.ActiveRow;
  1039. ugr.Cells["STD_NAME"].Value = ultraGrid1.DisplayLayout.ActiveRow.Cells["STD_NAME"].Value.ToString().Trim();
  1040. ugr.Cells["STD_CODE"].Value = ultraGrid1.DisplayLayout.ActiveRow.Cells["STD_CODE"].Value.ToString().Trim();
  1041. }
  1042. private void ultraGrid3_CellChange(object sender, CellEventArgs e)
  1043. {
  1044. ultraGrid3.UpdateData();
  1045. UltraGridRow ugr = ultraGrid3.DisplayLayout.ActiveRow;
  1046. if (e.Cell.Column.Key.Equals("CUST_CODE")) //客户
  1047. {
  1048. ugr.Cells["CUST_NAME"].Value = ugr.Cells["CUST_CODE"].Text;
  1049. }
  1050. if (e.Cell.Column.Key.Equals("CHC"))//选择
  1051. {
  1052. Activation activation = Activation.ActivateOnly;
  1053. if (Convert.ToBoolean(e.Cell.Value))
  1054. {
  1055. activation = Activation.AllowEdit;
  1056. isSelectData += 1;
  1057. }
  1058. else
  1059. isSelectData -= 1;
  1060. CellsCollection cells = e.Cell.Row.Cells;
  1061. for (int i = 0; i < cells.Count; i++)
  1062. {
  1063. if (!cells[i].Column.Key.Equals("CHC"))
  1064. {
  1065. e.Cell.Row.Cells[i].Activation = activation;
  1066. }
  1067. }
  1068. }
  1069. }
  1070. private void ultraGrid3_InitializeRow(object sender, InitializeRowEventArgs e)
  1071. {
  1072. if (e.Row.Cells["VALIDFLAG"].Value.ToString().Equals("无效"))
  1073. {
  1074. e.Row.Appearance.ForeColor = Color.Red;
  1075. }
  1076. else
  1077. {
  1078. e.Row.Appearance.ForeColor = Color.Black;
  1079. }
  1080. }
  1081. /// <summary>
  1082. /// 伸缩
  1083. /// </summary>
  1084. /// <param name="sender"></param>
  1085. /// <param name="e"></param>
  1086. private void ultraExpandableGroupBox1_ExpandedStateChanged(object sender, EventArgs e)
  1087. {
  1088. if (ultraExpandableGroupBox1.Expanded)
  1089. splitContainer2.SplitterDistance = distance;
  1090. else
  1091. splitContainer2.SplitterDistance = this.Height;
  1092. }
  1093. private void FrmStandard1_Shown(object sender, EventArgs e)
  1094. {
  1095. distance = splitContainer2.SplitterDistance;
  1096. disWidth = splitContainer1.SplitterDistance; ;
  1097. }
  1098. private void ultraExpandableGroupBox2_ExpandedStateChanged(object sender, EventArgs e)
  1099. {
  1100. if (ultraExpandableGroupBox2.Expanded)
  1101. splitContainer1.SplitterDistance = disWidth;
  1102. else
  1103. splitContainer1.SplitterDistance = this.Width;
  1104. }
  1105. }
  1106. }