FrmChooseStandard.cs 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using Core.Mes.Client.Comm.Server;
  10. using Core.Mes.Client.Comm.Tool;
  11. using Core.StlMes.Client.Mcp.Control.Entity;
  12. using CoreFS.CA06;
  13. using Infragistics.Win;
  14. using Infragistics.Win.UltraWinEditors;
  15. using Infragistics.Win.UltraWinGrid;
  16. using Infragistics.Win.UltraWinToolbars;
  17. namespace Core.StlMes.Client.Mcp.Control.HeatTreatment
  18. {
  19. public partial class FrmChooseStandard : FrmBase
  20. {
  21. private readonly List<HttReportDefaultEntity> _listDefault;
  22. public FrmChooseStandard(List<HttReportDefaultEntity> listDefault, List<HttCrackDetectionStandardEntity> listProbe, OpeBase Ob)
  23. {
  24. InitializeComponent();
  25. ob = Ob;
  26. _listDefault = listDefault;
  27. listProbe.ForEach(p=>p.Chk = true);
  28. var ProDefault = _listDefault.Where(p => p.ReportColumn.ToUpper() == "STANDARD_NAME").ToList();
  29. if (ProDefault.Any() )
  30. {
  31. DataTable dt;
  32. if (ProDefault[0].DroplistUsed != "")
  33. {
  34. dt =
  35. ServerHelper.GetData(
  36. "com.steering.mes.mcp.heatTreatment.ScrapHelper.doQuery",
  37. new object[] {"4021", ProDefault[0].DroplistUsed.Split(';')}, ob);
  38. }
  39. else
  40. {
  41. dt =
  42. ServerHelper.GetData(
  43. "com.steering.mes.mcp.collarMaterial.ComBaseInfo.getBaseInfo",
  44. new object[] {"4021"}, ob);
  45. }
  46. Standard.DataSource = dt;
  47. Standard.ValueMember = "BASECODE";
  48. Standard.DisplayMember = "BASENAME";
  49. if (ProDefault[0].TextDefault != "")
  50. {
  51. DataTable dtDefault =
  52. ServerHelper.GetData(
  53. "com.steering.mes.mcp.heatTreatment.ScrapHelper.doQuery",
  54. new object[] { "4021", ProDefault[0].TextDefault.Split(';') }, ob);
  55. if (dtDefault.Rows.Count > 0)
  56. {
  57. foreach (DataRow row in dtDefault.Rows)
  58. {
  59. if (listProbe.All(p => p.StandardCode != row["BASECODE"].ToString2()))
  60. {
  61. listProbe.Add(new HttCrackDetectionStandardEntity()
  62. {
  63. StandardCode = row["BASECODE"].ToString2(),
  64. StandardName = row["BASENAME"].ToString2()
  65. });
  66. }
  67. }
  68. }
  69. }
  70. }
  71. httCrackDetectionStandardEntityBindingSource.DataSource = listProbe;
  72. }
  73. private void ultraToolbarsManager1_ToolClick(object sender, ToolClickEventArgs e)
  74. {
  75. switch (e.Tool.Key)
  76. {
  77. case "Save":
  78. Save();
  79. break;
  80. case "Close":
  81. CloseFrm();
  82. break;
  83. }
  84. }
  85. protected override void OnLoad(EventArgs e)
  86. {
  87. base.OnLoad(e);
  88. foreach (var ugc in ultraGridDetailDes1.DisplayLayout.Bands[0].Columns)
  89. ugc.SortIndicator = SortIndicator.Disabled;
  90. ultraGridDetailDes1.DisplayLayout.Override.AllowRowFiltering = DefaultableBoolean.False;
  91. EntityHelper.ShowGridCaption<HttCrackDetectionStandardEntity>(ultraGridDetailDes1.DisplayLayout.Bands[0]);
  92. }
  93. private void CloseFrm()
  94. {
  95. DialogResult = DialogResult.Cancel;
  96. Close();
  97. }
  98. /// <summary>
  99. /// 保存可疑、剔除品
  100. /// </summary>
  101. private void Save()
  102. {
  103. ultraGridDetailDes1.UpdateData();
  104. List<HttCrackDetectionStandardEntity> list = GetValue();
  105. if (!list.Any())
  106. {
  107. MessageBox.Show("请选择探伤的标准");
  108. return;
  109. }
  110. if (list.Any(p => p.StandardCode == ""))
  111. {
  112. MessageBox.Show("探伤标准不能为空");
  113. return;
  114. }
  115. DialogResult = DialogResult.OK;
  116. }
  117. private void ultraGridDetailDes1_InitializeTemplateAddRow(object sender, Infragistics.Win.UltraWinGrid.InitializeTemplateAddRowEventArgs e)
  118. {
  119. if (ultraGridDetailDes1.ActiveRow == null && ultraGridDetailDes1.Rows.Count<=0)
  120. e.TemplateAddRow.Activated = true;
  121. }
  122. public List<HttCrackDetectionStandardEntity> GetValue()
  123. {
  124. ultraGridDetailDes1.UpdateData();
  125. List<HttCrackDetectionStandardEntity> data =
  126. httCrackDetectionStandardEntityBindingSource.DataSource as List<HttCrackDetectionStandardEntity>;
  127. if (data.Any())
  128. {
  129. return data.Where(p => p.Chk).ToList();
  130. }
  131. return new List<HttCrackDetectionStandardEntity>();
  132. }
  133. private void ultraGridDetailDes1_CellChange(object sender, CellEventArgs e)
  134. {
  135. ultraGridDetailDes1.UpdateData();
  136. if (e.Cell.Column.Key == "StandardCode")
  137. {
  138. HttCrackDetectionStandardEntity HttCrackDetectionStandardEntity =
  139. e.Cell.Row.ListObject as HttCrackDetectionStandardEntity;
  140. if (HttCrackDetectionStandardEntity == null) return;
  141. HttCrackDetectionStandardEntity.StandardName = e.Cell.Text;
  142. }
  143. }
  144. }
  145. }