CraftOrdFdCicCtrl.cs 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Drawing;
  5. using System.Data;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using Core.StlMes.Client.SaleOrder.BLL;
  10. using CoreFS.CA06;
  11. using Core.Mes.Client.Comm.Tool;
  12. using Infragistics.Win.UltraWinEditors;
  13. using Core.StlMes.Client.Qcm;
  14. using Infragistics.Win.UltraWinGrid;
  15. using CoreFS.SA06;
  16. using Infragistics.Win;
  17. using Core.Mes.Client.Comm.Control;
  18. using Core.Mes.Client.Comm.Server;
  19. using Core.Mes.Client.Comm.Format;
  20. using System.Reflection;
  21. namespace Core.StlMes.Client.SaleOrder.Control
  22. {
  23. public partial class CraftOrdFdCicCtrl : UserControl
  24. {
  25. private UltraComboEditor[] ultras = new UltraComboEditor[13];
  26. private OpeBase _ob;
  27. private string designKey = "";
  28. private string ordLnPk = "";
  29. public CraftOrdFdCicCtrl(System.Windows.Forms.Control container, string ordLnPk, string designKey, OpeBase ob)
  30. {
  31. InitializeComponent();
  32. _ob = ob;
  33. this.designKey = designKey;
  34. this.ordLnPk = ordLnPk;
  35. container.Controls.Add(this);
  36. this.Dock = DockStyle.Fill;
  37. for (int i = 0; i < ultras.Length; i++)
  38. {
  39. ultras[i] = new UltraComboEditor();
  40. Controls.Add(ultras[i]);
  41. ultras[i].Visible = false;
  42. ultras[i].DropDownListWidth = -1;
  43. }
  44. LoadBaseData();
  45. DataTable dt = ServerHelper.GetData("com.steering.pss.sale.order.CraftOrdFdCic.getFdCicCount",
  46. new object[]{ ordLnPk }, ob);
  47. if (dt.Rows.Count > 0)
  48. {
  49. //ultraNumericEditor1.Value = dt.Rows[0]["SMELTING_CNT_FD"].ToString();
  50. ultraNumericEditor2.Value = dt.Rows[0]["PRODUCT_CNT_FD"].ToString();
  51. ultraComboEditor3.Value = dt.Rows[0]["RATE_FD"].ToString();
  52. ultraComboEditor4.Value = dt.Rows[0]["COMMON"].ToString();
  53. }
  54. }
  55. private void LoadBaseData()
  56. {
  57. ClsBaseInfo.FillComBaseInfo(ultraComboEditor3, "4086", _ob, false);
  58. DataTable dtRate = (DataTable)ultraComboEditor3.DataSource;
  59. dtRate.DefaultView.RowFilter = "BASECODE IN ('408602', '408603')";
  60. UltraGridBand ugbC = entityGrid1.DisplayLayout.Bands[0];
  61. QcmBaseQuery.NitializeSignMin(ultras[0]);
  62. //标准范围下限符号
  63. QcmBaseQuery.BindColumn(ultras[0], "StdminSign", ugbC);
  64. //上限
  65. QcmBaseQuery.NitializeSignMax(ultras[1]);
  66. //标准范围上限符号
  67. QcmBaseQuery.BindColumn(ultras[1], "StdmaxSign", ugbC);
  68. //化学元素描述
  69. QcmBaseQuery.NitializeChemicalElement(ultras[2], false, _ob);
  70. QcmBaseQuery.BindColumn(ultras[2], "ChemCode", ugbC);
  71. //限制元素
  72. QcmBaseQuery.NitializeChemicalElement(ultras[11], true, _ob);
  73. QcmBaseQuery.BindColumn(ultras[11], "EleCode", ugbC);
  74. //替代元素
  75. QcmBaseQuery.BindColumn(ultras[0], "RepMinSign", ugbC);
  76. QcmBaseQuery.BindColumn(ultras[1], "RepMaxSign", ugbC);
  77. QcmBaseQuery.BindColumn(ultras[2], "RepCode", ugbC);
  78. QcmBaseQuery.NitializeProductBigType(ultras[12], false, _ob);
  79. }
  80. /// <summary>
  81. /// 查询质量设计成分
  82. /// </summary>
  83. /// <param name="designStdCicEntity"></param>
  84. public void Query()
  85. {
  86. CraftOrdDesignStdCicEntityBindingSource.Clear();
  87. DataTable dt = ServerHelper.GetData("com.steering.pss.sale.order.CraftOrdFdCic.queryM", new object[] { ordLnPk }, _ob);
  88. GridHelper.CopyDataToDatatable(dt, dataTable1, true);
  89. }
  90. public void Clear()
  91. {
  92. this.CraftOrdDesignStdCicEntityBindingSource.Clear();
  93. }
  94. public void Save()
  95. {
  96. List<CraftOrdFdCicEntity> parms = new List<CraftOrdFdCicEntity>();
  97. var mRow = ultraGrid1.Rows.Where(a=>a.GetValue("Chk") == "True").FirstOrDefault();
  98. var rows = entityGrid1.Rows.Where(a=>a.GetValue("Chk") == "True");
  99. //if (mRow == null && rows.Count() == 0)
  100. //{
  101. // MessageUtil.ShowWarning("请选择一条记录!");
  102. // return;
  103. //}
  104. //if (ultraNumericEditor1.Value.ToString2() == "0")
  105. //{
  106. // MessageUtil.ShowWarning("熔炼成分套数至少为一套!");
  107. // return;
  108. //}
  109. if (ultraNumericEditor2.Value.ToString2() == "0")
  110. {
  111. MessageUtil.ShowWarning("成品成分套数至少为一套!");
  112. return;
  113. }
  114. if (ultraComboEditor3.Value.ToString2() == "")
  115. {
  116. MessageUtil.ShowWarning("请选择成品成分取样频率!");
  117. return;
  118. }
  119. if (ultraComboEditor4.Value.ToString2() == "")
  120. {
  121. MessageUtil.ShowWarning("请选择是否共样!");
  122. return;
  123. }
  124. //string smeltingCnt = ultraNumericEditor1.Value.ToString2();
  125. string productCnt = ultraNumericEditor2.Value.ToString2();
  126. string rateFd = ultraComboEditor3.Value.ToString2();
  127. string common = ultraComboEditor4.Value.ToString2();
  128. string mscPline = ultraGrid1.ActiveRow.GetValue("MSC_PLINE");
  129. string processCode = ultraGrid1.ActiveRow.GetValue("PROCESS_CODE");
  130. string cic = ultraGrid1.ActiveRow.GetValue("CIC");
  131. foreach (var row in rows)
  132. {
  133. CraftOrdFdCicEntity parm = EntityHelper.CopyEntity<CraftOrdFdCicEntity>(row.ListObject);
  134. if (parm.ChemCode == "")
  135. {
  136. MessageUtil.ShowWarning("请选化学元素!");
  137. row.SetCellActive("ChemCode");
  138. return;
  139. }
  140. if (!parm.StdminSign.Equals(""))
  141. {
  142. if (parm.Stdmin.Equals(""))
  143. {
  144. MessageUtil.ShowWarning("请输入标准范围下限值!");
  145. row.SetCellActive("Stdmin");
  146. return;
  147. }
  148. if (parm.ComplexType.Equals("0"))
  149. {
  150. if (!StringUtil.IsNumber(parm.Stdmin))
  151. {
  152. MessageUtil.ShowWarning("标准范围下限值请输入数字!");
  153. row.SetCellActive("Stdmin");
  154. return;
  155. }
  156. }
  157. else
  158. {
  159. if (!QcmBaseCommon.CheckElement(parm.Stdmin, _ob))
  160. {
  161. MessageUtil.ShowWarning("标准范围下限值输入公式不合法,请重新输入!");
  162. row.SetCellActive("Stdmin");
  163. return;
  164. }
  165. }
  166. }
  167. else
  168. {
  169. if (!parm.Stdmin.Equals(""))
  170. {
  171. MessageUtil.ShowWarning("请选择标准范围下限符号!");
  172. row.SetCellActive("Stdmin");
  173. return;
  174. }
  175. }
  176. if (parm.StdminSign.Equals("=") && !parm.StdmaxSign.Equals(""))
  177. {
  178. MessageUtil.ShowWarning("标准范围下限符号为'=',不能选择上限符号!");
  179. row.SetCellActive("StdminSign");
  180. return;
  181. }
  182. if (parm.Isjudge.ToString().Equals("True") && parm.StdminSign.Equals("") && parm.StdmaxSign.Equals(""))
  183. {
  184. MessageUtil.ShowWarning("请选择标准范围下限符号或者上限符号!");
  185. row.SetCellActive("StdminSign");
  186. return;
  187. }
  188. if (!parm.StdmaxSign.Equals(""))
  189. {
  190. if (parm.Stdmax.Equals(""))
  191. {
  192. MessageUtil.ShowWarning("请输入标准范围上限值!");
  193. row.SetCellActive("Stdmax");
  194. return;
  195. }
  196. if (parm.ComplexType.Equals("0"))
  197. {
  198. if (!StringUtil.IsNumber(parm.Stdmax))
  199. {
  200. MessageUtil.ShowWarning("标准范围上限值请输入数字!");
  201. row.SetCellActive("Stdmax");
  202. return;
  203. }
  204. }
  205. else
  206. {
  207. if (!QcmBaseCommon.CheckElement(parm.Stdmax, _ob))
  208. {
  209. MessageUtil.ShowWarning("标准范围上限值输入公式不合法,请重新输入!");
  210. row.SetCellActive("Stdmax");
  211. return;
  212. }
  213. }
  214. }
  215. else
  216. {
  217. if (!parm.Stdmax.Equals(""))
  218. {
  219. MessageUtil.ShowWarning("请选择标准范围上限符号!");
  220. row.SetCellActive("Stdmax");
  221. return;
  222. }
  223. }
  224. if (parm.ComplexType.Equals("0") && !parm.Stdmin.Equals("") && !parm.Stdmax.Equals("")) //&& double.Parse(stdMin) > double.Parse(stdMax)
  225. {
  226. int i = QcmBaseInfo.CheckStdData(parm.StdminSign, parm.StdmaxSign, parm.Stdmin, parm.Stdmax);
  227. if (i == 0)
  228. {
  229. MessageUtil.ShowWarning("输入的数据不完整!");
  230. return;
  231. }
  232. if (i == 1)
  233. {
  234. MessageUtil.ShowWarning("标准范围下限值与上限值相等,上下限符号请选择<=和>=!");
  235. row.SetCellActive("StdminSign");
  236. return;
  237. }
  238. if (i == 2)
  239. {
  240. MessageUtil.ShowWarning("标准范围下限值不能大于上限值!");
  241. row.SetCellActive("Stdmin");
  242. return;
  243. }
  244. }
  245. if (parm.EleMinSign.Equals("=") && !parm.EleMaxSign.Equals(""))
  246. {
  247. MessageUtil.ShowWarning("限制元素下限符号为'=',不能选择上限符号!");
  248. row.SetCellActive("EleMaxSign");
  249. return;
  250. }
  251. if (parm.SizeMinSign2.Equals("=") && !parm.SizeMaxSign2.Equals(""))
  252. {
  253. MessageUtil.ShowWarning("限制规格(一)下限符号为'=',不能选择上限符号!");
  254. row.SetCellActive("SizeMaxSign2");
  255. return;
  256. }
  257. if (parm.SizeMinSign.Equals("=") && !parm.SizeMaxSign.Equals(""))
  258. {
  259. MessageUtil.ShowWarning("限制规格(二)下限符号为'=',不能选择上限符号!");
  260. row.SetCellActive("SizeMaxSign");
  261. return;
  262. }
  263. if (parm.RepMinSign.Equals("=") && !parm.RepMaxSign.Equals(""))
  264. {
  265. MessageUtil.ShowWarning("替代元素下限符号为'=',不能选择上限符号!");
  266. row.SetCellActive("RepMaxSign");
  267. return;
  268. }
  269. if (!parm.EleName.Equals(""))
  270. {
  271. if (parm.EleName.Equals(parm.ChemName))
  272. {
  273. MessageUtil.ShowWarning("化学元素描述不能与限制元素描述相同!");
  274. row.SetCellActive("ChemName");
  275. return;
  276. }
  277. if (parm.EleMinSign.Equals("") && parm.EleMaxSign.Equals(""))
  278. {
  279. MessageUtil.ShowWarning("请选择限制元素上限符号或者下限符号!");
  280. row.SetCellActive("EleMinSign");
  281. return;
  282. }
  283. if (!parm.EleMinSign.Equals("") && parm.EleMin.Equals(""))
  284. {
  285. MessageUtil.ShowWarning("请输入限制元素下限值!");
  286. row.SetCellActive("EleMin");
  287. return ;
  288. }
  289. if (parm.EleMinSign.Equals("") && !parm.EleMin.Equals(""))
  290. {
  291. MessageUtil.ShowWarning("请选择限制元素下限符号!");
  292. row.SetCellActive("EleMinSign");
  293. return;
  294. }
  295. if (!parm.EleMaxSign.Equals("") && parm.EleMax.Equals(""))
  296. {
  297. MessageUtil.ShowWarning("请输入限制元素上限值!");
  298. row.SetCellActive("EleMax");
  299. return;
  300. }
  301. if (parm.EleMaxSign.Equals("") && !parm.EleMax.Equals(""))
  302. {
  303. MessageUtil.ShowWarning("请选择限制元素上限符号!");
  304. row.SetCellActive("EleMaxSign");
  305. return;
  306. }
  307. if (!parm.EleMax.Equals("") && !StringUtil.IsNumber(parm.EleMax))
  308. {
  309. MessageUtil.ShowWarning("限制元素上限值请输入数字!");
  310. row.SetCellActive("EleMax");
  311. return;
  312. }
  313. if (!parm.EleMin.Equals("") && !StringUtil.IsNumber(parm.EleMin))
  314. {
  315. MessageUtil.ShowWarning("限制元素下限值请输入数字!");
  316. row.SetCellActive("EleMin");
  317. return;
  318. }
  319. if (!parm.EleMaxSign.Equals("") && !parm.EleMinSign.Equals("")) //&& Convert.ToInt32(ele_min) > Convert.ToInt32(ele_max)
  320. {
  321. int i = QcmBaseInfo.CheckStdData(parm.EleMinSign, parm.EleMaxSign, parm.EleMin, parm.EleMax);
  322. if (i == 0)
  323. {
  324. MessageUtil.ShowWarning("输入的数据不完整!");
  325. return;
  326. }
  327. if (i == 1)
  328. {
  329. MessageUtil.ShowWarning("限制元素下限值与上限值相等,上下限符号请选择<=和>=!");
  330. row.SetCellActive("EleMinSign");
  331. return;
  332. }
  333. if (i == 2)
  334. {
  335. MessageUtil.ShowWarning("限制元素下限值不能大于上限值!");
  336. row.SetCellActive("EleMin");
  337. return;
  338. }
  339. }
  340. }
  341. else
  342. {
  343. if (!parm.EleMaxSign.Equals("") || !parm.EleMinSign.Equals("") || !parm.EleMin.Equals("") || !parm.EleMax.Equals(""))
  344. {
  345. MessageUtil.ShowWarning("请选择限制元素描述!");
  346. row.SetCellActive("EleMinSign");
  347. return;
  348. }
  349. }
  350. //-------------------新增的7个字段-----------------------------------------
  351. if (!parm.RepName.Equals(""))
  352. {
  353. if (parm.RepName.Equals(parm.ChemName))
  354. {
  355. MessageUtil.ShowWarning("化学元素描述不能与替代元素描述相同!");
  356. row.SetCellActive("ChemName");
  357. return;
  358. }
  359. if (parm.RepMinSign.Equals("") && parm.RepMaxSign.Equals(""))
  360. {
  361. MessageUtil.ShowWarning("请选择替代元素上限符号或者下限符号!");
  362. row.SetCellActive("RepMinSign");
  363. return;
  364. }
  365. if (!parm.RepMinSign.Equals("") && parm.RepMin.Equals(""))
  366. {
  367. MessageUtil.ShowWarning("请输入替代元素下限值!");
  368. row.SetCellActive("RepMin");
  369. return;
  370. }
  371. if (parm.RepMinSign.Equals("") && !parm.RepMin.Equals(""))
  372. {
  373. MessageUtil.ShowWarning("请选择替代元素下限符号!");
  374. row.SetCellActive("RepMinSign");
  375. return;
  376. }
  377. if (!parm.RepMaxSign.Equals("") && parm.RepMax.Equals(""))
  378. {
  379. MessageUtil.ShowWarning("请输入替代元素上限值!");
  380. row.SetCellActive("RepMax");
  381. return;
  382. }
  383. if (parm.RepMaxSign.Equals("") && !parm.RepMax.Equals(""))
  384. {
  385. MessageUtil.ShowWarning("请选择替代元素上限符号!");
  386. row.SetCellActive("RepMaxSign");
  387. return;
  388. }
  389. if (!parm.RepMax.Equals("") && !StringUtil.IsNumber(parm.RepMax))
  390. {
  391. MessageUtil.ShowWarning("替代元素上限值请输入数字!");
  392. row.SetCellActive("RepMax");
  393. return;
  394. }
  395. if (!parm.RepMin.Equals("") && !StringUtil.IsNumber(parm.RepMin))
  396. {
  397. MessageUtil.ShowWarning("替代元素下限值请输入数字!");
  398. row.SetCellActive("RepMin");
  399. return;
  400. }
  401. if (!parm.RepMaxSign.Equals("") && !parm.RepMinSign.Equals("")) //&& Convert.ToInt32(repmin) > Convert.ToInt32(repmax)
  402. {
  403. int i = QcmBaseInfo.CheckStdData(parm.RepMinSign, parm.RepMaxSign, parm.RepMin, parm.RepMax);
  404. if (i == 0)
  405. {
  406. MessageUtil.ShowWarning("输入的数据不完整!");
  407. return;
  408. }
  409. if (i == 1)
  410. {
  411. MessageUtil.ShowWarning("替代元素下限值与上限值相等,上下限符号请选择<=和>=!");
  412. row.SetCellActive("RepMinSign");
  413. return;
  414. }
  415. if (i == 2)
  416. {
  417. MessageUtil.ShowWarning("替代元素下限值不能大于上限值!");
  418. row.SetCellActive("RepMin");
  419. return;
  420. }
  421. }
  422. }
  423. else
  424. {
  425. if (!parm.RepMaxSign.Equals("") || !parm.RepMinSign.Equals("") || !parm.RepMin.Equals("") || !parm.RepMax.Equals(""))
  426. {
  427. MessageUtil.ShowWarning("请选择替代元素!");
  428. row.SetCellActive("RepMinSign");
  429. return;
  430. }
  431. }
  432. if (parm.ChemType.Equals("单一元素"))
  433. parm.ChemType = "A";
  434. else if (parm.ChemType.Equals("复合元素"))
  435. parm.ChemType = "B";
  436. parm.CreateName = CoreUserInfo.UserInfo.GetUserName();
  437. parm.UpdateName = CoreUserInfo.UserInfo.GetUserName();
  438. parm.DeleteName = CoreUserInfo.UserInfo.GetUserName();
  439. parm.SpeclFl = "2";
  440. parm.DesginKey = designKey;
  441. parm.OrdLnPk = ordLnPk;
  442. parm.CicMemo = ultraGrid1.ActiveRow.GetValue("CIC_MEMO");
  443. parm.MscPline = ultraGrid1.ActiveRow.GetValue("MSC_PLINE");
  444. parm.ProcessCode = ultraGrid1.ActiveRow.GetValue("PROCESS_CODE");
  445. parm.Cic = ultraGrid1.ActiveRow.GetValue("CIC");
  446. parms.Add(parm);
  447. }
  448. if (MessageUtil.ShowYesNoAndQuestion("是否确认保存?") == DialogResult.No)
  449. {
  450. return;
  451. }
  452. List<string> jsons = new List<string>();
  453. foreach (var craftOrdFdCicEntity in parms)
  454. {
  455. jsons.Add(JSONFormat.Format(craftOrdFdCicEntity));
  456. }
  457. string chkMscPline = mRow == null ? "" : mRow.GetValue("MSC_PLINE");
  458. string chkProcessCode = mRow == null ? "" : mRow.GetValue("PROCESS_CODE");
  459. string chkMemo = mRow == null ? "" : mRow.GetValue("CIC_MEMO");
  460. ServerHelper.SetData("com.steering.pss.sale.order.CraftOrdFdCic.save",
  461. new object[] { jsons, ordLnPk, chkMscPline, chkProcessCode, chkMemo, productCnt, rateFd, common}, _ob);
  462. MessageUtil.ShowTips("保存成功!");
  463. Relocate(mscPline, processCode, cic);
  464. }
  465. private void Relocate(string mscPline, string processCode, string cic)
  466. {
  467. Query();
  468. var mRow = ultraGrid1.Rows.Where(a => a.GetValue("MSC_PLINE") == mscPline && a.GetValue("PROCESS_CODE") == processCode &&
  469. a.GetValue("CIC") == cic).FirstOrDefault();
  470. if (mRow != null)
  471. {
  472. mRow.Activate();
  473. }
  474. }
  475. public void Delete()
  476. {
  477. List<CraftOrdFdCicEntity> parms = new List<CraftOrdFdCicEntity>();
  478. var mRow = ultraGrid1.Rows.Where(a => a.GetValue("CHK") == "True").FirstOrDefault();
  479. var rows = entityGrid1.Rows.Where(a => a.GetValue("Chk") == "True");
  480. if (mRow == null && rows.Count() == 0)
  481. {
  482. MessageUtil.ShowWarning("请选择一条记录!");
  483. return;
  484. }
  485. string mscPline = ultraGrid1.ActiveRow.GetValue("MSC_PLINE");
  486. string processCode = ultraGrid1.ActiveRow.GetValue("PROCESS_CODE");
  487. string cic = ultraGrid1.ActiveRow.GetValue("CIC");
  488. foreach (var row in rows)
  489. {
  490. CraftOrdFdCicEntity parm = EntityHelper.CopyEntity<CraftOrdFdCicEntity>(row.ListObject);
  491. parm.CreateName = CoreUserInfo.UserInfo.GetUserName();
  492. parm.UpdateName = CoreUserInfo.UserInfo.GetUserName();
  493. parm.DeleteName = CoreUserInfo.UserInfo.GetUserName();
  494. parm.SpeclFl = "2";
  495. parm.DesginKey = designKey;
  496. parms.Add(parm);
  497. }
  498. if (MessageUtil.ShowYesNoAndQuestion("是否确认删除?") == DialogResult.No)
  499. {
  500. return;
  501. }
  502. List<string> jsons = new List<string>();
  503. foreach (var craftOrdDesignStdCicEntity in parms)
  504. {
  505. jsons.Add(JSONFormat.Format(craftOrdDesignStdCicEntity));
  506. }
  507. string parmMscPline = mRow == null ? "" : mRow.GetValue("MSC_PLINE");
  508. string parmProcessCode = mRow == null ? "" : mRow.GetValue("PROCESS_CODE");
  509. ServerHelper.SetData("com.steering.pss.sale.order.CraftOrdFdCic.delete",
  510. new object[] { jsons, ordLnPk, parmMscPline, parmProcessCode }, _ob);
  511. MessageUtil.ShowTips("删除成功!");
  512. Relocate(mscPline, processCode, cic);
  513. }
  514. public void CopyNkStd()
  515. {
  516. var mRow = ultraGrid1.Rows.Where(a => a.GetValue("CHK") == "True").FirstOrDefault();
  517. if (mRow == null)
  518. {
  519. MessageUtil.ShowWarning("请选择一条成分标准索引码!");
  520. return;
  521. }
  522. if (mRow.GetValue("CIC") == "")
  523. {
  524. MessageUtil.ShowWarning("请选择一条成分标准索引码!");
  525. return;
  526. }
  527. if (MessageUtil.ShowYesNoAndQuestion("是否确认复制内控索引码" + mRow.GetValue("CIC") + "?") == DialogResult.No)
  528. {
  529. return;
  530. }
  531. ServerHelper.SetData("com.steering.pss.sale.order.CraftOrdFdCic.copyNkStd", new object[] { designKey, ordLnPk,
  532. mRow.GetValue("MSC_PLINE"), mRow.GetValue("PROCESS_CODE"), mRow.GetValue("CIC") }, _ob);
  533. MessageUtil.ShowTips("复制成功!");
  534. Query();
  535. }
  536. private void GridEdite(UltraGridRow row)
  537. {
  538. if (row.GetValue("Chk") == "True")
  539. {
  540. foreach (UltraGridCell cell in row.Cells)
  541. {
  542. if (cell.Column.CellActivation == Activation.AllowEdit)
  543. {
  544. cell.Activation = Activation.AllowEdit;
  545. }
  546. }
  547. }
  548. else
  549. {
  550. foreach (UltraGridCell cell in row.Cells)
  551. {
  552. if (cell.Column.Key == "Chk") continue;
  553. if (cell.Column.CellActivation == Activation.AllowEdit)
  554. {
  555. cell.Activation = Activation.ActivateOnly;
  556. }
  557. }
  558. }
  559. }
  560. private void entityGrid1_CellChange(object sender, CellEventArgs e)
  561. {
  562. e.Cell.Row.Update();
  563. GridEdite(e.Cell.Row);
  564. var ugr = e.Cell.Row;
  565. if (e.Cell.Column.Key.Equals("ChemCode")) /// 成分下拉框操作
  566. {
  567. ugr.Cells["ChemName"].Value = ugr.Cells["ChemCode"].Text;
  568. string chemCode = ugr.Cells["ChemCode"].Value.ToString();
  569. DataRow[] dr = ((DataTable)ultras[2].DataSource).Select("CHEM_CODE ='" + chemCode + "'");
  570. if (dr.Length > 0)
  571. {
  572. //ugr.Cells["xh"].Value = Convert.ToInt32(dr[0][0].ToString().Substring(1));
  573. ugr.Cells["ChemType"].Value = dr[0]["CHEM_TYPE_CODE"].ToString();
  574. ugr.Cells["ChemFormula"].Value = dr[0]["CHEM_FORMULA"].ToString();
  575. }
  576. else
  577. {
  578. ugr.Cells["ChemName"].Value = "";
  579. ugr.Cells["ChemType"].Value = "";
  580. ugr.Cells["ChemFormula"].Value = "";
  581. }
  582. }
  583. }
  584. private void entityGrid1_AfterRowInsert(object sender, RowEventArgs e)
  585. {
  586. var mRow = ultraGrid1.ActiveRow;
  587. e.Row.SetValue("mscPline", mRow.GetValue("MSC_PLINE"));
  588. e.Row.SetValue("processCode", mRow.GetValue("PROCESS_CODE"));
  589. e.Row.SetValue("processDesc", mRow.GetValue("PROCESS_DESC"));
  590. e.Row.SetValue("cic", mRow.GetValue("CIC"));
  591. e.Row.Cells["IsCheck"].Value = true;
  592. e.Row.Cells["IsJudge"].Value = true;
  593. e.Row.Cells["IsQuote"].Value = true;
  594. e.Row.Cells["ComplexType"].Value = false;
  595. e.Row.Cells["CraftSource"].Value = "1";
  596. e.Row.Cells["SPeclFl"].Value = "2";
  597. e.Row.Cells["OrdLnPk"].Value = ordLnPk;
  598. e.Row.Update();
  599. }
  600. private void ultraTextEditor1_EditorButtonClick(object sender, EditorButtonEventArgs e)
  601. {
  602. if (ultraGrid1.ActiveCell.Column.Key == "MSC_PLINE")
  603. {
  604. if (entityGrid1.Rows.Count != 0)
  605. {
  606. MessageUtil.ShowWarning("已维护首日检数据,不能修改!");
  607. }
  608. else
  609. {
  610. UltraGridRow row = ultraGrid1.ActiveRow;
  611. string key = ultraGrid1.ActiveCell.Column.Key;
  612. DataTable dt = ServerHelper.GetData("com.steering.pss.sale.order.CraftOrdFdCic.getMscPlineProcess",
  613. new object[] { designKey }, _ob);
  614. dt.Columns["MSC_PLINE"].Caption = "制程号";
  615. dt.Columns["WHOLE_BACKLOG"].Caption = "全程途径码";
  616. dt.Columns["WHOLE_BACKLOG_DESC"].Caption = "全程途径描述";
  617. dt.Columns["PROCESS_DESC"].Caption = "工序";
  618. dt.DefaultView.RowFilter = "PROCESS_CODE = 'A'";
  619. BaseInfoPopup popup = new BaseInfoPopup(dt, "MSC_PLINE", "PROCESS_CODE");
  620. GridHelper.RefreshAndAutoSize(popup.UltraGrid1);
  621. popup.LabelTextBox1.Caption = "制程号";
  622. if (popup.ShowDialog() == DialogResult.OK)
  623. {
  624. row.SetValue("MSC_PLINE", popup.ChoicedRow.GetValue("MSC_PLINE"));
  625. row.SetValue("PROCESS_DESC", popup.ChoicedRow.GetValue("PROCESS_DESC"));
  626. row.SetValue("PROCESS_CODE", popup.ChoicedRow.GetValue("PROCESS_CODE"));
  627. row.SetValue("CIC", popup.ChoicedRow.GetValue("CIC"));
  628. row.Update();
  629. }
  630. }
  631. }
  632. }
  633. private void ultraGrid1_CellChange(object sender, CellEventArgs e)
  634. {
  635. e.Cell.Row.Update();
  636. }
  637. private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
  638. {
  639. var mRow = ultraGrid1.ActiveRow;
  640. string cic = mRow.GetValue("CIC");
  641. string mscPline = mRow.GetValue("MSC_PLINE");
  642. string processCode = mRow.GetValue("PROCESS_CODE");
  643. this.CraftOrdDesignStdCicEntityBindingSource.DataSource = EntityHelper.GetData<CraftOrdFdCicEntity>(
  644. "com.steering.pss.sale.order.CraftOrdFdCic.query",
  645. new object[] { ordLnPk, mscPline, processCode, cic }, _ob);
  646. foreach (var row in entityGrid1.Rows)
  647. {
  648. GridEdite(row);
  649. }
  650. }
  651. private void entityGrid1_BeforeRowInsert(object sender, BeforeRowInsertEventArgs e)
  652. {
  653. if (ultraGrid1.ActiveRow == null || ultraGrid1.ActiveRow.GetValue("CIC") == "")
  654. {
  655. e.Cancel = true;
  656. }
  657. }
  658. private void ultraGrid1_AfterRowInsert(object sender, RowEventArgs e)
  659. {
  660. e.Row.Update();
  661. }
  662. /// <summary>
  663. /// 复制
  664. /// </summary>
  665. public void Copy()
  666. {
  667. var chkRows = entityGrid1.Rows.Where(a=>a.GetValue("chk") == "True");
  668. if (chkRows.Count() == 0)
  669. {
  670. MessageUtil.ShowWarning("请选择记录后,再进行操作!");
  671. return;
  672. }
  673. ultraGrid1.UpdateData();
  674. DataTable copyTable = CreateTableByEntity((CraftOrdFdCicEntity)chkRows.FirstOrDefault().ListObject);
  675. foreach (UltraGridRow row in entityGrid1.Rows)
  676. {
  677. if (row.GetValue("Chk") != "True") continue;
  678. DataRow dr = copyTable.NewRow();
  679. CopyEntityToRow((CraftOrdFdCicEntity)row.ListObject, dr);
  680. copyTable.Rows.Add(dr);
  681. }
  682. DataTable[] copyTabs = new DataTable[] { copyTable, new DataTable() };
  683. Clipboard.SetData("Cic", copyTabs);
  684. }
  685. /// <summary>
  686. /// 粘贴
  687. /// </summary>
  688. public void Paste()
  689. {
  690. if (ultraGrid1.ActiveRow == null || ultraGrid1.ActiveRow.GetValue("CIC") == "")
  691. {
  692. MessageUtil.ShowWarning("请选择一条成分标准索引码!");
  693. return;
  694. }
  695. DataTable[] copyTabs = (DataTable[])Clipboard.GetData("Cic");
  696. if (copyTabs == null)
  697. {
  698. MessageUtil.ShowWarning("没有数据,请复制后再进行操作!");
  699. return;
  700. }
  701. DataTable copyTab = copyTabs[0];
  702. DataTable copyTab2 = copyTabs[1];
  703. if (copyTab == null || copyTab.Rows.Count == 0)
  704. {
  705. MessageUtil.ShowWarning("没有数据,请复制后再进行操作!");
  706. return;
  707. }
  708. dataTable1.BeginInit();
  709. List<CraftOrdFdCicEntity> data = (List<CraftOrdFdCicEntity>)CraftOrdDesignStdCicEntityBindingSource.DataSource;
  710. //if (entityGrid1.DataSource is List<CraftOrdFdCicEntity>)
  711. //{
  712. // data = (List<CraftOrdFdCicEntity>)entityGrid1.DataSource;
  713. //}
  714. CraftOrdFdCicEntity activeFd = null;
  715. foreach (DataRow row in copyTab.Rows)
  716. {
  717. CraftOrdFdCicEntity fd = new CraftOrdFdCicEntity();
  718. fd.Chk = true;
  719. CopyRowToEntity(row, fd);
  720. data.Add(fd);
  721. activeFd = fd;
  722. }
  723. CraftOrdDesignStdCicEntityBindingSource.ResetBindings(false);
  724. //CraftOrdDesignStdCicEntityBindingSource.DataSource = data;
  725. dataTable1.EndInit();
  726. entityGrid1.UpdateData();
  727. if (entityGrid1.Rows.Count > 0)
  728. {
  729. entityGrid1.Rows[entityGrid1.Rows.Count - 1].Activate();
  730. }
  731. }
  732. private string GetLineName(string name)
  733. {
  734. string lineName = "";
  735. for (int i = 0; i < name.Length; i++)
  736. {
  737. if (i == 0)
  738. {
  739. lineName += name[i];
  740. }
  741. else
  742. {
  743. if (name[i] >= 'A' && name[i] <= 'Z')
  744. {
  745. lineName += '_';
  746. lineName += name[i];
  747. }
  748. else
  749. {
  750. lineName += name[i];
  751. }
  752. }
  753. }
  754. return lineName.ToUpper();
  755. }
  756. private string GetName(string lineName)
  757. {
  758. string[] strs = lineName.Split('_');
  759. string name = "";
  760. for (int i = 0; i < strs.Length; i++)
  761. {
  762. name += strs[i].Substring(0, 1).ToUpper() + strs[i].Substring(1).ToLower();
  763. }
  764. return name;
  765. }
  766. private DataTable CreateTableByEntity(CraftOrdFdCicEntity fdEntity)
  767. {
  768. DataTable dt = new DataTable();
  769. PropertyInfo[] srcPropertyInfos = fdEntity.GetType().GetProperties();
  770. foreach (PropertyInfo srcPropertyInfo in srcPropertyInfos)
  771. {
  772. dt.Columns.Add(GetLineName(srcPropertyInfo.Name));
  773. }
  774. return dt;
  775. }
  776. private void CopyEntityToRow(CraftOrdFdCicEntity fdEntity, DataRow desRow)
  777. {
  778. PropertyInfo[] pros = fdEntity.GetType().GetProperties();
  779. foreach (PropertyInfo pro in pros)
  780. {
  781. desRow[GetLineName(pro.Name)] = pro.GetValue(fdEntity, null);
  782. }
  783. }
  784. private void CopyRowToEntity(DataRow row, CraftOrdFdCicEntity fdEntity)
  785. {
  786. PropertyInfo[] pros = fdEntity.GetType().GetProperties();
  787. foreach (DataColumn dc in row.Table.Columns)
  788. {
  789. if (dc.ColumnName == "CREATE_TIME") continue;
  790. PropertyInfo pro = fdEntity.GetType().GetProperty(GetName(dc.ColumnName));
  791. if(pro != null)
  792. {
  793. pro.SetValue(fdEntity, ConvertDataType(pro.PropertyType, row[dc.ColumnName].ToString()), null);
  794. }
  795. }
  796. }
  797. private object ConvertDataType(Type type, object objValue)
  798. {
  799. if (type == typeof(bool))
  800. {
  801. bool result;
  802. if (bool.TryParse(objValue.ToString(), out result))
  803. {
  804. return result;
  805. }
  806. else
  807. {
  808. return false;
  809. }
  810. }
  811. else if (type == typeof(bool?))
  812. {
  813. bool result;
  814. if (bool.TryParse(objValue.ToString(), out result))
  815. {
  816. return result;
  817. }
  818. else
  819. {
  820. return null;
  821. }
  822. }
  823. else if (type == typeof(int?))
  824. {
  825. if (objValue.ToString2() == "")
  826. {
  827. return null;
  828. }
  829. else
  830. {
  831. return int.Parse(objValue.ToString());
  832. }
  833. }
  834. else if (type == typeof(long?))
  835. {
  836. if (objValue.ToString2() == "")
  837. {
  838. return null;
  839. }
  840. else
  841. {
  842. return long.Parse(objValue.ToString());
  843. }
  844. }
  845. else if (type == typeof(short?))
  846. {
  847. if (objValue.ToString2() == "")
  848. {
  849. return null;
  850. }
  851. else
  852. {
  853. return short.Parse(objValue.ToString());
  854. }
  855. }
  856. else if (type == typeof(float?))
  857. {
  858. if (objValue.ToString2() == "")
  859. {
  860. return null;
  861. }
  862. else
  863. {
  864. return float.Parse(objValue.ToString());
  865. }
  866. }
  867. else if (type == typeof(double?))
  868. {
  869. if (objValue.ToString2() == "")
  870. {
  871. return null;
  872. }
  873. else
  874. {
  875. return double.Parse(objValue.ToString());
  876. }
  877. }
  878. else if (type == typeof(decimal?))
  879. {
  880. if (objValue.ToString2() == "")
  881. {
  882. return null;
  883. }
  884. else
  885. {
  886. return decimal.Parse(objValue.ToString());
  887. }
  888. }
  889. else if (type == typeof(DateTime?))
  890. {
  891. if (objValue.ToString2() == "")
  892. {
  893. return null;
  894. }
  895. else
  896. {
  897. return DateTime.Parse(objValue.ToString());
  898. }
  899. }
  900. else
  901. {
  902. return objValue == null ? "" : objValue.ToString();
  903. }
  904. }
  905. private void ultraGrid1_BeforeRowInsert(object sender, BeforeRowInsertEventArgs e)
  906. {
  907. if (ultraGrid1.Rows.Count > 0)
  908. {
  909. e.Cancel = true;
  910. }
  911. }
  912. }
  913. }