FrmPhySample.cs 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732
  1. using Core.Mes.Client.Comm.Control;
  2. using Core.Mes.Client.Comm.Server;
  3. using Core.Mes.Client.Comm.Tool;
  4. using Core.StlMes.Client.Qcm.Control;
  5. using Core.StlMes.Client.Qcm.model;
  6. using CoreFS.CA06;
  7. using Infragistics.Win.UltraWinGrid;
  8. using Newtonsoft.Json;
  9. using System;
  10. using System.Collections;
  11. using System.Collections.Generic;
  12. using System.Data;
  13. using System.Drawing;
  14. using System.Linq;
  15. using System.Windows.Forms;
  16. namespace Core.StlMes.Client.Qcm
  17. {
  18. public partial class FrmPhySample : FrmBase
  19. {
  20. private string ordLnPk = "";
  21. private string dimater = "1";
  22. private string height = "1";
  23. private string mscPline = "";
  24. private string processCode = "";
  25. //理化弹窗
  26. public FrmPhySample(OpeBase ob, DataTable dt, string ordLnPk, string customInfo)
  27. {
  28. InitializeComponent();
  29. this.IsLoadUserView = true;
  30. this._ob = ob;
  31. this.ordLnPk = ordLnPk;
  32. //DataRow drComBaseStd = GetComBaseStdByPk(dt.Rows[0]["STD_CODE"].ToString());
  33. //if (drComBaseStd != null)
  34. //{
  35. // foreach (DataRow dr in dt.Rows)
  36. // {
  37. // dr["STD_NAME"] = drComBaseStd["STD_NAME"];
  38. // }
  39. //}
  40. this.dt = dt;
  41. this.CustomInfo = customInfo;
  42. if (ordLnPk == "" || ordLnPk == "abc")
  43. {
  44. ultraToolbarsManager1.Tools["设定试样码"].SharedProps.Visible = false;
  45. }
  46. //显示转换的理化冲击
  47. DataTable dtConvertPhy = ServerHelper.GetData("com.steering.pss.qcm.CorePhySample.getConvertPhy",
  48. new object[] { ordLnPk }, _ob);
  49. if (dtConvertPhy.Rows.Count > 0)
  50. {
  51. ultraGroupBox4.Visible = true;
  52. GridHelper.CopyDataToDatatable(dtConvertPhy, this.dataTable3, true);
  53. }
  54. }
  55. //评审弹窗
  56. public FrmPhySample(OpeBase ob, string objKey, string ordLnPk, string designKey, string errMsg)
  57. {
  58. InitializeComponent();
  59. ultraStatusBar1.Visible = true;
  60. ultraStatusBar1.Panels["ExMsg"].Text = errMsg;
  61. ultraToolbarsManager1.Tools["确认"].SharedProps.Visible = true;
  62. ultraTabControl1.Tabs[0].Visible = false;
  63. this.IsLoadUserView = true;
  64. this._ob = ob;
  65. this.ordLnPk = ordLnPk;
  66. string[] objKeys = objKey.Split(',');
  67. string pic = objKeys[0];
  68. string speclFlg = objKeys[1];
  69. if (objKeys.Length >= 6)
  70. {
  71. this.dimater = objKeys[2];
  72. this.height = objKeys[3];
  73. this.mscPline = objKeys[4];
  74. this.processCode = objKeys[5];
  75. }
  76. if (speclFlg == "0" || speclFlg == "1")
  77. {
  78. this.CustomInfo = "1";
  79. }
  80. else if (speclFlg == "2")
  81. {
  82. this.CustomInfo = "2";
  83. }
  84. this.dt = GetPicData(pic, designKey, mscPline, processCode);
  85. }
  86. public FrmPhySample(OpeBase ob1)
  87. {
  88. this.Ob = ob1;
  89. }
  90. private OpeBase _ob;
  91. public OpeBase Ob
  92. {
  93. get { return _ob; }
  94. set { _ob = value; }
  95. }
  96. private DataTable dt;
  97. public DataTable Dt
  98. {
  99. get { return dt; }
  100. set { dt = value; }
  101. }
  102. FrmBaseSample fbs = new FrmBaseSample();
  103. private ComBaseSplineCtrl _splineCtrl;
  104. private ComBaseSplineCCtrl _splineCCtrl;
  105. private void FrmPhySample_Load(object sender, EventArgs e)
  106. {
  107. try
  108. {
  109. this.Cursor = Cursors.WaitCursor;
  110. _splineCtrl = new ComBaseSplineCtrl(ultraGroupBox2, _ob);
  111. _splineCtrl.Flag = "试样关系";
  112. _splineCtrl.UltraTextEditor1.ButtonsRight.Clear();
  113. _splineCtrl.UltraGrid1.DisplayLayout.Bands[0].Override.AllowAddNew = AllowAddNew.No;
  114. GridHelper.HidenColumns(_splineCtrl.UltraGrid1.DisplayLayout.Bands[0], "Chk");
  115. ClearGridColor(_splineCtrl.UltraGrid1);
  116. GridHelper.HidenColumns(_splineCtrl.UltraGrid1.DisplayLayout.Bands[0], "Chk");
  117. _splineCtrl.UltraGrid1.AfterRowActivate += _splineCtrl_AfterRowActivate;
  118. _splineCCtrl = new ComBaseSplineCCtrl(ultraGroupBox3, _ob);
  119. _splineCCtrl.UltraGrid1.DisplayLayout.Bands[0].Override.AllowAddNew = AllowAddNew.No;
  120. ClearGridColor(_splineCCtrl.UltraGrid1);
  121. GridHelper.HidenColumns(_splineCCtrl.UltraGrid1.DisplayLayout.Bands[0], "Chk");
  122. InitGrid1(dt);
  123. ultraGrid1.UpdateData();
  124. ultraGrid2.UpdateData();
  125. }
  126. finally
  127. {
  128. this.Cursor = Cursors.Default;
  129. }
  130. }
  131. private DataTable GetPicData(string pic, string designKey, string mscPline, string processCode)
  132. {
  133. DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CorePhySample.GetPicData",
  134. new object[] { pic, designKey, mscPline, processCode }, _ob);
  135. return dt;
  136. }
  137. private void ClearGridColor(UltraGrid grid)
  138. {
  139. foreach (UltraGridColumn column in grid.DisplayLayout.Bands[0].Columns)
  140. {
  141. column.CellAppearance.BackColor = grid.DisplayLayout.Bands[0].Columns["VALIDFLAG"].CellAppearance.BackColor;
  142. }
  143. }
  144. private void InitGrid1(DataTable dt)
  145. {
  146. string pic = "";
  147. ultraGrid1.BeginUpdate();
  148. GridHelper.CopyDataToDatatable(ref dt, ref dataTable1, true);
  149. if (dt.Rows.Count > 0)
  150. {
  151. pic = dt.Rows[0]["PIC"].ToString();
  152. DataTable dtStdTest = ServerHelper.GetData("com.steering.pss.qcm.CorePhySample.GetStdTest",
  153. new object[] { pic }, Ob);
  154. foreach (DataRow row in dataTable1.Rows)
  155. {
  156. foreach (DataRow dr in dtStdTest.Rows)
  157. {
  158. if (ultraTabControl1.SelectedTab.Index == 0)
  159. {
  160. if (dr["PHY_CODE_MIN"].ToString() == row["PHY_CODE_MIN"].ToString()
  161. && dr["ITEM_CODE_F"].ToString() == row["ITEM_CODE_F"].ToString()
  162. && dr["ITEM_CODE_W"].ToString() == row["ITEM_CODE_W"].ToString()
  163. && dr["ITEM_CODE_C"].ToString() == row["ITEM_CODE_C"].ToString())
  164. {
  165. row["STD_CODE_TEST"] = dr["STD_CODE_TEST"];
  166. row["STD_NAME_TEST"] = dr["STD_NAME_TEST"];
  167. }
  168. }
  169. else
  170. {
  171. if (dr["PHY_CODE_MIN"].ToString() == row["PHY_CODE_MIN"].ToString()
  172. && dr["ITEM_CODE_F"].ToString() == row["ITEM_CODE_F"].ToString()
  173. && dr["ITEM_CODE_C"].ToString() == row["ITEM_CODE_C"].ToString())
  174. {
  175. row["STD_CODE_TEST"] = dr["STD_CODE_TEST"];
  176. row["STD_NAME_TEST"] = dr["STD_NAME_TEST"];
  177. }
  178. }
  179. }
  180. if (row["STD_CODE_TEST"].ToString() == "")
  181. {
  182. foreach (DataRow dr in dtStdTest.Rows)
  183. {
  184. if (dr["PHY_CODE_MIN"].ToString() == row["PHY_CODE_MIN"].ToString())
  185. {
  186. row["STD_CODE_TEST"] = dr["STD_CODE_TEST"];
  187. row["STD_NAME_TEST"] = dr["STD_NAME_TEST"];
  188. }
  189. }
  190. }
  191. }
  192. }
  193. ultraGrid1.EndUpdate();
  194. }
  195. public void QueryPhyDown()
  196. {
  197. //string phycode, string stdCode
  198. string phyCode = ultraGrid1.ActiveRow.GetValue("PHY_CODE_MIN");
  199. string stdCode = ultraGrid1.ActiveRow.GetValue("STD_CODE");
  200. string stdCodeTest = ultraGrid1.ActiveRow.GetValue("STD_CODE_TEST");
  201. string produccode = ultraGrid1.ActiveRow.GetValue("PRODUCCODE");
  202. string steelcode = ultraGrid1.ActiveRow.GetValue("STEELCODE");
  203. ultraGrid2.BeginUpdate();
  204. DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CorePhySample.Query",
  205. new Object[] { phyCode, stdCode, steelcode, produccode }, this._ob);
  206. GridHelper.CopyDataToDatatable(ref dt, ref this.dataTable2, true);
  207. SetCHK();
  208. ultraGrid2.EndUpdate();
  209. ultraGrid2.UpdateData();
  210. _splineCtrl.UltraGrid1.BeginUpdate();
  211. string phyCodeMin = ultraGrid1.ActiveRow.Cells["PHY_CODE_MIN"].Value.ToString();
  212. string pic = ultraGrid1.ActiveRow.Cells["PIC"].Value.ToString();
  213. string itemCodeC = ultraGrid1.GetActiveRowValue("ITEM_CODE_C");
  214. string itemCodeF = ultraGrid1.GetActiveRowValue("ITEM_CODE_F");
  215. string itemCodeW = ultraGrid1.GetActiveRowValue("ITEM_CODE_W");
  216. _splineCCtrl.ClearDataSource();
  217. _splineCtrl.Query2(phyCodeMin, itemCodeF, itemCodeC, ordLnPk, itemCodeW);
  218. List<ComBaseSplineEntity> splines = (List<ComBaseSplineEntity>)_splineCtrl.ComBaseSplineEntityBindingSource.DataSource;
  219. foreach (var spline in splines)
  220. {
  221. if (spline.StdCodeS == "" || spline.StdCodeS.Split(';').Contains(stdCodeTest))
  222. {
  223. spline.Sort = "1";
  224. }
  225. }
  226. var sortSplines = splines.OrderByDescending(a => a.Sort).ThenBy(a => a.Eic);
  227. _splineCtrl.ComBaseSplineEntityBindingSource.DataSource = sortSplines.ToList();
  228. //DataTable dtSpline = ServerHelper.GetData("com.steering.pss.qcm.CorePhySample.QuerySpline",
  229. // new object[] { phyCodeMin, itemCodeF, itemCodeC, stdCodeTest, ordLnPk, dimater, height}, _ob);
  230. CoreClientParam ccp = new CoreClientParam();
  231. ccp.ServerName = "com.steering.pss.qcm.CorePhySample";
  232. ccp.MethodName = "QuerySpline";
  233. ccp.ServerParams = new object[] { phyCodeMin, itemCodeF, itemCodeC, stdCodeTest, ordLnPk, dimater, height };
  234. ccp = _ob.ExecuteQuery(ccp, CoreInvokeType.Internal);
  235. ArrayList eics = (ArrayList)ccp.ReturnObject;
  236. DataTable dtSetEic = ServerHelper.GetData("com.steering.pss.qcm.CorePhySample.querySetEic",
  237. new object[] { ordLnPk, phyCodeMin, itemCodeF, itemCodeC, itemCodeW }, _ob);
  238. foreach (var row in _splineCtrl.UltraGrid1.Rows)
  239. {
  240. row.Cells["Chk2"].Activation = Activation.ActivateOnly;
  241. if (eics.Contains(row.GetValue("Eic")))
  242. {
  243. row.SetValue("Chk2", "True");
  244. row.SetValue("Chk3", "False");
  245. }
  246. else
  247. {
  248. row.Cells["Chk3"].Activation = Activation.ActivateOnly;
  249. row.Cells["Chk3"].Value = DBNull.Value;
  250. }
  251. if (dtSetEic.Select("SET_EIC = '" + row.GetValue("Eic") + "'").Length > 0)
  252. {
  253. row.SetValue("Chk3", "True");
  254. }
  255. if (row.GetValue("StdCodeS") == "" || row.GetValue("StdCodeS").Split(';').Contains(stdCodeTest))
  256. {
  257. row.Appearance.BackColor = Color.FromArgb(255, 250, 205);
  258. }
  259. else
  260. {
  261. row.Appearance.BackColor = Color.FromArgb(211, 211, 211);
  262. }
  263. }
  264. _splineCtrl.UltraGrid1.EndUpdate();
  265. _splineCtrl.UltraGrid1.UpdateData();
  266. }
  267. private void SetCHK()
  268. {
  269. UltraGridRow ugr = this.ultraGrid1.ActiveRow;
  270. string phycode = ugr.Cells["PHY_CODE_MIN"].Value.ToString();
  271. string itemCodeC = ugr.Cells["ITEM_CODE_C"].Value.ToString();
  272. string itemCodeF = ugr.Cells["ITEM_CODE_F"].Value.ToString();
  273. string itemCodeW = ugr.Cells["ITEM_CODE_W"].Value.ToString();
  274. string pic = ugr.Cells["PIC"].Value.ToString();
  275. string sic = "";
  276. DataTable dt1 = ServerHelper.GetData("com.steering.pss.qcm.CorePhySample.GetSIC",
  277. new Object[] { phycode, itemCodeC, itemCodeF, itemCodeW, pic }, this._ob);
  278. if (dt1 != null && dt1.Rows.Count > 0)
  279. {
  280. sic = dt1.Rows[0][0].ToString();
  281. }
  282. foreach (UltraGridRow row in this.ultraGrid2.Rows)
  283. {
  284. int cnt = dt1.Select("SIC = '" + row.Cells["SIC"].Value.ToString() + "'").Length;
  285. if (cnt > 0)
  286. {
  287. row.Cells["CHK"].Value = true;
  288. }
  289. if (!row.Cells["VALIDFLAG"].Value.ToString().Equals("有效"))
  290. {
  291. row.Appearance.ForeColor = Color.Red;
  292. }
  293. else
  294. {
  295. row.Appearance.ForeColor = Color.Black;
  296. }
  297. }
  298. }
  299. private void doLink() //关联函数
  300. {
  301. UltraGridRow ugr = ultraGrid1.ActiveRow;
  302. this.ultraGrid2.UpdateData();
  303. int ischeck = 0;
  304. foreach (UltraGridRow row in ultraGrid2.Rows)
  305. {
  306. if (row.Cells["CHK"].Value.ToString().ToUpper() == "TRUE")
  307. {
  308. ischeck += 1;
  309. }
  310. }
  311. if (ischeck == 0)
  312. {
  313. MessageBox.Show("请选择取样要求进行关联!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  314. return;
  315. }
  316. if (ultraGrid1.ActiveRow.GetValue("STD_CODE_TEST") == "")
  317. {
  318. MessageUtil.ShowWarning("请选择试验标准!");
  319. ultraGrid1.ActiveRow.SetCellActive("STD_NAME_TEST");
  320. return;
  321. }
  322. if (MessageBox.Show("是否确认关联?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
  323. {
  324. return;
  325. }
  326. List<string> list = new List<string>();
  327. string sic = "";
  328. string phyCodeMin = "";
  329. string itemCodeF = "";
  330. string itemCodeC = "";
  331. string itemCodeW = "";
  332. foreach (UltraGridRow row in ultraGrid2.Rows)
  333. {
  334. if (row.Cells["CHK"].Value.ToString().ToUpper() == "TRUE")
  335. {
  336. ComMscPhySampleEntity phySampleEntity = new ComMscPhySampleEntity();
  337. phySampleEntity.Pic = ugr.GetValue("PIC");
  338. phySampleEntity.PhyCodeMin = ugr.GetValue("PHY_CODE_MIN");
  339. phySampleEntity.PhyNameMin = ugr.GetValue("PHY_NAME_MIN");
  340. phySampleEntity.Sic = row.GetValue("SIC");
  341. sic = row.GetValue("SIC");
  342. phyCodeMin = ugr.GetValue("PHY_CODE_MIN");
  343. itemCodeF = ugr.GetValue("ITEM_CODE_F");
  344. itemCodeC = ugr.GetValue("ITEM_CODE_C");
  345. itemCodeW = ugr.GetValue("ITEM_CODE_W");
  346. phySampleEntity.CreateName = this.UserInfo.GetUserName();
  347. phySampleEntity.Memo = row.GetValue("MEMO");
  348. phySampleEntity.StdCodeTest = ugr.GetValue("STD_CODE_TEST");
  349. phySampleEntity.StdNameTest = ugr.GetValue("STD_NAME_TEST");
  350. phySampleEntity.ItemCodeC = ugr.GetValue("ITEM_CODE_C");
  351. phySampleEntity.ItemCodeF = ugr.GetValue("ITEM_CODE_F");
  352. phySampleEntity.ItemCodeW = ugr.GetValue("ITEM_CODE_W");
  353. phySampleEntity.ItemNameC = ugr.GetValue("ITEM_NAME_C");
  354. phySampleEntity.ItemNameF = ugr.GetValue("ITEM_NAME_F");
  355. phySampleEntity.ItemNameW = ugr.GetValue("ITEM_NAME_W");
  356. phySampleEntity.SampleKey = phySampleEntity.PhyCodeMin;
  357. if (phySampleEntity.SampleKey == "")
  358. {
  359. phySampleEntity.SampleKey = phySampleEntity.ItemCodeF;
  360. }
  361. else
  362. {
  363. if (phySampleEntity.ItemCodeF != "")
  364. phySampleEntity.SampleKey = phySampleEntity.SampleKey + "_" + phySampleEntity.ItemCodeF;
  365. }
  366. if (phySampleEntity.SampleKey == "")
  367. {
  368. phySampleEntity.SampleKey = phySampleEntity.ItemCodeW;
  369. }
  370. else
  371. {
  372. if (phySampleEntity.ItemCodeW != "")
  373. phySampleEntity.SampleKey = phySampleEntity.SampleKey + "_" + phySampleEntity.ItemCodeW;
  374. }
  375. if (phySampleEntity.SampleKey == "")
  376. {
  377. phySampleEntity.SampleKey = phySampleEntity.ItemCodeC;
  378. }
  379. else
  380. {
  381. if (phySampleEntity.ItemCodeC != "")
  382. phySampleEntity.SampleKey = phySampleEntity.SampleKey + "_" + phySampleEntity.ItemCodeC;
  383. }
  384. phySampleEntity.SampleKeyDesc = phySampleEntity.PhyNameMin;
  385. if (phySampleEntity.SampleKeyDesc == "")
  386. {
  387. phySampleEntity.SampleKeyDesc = phySampleEntity.ItemNameF;
  388. }
  389. else
  390. {
  391. if (phySampleEntity.ItemNameF != "")
  392. phySampleEntity.SampleKeyDesc = phySampleEntity.SampleKeyDesc + "_" + phySampleEntity.ItemNameF;
  393. }
  394. if (phySampleEntity.SampleKeyDesc == "")
  395. {
  396. phySampleEntity.SampleKeyDesc = phySampleEntity.ItemNameW;
  397. }
  398. else
  399. {
  400. if (phySampleEntity.ItemNameW != "")
  401. phySampleEntity.SampleKeyDesc = phySampleEntity.SampleKeyDesc + "_" + phySampleEntity.ItemNameW;
  402. }
  403. if (phySampleEntity.SampleKeyDesc == "")
  404. {
  405. phySampleEntity.SampleKeyDesc = phySampleEntity.ItemNameC;
  406. }
  407. else
  408. {
  409. if (phySampleEntity.ItemNameC != "")
  410. phySampleEntity.SampleKeyDesc = phySampleEntity.SampleKeyDesc + "_" + phySampleEntity.ItemNameC;
  411. }
  412. if (phySampleEntity.SampleKey == "")//为空时等于下划线, 数据库不能为空
  413. {
  414. phySampleEntity.SampleKey = "_";
  415. }
  416. list.Add(JsonConvert.SerializeObject(phySampleEntity));
  417. }
  418. }
  419. List<string> list2 = new List<string>();
  420. var rows = _splineCtrl.UltraGrid1.Rows.AsQueryable().Where(a => a.GetValue("Chk2") == "True");
  421. foreach (var row in rows)
  422. {
  423. ComMscPhySpline2Entity splineEntity = new ComMscPhySpline2Entity();
  424. splineEntity.CreateName = this.UserInfo.GetUserName();
  425. splineEntity.StdCodeTest = ugr.GetValue("STD_CODE_TEST");
  426. splineEntity.StdNameTest = ugr.GetValue("STD_NAME_TEST");
  427. splineEntity.PhyCodeMin = ugr.GetValue("PHY_CODE_MIN");
  428. splineEntity.PhyNameMin = ugr.GetValue("PHY_NAME_MIN");
  429. splineEntity.Eic = row.GetValue("Eic");
  430. splineEntity.Memo = row.GetValue("Memo");
  431. splineEntity.ItemCodeC = ugr.GetValue("ITEM_CODE_C");
  432. splineEntity.ItemCodeF = ugr.GetValue("ITEM_CODE_F");
  433. splineEntity.ItemCodeW = ugr.GetValue("ITEM_CODE_W");
  434. splineEntity.ItemNameC = ugr.GetValue("ITEM_NAME_C");
  435. splineEntity.ItemNameF = ugr.GetValue("ITEM_NAME_F");
  436. splineEntity.ItemNameW = ugr.GetValue("ITEM_NAME_W");
  437. splineEntity.SampleKey = splineEntity.ItemCodeF;
  438. if (splineEntity.SampleKey == "")
  439. {
  440. splineEntity.SampleKey = splineEntity.ItemCodeW;
  441. }
  442. else
  443. {
  444. if (splineEntity.ItemCodeW != "")
  445. splineEntity.SampleKey = splineEntity.SampleKey + "_" + splineEntity.ItemCodeW;
  446. }
  447. if (splineEntity.SampleKey == "")
  448. {
  449. splineEntity.SampleKey = splineEntity.ItemCodeC;
  450. }
  451. else
  452. {
  453. if (splineEntity.ItemCodeC != "")
  454. splineEntity.SampleKey = splineEntity.SampleKey + "_" + splineEntity.ItemCodeC;
  455. }
  456. splineEntity.SampleKeyDesc = splineEntity.ItemNameF;
  457. if (splineEntity.SampleKeyDesc == "")
  458. {
  459. splineEntity.SampleKeyDesc = splineEntity.ItemNameW;
  460. }
  461. else
  462. {
  463. if (splineEntity.ItemNameW != "")
  464. splineEntity.SampleKeyDesc = splineEntity.SampleKeyDesc + "_" + splineEntity.ItemNameW;
  465. }
  466. if (splineEntity.SampleKeyDesc == "")
  467. {
  468. splineEntity.SampleKeyDesc = splineEntity.ItemNameC;
  469. }
  470. else
  471. {
  472. if (splineEntity.ItemNameC != "")
  473. splineEntity.SampleKeyDesc = splineEntity.SampleKeyDesc + "_" + splineEntity.ItemNameC;
  474. }
  475. if (splineEntity.SampleKey == "")//为空时等于下划线, 数据库不能为空
  476. {
  477. splineEntity.SampleKey = "_";
  478. }
  479. list2.Add(JsonConvert.SerializeObject(splineEntity));
  480. }
  481. string[] eics = _splineCtrl.UltraGrid1.Rows.Select(a => a.GetValue("EIC")).ToArray();
  482. int count = ServerHelper.SetData("com.steering.pss.qcm.CorePhySample.Link",
  483. new Object[] { list, list2, ugr.GetValue("PIC"), ugr.GetValue("PHY_CODE_MIN"),
  484. ugr.GetValue("ITEM_CODE_F"), ugr.GetValue("ITEM_CODE_C"), ugr.GetValue("ITEM_CODE_W"),
  485. ugr.GetValue("STD_CODE_TEST"), eics}, this.Ob);
  486. if (count > 0)
  487. {
  488. MessageUtil.ShowTips("关联成功!");
  489. InitGrid1(dt);
  490. var pRow = ultraGrid1.Rows.Where(a => a.GetValue("PHY_CODE_MIN") == phyCodeMin &&
  491. a.GetValue("ITEM_CODE_F") == itemCodeF && a.GetValue("ITEM_CODE_C") == itemCodeC &&
  492. a.GetValue("ITEM_CODE_W") == itemCodeW).FirstOrDefault();
  493. if (pRow != null)
  494. {
  495. pRow.Activate();
  496. }
  497. var row = ultraGrid2.Rows.Where(a => a.GetValue("SIC") == sic).FirstOrDefault();
  498. if (row != null)
  499. {
  500. row.Activate();
  501. }
  502. }
  503. }
  504. private void SetEic()
  505. {
  506. var row = ultraGrid1.ActiveRow;
  507. if (row == null) return;
  508. if (MessageUtil.ShowYesNoAndQuestion("是否确认设定试样码?") == System.Windows.Forms.DialogResult.No)
  509. {
  510. return;
  511. }
  512. string setEic = "";
  513. var rowSetEic = _splineCtrl.UltraGrid1.Rows.Where(a => a.GetValue("Chk3") == "True").FirstOrDefault();
  514. if (rowSetEic != null)
  515. {
  516. setEic = rowSetEic.GetValue("Eic");
  517. }
  518. ServerHelper.SetData("com.steering.pss.qcm.CorePhySample.setEic", new object[]{
  519. ordLnPk, row.GetValue("PHY_CODE_MIN"), row.GetValue("ITEM_CODE_F"), row.GetValue("ITEM_CODE_C"),
  520. row.GetValue("ITEM_CODE_W"), setEic}, Ob);
  521. MessageUtil.ShowTips("设定成功!");
  522. }
  523. private DataRow GetComBaseStdByPk(string stdCode)
  524. {
  525. DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreProductManage.getBaseStdByPk",
  526. new object[] { stdCode }, Ob);
  527. if (dt.Rows.Count > 0)
  528. {
  529. return dt.Rows[0];
  530. }
  531. else
  532. {
  533. return null;
  534. }
  535. }
  536. private void ultraToolbarsManager1_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
  537. {
  538. if (e.Tool.Key == "ButtonTool1") //关联
  539. {
  540. doLink();
  541. }
  542. else if (e.Tool.Key == "ButtonTool3") //关闭
  543. {
  544. this.Close();
  545. }
  546. else if (e.Tool.Key == "取样要求维护")
  547. {
  548. UltraGridRow ugr = this.ultraGrid1.ActiveRow;
  549. try
  550. {
  551. this.Cursor = Cursors.WaitCursor;
  552. FrmBaseSample fbs = new FrmBaseSample();
  553. fbs.Ob = this._ob; //ob对象
  554. fbs.CustomInfo = this.CustomInfo;
  555. fbs.Phycode = ugr.Cells["PHY_CODE_MIN"].Value.ToString(); //取样码
  556. fbs.Phydesc = ugr.Cells["PHY_NAME_MIN"].Value.ToString(); //取样码描述
  557. fbs.Stdcode = ugr.Cells["STD_CODE"].Value.ToString(); //标准代码
  558. fbs.Stddesc = ugr.Cells["STD_NAME"].Value.ToString(); //标准名称
  559. fbs.Load += new EventHandler((a, b) =>
  560. {
  561. this.Cursor = Cursors.Default;
  562. });
  563. fbs.ShowDialog();
  564. QueryPhyDown();
  565. }
  566. finally
  567. {
  568. this.Cursor = Cursors.Default;
  569. }
  570. }
  571. else if (e.Tool.Key == "试样要求维护")
  572. {
  573. DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CorePhySample.getSplineUnit",
  574. new object[] { }, Ob);
  575. if (dt.Rows.Count > 0 && dt.Rows[0]["DEPARTID"].ToString() != UserInfo.GetDeptid() && UserInfo.GetUserID() != "admin")
  576. {
  577. MessageUtil.ShowWarning("只有" + dt.Rows[0]["DEPARTNAME"].ToString() + "的成员才有权限维护!");
  578. return;
  579. }
  580. string phyNameMin = this.ultraGrid1.ActiveRow.Cells["PHY_NAME_MIN"].Value.ToString();
  581. ComBaseSplineFrm splineFrm = new ComBaseSplineFrm(Ob, phyNameMin, "FrmPhySamplePopup");
  582. splineFrm.ShowDialog();
  583. QueryPhyDown();
  584. }
  585. else if (e.Tool.Key == "确认")
  586. {
  587. this.DialogResult = System.Windows.Forms.DialogResult.OK;
  588. }
  589. else if (e.Tool.Key == "设定试样码")
  590. {
  591. //DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CorePhySample.getSplineUnit",
  592. // new object[] { }, Ob);
  593. //if (dt.Rows.Count > 0 && dt.Rows[0]["DEPARTID"].ToString() != UserInfo.GetDeptid() && UserInfo.GetUserID() != "admin")
  594. //{
  595. // MessageUtil.ShowWarning("只有" + dt.Rows[0]["DEPARTNAME"].ToString() + "的成员才有权限维护!");
  596. // return;
  597. //}
  598. SetEic();
  599. }
  600. }
  601. private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
  602. {
  603. try
  604. {
  605. this.Cursor = Cursors.WaitCursor;
  606. var ugr = ultraGrid1.ActiveRow;
  607. if (ugr != null)
  608. {
  609. QueryPhyDown();
  610. }
  611. }
  612. finally
  613. {
  614. this.Cursor = Cursors.Default;
  615. }
  616. // var rows = _splineCtrl.UltraGrid1.Rows.AsQueryable().Where(a=>a.GetValue(""));;
  617. //foreach()
  618. }
  619. private void _splineCtrl_AfterRowActivate(object sender, EventArgs e)
  620. {
  621. var splineUgr = _splineCtrl.UltraGrid1.ActiveRow;
  622. var phyUgr = ultraGrid1.ActiveRow;
  623. _splineCCtrl.Query2(splineUgr.GetValue("Eic"));
  624. }
  625. private void ultraTextEditor1_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
  626. {
  627. if (ultraTabControl1.SelectedTab.Text == "试样要求")
  628. {
  629. MessageUtil.ShowWarning("只有在维护取样要求时,才能选择试验标准!");
  630. return;
  631. }
  632. this.Cursor = Cursors.WaitCursor;
  633. string phyCodeMin = ultraGrid1.ActiveRow.GetValue("PHY_CODE_MIN");
  634. DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CorePhySample.QueryStdRTest",
  635. new object[] { phyCodeMin }, Ob);
  636. dt.Columns["STD_NAME_TEST"].Caption = "试验标准";
  637. dt.Columns["MEMO"].Caption = "备注";
  638. BaseInfoPopup baseInfoPopup = new BaseInfoPopup(dt, "STD_NAME_TEST", "STD_CODE_TEST");
  639. baseInfoPopup.LabelTextBox1.Caption = "试验标准";
  640. baseInfoPopup.Shown += new EventHandler((a, b) =>
  641. {
  642. var actRow = baseInfoPopup.UltraGrid1.Rows.AsQueryable().Where(
  643. c => c.GetValue("STD_CODE_TEST") == ultraGrid1.ActiveRow.GetValue("STD_CODE_TEST")).FirstOrDefault();
  644. if (actRow != null)
  645. {
  646. actRow.Activate();
  647. }
  648. });
  649. this.Cursor = Cursors.Default;
  650. if (baseInfoPopup.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  651. {
  652. ultraGrid1.ActiveRow.SetValue("STD_NAME_TEST", baseInfoPopup.ChoicedRow.GetValue("STD_NAME_TEST"));
  653. ultraGrid1.ActiveRow.SetValue("STD_CODE_TEST", baseInfoPopup.ChoicedRow.GetValue("STD_CODE_TEST"));
  654. ultraGrid1_AfterRowActivate(null, null);
  655. }
  656. }
  657. private void ultraGrid2_CellChange(object sender, CellEventArgs e)
  658. {
  659. ultraGrid2.UpdateData();
  660. }
  661. private void ultraTabControl1_SelectedTabChanged(object sender, Infragistics.Win.UltraWinTabControl.SelectedTabChangedEventArgs e)
  662. {
  663. var colums = ultraGrid1.DisplayLayout.Bands[0].Columns.Cast<UltraGridColumn>().Where(
  664. a => a.Key == "STD_NAME" || a.Key == "PRODUCNAME" || a.Key == "STEELNAME"
  665. || a.Key == "USE_DESC" || a.Key == "ITEM_NAME_W");
  666. if (e.Tab.Text == "试样要求")
  667. {
  668. foreach (var colum in colums)
  669. {
  670. colum.Hidden = true;
  671. }
  672. ultraToolbarsManager1.Tools["ButtonTool1"].SharedProps.Visible = false;
  673. ultraToolbarsManager1.Tools["取样要求维护"].SharedProps.Visible = false;
  674. ultraToolbarsManager1.Tools["试样要求维护"].SharedProps.Visible = true;
  675. ultraToolbarsManager1.Tools["设定试样码"].SharedProps.Visible = true;
  676. }
  677. else
  678. {
  679. foreach (var colum in colums)
  680. {
  681. colum.Hidden = false;
  682. }
  683. ultraToolbarsManager1.Tools["ButtonTool1"].SharedProps.Visible = true;
  684. ultraToolbarsManager1.Tools["取样要求维护"].SharedProps.Visible = true;
  685. ultraToolbarsManager1.Tools["试样要求维护"].SharedProps.Visible = false;
  686. ultraToolbarsManager1.Tools["设定试样码"].SharedProps.Visible = false;
  687. }
  688. }
  689. }
  690. }