CraftOrdFdPicCtrl.cs 64 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416
  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 Core.StlMes.Client.Qcm;
  13. using Infragistics.Win.UltraWinGrid;
  14. using Infragistics.Win.UltraWinEditors;
  15. using Core.Mes.Client.Comm.Server;
  16. using CoreFS.SA06;
  17. using Infragistics.Win;
  18. using Core.Mes.Client.Comm.Control;
  19. using Core.Mes.Client.Comm.Format;
  20. using Core.StlMes.Client.SaleOrder.Dialog;
  21. using System.Reflection;
  22. namespace Core.StlMes.Client.SaleOrder.Control
  23. {
  24. public partial class CraftOrdFdPicCtrl : UserControl
  25. {
  26. private OpeBase _ob;
  27. private UltraComboEditor Pics = new UltraComboEditor();
  28. public CraftOrdFdPicCtrl(System.Windows.Forms.Control container, string designKey, string ordLnPk, OpeBase ob)
  29. {
  30. InitializeComponent();
  31. _ob = ob;
  32. this.designKey = designKey;
  33. this.ordLnPk = ordLnPk;
  34. container.Controls.Add(this);
  35. this.Dock = DockStyle.Fill;
  36. LoadBaseData();
  37. }
  38. private void LoadBaseData()
  39. {
  40. QcmBaseCommon.InitSignMin(ultraComSignMin);
  41. QcmBaseCommon.InitSignMax(ultraComSignMax);
  42. //初始化理化检验项大类
  43. ultraComPhyMax.DropDownListWidth = -1;
  44. QcmBaseQuery.NitializeDropDownBox(ultraComPhyMax, "com.steering.pss.qcm.ComBaseQuery.geComBasePhyRStd", "PHY_TYPE", "PHY_CODE", false, _ob);
  45. //初始化结箍名称
  46. QcmBaseQuery.NitializeJG(ultraComJG, true, _ob);
  47. //初始化限制规格
  48. QcmBaseCommon.InitDropUltraComEditor(ultraComSize, "com.steering.pss.qcm.ComBaseQuery.geComBaseInfo4003", "BASENAME", _ob, true);
  49. //交货标准
  50. QcmBaseCommon.InitDropUltraComEditor(ultraComboDelivery, "com.steering.pss.qcm.ComBaseQuery.geComBaseInfo4060", "BASENAME", _ob, true);
  51. //内控标准
  52. UltraGridBand ugc = entityGrid1.DisplayLayout.Bands[0];
  53. //附加标准
  54. UltraComboEditor uceAddStdCon = new UltraComboEditor();
  55. this.Controls.Add(uceAddStdCon);
  56. uceAddStdCon.Visible = false;
  57. QcmBaseCommon.InitDropUltraComEditor(uceAddStdCon, "com.steering.pss.qcm.ComMaterial.getAddCondition", "BASENAME", _ob, false);
  58. entityGrid1.DisplayLayout.Bands[0].Columns["AddstdconCode"].EditorComponent = uceAddStdCon;
  59. entityGrid1.DisplayLayout.Bands[0].Columns["AddstdconCode"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList;
  60. ClsBaseInfo.SetComboItemHeight(uceAddStdCon);
  61. this.Controls.Add(Pics);
  62. Pics.Visible = false;
  63. //多标准选择分类
  64. UltraComboEditor uceMultStd = new UltraComboEditor();
  65. this.Controls.Add(uceMultStd);
  66. uceMultStd.Visible = false;
  67. QcmBaseCommon.InitDropUltraComEditor(uceMultStd, "com.steering.pss.qcm.ComMaterial.getMultStd", "BASENAME", _ob, true);
  68. entityGrid1.DisplayLayout.Bands[0].Columns["StdChoose"].EditorComponent = uceMultStd;
  69. entityGrid1.DisplayLayout.Bands[0].Columns["StdChoose"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList;
  70. ClsBaseInfo.SetComboItemHeight(uceMultStd);
  71. }
  72. private string designKey = "";
  73. private string ordLnPk = "";
  74. /// <summary>
  75. /// 查询质量设计理化
  76. /// </summary>
  77. /// <param name="designStdPicEntity"></param>
  78. public void Query()
  79. {
  80. CraftOrdDesignStdPicEntityBindingSource.Clear();
  81. DataTable dt = ServerHelper.GetData("com.steering.pss.sale.order.CraftOrdFdPic.queryM", new object[] { ordLnPk }, _ob);
  82. GridHelper.CopyDataToDatatable(dt, dataTable1, true);
  83. foreach (var row in ultraGrid1.Rows)
  84. {
  85. row.Cells["SAMPLE"].Value = "维护";
  86. row.Cells["SAMPLE"].ButtonAppearance.TextHAlign = HAlign.Center;
  87. }
  88. }
  89. private string[] _parms;
  90. public void Clear()
  91. {
  92. this.CraftOrdDesignStdPicEntityBindingSource.Clear();
  93. }
  94. public void Save()
  95. {
  96. List<CrafOrdFdPicEntity> parms = new List<CrafOrdFdPicEntity>();
  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. string mscPline = ultraGrid1.ActiveRow.GetValue("MSC_PLINE");
  105. string processCode = ultraGrid1.ActiveRow.GetValue("PROCESS_CODE");
  106. string pic = ultraGrid1.ActiveRow.GetValue("PIC");
  107. foreach (var row in rows)
  108. {
  109. var parm = EntityHelper.CopyEntity<CrafOrdFdPicEntity>(row.ListObject);
  110. if (parm.PhyNameMax == "")
  111. {
  112. MessageUtil.ShowWarning("请选择检验项!");
  113. row.SetCellActive("PhyNameMax");
  114. return;
  115. }
  116. if (parm.PhyNameMin == "")
  117. {
  118. MessageUtil.ShowWarning("请选择试样组!");
  119. row.SetCellActive("PhyNameMin");
  120. return;
  121. }
  122. if (parm.PhyName == "")
  123. {
  124. MessageUtil.ShowWarning("请选择检验项目!");
  125. row.SetCellActive("PhyName");
  126. return;
  127. }
  128. if (parm.StdminSign == "=" && (parm.StdmaxSign != "" || parm.Stdmax != ""))
  129. {
  130. MessageUtil.ShowWarning("标准范围下限符号为'=',不能存在上限!");
  131. row.SetCellActive("Stdmax");
  132. return;
  133. }
  134. if (parm.Isjudge == true)
  135. {
  136. if (parm.StdminSign.Equals("") && parm.StdmaxSign.Equals(""))
  137. {
  138. MessageUtil.ShowWarning("请选择标准范围(默认)下限符号或者上限符号!");
  139. row.SetCellActive("StdminSign");
  140. return;
  141. }
  142. }
  143. if (!parm.StdminSign.Equals("") && parm.Stdmin.Equals(""))
  144. {
  145. MessageUtil.ShowWarning("请输入标准范围(默认)下限值!");
  146. row.SetCellActive("Stdmin");
  147. return;
  148. }
  149. if (parm.StdminSign.Equals("") && !parm.Stdmin.Equals(""))
  150. {
  151. MessageUtil.ShowWarning("请选择标准范围(默认)下限符号!");
  152. row.SetCellActive("StdminSign");
  153. return;
  154. }
  155. if (!parm.StdmaxSign.Equals("") && parm.Stdmax.Equals(""))
  156. {
  157. MessageUtil.ShowWarning("请输入标准范围(默认)上限值!");
  158. row.SetCellActive("Stdmax");
  159. return;
  160. }
  161. if (parm.StdmaxSign.Equals("") && !parm.Stdmax.Equals(""))
  162. {
  163. MessageUtil.ShowWarning("已有标准范围(默认)上限值,请选择标准范围(默认)上限符号!");
  164. row.SetCellActive("StdmaxSign");
  165. return;
  166. }
  167. if (parm.PhyType == false)
  168. {
  169. if (!parm.Stdmin.Equals("") && !StringUtil.IsNumber(parm.Stdmin) && !parm.StdminSign.Equals("="))
  170. {
  171. MessageUtil.ShowWarning("标准范围(默认)下限值由数字组成!");
  172. row.SetCellActive("Stdmin");
  173. return;
  174. }
  175. if (!parm.Stdmax.Equals("") && !StringUtil.IsNumber(parm.Stdmax))
  176. {
  177. MessageUtil.ShowWarning("标准范围(默认)上限值由数字组成!");
  178. row.SetCellActive("Stdmax");
  179. return;
  180. }
  181. }
  182. else
  183. {
  184. if (!parm.Stdmin.Equals("") && !parm.StdminSign.Equals("=") && !QcmBaseCommon.CheckCompositeFormula(parm.Stdmin))
  185. {
  186. MessageUtil.ShowWarning("标准范围(默认)下限值,输入公式不合法,请重新输入!");
  187. row.SetCellActive("Stdmin");
  188. return;
  189. }
  190. if (!parm.Stdmax.Equals("") && !QcmBaseCommon.CheckCompositeFormula(parm.Stdmax))
  191. {
  192. MessageUtil.ShowWarning("标准范围(默认)上限值,输入公式不合法,请重新输入!");
  193. row.SetCellActive("Stdmax");
  194. return;
  195. }
  196. }
  197. if (!parm.Stdmin.Equals(""))
  198. {
  199. if (parm.Stdmin.StartsWith("."))
  200. parm.Stdmin = "0" + parm.Stdmin;
  201. }
  202. if (!parm.Stdmax.Equals(""))
  203. {
  204. if (parm.Stdmax.StartsWith("."))
  205. parm.Stdmax = "0" + parm.Stdmax;
  206. }
  207. if (!parm.Stdmin.Equals("") && !parm.Stdmax.Equals("")) //&& Convert.ToDouble(stdmin) > Convert.ToDouble(stdmax)
  208. {
  209. int i = QcmBaseInfo.CheckStdData(parm.StdminSign, parm.StdmaxSign, parm.Stdmin, parm.Stdmax);
  210. if (i == 0)
  211. {
  212. MessageUtil.ShowWarning("输入的数据不完整!");
  213. return;
  214. }
  215. if (i == 1)
  216. {
  217. MessageUtil.ShowWarning("标准范围(默认)下限值与上限值相等,上下限符号请选择<=和>=!");
  218. row.SetCellActive("StdminSign");
  219. return;
  220. }
  221. if (i == 2)
  222. {
  223. MessageUtil.ShowWarning("标准范围(默认)下限值不能大于上限值!");
  224. row.SetCellActive("Stdmin");
  225. return;
  226. }
  227. }
  228. if (parm.JudgeBasis.Equals(""))
  229. {
  230. MessageUtil.ShowWarning("判断依据不能为空!");
  231. row.SetCellActive("JudgeBasis");
  232. return;
  233. }
  234. if (parm.StdminSign2 == "=" && (parm.StdmaxSign2 != "" || parm.Stdmax2 != ""))
  235. {
  236. MessageUtil.ShowWarning("标准范围(二)下限符号为'=',不能存在上限!");
  237. row.SetCellActive("Stdmax2");
  238. return;
  239. }
  240. if (parm.StdChoose != "") //取大/小值
  241. {
  242. if (parm.StdminSign2.Equals("") && parm.StdmaxSign2.Equals(""))
  243. {
  244. MessageUtil.ShowWarning("请选择标准范围(二)下限符号或者上限符号!");
  245. row.SetCellActive("StdminSign2");
  246. return;
  247. }
  248. if (!parm.StdminSign2.Equals("") && parm.Stdmin2.Equals(""))
  249. {
  250. MessageUtil.ShowWarning("请输入标准范围(二)下限值!");
  251. row.SetCellActive("Stdmin2");
  252. return;
  253. }
  254. if (parm.StdminSign2.Equals("") && !parm.Stdmin2.Equals(""))
  255. {
  256. MessageUtil.ShowWarning("标准范围(默认)不存在下限符号,则标准范围(二)下限不能存在值!");
  257. row.SetCellActive("Stdmin2");
  258. return;
  259. }
  260. if (!parm.StdmaxSign2.Equals("") && parm.Stdmax2.Equals(""))
  261. {
  262. MessageUtil.ShowWarning("请输入标准范围(二)上限值!");
  263. row.SetCellActive("Stdmax2");
  264. return;
  265. }
  266. if (parm.StdmaxSign2.Equals("") && !parm.Stdmax2.Equals(""))
  267. {
  268. MessageUtil.ShowWarning("标准范围(默认)不存在上限符号,则标准范围(二)上限不能存在值!");
  269. row.SetCellActive("Stdmax2");
  270. return;
  271. }
  272. if (parm.PhyType == false)
  273. {
  274. if (!parm.Stdmin2.Equals("") && !StringUtil.IsNumber(parm.Stdmin2) && !parm.StdminSign2.Equals("="))
  275. {
  276. MessageUtil.ShowWarning("标准范围(二)下限值由数字组成!");
  277. row.SetCellActive("Stdmin2");
  278. return;
  279. }
  280. if (!parm.Stdmax2.Equals("") && !StringUtil.IsNumber(parm.Stdmax2))
  281. {
  282. MessageUtil.ShowWarning("标准范围(二)上限值由数字组成!");
  283. row.SetCellActive("Stdmax2");
  284. return;
  285. }
  286. }
  287. else
  288. {
  289. if (!parm.Stdmin2.Equals("") && !parm.StdminSign2.Equals("=") && !StringUtil.IsNumber(parm.Stdmin2)
  290. && !QcmBaseCommon.CheckCompositeFormula(parm.Stdmin2))
  291. {
  292. MessageUtil.ShowWarning("标准范围(二)下限值输入公式不合法,请重新输入!");
  293. row.SetCellActive("Stdmin2");
  294. return;
  295. }
  296. if (!parm.Stdmax2.Equals("") && !StringUtil.IsNumber(parm.Stdmax2) && !QcmBaseCommon.CheckCompositeFormula(parm.Stdmax2))
  297. {
  298. MessageUtil.ShowWarning("标准范围(二)上限值输入公式不合法,请重新输入!");
  299. row.SetCellActive("Stdmax2");
  300. return;
  301. }
  302. }
  303. if (!parm.Stdmin2.Equals(""))
  304. {
  305. if (parm.Stdmin2.StartsWith("."))
  306. parm.Stdmin2 = "0" + parm.Stdmin2;
  307. }
  308. if (!parm.Stdmax2.Equals(""))
  309. {
  310. if (parm.Stdmax2.StartsWith("."))
  311. parm.Stdmax2 = "0" + parm.Stdmax2;
  312. }
  313. if (!parm.Stdmin2.Equals("") && !parm.Stdmax2.Equals("")) //&& Convert.ToDouble(stdmin2) > Convert.ToDouble(stdmax2)
  314. {
  315. int i = QcmBaseInfo.CheckStdData(parm.StdminSign2, parm.StdmaxSign2, parm.Stdmin2, parm.Stdmax2);
  316. if (i == 0)
  317. {
  318. MessageUtil.ShowWarning("输入的数据不完整!");
  319. return;
  320. }
  321. if (i == 1)
  322. {
  323. MessageUtil.ShowWarning("标准范围(二)下限值与上限值相等,上下限符号请选择<=和>=!");
  324. row.SetCellActive("StdminSign2");
  325. return;
  326. }
  327. if (i == 2)
  328. {
  329. MessageUtil.ShowWarning("标准范围(二)下限值不能大于上限值!");
  330. row.SetCellActive("Stdmin2");
  331. return;
  332. }
  333. }
  334. }
  335. if (parm.SizeMinSign2 == "=" && (parm.SizeMaxSign2 != "" || parm.SizeMax2 != ""))
  336. {
  337. MessageUtil.ShowWarning("限制规格(一)下限符号为'=',不能存在上限!");
  338. row.SetCellActive("SizeMax2");
  339. return;
  340. }
  341. if (parm.SizeMinSign == "=" && (parm.SizeMaxSign != "" || parm.SizeMax != ""))
  342. {
  343. MessageUtil.ShowWarning("限制规格(二)下限符号为'=',不能存在上限!");
  344. row.SetCellActive("SizeMax");
  345. return;
  346. }
  347. if (!parm.SpecJg.Equals("") && !parm.SpecJgDesc.Equals("-1"))
  348. {
  349. if (!parm.SizeName2.Equals("") || !parm.SizeName.Equals(""))
  350. {
  351. MessageUtil.ShowWarning("接箍描述与限制规格不能同时存在!");
  352. row.SetCellActive("SpecJg");
  353. return;
  354. }
  355. }
  356. if (!parm.SizeName2.Equals(""))
  357. {
  358. if (parm.SizeMinSign2.Equals("") && parm.SizeMaxSign2.Equals(""))
  359. {
  360. MessageUtil.ShowWarning("请选择限制规格(一)下限符号或者上限符号!");
  361. row.SetCellActive("SizeMinSign2");
  362. return;
  363. }
  364. if (!parm.SizeMinSign2.Equals("") && parm.SizeMin2.Equals(""))
  365. {
  366. MessageUtil.ShowWarning("存在限制规格(一)下限符号,下限值不能为空!");
  367. row.SetCellActive("SizeMin2");
  368. return;
  369. }
  370. if (parm.SizeMinSign2.Equals("") && !parm.SizeMin2.Equals(""))
  371. {
  372. MessageUtil.ShowWarning("存在限制规格(一)下限值,下限符号不能为空!");
  373. row.SetCellActive("SizeMinSign2");
  374. return;
  375. }
  376. if (!parm.SizeMaxSign2.Equals("") && parm.SizeMax2.Equals(""))
  377. {
  378. MessageUtil.ShowWarning("存在限制规格(一)上限符号,上限值不能为空!");
  379. row.SetCellActive("SizeMax2");
  380. return;
  381. }
  382. if (parm.SizeMaxSign2.Equals("") && !parm.SizeMax2.Equals(""))
  383. {
  384. MessageUtil.ShowWarning("存在限制规格(一)上限值,上限符号不能为空!");
  385. row.SetCellActive("SizeMaxSign2");
  386. return;
  387. }
  388. if (!parm.SizeMin2.Equals("") && !StringUtil.IsNumber(parm.SizeMin2) && !parm.SizeMinSign2.Equals("="))
  389. {
  390. MessageUtil.ShowWarning("限制规格(一)下限值由数字组成!");
  391. row.SetCellActive("SizeMin2");
  392. return;
  393. }
  394. if (!parm.SizeMax2.Equals("") && !StringUtil.IsNumber(parm.SizeMax2))
  395. {
  396. MessageUtil.ShowWarning("限制规格(一)上限值由数字组成!");
  397. row.SetCellActive("SizeMax2");
  398. return;
  399. }
  400. if (!parm.SizeMin2.Equals("") && !parm.SizeMax2.Equals("")) //&& Convert.ToDouble(size_max2) < Convert.ToDouble(size_min2)
  401. {
  402. int i = QcmBaseInfo.CheckStdData(parm.SizeMinSign2, parm.SizeMaxSign2, parm.SizeMin2, parm.SizeMax2);
  403. if (i == 0)
  404. {
  405. MessageUtil.ShowWarning("输入的数据不完整!");
  406. return;
  407. }
  408. if (i == 1)
  409. {
  410. MessageUtil.ShowWarning("限制规格(一)下限值与上限值相等,上下限符号请选择<=和>=!");
  411. row.SetCellActive("SizeMinSign2");
  412. return;
  413. }
  414. if (i == 2)
  415. {
  416. MessageUtil.ShowWarning("限制规格(一)下限值不能大于上限值!");
  417. row.SetCellActive("SizeMin2");
  418. return;
  419. }
  420. }
  421. }
  422. else
  423. {
  424. if (parm.SizeMaxSign2 != "" || parm.SizeMinSign2 != "" || parm.SizeMin2 != "" || parm.SizeMax2 != "")
  425. {
  426. MessageUtil.ShowWarning("限制规格(一)描述不存在!");
  427. row.SetCellActive("SizeCode2");
  428. return;
  429. }
  430. }
  431. if (!parm.SizeMin2.Equals(""))
  432. {
  433. if (parm.SizeMin2.StartsWith("."))
  434. parm.SizeMin2 = "0" + parm.SizeMin2;
  435. }
  436. if (!parm.SizeMax2.Equals(""))
  437. {
  438. if (parm.SizeMax2.StartsWith("."))
  439. parm.SizeMax2 = "0" + parm.SizeMax2;
  440. }
  441. if (!parm.SizeName.Equals(""))
  442. {
  443. if (parm.SizeMinSign.Equals("") && parm.SizeMaxSign.Equals(""))
  444. {
  445. MessageUtil.ShowWarning("限制规格(二)下限符号与上限符号必须存在一项!");
  446. row.SetCellActive("SizeMinSign");
  447. return;
  448. }
  449. if (!parm.SizeMinSign.Equals("") && parm.SizeMin.Equals(""))
  450. {
  451. MessageUtil.ShowWarning("存在限制规格(二)下限符号,下限值不能为空!");
  452. row.SetCellActive("SizeMin");
  453. return;
  454. }
  455. if (parm.SizeMinSign.Equals("") && !parm.SizeMin.Equals(""))
  456. {
  457. MessageUtil.ShowWarning("存在限制规格(二)下限值,下限符号不能为空!");
  458. row.SetCellActive("SizeMinSign");
  459. return;
  460. }
  461. if (!parm.SizeMaxSign.Equals("") && parm.SizeMax.Equals(""))
  462. {
  463. MessageUtil.ShowWarning("存在限制规格(二)上限符号,上限值不能为空!");
  464. row.SetCellActive("SizeMax");
  465. return;
  466. }
  467. if (parm.SizeMaxSign.Equals("") && !parm.SizeMax.Equals(""))
  468. {
  469. MessageUtil.ShowWarning("存在限制规格(二)上限值,上限符号不能为空!");
  470. row.SetCellActive("SizeMaxSign");
  471. return;
  472. }
  473. if (!parm.SizeMax.Equals("") && !StringUtil.IsNumber(parm.SizeMax))
  474. {
  475. MessageUtil.ShowWarning("限制规格(二)上限值由数字组成!");
  476. row.SetCellActive("SizeMax");
  477. return;
  478. }
  479. if (!parm.SizeMin.Equals("") && !StringUtil.IsNumber(parm.SizeMin) && !parm.SizeMinSign.Equals("="))
  480. {
  481. MessageUtil.ShowWarning("限制规格(二)下限值由数字组成!");
  482. row.SetCellActive("SizeMin");
  483. return;
  484. }
  485. if (!parm.SizeMin.Equals("") && !parm.SizeMax.Equals("")) //&& Convert.ToDouble(size_max) < Convert.ToDouble(size_min)
  486. {
  487. int i = QcmBaseInfo.CheckStdData(parm.SizeMinSign, parm.SizeMaxSign, parm.SizeMin, parm.SizeMax);
  488. if (i == 0)
  489. {
  490. MessageUtil.ShowWarning("输入的数据不完整!");
  491. return;
  492. }
  493. if (i == 1)
  494. {
  495. MessageUtil.ShowWarning("限制规格(二)下限值与上限值相等,上下限符号请选择<=和>=!");
  496. row.SetCellActive("SizeMinSign");
  497. return;
  498. }
  499. if (i == 2)
  500. {
  501. MessageUtil.ShowWarning("限制规格(二)下限值不能大于上限值!");
  502. row.SetCellActive("SizeMin");
  503. return;
  504. }
  505. }
  506. }
  507. else
  508. {
  509. if (parm.SizeMaxSign != "" || parm.SizeMinSign != "" || parm.SizeMin != "" || parm.SizeMax != "")
  510. {
  511. MessageUtil.ShowWarning("限制规格(二)描述不存在!");
  512. row.SetCellActive("SizeCode");
  513. return;
  514. }
  515. }
  516. if (!parm.SizeName2.Equals("") && !parm.SizeName.Equals("") && parm.SizeName.Equals(parm.SizeName2))
  517. {
  518. MessageUtil.ShowWarning("限制规格(一)与限制规格(二)描述不能相同!");
  519. row.SetCellActive("SizeCode");
  520. return;
  521. }
  522. if (!parm.SizeMax.Equals(""))
  523. {
  524. if (parm.SizeMax.StartsWith("."))
  525. parm.SizeMax = "0" + parm.SizeMax;
  526. }
  527. if (!parm.SizeMin.Equals(""))
  528. {
  529. if (parm.SizeMin.StartsWith("."))
  530. parm.SizeMin = "0" + parm.SizeMin;
  531. }
  532. if (parm.Addcondition != "") //存在附加标准约束
  533. {
  534. if (parm.AddstdconCode == "")
  535. {
  536. MessageUtil.ShowWarning("请选择附加标准项!");
  537. row.SetCellActive("AddstdconCode");
  538. return;
  539. }
  540. if (parm.AddstdMinSign == "=" && (parm.AddstdMaxSign != "" || parm.AddstdMax != ""))
  541. {
  542. MessageUtil.ShowWarning("附加标准范围下限符号为'=',不能存在上限!");
  543. row.SetCellActive("AddstdMax");
  544. return;
  545. }
  546. if (parm.AddstdMinSign.Equals("") && parm.AddstdMaxSign.Equals(""))
  547. {
  548. MessageUtil.ShowWarning("请选择附加标准范围下限符号或者上限符号!");
  549. row.SetCellActive("AddstdMinSign");
  550. return;
  551. }
  552. if (!parm.AddstdMinSign.Equals("") && parm.AddstdMin.Equals(""))
  553. {
  554. MessageUtil.ShowWarning("请输入附加标准范围下限值!");
  555. row.SetCellActive("AddstdMin");
  556. return;
  557. }
  558. if (parm.AddstdMinSign.Equals("") && !parm.AddstdMin.Equals(""))
  559. {
  560. MessageUtil.ShowWarning("请选择附加标准范围下限符号!");
  561. row.SetCellActive("AddstdMinSign");
  562. return;
  563. }
  564. if (!parm.AddstdMinSign.Equals("") && parm.AddstdMin.Replace("Value", "1").CompileFormula() == null)
  565. {
  566. MessageUtil.ShowWarning("附加标准范围下限值,只能包含附加标准符号'Value'!");
  567. row.SetCellActive("AddstdMin");
  568. return;
  569. }
  570. if (!parm.AddstdMaxSign.Equals("") && parm.AddstdMax.Equals(""))
  571. {
  572. MessageUtil.ShowWarning("请输入附加标准范围上限值!");
  573. row.SetCellActive("AddstdMax");
  574. return;
  575. }
  576. if (!parm.AddstdMaxSign.Equals("") && parm.AddstdMax.Replace("Value", "1").CompileFormula() == null)
  577. {
  578. MessageUtil.ShowWarning("附加标准范围上限值,只能包含附加标准符号'Value'!");
  579. row.SetCellActive("AddstdMax");
  580. return;
  581. }
  582. if (parm.AddstdMaxSign.Equals("") && !parm.AddstdMax.Equals(""))
  583. {
  584. MessageUtil.ShowWarning("已有附加标准范围上限值,请选择附加标准范围上限符号!");
  585. row.SetCellActive("AddstdMaxSign");
  586. return;
  587. }
  588. if (!parm.AddstdMin.Equals(""))
  589. {
  590. if (parm.AddstdMin.StartsWith("."))
  591. parm.AddstdMin = "0" + parm.AddstdMin;
  592. }
  593. if (!parm.AddstdMax.Equals(""))
  594. {
  595. if (parm.AddstdMax.StartsWith("."))
  596. parm.AddstdMax = "0" + parm.AddstdMax;
  597. }
  598. if (!parm.AddstdMin.Equals("") && !parm.AddstdMax.Equals(""))//&& Convert.ToDouble(addstd_min) > Convert.ToDouble(addstd_max)
  599. {
  600. int i = QcmBaseInfo.CheckStdData(parm.AddstdMinSign, parm.AddstdMaxSign, parm.AddstdMin, parm.AddstdMax);
  601. if (i == 0)
  602. {
  603. MessageUtil.ShowWarning("输入的数据不完整!");
  604. return;
  605. }
  606. if (i == 1)
  607. {
  608. MessageUtil.ShowWarning("附加标准范围下限值与上限值相等,上下限符号请选择<=和>=!");
  609. row.SetCellActive("AddstdMinSign");
  610. return;
  611. }
  612. if (i == 2)
  613. {
  614. MessageUtil.ShowWarning("附加标准范围下限值不能大于上限值!");
  615. row.SetCellActive("AddstdMin");
  616. return;
  617. }
  618. }
  619. }
  620. string[] strJudgeBiasis = new string[] { "A", "B", "C", "D" };
  621. if (!strJudgeBiasis.Contains(parm.JudgeBasis)) //中文就是从交付或内控复制过来的,特殊处理。
  622. {
  623. if (parm.JudgeBasis.Equals("最小值"))
  624. parm.JudgeBasis = "A";
  625. else if (parm.JudgeBasis.Equals("最大值"))
  626. parm.JudgeBasis = "B";
  627. else if (parm.JudgeBasis.Equals("平均值"))
  628. parm.JudgeBasis = "C";
  629. else
  630. parm.JudgeBasis = "D";
  631. }
  632. parm.CreateName = CoreUserInfo.UserInfo.GetUserName();
  633. parm.UpdateName = CoreUserInfo.UserInfo.GetUserName();
  634. parm.DeleteName = CoreUserInfo.UserInfo.GetUserName();
  635. parm.SpeclFl = "2";
  636. parm.DesginKey = designKey;
  637. parm.OrdLnPk = ordLnPk;
  638. parm.PicMemo = ultraGrid1.ActiveRow.GetValue("PIC_MEMO");
  639. parm.MscPline = ultraGrid1.ActiveRow.GetValue("MSC_PLINE");
  640. parm.ProcessCode = ultraGrid1.ActiveRow.GetValue("PROCESS_CODE");
  641. parm.Pic = ultraGrid1.ActiveRow.GetValue("PIC");
  642. parms.Add(parm);
  643. }
  644. if (MessageUtil.ShowYesNoAndQuestion("是否确认保存?") == DialogResult.No)
  645. {
  646. return;
  647. }
  648. List<string> jsons = new List<string>();
  649. foreach (var craftOrdDesignStdPicEntity in parms)
  650. {
  651. jsons.Add(JSONFormat.Format(craftOrdDesignStdPicEntity));
  652. }
  653. string chkMscPline = mRow == null ? "" : mRow.GetValue("MSC_PLINE");
  654. string chkProcessCode = mRow == null ? "" : mRow.GetValue("PROCESS_CODE");
  655. string chkMemo = mRow == null ? "" : mRow.GetValue("PIC_MEMO");
  656. ServerHelper.SetData("com.steering.pss.sale.order.CraftOrdFdPic.save", new object[] { jsons, ordLnPk, mscPline, processCode, pic,
  657. chkMscPline, chkProcessCode, chkMemo }, _ob);
  658. MessageUtil.ShowTips("保存成功!");
  659. Relocate(mscPline, processCode, pic);
  660. }
  661. public void CopyNkStd()
  662. {
  663. var mRow = ultraGrid1.Rows.Where(a=>a.GetValue("CHK") == "True").FirstOrDefault();
  664. if (mRow == null)
  665. {
  666. MessageUtil.ShowWarning("请选择一条理化标准索引码!");
  667. return;
  668. }
  669. if (mRow.GetValue("PIC") == "")
  670. {
  671. MessageUtil.ShowWarning("请选择一条理化标准索引码!");
  672. return;
  673. }
  674. if (MessageUtil.ShowYesNoAndQuestion("是否确认复制内控索引码" + mRow.GetValue("PIC") + "?") == DialogResult.No)
  675. {
  676. return;
  677. }
  678. ServerHelper.SetData("com.steering.pss.sale.order.CraftOrdFdPic.copyNkStd", new object[] { designKey, ordLnPk, mRow.GetValue("MSC_PLINE"),
  679. mRow.GetValue("PROCESS_CODE"), mRow.GetValue("PIC") }, _ob);
  680. MessageUtil.ShowTips("复制成功!");
  681. Query();
  682. }
  683. public void Delete()
  684. {
  685. List<CrafOrdFdPicEntity> parms = new List<CrafOrdFdPicEntity>();
  686. var pRow = ultraGrid1.Rows.Where(a=>a.GetValue("CHK") == "True").FirstOrDefault();
  687. var rows = entityGrid1.Rows.Where(a => a.GetValue("Chk") == "True");
  688. if (pRow == null && rows.Count() == 0)
  689. {
  690. MessageUtil.ShowWarning("请选择一条记录!");
  691. return;
  692. }
  693. string mscPline = ultraGrid1.ActiveRow.GetValue("MSC_PLINE");
  694. string processCode = ultraGrid1.ActiveRow.GetValue("PROCESS_CODE");
  695. string pic = ultraGrid1.ActiveRow.GetValue("PIC");
  696. foreach (var row in rows)
  697. {
  698. var parm = EntityHelper.CopyEntity<CrafOrdFdPicEntity>(row.ListObject);
  699. parm.CreateName = CoreUserInfo.UserInfo.GetUserName();
  700. parm.UpdateName = CoreUserInfo.UserInfo.GetUserName();
  701. parm.DeleteName = CoreUserInfo.UserInfo.GetUserName();
  702. parm.SpeclFl = "2";
  703. parm.DesginKey = designKey;
  704. parms.Add(parm);
  705. }
  706. if (MessageUtil.ShowYesNoAndQuestion("是否确认删除?") == DialogResult.No)
  707. {
  708. return;
  709. }
  710. List<string> jsons = new List<string>();
  711. foreach (var craftOrdDesignStdPicEntity in parms)
  712. {
  713. jsons.Add(JSONFormat.Format(craftOrdDesignStdPicEntity));
  714. }
  715. string parmMscPline = pRow == null ? "" : pRow.GetValue("MSC_PLINE");
  716. string parmProcessCode = pRow == null ? "" : pRow.GetValue("PROCESS_CODE");
  717. ServerHelper.SetData("com.steering.pss.sale.order.CraftOrdFdPic.Delete", new object[] { ordLnPk, parmMscPline, parmProcessCode,
  718. jsons }, _ob);
  719. MessageUtil.ShowTips("删除成功!");
  720. Relocate(mscPline, processCode, pic);
  721. }
  722. private void Relocate(string mscPline, string processCode, string pic)
  723. {
  724. Query();
  725. var mRow = ultraGrid1.Rows.Where(a=>a.GetValue("MSC_PLINE") == mscPline && a.GetValue("PROCESS_CODE") == processCode &&
  726. a.GetValue("PIC") == pic).FirstOrDefault();
  727. if (mRow != null)
  728. {
  729. mRow.Activate();
  730. }
  731. }
  732. private void entityGrid1_CellChange(object sender, CellEventArgs e)
  733. {
  734. e.Cell.Row.Update();
  735. var ugr = e.Cell.Row;
  736. string deliverystate = ugr.Cells["DELIVERYSTATE"].Value.ToString();
  737. ugr.Cells["SizeName2"].Value = ugr.Cells["SizeCode2"].Text;
  738. ugr.Cells["SizeName"].Value = ugr.Cells["SizeCode"].Text;
  739. ugr.Cells["SpecJgDesc"].Value = ugr.Cells["SpecJg"].Text;
  740. GridEdite(e.Cell.Row);
  741. }
  742. private void GridEdite(UltraGridRow row)
  743. {
  744. if (row.GetValue("Chk") == "True")
  745. {
  746. foreach (UltraGridCell cell in row.Cells)
  747. {
  748. if (cell.Column.CellActivation == Activation.AllowEdit)
  749. {
  750. cell.Activation = Activation.AllowEdit;
  751. }
  752. }
  753. }
  754. else
  755. {
  756. foreach (UltraGridCell cell in row.Cells)
  757. {
  758. if (cell.Column.Key == "Chk") continue;
  759. if (cell.Column.CellActivation == Activation.AllowEdit)
  760. {
  761. cell.Activation = Activation.ActivateOnly;
  762. }
  763. }
  764. }
  765. }
  766. private void entityGrid1_AfterRowInsert(object sender, RowEventArgs e)
  767. {
  768. var mRow = ultraGrid1.ActiveRow;
  769. e.Row.SetValue("mscPline", mRow.GetValue("MSC_PLINE"));
  770. e.Row.SetValue("processCode", mRow.GetValue("PROCESS_CODE"));
  771. e.Row.SetValue("processDesc", mRow.GetValue("PROCESS_DESC"));
  772. e.Row.SetValue("pic", mRow.GetValue("PIC"));
  773. //将增加行的是否必选项置为默认选择 和 复合元素选择项置为默认不选
  774. e.Row.Cells["PhyType"].Value = false;
  775. e.Row.Cells["BilletSample"].Value = false;
  776. e.Row.Cells["JudgeBasis"].Value = "D";
  777. e.Row.Cells["IsJudge"].Value = true;
  778. e.Row.Cells["IsQuote"].Value = true;
  779. e.Row.Cells["Ischeck"].Value = true;
  780. e.Row.Cells["CraftSource"].Value = "1";
  781. e.Row.Cells["SpeclFl"].Value = "2";
  782. e.Row.Cells["OrdLnPk"].Value = ordLnPk;
  783. }
  784. private void ultraTextEditor3_EditorButtonClick(object sender, EditorButtonEventArgs e)
  785. {
  786. UltraGridRow row = entityGrid1.ActiveRow;
  787. string key = entityGrid1.ActiveCell.Column.Key;
  788. //if (key == "MscPline")
  789. //{
  790. // DataTable dt = ServerHelper.GetData("com.steering.pss.sale.order.CraftOrdFdPic.getMscPlineProcess",
  791. // new object[]{ designKey }, _ob);
  792. // dt.Columns["MSC_PLINE"].Caption = "制程号";
  793. // dt.Columns["WHOLE_BACKLOG"].Caption = "全程途径码";
  794. // dt.Columns["WHOLE_BACKLOG_DESC"].Caption = "全程途径描述";
  795. // dt.Columns["PROCESS_DESC"].Caption = "工序";
  796. // BaseInfoPopup popup = new BaseInfoPopup(dt, "MSC_PLINE", "PROCESS_CODE");
  797. // GridHelper.RefreshAndAutoSize(popup.UltraGrid1);
  798. // popup.LabelTextBox1.Caption = "制程号";
  799. // if (popup.ShowDialog() == DialogResult.OK)
  800. // {
  801. // row.SetValue("MscPline", popup.ChoicedRow.GetValue("MSC_PLINE"));
  802. // row.SetValue("ProcessDesc", popup.ChoicedRow.GetValue("PROCESS_DESC"));
  803. // row.SetValue("ProcessCode", popup.ChoicedRow.GetValue("PROCESS_CODE"));
  804. // }
  805. //}
  806. //else if (key == "ProcessDescC")
  807. //{
  808. // string mscPline = entityGrid1.ActiveRow.GetValue("MscPline");
  809. // DataTable dt = _designMscPlPrcBLL.queryProcess(designKey, mscPline);
  810. // dt.Columns["PROCESS_DESC"].Caption = "工序";
  811. // dt.Columns["PROCESS_DESC_C"].Caption = "二级工序";
  812. // BaseInfoPopup popup = new BaseInfoPopup(dt, "PROCESS_DESC_C", "PROCESS_CODE", "PROCESS_CODE_C");
  813. // popup.LabelTextBox1.Caption = "二级工序";
  814. // if (popup.ShowDialog() == DialogResult.OK)
  815. // {
  816. // row.SetValue("ProcessDescC", popup.ChoicedRow.GetValue("PROCESS_DESC_C"));
  817. // row.SetValue("ProcessCodeC", popup.ChoicedRow.GetValue("PROCESS_CODE_C"));
  818. // row.SetValue("ProcessDesc", popup.ChoicedRow.GetValue("PROCESS_DESC"));
  819. // row.SetValue("ProcessCode", popup.ChoicedRow.GetValue("PROCESS_CODE"));
  820. // }
  821. //}
  822. //else if (key == "Pic")
  823. //{
  824. // string mscPline = entityGrid1.ActiveRow.GetValue("MscPline");
  825. // string processCode = entityGrid1.ActiveRow.GetValue("ProcessCode");
  826. // DataTable dt = _designMscPlPrcBLL.queryProcessNkIndex(designKey, mscPline, processCode);
  827. // dt.Columns["PIC"].Caption = "理化内控索引码";
  828. // BaseInfoPopup popup = new BaseInfoPopup(dt, "PIC", "CIC", "SIC", "DIC", "WIC", "GIC");
  829. // popup.LabelTextBox1.Caption = "理化内控索引码";
  830. // if (popup.ShowDialog() == DialogResult.OK)
  831. // {
  832. // row.SetValue("Pic", popup.ChoicedRow.GetValue("PIC"));
  833. // }
  834. //}
  835. if (entityGrid1.ActiveCell.Column.Key == "PhyNameMax")
  836. {
  837. DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.ComBaseQuery.geComBasePhyRStd", null, _ob);
  838. dt.Columns["PHY_TYPE"].Caption = "检验大项";
  839. BaseInfoPopup baseInfoPopup = new BaseInfoPopup(dt, "PHY_TYPE", "PHY_CODE");
  840. baseInfoPopup.Text = "检验大项";
  841. baseInfoPopup.LabelTextBox1.Caption = "检验大项";
  842. baseInfoPopup.Shown += new EventHandler((c, d) =>
  843. {
  844. IQueryable<UltraGridRow> rows = baseInfoPopup.UltraGrid1.Rows.AsQueryable().Where(
  845. a => a.GetValue("PHY_CODE") == entityGrid1.ActiveRow.GetValue("PhyCodeMax"));
  846. if (rows.Count() > 0)
  847. {
  848. rows.First().Activate();
  849. }
  850. });
  851. if (baseInfoPopup.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  852. {
  853. entityGrid1.ActiveRow.SetValue("PhyNameMax", baseInfoPopup.ChoicedRow.GetValue("PHY_TYPE"));
  854. entityGrid1.ActiveRow.SetValue("PhyCodeMax", baseInfoPopup.ChoicedRow.GetValue("PHY_CODE"));
  855. entityGrid1.ActiveRow.SetValue("PhyNameMin", "");
  856. entityGrid1.ActiveRow.SetValue("PhyCodeMin", "");
  857. entityGrid1.ActiveRow.SetValue("PhyName", "");
  858. entityGrid1.ActiveRow.SetValue("PhyCode", "");
  859. entityGrid1.ActiveRow.SetValue("ItemNameF", "");
  860. entityGrid1.ActiveRow.SetValue("ItemCodeF", "");
  861. entityGrid1.ActiveRow.SetValue("ItemNameS", "");
  862. entityGrid1.ActiveRow.SetValue("ItemCodeS", "");
  863. entityGrid1.ActiveRow.SetValue("ItemNameW", "");
  864. entityGrid1.ActiveRow.SetValue("ItemCodeW", "");
  865. }
  866. }
  867. else if (entityGrid1.ActiveCell.Column.Key == "PhyNameMin")
  868. {
  869. string phyCodeMax = entityGrid1.ActiveRow.GetValue("PhyCodeMax");
  870. if (phyCodeMax == "")
  871. {
  872. MessageUtil.ShowWarning("请选检验大项!");
  873. return;
  874. }
  875. DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.ComBaseQuery.geComBasePhyC", new object[] { phyCodeMax }, _ob);
  876. dt.Columns["PHY_TYPE"].Caption = "试样组";
  877. BaseInfoPopup baseInfoPopup = new BaseInfoPopup(dt, "PHY_TYPE", "PHY_CODE");
  878. baseInfoPopup.Text = "试样组";
  879. baseInfoPopup.LabelTextBox1.Caption = "试样组";
  880. baseInfoPopup.Shown += new EventHandler((c, d) =>
  881. {
  882. IQueryable<UltraGridRow> rows = baseInfoPopup.UltraGrid1.Rows.AsQueryable().Where(
  883. a => a.GetValue("PHY_CODE") == entityGrid1.ActiveRow.GetValue("PhyCodeMin"));
  884. if (rows.Count() > 0)
  885. {
  886. rows.First().Activate();
  887. }
  888. });
  889. if (baseInfoPopup.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  890. {
  891. entityGrid1.ActiveRow.SetValue("PhyNameMin", baseInfoPopup.ChoicedRow.GetValue("PHY_TYPE"));
  892. entityGrid1.ActiveRow.SetValue("PhyCodeMin", baseInfoPopup.ChoicedRow.GetValue("PHY_CODE"));
  893. entityGrid1.ActiveRow.SetValue("PhyName", "");
  894. entityGrid1.ActiveRow.SetValue("PhyCode", "");
  895. entityGrid1.ActiveRow.SetValue("ItemNameF", "");
  896. entityGrid1.ActiveRow.SetValue("ItemCodeF", "");
  897. entityGrid1.ActiveRow.SetValue("ItemNameS", "");
  898. entityGrid1.ActiveRow.SetValue("ItemCodeS", "");
  899. entityGrid1.ActiveRow.SetValue("ItemNameW", "");
  900. entityGrid1.ActiveRow.SetValue("ItemCodeW", "");
  901. }
  902. }
  903. else if (entityGrid1.ActiveCell.Column.Key == "PhyName")
  904. {
  905. string phyCodeMax = entityGrid1.ActiveRow.GetValue("PhyCodeMax");
  906. string phyCodeMin = entityGrid1.ActiveRow.GetValue("PhyCodeMin");
  907. if (phyCodeMax == "")
  908. {
  909. MessageUtil.ShowWarning("请选择检验大项");
  910. entityGrid1.ActiveRow.Cells["PhyNameMax"].Activate();
  911. return;
  912. }
  913. else if (phyCodeMin == "")
  914. {
  915. MessageUtil.ShowWarning("请选择试样组");
  916. entityGrid1.ActiveRow.Cells["PhyNameMin"].Activate();
  917. return;
  918. }
  919. DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.ComBaseQuery.geComBasePhy", new object[] { phyCodeMax, phyCodeMin }, _ob);
  920. dt.Columns["PHY_NAME"].Caption = "检验项";
  921. BaseInfoPopup baseInfoPopup = new BaseInfoPopup(dt, "PHY_NAME", "PHY_CODE");
  922. baseInfoPopup.Text = "检验项";
  923. baseInfoPopup.LabelTextBox1.Caption = "检验项";
  924. baseInfoPopup.Shown += new EventHandler((c, d) =>
  925. {
  926. IQueryable<UltraGridRow> rows = baseInfoPopup.UltraGrid1.Rows.AsQueryable().Where(
  927. a => a.GetValue("PHY_CODE") == entityGrid1.ActiveRow.GetValue("PhyCode"));
  928. if (rows.Count() > 0)
  929. {
  930. rows.First().Activate();
  931. }
  932. });
  933. if (baseInfoPopup.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  934. {
  935. entityGrid1.ActiveRow.SetValue("PhyName", baseInfoPopup.ChoicedRow.GetValue("PHY_NAME"));
  936. entityGrid1.ActiveRow.SetValue("PhyCode", baseInfoPopup.ChoicedRow.GetValue("PHY_CODE"));
  937. entityGrid1.ActiveRow.SetValue("ItemNameW", "");
  938. entityGrid1.ActiveRow.SetValue("ItemCodeW", "");
  939. }
  940. }
  941. else if (entityGrid1.ActiveCell.Column.Key == "ItemNameF")
  942. {
  943. string phyTypeC = entityGrid1.ActiveRow.GetValue("PhyCodeMin");
  944. if (phyTypeC == "")
  945. {
  946. MessageUtil.ShowWarning("请选择试样组");
  947. entityGrid1.ActiveRow.Cells["PhyNameMin"].Activate();
  948. return;
  949. }
  950. DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.ComBaseQuery.geComBasePhyRItem",
  951. new object[] { phyTypeC }, _ob);
  952. dt.Columns["ITEM_NAME_F"].Caption = "试验方向";
  953. dt.Columns["ITEM_NAME_C"].Caption = "试验尺寸";
  954. BaseInfoPopup baseInfoPopup = new BaseInfoPopup(dt, "ITEM_NAME_F", "ITEM_CODE_F", "ITEM_CODE_C");
  955. baseInfoPopup.Text = "试验选择";
  956. baseInfoPopup.LabelTextBox1.Caption = "试验方向";
  957. baseInfoPopup.Shown += new EventHandler((c, d) =>
  958. {
  959. IQueryable<UltraGridRow> rows = baseInfoPopup.UltraGrid1.Rows.AsQueryable().Where(
  960. a => a.GetValue("ITEM_CODE_F") == entityGrid1.ActiveRow.GetValue("ItemCodeF")
  961. && a.GetValue("ITEM_CODE_C") == entityGrid1.ActiveRow.GetValue("ItemCodeS"));
  962. if (rows.Count() > 0)
  963. {
  964. rows.First().Activate();
  965. }
  966. });
  967. if (baseInfoPopup.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  968. {
  969. entityGrid1.ActiveRow.SetValue("ItemNameF", baseInfoPopup.ChoicedRow.GetValue("ITEM_NAME_F"));
  970. entityGrid1.ActiveRow.SetValue("ItemCodeF", baseInfoPopup.ChoicedRow.GetValue("ITEM_CODE_F"));
  971. entityGrid1.ActiveRow.SetValue("ItemNameS", baseInfoPopup.ChoicedRow.GetValue("ITEM_NAME_C"));
  972. entityGrid1.ActiveRow.SetValue("ItemCodeS", baseInfoPopup.ChoicedRow.GetValue("ITEM_CODE_C"));
  973. }
  974. }
  975. else if (entityGrid1.ActiveCell.Column.Key == "ItemNameW")
  976. {
  977. string phyCode = entityGrid1.ActiveRow.GetValue("PhyCode");
  978. if (phyCode == "")
  979. {
  980. MessageUtil.ShowWarning("请选择检验项");
  981. entityGrid1.ActiveRow.Cells["PhyName"].Activate();
  982. return;
  983. }
  984. DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.ComBaseQuery.geComBasePhyRPos",
  985. new object[] { phyCode }, _ob);
  986. dt.Columns["ITEM_NAME_W"].Caption = "试验温度";
  987. BaseInfoPopup baseInfoPopup = new BaseInfoPopup(dt, "ITEM_NAME_W", "ITEM_CODE_W");
  988. baseInfoPopup.Text = "试验选择";
  989. baseInfoPopup.LabelTextBox1.Caption = "试验温度";
  990. baseInfoPopup.Shown += new EventHandler((c, d) =>
  991. {
  992. IQueryable<UltraGridRow> rows = baseInfoPopup.UltraGrid1.Rows.AsQueryable().Where(
  993. a => a.GetValue("ITEM_CODE_W") == entityGrid1.ActiveRow.GetValue("ItemCodeW"));
  994. if (rows.Count() > 0)
  995. {
  996. rows.First().Activate();
  997. }
  998. });
  999. if (baseInfoPopup.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  1000. {
  1001. entityGrid1.ActiveRow.SetValue("ItemNameW", baseInfoPopup.ChoicedRow.GetValue("ITEM_NAME_W"));
  1002. entityGrid1.ActiveRow.SetValue("ItemCodeW", baseInfoPopup.ChoicedRow.GetValue("ITEM_CODE_W"));
  1003. }
  1004. }
  1005. }
  1006. private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
  1007. {
  1008. var row = ultraGrid1.ActiveRow;
  1009. string pic = row.GetValue("PIC");
  1010. string mscPline = row.GetValue("MSC_PLINE");
  1011. string processCode = row.GetValue("PROCESS_CODE");
  1012. this.CraftOrdDesignStdPicEntityBindingSource.DataSource = EntityHelper.GetData<CrafOrdFdPicEntity>(
  1013. "com.steering.pss.sale.order.CraftOrdFdPic.query", new object[] { ordLnPk, mscPline, processCode, pic }, _ob);
  1014. foreach (var row2 in entityGrid1.Rows)
  1015. {
  1016. GridEdite(row2);
  1017. }
  1018. }
  1019. private void ultraTextEditor1_EditorButtonClick(object sender, EditorButtonEventArgs e)
  1020. {
  1021. if (ultraGrid1.ActiveCell.Column.Key == "MSC_PLINE")
  1022. {
  1023. if (entityGrid1.Rows.Count != 0)
  1024. {
  1025. MessageUtil.ShowWarning("已维护首日检数据,不能修改!");
  1026. }
  1027. else
  1028. {
  1029. UltraGridRow row = ultraGrid1.ActiveRow;
  1030. string key = ultraGrid1.ActiveCell.Column.Key;
  1031. if (key == "MSC_PLINE")
  1032. {
  1033. DataTable dt = ServerHelper.GetData("com.steering.pss.sale.order.CraftOrdFdPic.getMscPlineProcess",
  1034. new object[] { designKey }, _ob);
  1035. dt.Columns["MSC_PLINE"].Caption = "制程号";
  1036. dt.Columns["WHOLE_BACKLOG"].Caption = "全程途径码";
  1037. dt.Columns["WHOLE_BACKLOG_DESC"].Caption = "全程途径描述";
  1038. dt.Columns["PROCESS_DESC"].Caption = "工序";
  1039. dt.Columns["PIC"].Caption = "理化索引码";
  1040. BaseInfoPopup popup = new BaseInfoPopup(dt, "MSC_PLINE", "PROCESS_CODE");
  1041. GridHelper.RefreshAndAutoSize(popup.UltraGrid1);
  1042. popup.LabelTextBox1.Caption = "制程号";
  1043. if (popup.ShowDialog() == DialogResult.OK)
  1044. {
  1045. var mRow = ultraGrid1.Rows.Where(a => a.GetValue("MSC_PLINE") == popup.ChoicedRow.GetValue("MSC_PLINE")
  1046. && a.GetValue("PROCESS_CODE") == popup.ChoicedRow.GetValue("PROCESS_CODE")).FirstOrDefault();
  1047. if (mRow != null)
  1048. {
  1049. MessageUtil.ShowWarning("同制程、同工序下只能维护一套首日检数据,请先删除制程" + popup.ChoicedRow.GetValue("MSC_PLINE") +
  1050. " - 工序" + popup.ChoicedRow.GetValue("PROCESS_DESC") + "下的索引码" + mRow.GetValue("PIC") + "!");
  1051. return;
  1052. }
  1053. row.SetValue("MSC_PLINE", popup.ChoicedRow.GetValue("MSC_PLINE"));
  1054. row.SetValue("PROCESS_DESC", popup.ChoicedRow.GetValue("PROCESS_DESC"));
  1055. row.SetValue("PROCESS_CODE", popup.ChoicedRow.GetValue("PROCESS_CODE"));
  1056. row.SetValue("PIC", popup.ChoicedRow.GetValue("PIC"));
  1057. }
  1058. }
  1059. }
  1060. }
  1061. }
  1062. private void entityGrid1_BeforeRowInsert(object sender, BeforeRowInsertEventArgs e)
  1063. {
  1064. if (ultraGrid1.ActiveRow == null) e.Cancel = true;
  1065. if (ultraGrid1.ActiveRow.GetValue("PIC") == "") e.Cancel = true;
  1066. }
  1067. private void ultraGrid1_CellChange(object sender, CellEventArgs e)
  1068. {
  1069. e.Cell.Row.Update();
  1070. if (e.Cell.Column.Key == "CHK")
  1071. {
  1072. UltraGridRow chkRow = e.Cell.Row;
  1073. foreach (UltraGridRow row in ultraGrid1.Rows)
  1074. {
  1075. if (row.Cells["CHK"].Value.ToString() == "True" && row != chkRow)
  1076. {
  1077. row.Cells["CHK"].Value = "False";
  1078. row.Update();
  1079. }
  1080. }
  1081. }
  1082. }
  1083. private void ultraGrid1_AfterRowInsert(object sender, RowEventArgs e)
  1084. {
  1085. }
  1086. private void ultraGrid1_BeforeRowInsert(object sender, BeforeRowInsertEventArgs e)
  1087. {
  1088. if (ultraGrid1.Rows.Count > 0)
  1089. {
  1090. e.Cancel = true;
  1091. }
  1092. }
  1093. private void ultraGrid1_ClickCellButton(object sender, CellEventArgs e)
  1094. {
  1095. if (entityGrid1.Rows.Count == 0)
  1096. {
  1097. MessageUtil.ShowWarning("请先维护首日检数据!");
  1098. return;
  1099. }
  1100. string mscPline = ultraGrid1.ActiveRow.GetValue("MSC_PLINE");
  1101. string processCode = ultraGrid1.ActiveRow.GetValue("PROCESS_CODE");
  1102. CraftOrdFdPicSmpFrm picSmp = new CraftOrdFdPicSmpFrm(ordLnPk, mscPline, processCode, _ob);
  1103. picSmp.ShowDialog();
  1104. }
  1105. /// <summary>
  1106. /// 复制
  1107. /// </summary>
  1108. public void Copy()
  1109. {
  1110. var chkRows = entityGrid1.Rows.Where(a => a.GetValue("chk") == "True");
  1111. if (chkRows.Count() == 0)
  1112. {
  1113. MessageUtil.ShowWarning("请选择记录后,再进行操作!");
  1114. return;
  1115. }
  1116. ultraGrid1.UpdateData();
  1117. DataTable copyTable = CreateTableByEntity((CrafOrdFdPicEntity)chkRows.FirstOrDefault().ListObject);
  1118. foreach (UltraGridRow row in entityGrid1.Rows)
  1119. {
  1120. if (row.GetValue("Chk") != "True") continue;
  1121. DataRow dr = copyTable.NewRow();
  1122. CopyEntityToRow((CrafOrdFdPicEntity)row.ListObject, dr);
  1123. dr["ORD_SEQ"] = "";
  1124. copyTable.Rows.Add(dr);
  1125. }
  1126. DataTable[] copyTabs = new DataTable[] { copyTable, new DataTable() };
  1127. Clipboard.SetData("Pic", copyTabs);
  1128. }
  1129. /// <summary>
  1130. /// 粘贴
  1131. /// </summary>
  1132. public void Paste()
  1133. {
  1134. if (ultraGrid1.ActiveRow == null || ultraGrid1.ActiveRow.GetValue("PIC") == "")
  1135. {
  1136. MessageUtil.ShowWarning("请选择一条成分标准索引码!");
  1137. return;
  1138. }
  1139. DataTable[] copyTabs = (DataTable[])Clipboard.GetData("Pic");
  1140. if (copyTabs == null)
  1141. {
  1142. MessageUtil.ShowWarning("没有数据,请复制后再进行操作!");
  1143. return;
  1144. }
  1145. DataTable copyTab = copyTabs[0];
  1146. DataTable copyTab2 = copyTabs[1];
  1147. if (copyTab == null || copyTab.Rows.Count == 0)
  1148. {
  1149. MessageUtil.ShowWarning("没有数据,请复制后再进行操作!");
  1150. return;
  1151. }
  1152. dataTable1.BeginInit();
  1153. List<CrafOrdFdPicEntity> data = (List<CrafOrdFdPicEntity>)CraftOrdDesignStdPicEntityBindingSource.DataSource;
  1154. CrafOrdFdPicEntity activeFd = null;
  1155. foreach (DataRow row in copyTab.Rows)
  1156. {
  1157. CrafOrdFdPicEntity fd = new CrafOrdFdPicEntity();
  1158. fd.Chk = true;
  1159. CopyRowToEntity(row, fd);
  1160. data.Add(fd);
  1161. activeFd = fd;
  1162. }
  1163. CraftOrdDesignStdPicEntityBindingSource.ResetBindings(false);
  1164. //CraftOrdDesignStdCicEntityBindingSource.DataSource = data;
  1165. dataTable1.EndInit();
  1166. entityGrid1.UpdateData();
  1167. if (entityGrid1.Rows.Count > 0)
  1168. {
  1169. entityGrid1.Rows[entityGrid1.Rows.Count - 1].Activate();
  1170. }
  1171. }
  1172. private string GetLineName(string name)
  1173. {
  1174. string lineName = "";
  1175. for (int i = 0; i < name.Length; i++)
  1176. {
  1177. if (i == 0)
  1178. {
  1179. lineName += name[i];
  1180. }
  1181. else
  1182. {
  1183. if (name[i] >= 'A' && name[i] <= 'Z')
  1184. {
  1185. lineName += '_';
  1186. lineName += name[i];
  1187. }
  1188. else
  1189. {
  1190. lineName += name[i];
  1191. }
  1192. }
  1193. }
  1194. return lineName.ToUpper();
  1195. }
  1196. private string GetName(string lineName)
  1197. {
  1198. string[] strs = lineName.Split('_');
  1199. string name = "";
  1200. for (int i = 0; i < strs.Length; i++)
  1201. {
  1202. name += strs[i].Substring(0, 1).ToUpper() + strs[i].Substring(1).ToLower();
  1203. }
  1204. return name;
  1205. }
  1206. private DataTable CreateTableByEntity(CrafOrdFdPicEntity fdEntity)
  1207. {
  1208. DataTable dt = new DataTable();
  1209. PropertyInfo[] srcPropertyInfos = fdEntity.GetType().GetProperties();
  1210. foreach (PropertyInfo srcPropertyInfo in srcPropertyInfos)
  1211. {
  1212. dt.Columns.Add(GetLineName(srcPropertyInfo.Name));
  1213. }
  1214. return dt;
  1215. }
  1216. private void CopyEntityToRow(CrafOrdFdPicEntity fdEntity, DataRow desRow)
  1217. {
  1218. PropertyInfo[] pros = fdEntity.GetType().GetProperties();
  1219. foreach (PropertyInfo pro in pros)
  1220. {
  1221. desRow[GetLineName(pro.Name)] = pro.GetValue(fdEntity, null);
  1222. }
  1223. }
  1224. private void CopyRowToEntity(DataRow row, CrafOrdFdPicEntity fdEntity)
  1225. {
  1226. PropertyInfo[] pros = fdEntity.GetType().GetProperties();
  1227. foreach (DataColumn dc in row.Table.Columns)
  1228. {
  1229. if (dc.ColumnName == "CREATE_TIME") continue;
  1230. PropertyInfo pro = fdEntity.GetType().GetProperty(GetName(dc.ColumnName));
  1231. if (pro != null)
  1232. {
  1233. pro.SetValue(fdEntity, ConvertDataType(pro.PropertyType, row[dc.ColumnName].ToString()), null);
  1234. }
  1235. }
  1236. }
  1237. private object ConvertDataType(Type type, object objValue)
  1238. {
  1239. if (type == typeof(bool))
  1240. {
  1241. bool result;
  1242. if (bool.TryParse(objValue.ToString(), out result))
  1243. {
  1244. return result;
  1245. }
  1246. else
  1247. {
  1248. return false;
  1249. }
  1250. }
  1251. else if (type == typeof(bool?))
  1252. {
  1253. bool result;
  1254. if (bool.TryParse(objValue.ToString(), out result))
  1255. {
  1256. return result;
  1257. }
  1258. else
  1259. {
  1260. return null;
  1261. }
  1262. }
  1263. else if (type == typeof(int?))
  1264. {
  1265. if (objValue.ToString2() == "")
  1266. {
  1267. return null;
  1268. }
  1269. else
  1270. {
  1271. return int.Parse(objValue.ToString());
  1272. }
  1273. }
  1274. else if (type == typeof(long?))
  1275. {
  1276. if (objValue.ToString2() == "")
  1277. {
  1278. return null;
  1279. }
  1280. else
  1281. {
  1282. return long.Parse(objValue.ToString());
  1283. }
  1284. }
  1285. else if (type == typeof(short?))
  1286. {
  1287. if (objValue.ToString2() == "")
  1288. {
  1289. return null;
  1290. }
  1291. else
  1292. {
  1293. return short.Parse(objValue.ToString());
  1294. }
  1295. }
  1296. else if (type == typeof(float?))
  1297. {
  1298. if (objValue.ToString2() == "")
  1299. {
  1300. return null;
  1301. }
  1302. else
  1303. {
  1304. return float.Parse(objValue.ToString());
  1305. }
  1306. }
  1307. else if (type == typeof(double?))
  1308. {
  1309. if (objValue.ToString2() == "")
  1310. {
  1311. return null;
  1312. }
  1313. else
  1314. {
  1315. return double.Parse(objValue.ToString());
  1316. }
  1317. }
  1318. else if (type == typeof(decimal?))
  1319. {
  1320. if (objValue.ToString2() == "")
  1321. {
  1322. return null;
  1323. }
  1324. else
  1325. {
  1326. return decimal.Parse(objValue.ToString());
  1327. }
  1328. }
  1329. else if (type == typeof(DateTime?))
  1330. {
  1331. if (objValue.ToString2() == "")
  1332. {
  1333. return null;
  1334. }
  1335. else
  1336. {
  1337. return DateTime.Parse(objValue.ToString());
  1338. }
  1339. }
  1340. else
  1341. {
  1342. return objValue == null ? "" : objValue.ToString();
  1343. }
  1344. }
  1345. }
  1346. }