FrmPhyOutsourcing.cs 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740
  1. using Core.Mes.Client.Comm.Control;
  2. using Core.Mes.Client.Comm.Format;
  3. using Core.Mes.Client.Comm.Tool;
  4. using CoreFS.CA06;
  5. using Infragistics.Win.UltraWinGrid;
  6. using System;
  7. using System.Collections;
  8. using System.Collections.Generic;
  9. using System.ComponentModel;
  10. using System.Data;
  11. using System.Drawing;
  12. using System.IO;
  13. using System.Linq;
  14. using System.Reflection;
  15. using System.Text;
  16. using System.Windows.Forms;
  17. using Infragistics.Win;
  18. using Core.StlMes.Client.Lims.Port.数据管理.实体类;
  19. namespace Core.StlMes.Client.Lims.Port
  20. {
  21. public partial class FrmPhyOutsourcing : FrmBase
  22. {
  23. public FrmPhyOutsourcing()
  24. {
  25. InitializeComponent();
  26. }
  27. private void FrmPhyOutsourcing_Load(object sender, EventArgs e)
  28. {
  29. DateTime now = DateTime.Now;
  30. DateTime dt1 = new DateTime(now.Year, now.Month, 1);//当月第一天
  31. DateTime dt2 = dt1.AddMonths(1).AddDays(-1);//当月最后一天
  32. this.RegStartTime.Value = DateTime.Parse(dt1.ToString("yyyy-MM-dd") + " 00:00:00");
  33. this.RegEndTime.Value = DateTime.Parse(dt2.ToString("yyyy-MM-dd") + " 23:59:59");
  34. EntityHelper.ShowGridCaption<YdmBcInlistEntity>(ultraGrid1.DisplayLayout.Bands[0]);
  35. EntityHelper.ShowGridCaption<QcmJhyPhyresultEntity>(ultraGrid2.DisplayLayout.Bands[0]);
  36. EntityHelper.ShowGridCaption<QcmZgJugdeApplyEntity>(ultraGrid3.DisplayLayout.Bands[0]);
  37. initPhyCodeM();
  38. }
  39. /// <summary>
  40. /// 加载试样组\检验项
  41. /// </summary>
  42. private void initPhyCodeM()
  43. {
  44. DataTable dsPhyCodeM = PublicServer.GetData("com.steering.mes.port.vrp.FrmPhyOutsourcing.doQueryPhyCodeM", new object[] { }, ob);
  45. if (dsPhyCodeM.Rows.Count > 0)
  46. {
  47. ultraComboEditor1.DataSource = dsPhyCodeM;
  48. ultraComboEditor1.ValueMember = "PHY_CODE";
  49. }
  50. doQueryPhyF();
  51. doQueryPhyS();
  52. doQueryPhyW();
  53. }
  54. /// <summary>
  55. /// 重写基类方法
  56. /// </summary>
  57. /// <param name="sender"></param>
  58. /// <param name="ToolbarKey"></param>
  59. public override void ToolBar_Click(object sender, string ToolbarKey)
  60. {
  61. switch (ToolbarKey)
  62. {
  63. case "Query":
  64. doQueryData();
  65. break;
  66. case "Add":
  67. doAdd();
  68. break;
  69. case"AddTesting":
  70. doAddTesting();
  71. break;
  72. case"Update":
  73. doUpdate();
  74. break;
  75. case "Delete":
  76. doDelete();
  77. break;
  78. case "Cope":
  79. doCope();
  80. break;
  81. case"Export":
  82. exportData();
  83. break;
  84. case "Close":
  85. close();
  86. break;
  87. }
  88. }
  89. /// <summary>
  90. /// 导出
  91. /// </summary>
  92. private void exportData()
  93. {
  94. GridHelper.ulGridToExcel(ultraGrid2, "外购管成品成分导出");
  95. }
  96. /// <summary>
  97. /// 查询
  98. /// </summary>
  99. private void doQueryData()
  100. {
  101. string stoveNo = "";
  102. string judgeNo = "";
  103. string strRegStart = "";
  104. string strRegEnd = "";
  105. if (this.chkFurnace.Checked && this.txtFurnace.Text.Trim() != "")
  106. {
  107. stoveNo = this.txtFurnace.Text.Trim();
  108. }
  109. if(this.chkJudgeNo.Checked && this.txtJudgeNo.Text.Trim() != "")
  110. {
  111. judgeNo = this.txtJudgeNo.Text.Trim();
  112. }
  113. ArrayList parm = new ArrayList();
  114. if (chkRegTime.Checked)
  115. {
  116. strRegStart = RegStartTime.Value.ToString();
  117. strRegEnd = RegEndTime.Value.ToString();
  118. }
  119. parm.Add(stoveNo);
  120. parm.Add(judgeNo);
  121. parm.Add(strRegStart);
  122. parm.Add(strRegEnd);
  123. List<YdmBcInlistEntity> listSource = EntityHelper.GetData<YdmBcInlistEntity>(
  124. "com.steering.mes.port.vrp.FrmPhyOutsourcing.doQueryData", new object[] { parm }, this.ob);
  125. ydmBcInlistEntityBindingSource.DataSource = listSource;
  126. }
  127. /// <summary>
  128. /// 查询理化数据
  129. /// </summary>
  130. private void doQueryChemical(string judgeNo,string batchNo,string ordLnDlyPk)
  131. {
  132. List<QcmJhyPhyresultEntity> listSource = EntityHelper.GetData<QcmJhyPhyresultEntity>(
  133. "com.steering.mes.port.vrp.FrmPhyOutsourcing.doQueryPhy", new object[] { judgeNo,batchNo,ordLnDlyPk }, this.ob);
  134. bool isnull = false;
  135. if (listSource.Count() == 0)
  136. {
  137. isnull = true;
  138. listSource = new List<QcmJhyPhyresultEntity>() { new QcmJhyPhyresultEntity() };
  139. }
  140. qcmJhyPhyresultEntityBindingSource.DataSource = listSource;
  141. foreach (UltraGridRow row in ultraGrid2.Rows)
  142. {
  143. row.Cells["CHK"].Value = "True";
  144. }
  145. //if (!isnull)
  146. //{
  147. // ultraGrid2.Rows[0].Cells["CHK"].Value = "True";
  148. //}
  149. }
  150. /// <summary>
  151. /// 新增
  152. /// </summary>
  153. private void doAdd()
  154. {
  155. if (tabMain.SelectedTab.Index == 0)
  156. {
  157. this.ultraGrid2.UpdateData();
  158. UltraGridRow uRow = this.ultraGrid1.ActiveRow;
  159. if (uRow == null)
  160. {
  161. return;
  162. }
  163. IQueryable<UltraGridRow> checkMagRows = this.ultraGrid2.Rows.AsQueryable().Where(" CHK = 'True'");
  164. if (checkMagRows.Count() == 0)
  165. {
  166. MessageUtil.ShowTips("请选择录入的理化性能数据!");
  167. return;
  168. }
  169. YdmBcInlistEntity ydmTity = (YdmBcInlistEntity)uRow.ListObject;
  170. string ydmBcEntity = JSONFormat.Format(ydmTity);
  171. ArrayList parm = new ArrayList();
  172. List<List<string>> parmList = new List<List<string>>();
  173. foreach (UltraGridRow row in checkMagRows)
  174. {
  175. if (row.Cells["SampleNo"].Text.Trim().Equals("") || row.Cells["PhyCodeMin"].Text.Trim().Equals("") || row.Cells["PhyCode"].Text.Trim().Equals(""))
  176. {
  177. MessageUtil.ShowTips("试样号、式样组、检验项不能为空!");
  178. return;
  179. }
  180. QcmJhyPhyresultEntity entity = (QcmJhyPhyresultEntity)row.ListObject;
  181. entity.PhyCodeMin = row.Cells["PhyCodeMin"].Value.ToString();
  182. entity.PhyNameMin = row.Cells["PhyCodeMin"].Text.Trim();
  183. entity.PhyCode = row.Cells["PhyCode"].Value.ToString();
  184. entity.PhyName = row.Cells["PhyCode"].Text;
  185. entity.ItemCodeF = row.Cells["ItemCodeF"].Value.ToString();
  186. entity.ItemNameF = row.Cells["ItemCodeF"].Text;
  187. entity.ItemCodeW = row.Cells["ItemCodeW"].Value.ToString();
  188. entity.ItemNameW = row.Cells["ItemCodeW"].Text;
  189. entity.ItemCodeS = row.Cells["ItemCodeS"].Value.ToString();
  190. entity.ItemNameS = row.Cells["ItemCodeS"].Text;
  191. entity.IsGood = row.Cells["IsGood"].Value.ToString();
  192. entity.IsDefect = row.Cells["IsDefect"].Value.ToString();
  193. entity.ItemCodeW1 = row.Cells["ItemCodeW1"].Value.ToString();
  194. entity.ItemNameW1 = row.Cells["ItemCodeW1"].Text.ToString();
  195. entity.ItemCodeS1 = row.Cells["ItemCodeS1"].Value.ToString();
  196. entity.ItemNameS1 = row.Cells["ItemCodeS1"].Text.ToString();
  197. if (entity.PhyCodeMin.Equals("C0002") || entity.PhyCodeMin.Equals("C0074") || entity.PhyCodeMin.Equals("C0126") || entity.PhyCodeMin.Equals("C0127") || entity.PhyCodeMin.Equals("C0129"))
  198. {
  199. }
  200. string qcmEntity = JSONFormat.Format(entity);
  201. parm.Add(qcmEntity);
  202. List<string> ss = new List<string>();
  203. ss.Add(row.Cells["SampleNo"].Text);
  204. ss.Add(row.Cells["PhyCodeMin"].Value.ToString());
  205. ss.Add(row.Cells["PhyCodeMin"].Text);
  206. parmList.Add(ss);
  207. }
  208. if (MessageUtil.ShowYesNoAndQuestion("是否新增该理化性能数据?") == DialogResult.No)
  209. {
  210. return;
  211. }
  212. List<List<string>> batchList = parmList.GroupBy(p => p[0]+ "-"+ p[1]).Select(p => p.FirstOrDefault()
  213. ).ToList();
  214. CoreClientParam ccp = new CoreClientParam();
  215. ccp.ServerName = "com.steering.mes.port.vrp.FrmPhyOutsourcing";
  216. ccp.MethodName = "doAdd";
  217. ccp.ServerParams = new object[] { parm, ydmBcEntity, UserInfo.GetUserName(), batchList };
  218. ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  219. if (ccp.ReturnCode != -1)
  220. {
  221. if (ccp.ReturnInfo.Equals("新增成功!"))
  222. {
  223. doQueryData();
  224. MessageUtil.ShowTips(ccp.ReturnInfo);
  225. }
  226. else
  227. {
  228. MessageUtil.ShowTips(ccp.ReturnInfo);
  229. }
  230. }
  231. }
  232. }
  233. /// <summary>
  234. /// 增加探伤信息
  235. /// </summary>
  236. private void doAddTesting()
  237. {
  238. this.ultraGrid3.UpdateData();
  239. IQueryable<UltraGridRow> checkMagRows = this.ultraGrid3.Rows.AsQueryable().Where(" CHK = 'True'");
  240. if (checkMagRows.Count() == 0)
  241. {
  242. MessageUtil.ShowTips("请选择需要保存的探伤信息!");
  243. return;
  244. }
  245. ArrayList parmList = new ArrayList();
  246. foreach(UltraGridRow row in checkMagRows)
  247. {
  248. QcmZgJugdeApplyEntity qcmTity = (QcmZgJugdeApplyEntity)row.ListObject;
  249. string qcmEntity = JSONFormat.Format(qcmTity);
  250. parmList.Add(qcmEntity);
  251. }
  252. CoreClientParam ccp = new CoreClientParam();
  253. ccp.ServerName = "com.steering.mes.port.vrp.FrmPhyOutsourcing";
  254. ccp.MethodName = "doAddTesting";
  255. ccp.ServerParams = new object[] { parmList };
  256. ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  257. if (ccp.ReturnCode != -1)
  258. {
  259. if (ccp.ReturnInfo.Equals("保存成功!"))
  260. {
  261. doQueryData();
  262. MessageUtil.ShowTips(ccp.ReturnInfo);
  263. }
  264. else
  265. {
  266. MessageUtil.ShowTips(ccp.ReturnInfo);
  267. }
  268. }
  269. }
  270. /// <summary>
  271. /// 修改
  272. /// </summary>
  273. private void doUpdate()
  274. {
  275. this.ultraGrid2.UpdateData();
  276. this.ultraGrid1.UpdateData();
  277. IQueryable<UltraGridRow> checkMagRows = this.ultraGrid2.Rows.AsQueryable().Where(" CHK = 'True'");
  278. if (checkMagRows.Count() == 0)
  279. {
  280. MessageUtil.ShowTips("请选择需要修改的理化性能数据!");
  281. return;
  282. }
  283. UltraGridRow row = this.ultraGrid1.ActiveRow;
  284. YdmBcInlistEntity ydmBcEntity = (YdmBcInlistEntity)row.ListObject;
  285. string ydmEntity = JSONFormat.Format(ydmBcEntity);
  286. ArrayList parm = new ArrayList();
  287. foreach(UltraGridRow uRow in checkMagRows)
  288. {
  289. QcmJhyPhyresultEntity entity = (QcmJhyPhyresultEntity)uRow.ListObject;
  290. entity.ItemCodeF = uRow.Cells["ItemCodeF"].Value.ToString();
  291. entity.ItemNameF = uRow.Cells["ItemCodeF"].Text.ToString();
  292. entity.ItemCodeS = uRow.Cells["ItemCodeS"].Value.ToString();
  293. entity.ItemNameS = uRow.Cells["ItemCodeS"].Text.ToString();
  294. entity.ItemCodeW = uRow.Cells["ItemCodeW"].Value.ToString();
  295. entity.ItemNameW = uRow.Cells["ItemCodeW"].Text.ToString();
  296. entity.ItemCodeW1 = uRow.Cells["ItemCodeW1"].Value.ToString();
  297. entity.ItemNameW1 = uRow.Cells["ItemCodeW1"].Text.ToString();
  298. entity.ItemCodeS1 = uRow.Cells["ItemCodeS1"].Value.ToString();
  299. entity.ItemNameS1 = uRow.Cells["ItemCodeS1"].Text.ToString();
  300. string qcmEntity = JSONFormat.Format(entity);
  301. parm.Add(qcmEntity);
  302. }
  303. if (MessageUtil.ShowYesNoAndQuestion("是否修改该理化性能数据?") == DialogResult.No)
  304. {
  305. return;
  306. }
  307. CoreClientParam ccp = new CoreClientParam();
  308. ccp.ServerName = "com.steering.mes.port.vrp.FrmPhyOutsourcing";
  309. ccp.MethodName = "doUpdate";
  310. ccp.ServerParams = new object[] { parm, ydmEntity };
  311. ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  312. if (ccp.ReturnCode != -1)
  313. {
  314. if (ccp.ReturnInfo.Equals("修改成功!"))
  315. {
  316. doQueryData();
  317. MessageUtil.ShowTips(ccp.ReturnInfo);
  318. }
  319. else
  320. {
  321. MessageUtil.ShowTips(ccp.ReturnInfo);
  322. }
  323. }
  324. }
  325. /// <summary>
  326. /// 删除
  327. /// </summary>
  328. private void doDelete()
  329. {
  330. this.ultraGrid2.UpdateData();
  331. this.ultraGrid1.UpdateData();
  332. IQueryable<UltraGridRow> checkMagRows = this.ultraGrid2.Rows.AsQueryable().Where(" CHK = 'True'");
  333. if (checkMagRows.Count() == 0)
  334. {
  335. MessageUtil.ShowTips("请选择需要删除的理化性能数据!");
  336. return;
  337. }
  338. UltraGridRow row = this.ultraGrid1.ActiveRow;
  339. YdmBcInlistEntity ydmBcEntity = (YdmBcInlistEntity)row.ListObject;
  340. string ydmEntity = JSONFormat.Format(ydmBcEntity);
  341. ArrayList parm = new ArrayList();
  342. foreach (UltraGridRow uRow in checkMagRows)
  343. {
  344. QcmJhyPhyresultEntity entity = (QcmJhyPhyresultEntity)uRow.ListObject;
  345. string qcmEntity = JSONFormat.Format(entity);
  346. parm.Add(qcmEntity);
  347. }
  348. if (MessageUtil.ShowYesNoAndQuestion("是否删除该理化性能数据?") == DialogResult.No)
  349. {
  350. return;
  351. }
  352. CoreClientParam ccp = new CoreClientParam();
  353. ccp.ServerName = "com.steering.mes.port.vrp.FrmPhyOutsourcing";
  354. ccp.MethodName = "doDelete";
  355. ccp.ServerParams = new object[] { parm, ydmEntity };
  356. ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  357. if (ccp.ReturnCode != -1)
  358. {
  359. if (ccp.ReturnInfo.Equals("删除成功!"))
  360. {
  361. doQueryData();
  362. MessageUtil.ShowTips(ccp.ReturnInfo);
  363. }
  364. else
  365. {
  366. MessageUtil.ShowTips(ccp.ReturnInfo);
  367. }
  368. }
  369. }
  370. /// <summary>
  371. /// 复制
  372. /// </summary>
  373. private void doCope()
  374. {
  375. if (tabMain.SelectedTab.Index == 0)
  376. {
  377. this.ultraGrid2.UpdateData();
  378. UltraGridRow uRow = this.ultraGrid1.ActiveRow;
  379. if (uRow == null)
  380. {
  381. return;
  382. }
  383. IQueryable<UltraGridRow> checkMagRows = this.ultraGrid2.Rows.AsQueryable().Where(" CHK = 'True'");
  384. if (checkMagRows.Count() == 0)
  385. {
  386. MessageUtil.ShowTips("请选择复制的理化性能数据!");
  387. return;
  388. }
  389. DataTable copyTable = CreateTableByEntity((QcmJhyPhyresultEntity)ultraGrid2.Rows.FirstOrDefault().ListObject);
  390. foreach (UltraGridRow row in checkMagRows)
  391. {
  392. DataRow dr = copyTable.NewRow();
  393. CopyEntityToRow((QcmJhyPhyresultEntity)row.ListObject, dr);
  394. copyTable.Rows.Add(dr);
  395. }
  396. List<QcmJhyPhyresultEntity> data = (List<QcmJhyPhyresultEntity>)qcmJhyPhyresultEntityBindingSource.DataSource;
  397. QcmJhyPhyresultEntity activeFd = null;
  398. foreach (DataRow row in copyTable.Rows)
  399. {
  400. QcmJhyPhyresultEntity fd = new QcmJhyPhyresultEntity();
  401. CopyRowToEntity(row, fd);
  402. data.Add(fd);
  403. activeFd = fd;
  404. }
  405. qcmJhyPhyresultEntityBindingSource.ResetBindings(false);
  406. ultraGrid2.UpdateData();
  407. }
  408. }
  409. private void CopyRowToEntity(DataRow row, QcmJhyPhyresultEntity fdEntity)
  410. {
  411. PropertyInfo[] pros = fdEntity.GetType().GetProperties();
  412. foreach (DataColumn dc in row.Table.Columns)
  413. {
  414. if (dc.ColumnName == "CREATE_TIME") continue;
  415. PropertyInfo pro = fdEntity.GetType().GetProperty(dc.ColumnName);
  416. if (pro != null)
  417. {
  418. pro.SetValue(fdEntity, ConvertDataType(pro.PropertyType, row[dc.ColumnName].ToString()), null);
  419. }
  420. }
  421. }
  422. private void CopyEntityToRow(QcmJhyPhyresultEntity fdEntity, DataRow desRow)
  423. {
  424. PropertyInfo[] pros = fdEntity.GetType().GetProperties();
  425. foreach (PropertyInfo pro in pros)
  426. {
  427. desRow[pro.Name] = pro.GetValue(fdEntity, null);
  428. }
  429. }
  430. private DataTable CreateTableByEntity(QcmJhyPhyresultEntity fdEntity)
  431. {
  432. DataTable dt = new DataTable();
  433. PropertyInfo[] srcPropertyInfos = fdEntity.GetType().GetProperties();
  434. foreach (PropertyInfo srcPropertyInfo in srcPropertyInfos)
  435. {
  436. dt.Columns.Add(srcPropertyInfo.Name);
  437. }
  438. return dt;
  439. }
  440. /// <summary>
  441. /// 关闭
  442. /// </summary>
  443. private void close()
  444. {
  445. this.Close();
  446. }
  447. private void chkFurnace_CheckedChanged(object sender, EventArgs e)
  448. {
  449. this.txtFurnace.Enabled = this.chkFurnace.Checked;
  450. }
  451. private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
  452. {
  453. UltraGridRow uRow = this.ultraGrid1.ActiveRow;
  454. if (uRow == null)
  455. {
  456. return;
  457. }
  458. doQueryChemical(uRow.Cells["JudgeStoveNo"].Text,uRow.Cells["BatchNo"].Text, uRow.Cells["OrdLnDlyPk"].Text);
  459. doQueryQcmApply(uRow.Cells["JudgeStoveNo"].Text, uRow.Cells["BatchNo"].Text);
  460. }
  461. /// <summary>
  462. /// 查询送判信息
  463. /// </summary>
  464. /// <param name="judgeNo"></param>
  465. /// <param name="batchNo"></param>
  466. private void doQueryQcmApply(string judgeNo,string batchNo)
  467. {
  468. List<QcmZgJugdeApplyEntity> listSource = EntityHelper.GetData<QcmZgJugdeApplyEntity>(
  469. "com.steering.mes.port.vrp.FrmPhyOutsourcing.doQueryQcmApply", new object[] { judgeNo, batchNo }, this.ob);
  470. qcmZgJugdeApplyEntityBindingSource.DataSource = listSource;
  471. foreach (UltraGridRow row in ultraGrid3.Rows)
  472. {
  473. row.Cells["CHK"].Value = "True";
  474. }
  475. }
  476. private void ultraGrid2_KeyDown(object sender, KeyEventArgs e)
  477. {
  478. if (e.KeyData == Keys.Right)
  479. {
  480. if (ultraGrid2.ActiveCell.Column.Index + 1== ultraGrid2.DisplayLayout.Bands[0].Columns.Count)
  481. {
  482. return;
  483. }
  484. ultraGrid2.ActiveColScrollRegion.ScrollColIntoView(ultraGrid2.DisplayLayout.Bands[0].Columns[ultraGrid2.ActiveCell.Column.Index + 1], true);
  485. ultraGrid2.PerformAction(UltraGridAction.EnterEditMode);
  486. }
  487. if (e.KeyData == Keys.Left)
  488. {
  489. if (ultraGrid2.ActiveCell.Column.Index - 1 == 0)
  490. {
  491. return;
  492. }
  493. ultraGrid2.ActiveColScrollRegion.ScrollColIntoView(ultraGrid2.DisplayLayout.Bands[0].Columns[ultraGrid2.ActiveCell.Column.Index - 1], true);
  494. ultraGrid2.PerformAction(UltraGridAction.EnterEditMode);
  495. }
  496. }
  497. private void ultraGrid1_InitializeRow(object sender, InitializeRowEventArgs e)
  498. {
  499. YdmBcInlistEntity matGpEntity = e.Row.ListObject as YdmBcInlistEntity;
  500. if (!matGpEntity.ActCount.ToString().Equals("0"))
  501. {
  502. e.Row.RowSelectorAppearance.BackColor = Color.LightGreen;
  503. }
  504. }
  505. private void txtFurnace_KeyDown(object sender, KeyEventArgs e)
  506. {
  507. if (e.KeyValue == 13)
  508. {
  509. doQueryData();
  510. }
  511. }
  512. private void tabMain_SelectedTabChanged(object sender, Infragistics.Win.UltraWinTabControl.SelectedTabChangedEventArgs e)
  513. {
  514. if (toolMenu==null|| toolMenu.Toolbars==null ) return;
  515. if (toolMenu.Toolbars[0].Tools.Exists("Query")) { toolMenu.Toolbars[0].Tools["Query"].InstanceProps.Visible = tabMain.SelectedTab.Index == 0 ? DefaultableBoolean.True : DefaultableBoolean.False; }
  516. if (toolMenu.Toolbars[0].Tools.Exists("Update")) { toolMenu.Toolbars[0].Tools["Update"].InstanceProps.Visible = tabMain.SelectedTab.Index == 0 ? DefaultableBoolean.True : DefaultableBoolean.False; }
  517. if (toolMenu.Toolbars[0].Tools.Exists("Delete")) { toolMenu.Toolbars[0].Tools["Delete"].InstanceProps.Visible = tabMain.SelectedTab.Index == 0 ? DefaultableBoolean.True : DefaultableBoolean.False; }
  518. if (toolMenu.Toolbars[0].Tools.Exists("Export")) { toolMenu.Toolbars[0].Tools["Export"].InstanceProps.Visible = tabMain.SelectedTab.Index == 0 ? DefaultableBoolean.True : DefaultableBoolean.False; }
  519. }
  520. private void chkRegTime_CheckedChanged(object sender, EventArgs e)
  521. {
  522. this.RegStartTime.Enabled = this.RegEndTime.Enabled = this.chkRegTime.Checked;
  523. }
  524. private void chkJudgeNo_CheckedChanged(object sender, EventArgs e)
  525. {
  526. this.txtJudgeNo.Enabled = this.chkJudgeNo.Checked;
  527. }
  528. private void ultraGrid2_CellChange(object sender, CellEventArgs e)
  529. {
  530. this.ultraGrid2.UpdateData();
  531. int m = 0;
  532. if (e.Cell.Column.Key == "PhyCodeMin")
  533. {
  534. ultraGrid2.ActiveRow.Cells["PhyCode"].Value = "";
  535. var list1 = new ValueList();
  536. DataTable ds = PublicServer.GetData("com.steering.mes.port.vrp.FrmPhyOutsourcing.doQueryPhyCodeP", new object[] { e.Cell.Value }, ob);
  537. foreach (DataRow row in ds.Rows)
  538. {
  539. list1.ValueListItems.Add(row["PHY_CODE"].ToString(), row["PHY_NAME"].ToString());
  540. }
  541. ultraGrid2.ActiveRow.Cells["PhyCode"].ValueList = list1;
  542. }
  543. }
  544. /// <summary>
  545. /// 加载尺寸
  546. /// </summary>
  547. /// <param name="p"></param>
  548. private void doQueryPhyS()
  549. {
  550. ultraComboEditor5.DataSource = null;
  551. DataTable ds = PublicServer.GetData("com.steering.mes.port.vrp.FrmPhyOutsourcing.doQueryItemC", new object[] { }, ob);
  552. ultraComboEditor5.DataSource = ds;
  553. ultraComboEditor5.ValueMember = "ITEM_CODE_C";
  554. }
  555. /// <summary>
  556. /// 加载方向
  557. /// </summary>
  558. /// <param name="p"></param>
  559. private void doQueryPhyF()
  560. {
  561. ultraComboEditor3.DataSource = null;
  562. DataTable ds = PublicServer.GetData("com.steering.mes.port.vrp.FrmPhyOutsourcing.doQueryItemF", new object[] { }, ob);
  563. ultraComboEditor3.DataSource = ds;
  564. ultraComboEditor3.ValueMember = "ITEM_CODE_F";
  565. }
  566. /// <summary>
  567. /// 加载温度
  568. /// </summary>
  569. private void doQueryPhyW()
  570. {
  571. ultraComboEditor4.DataSource = null;
  572. DataTable ds = PublicServer.GetData("com.steering.mes.port.vrp.FrmPhyOutsourcing.doQueryItemW", new object[] { }, ob);
  573. ultraComboEditor4.DataSource = ds;
  574. ultraComboEditor4.ValueMember = "ITEM_CODE_W";
  575. }
  576. private void ultraGrid2_InitializeRow(object sender, InitializeRowEventArgs e)
  577. {
  578. var list1 = new ValueList();
  579. DataTable ds = PublicServer.GetData("com.steering.mes.port.vrp.FrmPhyOutsourcing.doQueryPhyCodeP", new object[] {e.Row.Cells["PhyCodeMin"].Value}, ob);
  580. foreach (DataRow row in ds.Rows)
  581. {
  582. list1.ValueListItems.Add(row["PHY_CODE"].ToString(), row["PHY_NAME"].ToString());
  583. }
  584. e.Row.Cells["PhyCode"].ValueList = list1;
  585. }
  586. private object ConvertDataType(Type type, object objValue)
  587. {
  588. if (type == typeof(bool))
  589. {
  590. bool result;
  591. if (bool.TryParse(objValue.ToString(), out result))
  592. {
  593. return result;
  594. }
  595. else
  596. {
  597. return false;
  598. }
  599. }
  600. else if (type == typeof(bool?))
  601. {
  602. bool result;
  603. if (bool.TryParse(objValue.ToString(), out result))
  604. {
  605. return result;
  606. }
  607. else
  608. {
  609. return null;
  610. }
  611. }
  612. else if (type == typeof(int?))
  613. {
  614. if (objValue.ToString2() == "")
  615. {
  616. return null;
  617. }
  618. else
  619. {
  620. return int.Parse(objValue.ToString());
  621. }
  622. }
  623. else if (type == typeof(long?))
  624. {
  625. if (objValue.ToString2() == "")
  626. {
  627. return null;
  628. }
  629. else
  630. {
  631. return long.Parse(objValue.ToString());
  632. }
  633. }
  634. else if (type == typeof(short?))
  635. {
  636. if (objValue.ToString2() == "")
  637. {
  638. return null;
  639. }
  640. else
  641. {
  642. return short.Parse(objValue.ToString());
  643. }
  644. }
  645. else if (type == typeof(float?))
  646. {
  647. if (objValue.ToString2() == "")
  648. {
  649. return null;
  650. }
  651. else
  652. {
  653. return float.Parse(objValue.ToString());
  654. }
  655. }
  656. else if (type == typeof(double?))
  657. {
  658. if (objValue.ToString2() == "")
  659. {
  660. return null;
  661. }
  662. else
  663. {
  664. return double.Parse(objValue.ToString());
  665. }
  666. }
  667. else if (type == typeof(decimal?))
  668. {
  669. if (objValue.ToString2() == "")
  670. {
  671. return null;
  672. }
  673. else
  674. {
  675. return decimal.Parse(objValue.ToString());
  676. }
  677. }
  678. else if (type == typeof(DateTime?))
  679. {
  680. if (objValue.ToString2() == "")
  681. {
  682. return null;
  683. }
  684. else
  685. {
  686. return DateTime.Parse(objValue.ToString());
  687. }
  688. }
  689. else
  690. {
  691. return objValue == null ? "" : objValue.ToString();
  692. }
  693. }
  694. }
  695. }