CraftOrdDesignStdSicCtrl.cs 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895
  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 Infragistics.Win.UltraWinGrid;
  14. using Core.StlMes.Client.Qcm;
  15. using Core.Mes.Client.Comm.Server;
  16. using CoreFS.SA06;
  17. using Infragistics.Win;
  18. using Core.Mes.Client.Comm.Control;
  19. namespace Core.StlMes.Client.SaleOrder.Control
  20. {
  21. public partial class CraftOrdDesignStdSicCtrl : UserControl
  22. {
  23. private CraftOrdDesignStdSicBLL _designStdSicBLL;
  24. private CraftOrdDesignMscPlBLL _designMscPlBLL;
  25. private CraftOrdDesignMscPlPrcBLL _designMscPlPrcBLL;
  26. //初始下拉框
  27. private UltraComboEditor[] ultras = new UltraComboEditor[9];
  28. private OpeBase _ob;
  29. public CraftOrdDesignStdSicCtrl(System.Windows.Forms.Control container, OpeBase ob)
  30. {
  31. InitializeComponent();
  32. _ob = ob;
  33. _designStdSicBLL = new CraftOrdDesignStdSicBLL(ob);
  34. _designMscPlBLL = new CraftOrdDesignMscPlBLL(ob);
  35. _designMscPlPrcBLL = new CraftOrdDesignMscPlPrcBLL(ob);
  36. container.Controls.Add(this);
  37. this.Dock = DockStyle.Fill;
  38. LoadBaseData();
  39. }
  40. private void LoadBaseData()
  41. {
  42. for (int i = 0; i < ultras.Length; i++)
  43. {
  44. ultras[i] = new UltraComboEditor();
  45. Controls.Add(ultras[i]);
  46. ultras[i].Visible = false;
  47. ultras[i].DropDownListWidth = -1;
  48. }
  49. //从表
  50. UltraGridBand ugbC = entityGrid1.DisplayLayout.Bands[0];
  51. //下限符号
  52. QcmBaseQuery.NitializeSignMin(ultras[1]);
  53. //公差约束项一下限符号
  54. QcmBaseQuery.BindColumn(ultras[1], "ZminSign", ugbC);
  55. //公差约束项二下限符号
  56. QcmBaseQuery.BindColumn(ultras[1], "CminSign", ugbC);
  57. //公差约束项三下限符号
  58. QcmBaseQuery.BindColumn(ultras[1], "SminSign", ugbC);
  59. //上限符号
  60. QcmBaseQuery.NitializeSignMax(ultras[2]);
  61. //公差约束项一上限符号
  62. QcmBaseQuery.BindColumn(ultras[2], "ZmaxSign", ugbC);
  63. //公差约束项二上限符号
  64. QcmBaseQuery.BindColumn(ultras[2], "CmaxSign", ugbC);
  65. //公差约束项三上限符号
  66. QcmBaseQuery.BindColumn(ultras[2], "SmaxSign", ugbC);
  67. //公差项
  68. QcmBaseQuery.NitializeTolerance(ultras[3], false, _ob);
  69. QcmBaseQuery.BindColumn(ultras[3], "BiasCode", ugbC);
  70. //精度等级
  71. QcmBaseQuery.NitializePrecision(ultras[4], true, _ob);
  72. QcmBaseQuery.BindColumn(ultras[4], "Lv", ugbC);
  73. //公差约束项
  74. QcmBaseQuery.NitializeToleranceRestrain(ultras[7], true, _ob);
  75. QcmBaseQuery.BindColumn(ultras[7], "BiasCodeZ", ugbC);
  76. QcmBaseQuery.BindColumn(ultras[7], "BiasCodeC", ugbC);
  77. QcmBaseQuery.BindColumn(ultras[7], "BiasCodeS", ugbC);
  78. }
  79. /// <summary>
  80. /// 查询质量设计公差
  81. /// </summary>
  82. /// <param name="designStdSicEntity"></param>
  83. public void Query(CraftOrdDesignStdSicEntity designStdSicEntity)
  84. {
  85. this.CraftOrdDesignStdSicEntityBindingSource.DataSource = _designStdSicBLL.Query(designStdSicEntity);
  86. }
  87. private string designKey = "";
  88. private string[] _parms;
  89. /// <summary>
  90. /// 查询质量设计公差
  91. /// </summary>
  92. /// <param name="designStdSicEntity"></param>
  93. public void QueryByDesignKeySic(string[] parms)
  94. {
  95. designKey = parms[0];
  96. _parms = parms;
  97. var data = _designStdSicBLL.QueryByDesignKeySic(parms);
  98. var list = data.Select(p => p.Sic).Distinct().ToList();
  99. if (list.Count > 1)
  100. {
  101. ultras[6].DataSource = data.Select(p => p.Sic).Distinct().ToList();
  102. QcmBaseQuery.BindColumn(ultras[6], "Sic", entityGrid1.DisplayLayout.Bands[0]);
  103. }
  104. this.CraftOrdDesignStdSicEntityBindingSource.DataSource = data;
  105. //UltraComboEditor cmb = new UltraComboEditor();
  106. foreach (var row in entityGrid1.Rows)
  107. {
  108. GridEdite(row);
  109. if (row.GetValue("CraftSource") == "0")
  110. {
  111. row.Cells["Chk"].Value = null;
  112. row.Cells["Chk"].Activation = Activation.ActivateOnly;
  113. row.Update();
  114. }
  115. //if (cmb.ValueList.FindString(row.GetValue("Sic")) == -1)
  116. //{
  117. // cmb.ValueList.ValueListItems.Add(row.GetValue("Sic"));
  118. //}
  119. }
  120. //cmb.DisplayStyle = EmbeddableElementDisplayStyle.WindowsVista;
  121. //entityGrid1.DisplayLayout.Bands[0].Columns["Sic"].EditorComponent = cmb;
  122. //entityGrid1.DisplayLayout.Bands[0].Columns["Sic"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList;
  123. }
  124. private void entityGrid1_CellChange(object sender, CellEventArgs e)
  125. {
  126. entityGrid1.UpdateData();
  127. GridEdite(e.Cell.Row);
  128. }
  129. public void Clear()
  130. {
  131. this.CraftOrdDesignStdSicEntityBindingSource.Clear();
  132. }
  133. public void Save()
  134. {
  135. List<CraftOrdDesignStdSicEntity> parms = new List<CraftOrdDesignStdSicEntity>();
  136. var rows = entityGrid1.Rows.Where(a => a.GetValue("Chk") == "True");
  137. foreach (var row in rows)
  138. {
  139. var parm = EntityHelper.CopyEntity<CraftOrdDesignStdSicEntity>(row.ListObject);
  140. if (parm.MscPline == "")
  141. {
  142. MessageUtil.ShowWarning("请选择制程!");
  143. row.SetCellActive("MscPline");
  144. return;
  145. }
  146. //if (parm.ProcessDescC == "")
  147. //{
  148. // MessageUtil.ShowWarning("请选择二级工序!");
  149. // row.SetCellActive("ProcessDescC");
  150. // return;
  151. //}
  152. if (parm.Sic == "")
  153. {
  154. MessageUtil.ShowWarning("请选择公差索引码!");
  155. row.SetCellActive("Sic");
  156. return;
  157. }
  158. if (parm.BiasCode == "")
  159. {
  160. MessageUtil.ShowWarning("请选择公差主项!");
  161. row.SetCellActive("BiasCode");
  162. return;
  163. }
  164. if (!parm.BiasCodeZ.Equals(""))
  165. {
  166. if (parm.ZminSign.Equals("=") && !parm.ZmaxSign.Equals(""))
  167. {
  168. MessageUtil.ShowWarning("公差约束项<一>:下限符号为‘=’,不能选择上限符号!");
  169. row.SetCellActive("ZmaxSign");
  170. return;
  171. }
  172. if (parm.ZminSign.Equals("") && parm.ZmaxSign.Equals(""))
  173. {
  174. MessageUtil.ShowWarning("请选择公差约束项<一>:下限符号或者上限符号!");
  175. row.SetCellActive("ZminSign");
  176. return;
  177. }
  178. //上限符号与上限值
  179. if (!parm.Zmax.Equals(""))
  180. {
  181. if (parm.ZmaxSign.Equals(""))
  182. {
  183. MessageUtil.ShowWarning("请选择公差约束项<一>:上限符号!");
  184. row.SetCellActive("ZmaxSign");
  185. return;
  186. }
  187. if (StringUtil.IsNumber(parm.Zmax) && parm.Zmax.Length > 10)
  188. {
  189. MessageUtil.ShowWarning("公差约束项<一>:上限值(10位以内数字)!");
  190. row.SetCellActive("Zmax");
  191. return;
  192. }
  193. string zMax = parm.Zmax.Replace('t', '1').Replace('D', '1').Replace('L', '1');
  194. if (!StringUtil.IsNumber(parm.Zmax) && zMax.CompileFormula() == null)
  195. {
  196. MessageUtil.ShowWarning("公差约束项<一>:上限值(请输入合法公式!");
  197. row.SetCellActive("Zmax");
  198. return;
  199. }
  200. }
  201. else
  202. {
  203. if (!parm.ZmaxSign.Equals(""))
  204. {
  205. MessageUtil.ShowWarning("请输入公差约束项<一>:上限值!");
  206. row.SetCellActive("ZmaxSign");
  207. return;
  208. }
  209. }
  210. //下限符号与下限值
  211. if (!parm.Zmin.Equals(""))
  212. {
  213. if (parm.ZminSign.Equals(""))
  214. {
  215. MessageUtil.ShowWarning("请选择公差约束项<一>:下限符号!");
  216. row.SetCellActive("ZminSign");
  217. return;
  218. }
  219. if (StringUtil.IsNumber(parm.Zmin) && parm.Zmin.Length > 10)
  220. {
  221. MessageUtil.ShowWarning("请输入公差约束项<一>:下限值(10位以内数字)!");
  222. row.SetCellActive("Zmin");
  223. return;
  224. }
  225. string zMin = parm.Zmin.Replace('t', '1').Replace('D', '1').Replace('L', '1');
  226. if (!StringUtil.IsNumber(parm.Zmin) && zMin.CompileFormula() == null)
  227. {
  228. MessageUtil.ShowWarning("公差约束项<一>:下限值(请输入合法公式!");
  229. row.SetCellActive("Zmin");
  230. return;
  231. }
  232. }
  233. else
  234. {
  235. if (!parm.ZminSign.Equals(""))
  236. {
  237. MessageUtil.ShowWarning("请输入公差约束项<一>:下限值!");
  238. row.SetCellActive("Zmin");
  239. return;
  240. }
  241. }
  242. if (!parm.Zmax.Equals("") && !parm.Zmin.Equals("")) //&&Convert.ToDouble(com.Zmin)>Convert.ToDouble(com.Zmax)
  243. {
  244. int retrunValue = QcmBaseInfo.CheckStdData(parm.ZminSign, parm.ZmaxSign, parm.Zmin, parm.Zmax);
  245. if (retrunValue == 0)
  246. {
  247. MessageUtil.ShowWarning("请输入公差约束项!");
  248. row.SetCellActive("ZminSign");
  249. return;
  250. }
  251. if (retrunValue == 1)
  252. {
  253. MessageUtil.ShowWarning("公差约束项<一>下限值与上限值相等,上下限符号请选择<=和>=!");
  254. row.SetCellActive("ZminSign");
  255. return;
  256. }
  257. if (retrunValue == 2)
  258. {
  259. MessageUtil.ShowWarning("公差约束项<一>下限值不能大于上限值!");
  260. row.SetCellActive("Zmin");
  261. return;
  262. }
  263. }
  264. }
  265. else
  266. {
  267. if (!parm.ZminSign.Equals("") || !parm.Zmin.Equals("") || !parm.ZmaxSign.Equals("") || !parm.Zmax.Equals(""))
  268. {
  269. MessageUtil.ShowWarning("请选择公差约束项<一>:公差约束项!");
  270. row.SetCellActive("BiasCodeZ");
  271. return;
  272. }
  273. }
  274. if (!parm.BiasCodeC.Equals(""))
  275. {
  276. if (parm.CminSign.Equals("=") && !parm.CmaxSign.Equals(""))
  277. {
  278. MessageUtil.ShowWarning("公差约束项<二>:下限符号为‘=’,不能选择上限符号!");
  279. row.SetCellActive("CmaxSign");
  280. return;
  281. }
  282. if (parm.CminSign.Equals("") && parm.CmaxSign.Equals(""))
  283. {
  284. MessageUtil.ShowWarning("请选择公差约束项<二>:下限符号或者上限符号!");
  285. row.SetCellActive("CminSign");
  286. return;
  287. }
  288. //上限符号与上限值
  289. if (!parm.Cmax.Equals(""))
  290. {
  291. if (parm.CmaxSign.Equals(""))
  292. {
  293. MessageUtil.ShowWarning("请选择公差约束项<二>:上限符号!");
  294. row.SetCellActive("CmaxSign");
  295. return;
  296. }
  297. if (StringUtil.IsNumber(parm.Cmax) && parm.Cmax.Length > 10)
  298. {
  299. MessageUtil.ShowWarning("请输入公差约束项<二>:上限值(10位以内数字)!");
  300. row.SetCellActive("Cmax");
  301. return;
  302. }
  303. string Cmax = parm.Cmax.Replace('t', '1').Replace('D', '1').Replace('L', '1');
  304. if (!StringUtil.IsNumber(parm.Cmax) && Cmax.CompileFormula() == null)
  305. {
  306. MessageUtil.ShowWarning("公差约束项<二>:上限值(请输入合法公式!");
  307. row.SetCellActive("Cmax");
  308. return;
  309. }
  310. }
  311. else
  312. {
  313. if (!parm.CmaxSign.Equals(""))
  314. {
  315. MessageUtil.ShowWarning("请输入公差约束项<二>:上限值!");
  316. row.SetCellActive("Cmax");
  317. return;
  318. }
  319. }
  320. //下限符号与下限值
  321. if (!parm.Cmin.Equals(""))
  322. {
  323. if (parm.CminSign.Equals(""))
  324. {
  325. MessageUtil.ShowWarning("请选择公差约束项<二>:下限符号!");
  326. row.SetCellActive("CminSign");
  327. return;
  328. }
  329. if (StringUtil.IsNumber(parm.Cmin) && parm.Cmin.Length > 10)
  330. {
  331. MessageUtil.ShowWarning("请输入公差约束项<二>:下限值(10位以内数字)!");
  332. row.SetCellActive("Cmin");
  333. return;
  334. }
  335. string Cmin = parm.Cmin.Replace('t', '1').Replace('D', '1').Replace('L', '1');
  336. if (!StringUtil.IsNumber(parm.Cmin) && Cmin.CompileFormula() == null)
  337. {
  338. MessageUtil.ShowWarning("公差约束项<二>:下限值(请输入合法公式!");
  339. row.SetCellActive("Cmin");
  340. return;
  341. }
  342. }
  343. else
  344. {
  345. if (!parm.CminSign.Equals(""))
  346. {
  347. MessageUtil.ShowWarning("请输入公差约束项<二>:下限值!");
  348. row.SetCellActive("Cmin");
  349. return;
  350. }
  351. }
  352. if (!parm.Cmax.Equals("") && !parm.Cmin.Equals("")) // && Convert.ToDouble(com.Cmin) > Convert.ToDouble(com.Cmax)
  353. {
  354. int retrunValue = QcmBaseInfo.CheckStdData(parm.CminSign, parm.CmaxSign, parm.Cmin, parm.Cmax);
  355. if (retrunValue == 0)
  356. {
  357. MessageUtil.ShowWarning("输入的数据不完整!");
  358. return;
  359. }
  360. if (retrunValue == 1)
  361. {
  362. MessageUtil.ShowWarning("公差约束项<二>下限值与上限值相等,上下限符号请选择<=和>=!");
  363. row.SetCellActive("CminSign");
  364. return;
  365. }
  366. if (retrunValue == 2)
  367. {
  368. MessageUtil.ShowWarning("公差约束项<二>下限值不能大于上限值!");
  369. row.SetCellActive("Cmin");
  370. return;
  371. }
  372. }
  373. }
  374. else
  375. {
  376. if (!parm.CminSign.Equals("") || !parm.Cmin.Equals("") || !parm.CmaxSign.Equals("") || !parm.Cmax.Equals(""))
  377. {
  378. MessageUtil.ShowWarning("请选择公差约束项<二>:公差约束项!");
  379. row.SetCellActive("BiasCodeC");
  380. return;
  381. }
  382. }
  383. if (!parm.BiasCodeS.Equals(""))
  384. {
  385. if (parm.SminSign.Equals("=") && !parm.SmaxSign.Equals(""))
  386. {
  387. MessageUtil.ShowWarning("公差约束项<三>:下限符号为‘=’,不能选择上限符号!");
  388. row.SetCellActive("SmaxSign");
  389. return;
  390. }
  391. if (parm.SminSign.Equals("") && parm.SmaxSign.Equals(""))
  392. {
  393. MessageUtil.ShowWarning("请选择公差约束项<三>:下限符号或者上限符号!");
  394. row.SetCellActive("SminSign");
  395. return;
  396. }
  397. //上限符号与上限值
  398. if (!parm.Smax.Equals(""))
  399. {
  400. if (parm.SmaxSign.Equals(""))
  401. {
  402. MessageUtil.ShowWarning("请选择公差约束项<三>:上限符号!");
  403. row.SetCellActive("SmaxSign");
  404. return;
  405. }
  406. if (StringUtil.IsNumber(parm.Smax) && parm.Smax.Length > 10)
  407. {
  408. MessageUtil.ShowWarning("请输入公差约束项<三>:上限值(10位以内数字)!");
  409. row.SetCellActive("Smax");
  410. return;
  411. }
  412. string Smax = parm.Smax.Replace('t', '1').Replace('D', '1').Replace('L', '1');
  413. if (!StringUtil.IsNumber(parm.Smax) && Smax.CompileFormula() == null)
  414. {
  415. MessageUtil.ShowWarning("公差约束项<三>:上限值(请输入合法公式!");
  416. row.SetCellActive("Smax");
  417. return;
  418. }
  419. }
  420. else
  421. {
  422. if (!parm.SmaxSign.Equals(""))
  423. {
  424. MessageUtil.ShowWarning("请输入公差约束项<三>:上限值!");
  425. row.SetCellActive("Smax");
  426. return;
  427. }
  428. }
  429. //下限符号与下限值
  430. if (!parm.Smin.Equals(""))
  431. {
  432. if (parm.SminSign.Equals(""))
  433. {
  434. MessageUtil.ShowWarning("请选择公差约束项<三>:下限符号!");
  435. row.SetCellActive("SminSign");
  436. return;
  437. }
  438. if (StringUtil.IsNumber(parm.Smin) && parm.Smin.Length > 10)
  439. {
  440. MessageUtil.ShowWarning("请输入公差约束项<三>:下限值(10位以内数字)!");
  441. row.SetCellActive("Smin");
  442. return;
  443. }
  444. string Smin = parm.Smin.Replace('t', '1').Replace('D', '1').Replace('L', '1');
  445. if (!StringUtil.IsNumber(parm.Smin) && Smin.CompileFormula() == null)
  446. {
  447. MessageUtil.ShowWarning("公差约束项<三>:下限值(请输入合法公式)!");
  448. row.SetCellActive("Smin");
  449. return;
  450. }
  451. }
  452. else
  453. {
  454. if (!parm.SminSign.Equals(""))
  455. {
  456. MessageUtil.ShowWarning("请输入公差约束项<三>:下限值!");
  457. row.SetCellActive("Smin");
  458. return;
  459. }
  460. }
  461. if (!parm.Smax.Equals("") && !parm.Smin.Equals("")) //&& Convert.ToDouble(com.Smin) > Convert.ToDouble(com.Smax)
  462. {
  463. int retrunValue = QcmBaseInfo.CheckStdData(parm.SminSign, parm.SmaxSign, parm.Smin, parm.Smax);
  464. if (retrunValue == 0)
  465. {
  466. MessageUtil.ShowWarning("输入的数据不完整!");
  467. return;
  468. }
  469. if (retrunValue == 1)
  470. {
  471. MessageUtil.ShowWarning("公差约束项<三>下限值与上限值相等,上下限符号请选择<=和>=!");
  472. row.SetCellActive("SminSign");
  473. return;
  474. }
  475. if (retrunValue == 2)
  476. {
  477. MessageUtil.ShowWarning("公差约束项<三>下限值不能大于上限值!");
  478. row.SetCellActive("Smin");
  479. return;
  480. }
  481. }
  482. }
  483. else
  484. {
  485. if (!parm.SminSign.Equals("") || !parm.Smin.Equals("") || !parm.SmaxSign.Equals("") || !parm.Smax.Equals(""))
  486. {
  487. MessageUtil.ShowWarning("请选择公差约束项<三>:公差约束项!");
  488. row.SetCellActive("BiasCodeS");
  489. return;
  490. }
  491. }
  492. if (!parm.BiasCodeS.Equals(""))
  493. {
  494. if (parm.BiasCodeC.Equals(""))
  495. {
  496. MessageUtil.ShowWarning("请依次填写公差约束项!");
  497. row.SetCellActive("BiasCodeC");
  498. return;
  499. }
  500. else
  501. {
  502. if (parm.BiasCodeZ.Equals(""))
  503. {
  504. MessageUtil.ShowWarning("请依次填写公差约束项!");
  505. row.SetCellActive("BiasCodeZ");
  506. return;
  507. }
  508. }
  509. }
  510. else
  511. {
  512. if (!parm.BiasCodeC.Equals(""))
  513. {
  514. if (parm.BiasCodeZ.Equals(""))
  515. {
  516. MessageUtil.ShowWarning("请依次填写公差约束项!");
  517. row.SetCellActive("BiasCodeZ");
  518. return;
  519. }
  520. }
  521. }
  522. int i = 0;
  523. if (!parm.StdMinVal.Equals(""))
  524. {
  525. i += 1;
  526. if (!StringUtil.IsNumber(parm.StdMinVal) || parm.StdMinVal.Length > 10)
  527. {
  528. MessageUtil.ShowWarning("下偏差值(mm)请输入10位以内数字!");
  529. row.SetCellActive("StdMinVal");
  530. return;
  531. }
  532. //if (decimal.Parse(com.StdMinVal) < 0)
  533. //{
  534. // errMessage = "下偏差值(mm)不能输入负值";
  535. // return null;
  536. //}
  537. }
  538. if (!parm.StdMaxVal.Equals(""))
  539. {
  540. if (!StringUtil.IsNumber(parm.StdMaxVal) || parm.StdMaxVal.Length > 10)
  541. {
  542. MessageUtil.ShowWarning("上偏差值(mm)请输入10位以内数字!");
  543. row.SetCellActive("StdMaxVal");
  544. return;
  545. }
  546. }
  547. if (!parm.StdMinIn.Equals(""))
  548. {
  549. if (!StringUtil.IsNumber(parm.StdMinIn) || parm.StdMinIn.Length > 10)
  550. {
  551. MessageUtil.ShowWarning("标准负值(in)请输入10位以内数字!");
  552. row.SetCellActive("StdMinIn");
  553. return;
  554. }
  555. }
  556. if (!parm.StdMaxIn.Equals(""))
  557. {
  558. if (!StringUtil.IsNumber(parm.StdMaxIn) || parm.StdMaxIn.Length > 10)
  559. {
  560. MessageUtil.ShowWarning("标准正值(in)请输入10位以内数字!");
  561. row.SetCellActive("StdMaxIn");
  562. return;
  563. }
  564. }
  565. if (!parm.StdMinPercent.Equals(""))
  566. {
  567. i += 1;
  568. if (!StringUtil.IsNumber(parm.StdMinPercent) || parm.StdMinPercent.Length > 10)
  569. {
  570. MessageUtil.ShowWarning("下偏差值(%)请输入10位以内数字!");
  571. row.SetCellActive("StdMinPercent");
  572. return;
  573. }
  574. //if (decimal.Parse(com.StdMinPercent) < 0)
  575. //{
  576. // errMessage = "下偏差值(%)不能输入负值";
  577. // return null;
  578. //}
  579. }
  580. if (!parm.StdMaxPercent.Equals(""))
  581. {
  582. if (!StringUtil.IsNumber(parm.StdMaxPercent) || parm.StdMaxPercent.Length > 10)
  583. {
  584. MessageUtil.ShowWarning("上偏差值(%)请输入10位以内数字!");
  585. row.SetCellActive("StdMaxPercent");
  586. return;
  587. }
  588. }
  589. if (!parm.StdMinFormula.Equals(""))
  590. {
  591. i += 1;
  592. if (parm.StdMinFormula.Length > 100)
  593. {
  594. MessageUtil.ShowWarning("请输入标准公式下偏差值(mm)!");
  595. row.SetCellActive("StdMinFormula");
  596. return;
  597. }
  598. //if (com.StdMinFormula.StartsWith("-"))
  599. //{
  600. // errMessage = "标准公式下偏差值(mm)不能有负号";
  601. // return null;
  602. //}
  603. }
  604. if (!parm.StdMaxFormula.Equals(""))
  605. {
  606. if (parm.StdMaxFormula.Length > 100)
  607. {
  608. MessageUtil.ShowWarning("请输入标准公式上偏差值(mm)!");
  609. row.SetCellActive("StdMaxFormula");
  610. return;
  611. }
  612. }
  613. if (parm.StdMinVal.Equals("") && parm.StdMinFormula.Equals("") && parm.StdMinPercent.Equals(""))
  614. {
  615. MessageUtil.ShowWarning("请输入一组标准值!");
  616. row.SetCellActive("StdMinVal");
  617. return;
  618. }
  619. if (parm.StdMinVal.Equals(""))
  620. {
  621. if (!parm.StdMaxVal.Equals(""))
  622. {
  623. MessageUtil.ShowWarning("下偏差值(mm)请输入10位以内数字!");
  624. row.SetCellActive("StdMinVal");
  625. return;
  626. }
  627. }
  628. else
  629. {
  630. if (parm.StdMaxVal.Equals(""))
  631. {
  632. MessageUtil.ShowWarning("上偏差值(mm)请输入10位以内数字!");
  633. row.SetCellActive("StdMaxVal");
  634. return;
  635. }
  636. }
  637. if (parm.StdMinPercent.Equals(""))
  638. {
  639. if (!parm.StdMaxPercent.Equals(""))
  640. {
  641. MessageUtil.ShowWarning("下偏差值(%)请输入10位以内数字!");
  642. row.SetCellActive("StdMinPercent");
  643. return;
  644. }
  645. }
  646. else
  647. {
  648. if (parm.StdMaxPercent.Equals(""))
  649. {
  650. MessageUtil.ShowWarning("上偏差值(%)请输入10位以内数字!");
  651. row.SetCellActive("StdMaxPercent");
  652. return;
  653. }
  654. }
  655. if (parm.StdMinFormula.Equals(""))
  656. {
  657. if (!parm.StdMaxFormula.Equals(""))
  658. {
  659. MessageUtil.ShowWarning("请输入标准公式下偏差值(mm)!");
  660. row.SetCellActive("StdMinFormula");
  661. return;
  662. }
  663. }
  664. else
  665. {
  666. if (parm.StdMaxFormula.Equals(""))
  667. {
  668. MessageUtil.ShowWarning("请输入标准公式上偏差值(mm)!");
  669. row.SetCellActive("StdMaxFormula");
  670. return;
  671. }
  672. }
  673. if (!parm.StdMinFormula.Equals("") && !StringUtil.IsNumber(parm.StdMinFormula))
  674. {
  675. if (!QcmBaseCommon.CheckToleranceFormula(parm.StdMinFormula))
  676. {
  677. MessageUtil.ShowWarning("您输入的标准值-公式下偏差值(mm):[" + parm.StdMinFormula + "]不合法,请重新输入!");
  678. row.SetCellActive("StdMinFormula");
  679. return;
  680. }
  681. }
  682. if (!parm.StdMaxFormula.Equals("") && !StringUtil.IsNumber(parm.StdMaxFormula))
  683. {
  684. if (!QcmBaseCommon.CheckToleranceFormula(parm.StdMaxFormula))
  685. {
  686. MessageUtil.ShowWarning("您输入的标准值-公式上偏差值(mm):[" + parm.StdMaxFormula + "]不合法,请重新输入!");
  687. row.SetCellActive("StdMaxFormula");
  688. return;
  689. }
  690. }
  691. if (parm.StdMaxFormulaV.Equals("1") && parm.StdMinFormulaV.Equals("1"))
  692. {
  693. MessageUtil.ShowWarning("不能同时选择标准取小值和取大值!");
  694. row.SetCellActive("StdMaxFormula");
  695. return;
  696. }
  697. if (i > 1 && parm.StdMinFormulaV.Equals("0") && parm.StdMaxFormulaV.Equals("0"))
  698. {
  699. MessageUtil.ShowWarning("请选择标准取小值或者取大值!");
  700. row.SetCellActive("StdMinFormulaV");
  701. return;
  702. }
  703. if (!parm.BiasCodeC.Equals(""))
  704. {
  705. if (parm.BiasCodeC.Equals(parm.BiasCodeS) || parm.BiasCodeC.Equals(parm.BiasCodeZ))
  706. {
  707. MessageUtil.ShowWarning("公差约束项不能相同,请重新选择!");
  708. row.SetCellActive("BiasCodeC");
  709. return;
  710. }
  711. }
  712. if (!parm.BiasCodeS.Equals(""))
  713. {
  714. if (parm.BiasCodeS.Equals(parm.BiasCodeC) || parm.BiasCodeS.Equals(parm.BiasCodeZ))
  715. {
  716. MessageUtil.ShowWarning("公差约束项不能相同,请重新选择!");
  717. row.SetCellActive("BiasCodeS");
  718. return;
  719. }
  720. }
  721. if (!parm.BiasCodeZ.Equals(""))
  722. {
  723. if (parm.BiasCodeZ.Equals(parm.BiasCodeC) || parm.BiasCodeZ.Equals(parm.BiasCodeS))
  724. {
  725. MessageUtil.ShowWarning("公差约束项不能相同,请重新选择!");
  726. row.SetCellActive("BiasCodeZ");
  727. return;
  728. }
  729. }
  730. parm.CreateName = CoreUserInfo.UserInfo.GetUserName();
  731. parm.UpdateName = CoreUserInfo.UserInfo.GetUserName();
  732. parm.DeleteName = CoreUserInfo.UserInfo.GetUserName();
  733. parm.SpeclFl = "2";
  734. parm.DesginKey = designKey;
  735. parms.Add(parm);
  736. }
  737. if (MessageUtil.ShowYesNoAndQuestion("是否确认保存?") == DialogResult.No)
  738. {
  739. return;
  740. }
  741. _designStdSicBLL.Save(parms);
  742. MessageUtil.ShowTips("保存成功!");
  743. QueryByDesignKeySic(_parms);
  744. }
  745. public void Delete()
  746. {
  747. List<CraftOrdDesignStdSicEntity> parms = new List<CraftOrdDesignStdSicEntity>();
  748. var rows = entityGrid1.Rows.Where(a => a.GetValue("Chk") == "True");
  749. foreach (var row in rows)
  750. {
  751. var parm = EntityHelper.CopyEntity<CraftOrdDesignStdSicEntity>(row.ListObject);
  752. parm.CreateName = CoreUserInfo.UserInfo.GetUserName();
  753. parm.UpdateName = CoreUserInfo.UserInfo.GetUserName();
  754. parm.DeleteName = CoreUserInfo.UserInfo.GetUserName();
  755. parm.SpeclFl = "2";
  756. parm.DesginKey = designKey;
  757. parms.Add(parm);
  758. }
  759. if (MessageUtil.ShowYesNoAndQuestion("是否确认删除?") == DialogResult.No)
  760. {
  761. return;
  762. }
  763. _designStdSicBLL.Delete(parms);
  764. MessageUtil.ShowTips("删除成功!");
  765. }
  766. private void GridEdite(UltraGridRow row)
  767. {
  768. if (row.GetValue("Chk") == "True")
  769. {
  770. foreach (UltraGridCell cell in row.Cells)
  771. {
  772. if (cell.Column.CellActivation == Activation.AllowEdit)
  773. {
  774. cell.Activation = Activation.AllowEdit;
  775. }
  776. }
  777. }
  778. else
  779. {
  780. foreach (UltraGridCell cell in row.Cells)
  781. {
  782. if (cell.Column.Key == "Chk") continue;
  783. if (cell.Column.CellActivation == Activation.AllowEdit)
  784. {
  785. cell.Activation = Activation.ActivateOnly;
  786. }
  787. }
  788. }
  789. }
  790. private void entityGrid1_AfterRowInsert(object sender, RowEventArgs e)
  791. {
  792. e.Row.Cells["IsCheck"].Value = true;
  793. e.Row.Cells["StdMinFormulaV"].Value = true;
  794. e.Row.Cells["StdMaxFormulaV"].Value = false;
  795. e.Row.Cells["CraftSource"].Value = "1";
  796. e.Row.Cells["SpeclFl"].Value = "2";
  797. }
  798. private void ultraTextEditor1_EditorButtonClick(object sender, EditorButtonEventArgs e)
  799. {
  800. UltraGridRow row = entityGrid1.ActiveRow;
  801. string key = entityGrid1.ActiveCell.Column.Key;
  802. if (key == "MscPline")
  803. {
  804. DataTable dt = _designMscPlBLL.QueryMscPlineProcess(designKey);
  805. dt.Columns["MSC_PLINE"].Caption = "制程号";
  806. dt.Columns["WHOLE_BACKLOG"].Caption = "全程途径码";
  807. dt.Columns["WHOLE_BACKLOG_DESC"].Caption = "全程途径描述";
  808. dt.Columns["PROCESS_DESC"].Caption = "工序";
  809. dt.Columns["PROCESS_DESC_C"].Caption = "二级工序";
  810. dt.Columns["SIC"].Caption = "公差内控索引码";
  811. DataTable dtNew = dt.Clone();
  812. foreach (DataRow dr in dt.Rows)
  813. {
  814. string[] sics = dr["SIC"].ToString().Split(',');
  815. foreach (string sic in sics)
  816. {
  817. DataRow drNew = dtNew.NewRow();
  818. drNew["MSC_PLINE"] = dr["MSC_PLINE"];
  819. drNew["WHOLE_BACKLOG"] = dr["WHOLE_BACKLOG"];
  820. drNew["WHOLE_BACKLOG_DESC"] = dr["WHOLE_BACKLOG_DESC"];
  821. drNew["PROCESS_DESC"] = dr["PROCESS_DESC"];
  822. drNew["PROCESS_DESC_C"] = dr["PROCESS_DESC_C"];
  823. drNew["PROCESS_CODE"] = dr["PROCESS_CODE"];
  824. drNew["PROCESS_CODE_C"] = dr["PROCESS_CODE_C"];
  825. drNew["SIC"] = sic.Trim();
  826. dtNew.Rows.Add(drNew);
  827. }
  828. }
  829. BaseInfoPopup popup = new BaseInfoPopup(dtNew, "MSC_PLINE", "PIC", "DIC", "CIC", "WIC", "GIC", "PROCESS_CODE", "PROCESS_CODE_C");
  830. GridHelper.RefreshAndAutoSize(popup.UltraGrid1);
  831. popup.LabelTextBox1.Caption = "制程号";
  832. if (popup.ShowDialog() == DialogResult.OK)
  833. {
  834. row.SetValue("MscPline", popup.ChoicedRow.GetValue("MSC_PLINE"));
  835. row.SetValue("ProcessDescC", popup.ChoicedRow.GetValue("PROCESS_DESC_C"));
  836. row.SetValue("ProcessCodeC", popup.ChoicedRow.GetValue("PROCESS_CODE_C"));
  837. row.SetValue("ProcessDesc", popup.ChoicedRow.GetValue("PROCESS_DESC"));
  838. row.SetValue("ProcessCode", popup.ChoicedRow.GetValue("PROCESS_CODE"));
  839. row.SetValue("Sic", popup.ChoicedRow.GetValue("SIC"));
  840. }
  841. }
  842. else if (key == "ProcessDescC")
  843. {
  844. string mscPline = entityGrid1.ActiveRow.GetValue("MscPline");
  845. DataTable dt = _designMscPlPrcBLL.queryProcess(designKey, mscPline);
  846. dt.Columns["PROCESS_DESC"].Caption = "工序";
  847. dt.Columns["PROCESS_DESC_C"].Caption = "二级工序";
  848. BaseInfoPopup popup = new BaseInfoPopup(dt, "PROCESS_DESC_C", "PROCESS_CODE", "PROCESS_CODE_C");
  849. popup.LabelTextBox1.Caption = "二级工序";
  850. if (popup.ShowDialog() == DialogResult.OK)
  851. {
  852. row.SetValue("ProcessDescC", popup.ChoicedRow.GetValue("PROCESS_DESC_C"));
  853. row.SetValue("ProcessCodeC", popup.ChoicedRow.GetValue("PROCESS_CODE_C"));
  854. row.SetValue("ProcessDesc", popup.ChoicedRow.GetValue("PROCESS_DESC"));
  855. row.SetValue("ProcessCode", popup.ChoicedRow.GetValue("PROCESS_CODE"));
  856. }
  857. }
  858. else if (key == "Sic")
  859. {
  860. string mscPline = entityGrid1.ActiveRow.GetValue("MscPline");
  861. string processCode = entityGrid1.ActiveRow.GetValue("ProcessCode");
  862. DataTable dt = _designMscPlPrcBLL.queryProcessNkIndex(designKey, mscPline, processCode);
  863. dt.Columns["SIC"].Caption = "公差内控索引码";
  864. BaseInfoPopup popup = new BaseInfoPopup(dt, "SIC", "PIC", "CIC", "DIC", "WIC", "GIC");
  865. popup.LabelTextBox1.Caption = "公差内控索引码";
  866. if (popup.ShowDialog() == DialogResult.OK)
  867. {
  868. row.SetValue("Sic", popup.ChoicedRow.GetValue("SIC"));
  869. }
  870. }
  871. }
  872. }
  873. }