ComBaseImpactCtrl.cs 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. using Core.Mes.Client.Comm.Tool;
  2. using Core.StlMes.Client.Qcm.BLL;
  3. using Core.StlMes.Client.Qcm.model;
  4. using CoreFS.CA06;
  5. using CoreFS.SA06;
  6. using Infragistics.Win.UltraWinGrid;
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Data;
  10. using System.Drawing;
  11. using System.Linq;
  12. using System.Windows.Forms;
  13. namespace Core.StlMes.Client.Qcm.Control
  14. {
  15. public partial class ComBaseImpactCtrl : UserControl
  16. {
  17. private ComBaseImpactBLL _impactBLL;
  18. public ComBaseImpactCtrl(System.Windows.Forms.Control container, OpeBase ob)
  19. {
  20. InitializeComponent();
  21. _impactBLL = new ComBaseImpactBLL(ob);
  22. this.Dock = DockStyle.Fill;
  23. container.Controls.Add(this);
  24. }
  25. private string _impact = "";
  26. private string _validflag = "";
  27. public void Query(string impact, string validflag)
  28. {
  29. this.comBaseImpactEntityBindingSource.DataSource = _impactBLL.Query(impact, validflag);
  30. foreach (var row in entityGrid1.Rows)
  31. {
  32. GridEdite(row);
  33. }
  34. }
  35. public void Save(List<ComBaseImpactCEntity> subParms, List<ComBaseImpactTempCEntity> subTempParms)
  36. {
  37. if (entityGrid1.ActiveRow == null)
  38. {
  39. MessageUtil.ShowWarning("请选择一条记录!");
  40. return;
  41. }
  42. var row = entityGrid1.Rows.Where(a => a.GetValue("Chk") == "True").FirstOrDefault();
  43. if (row == null && subParms.Count == 0 && subTempParms.Count == 0)
  44. {
  45. MessageUtil.ShowWarning("请选择一条记录!");
  46. return;
  47. }
  48. ComBaseImpactEntity parm = null;
  49. if (row != null)
  50. {
  51. parm = EntityHelper.CopyEntity<ComBaseImpactEntity>(row.ListObject);
  52. if (parm.AllowArc == null)
  53. {
  54. MessageUtil.ShowWarning("请选择是否允许弧形样!");
  55. row.SetCellActive("AllowArc");
  56. return;
  57. }
  58. if (parm.AllowArc == true)
  59. {
  60. if (parm.MinSideArc == null)
  61. {
  62. MessageUtil.ShowWarning("请输入弧形样侧边最短(%)!");
  63. row.SetCellActive("MinSideArc");
  64. return;
  65. }
  66. if (parm.MinAboveArc == null)
  67. {
  68. MessageUtil.ShowWarning("弧形样上边最短(mm)!");
  69. row.SetCellActive("MinAboveArc");
  70. return;
  71. }
  72. }
  73. if (parm.ProcessSurplus == null)
  74. {
  75. MessageUtil.ShowWarning("加工余量(mm)不能为空!");
  76. row.SetCellActive("ProcessSurplus");
  77. return;
  78. }
  79. parm.CreateName = CoreUserInfo.UserInfo.GetUserName();
  80. parm.UpdateName = CoreUserInfo.UserInfo.GetUserName();
  81. }
  82. if (MessageUtil.ShowYesNoAndQuestion("是否确认保存?") == DialogResult.No)
  83. {
  84. return;
  85. }
  86. _impactBLL.Save(parm, subParms, subTempParms);
  87. MessageUtil.ShowTips("保存成功!");
  88. string id = entityGrid1.ActiveRow.GetValue("Id");
  89. Relocate(id, _validflag);
  90. }
  91. public void Relocate(string id, string validflag)
  92. {
  93. Query(_impact, validflag);
  94. var row = entityGrid1.Rows.AsQueryable().Where(a => a.GetValue("Id") == id).FirstOrDefault();
  95. if (row != null)
  96. {
  97. row.Activate();
  98. }
  99. }
  100. public void UpdateValidflag(string flag)
  101. {
  102. entityGrid1.UpdateData();
  103. var rows = entityGrid1.Rows.AsQueryable().Where(a => a.GetValue("Chk") == "True")
  104. .Select(a => EntityHelper.CopyEntity<ComBaseImpactEntity>(a.ListObject)).ToList();
  105. string id = "";
  106. foreach (var row in rows)
  107. {
  108. row.DeleteName = CoreUserInfo.UserInfo.GetUserName();
  109. row.UpdateName = CoreUserInfo.UserInfo.GetUserName();
  110. id = row.Id;
  111. }
  112. _impactBLL.UpdateValidflag(rows, flag);
  113. }
  114. private void entityGrid1_CellChange(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e)
  115. {
  116. e.Cell.Row.Update();
  117. GridEdite(e.Cell.Row);
  118. if (e.Cell.Column.Key == "Chk")
  119. {
  120. UltraGridRow chkRow = e.Cell.Row;
  121. foreach (UltraGridRow row in entityGrid1.Rows)
  122. {
  123. if (row.Cells["Chk"].Value.ToString() == "True" && row != chkRow)
  124. {
  125. row.Cells["Chk"].Value = "False";
  126. row.Update();
  127. }
  128. }
  129. }
  130. }
  131. private void GridEdite(UltraGridRow row)
  132. {
  133. if (row.GetValue("Chk") == "True")
  134. {
  135. foreach (UltraGridCell cell in row.Cells)
  136. {
  137. if (cell.Column.CellActivation == Activation.AllowEdit)
  138. {
  139. cell.Activation = Activation.AllowEdit;
  140. }
  141. }
  142. }
  143. else
  144. {
  145. foreach (UltraGridCell cell in row.Cells)
  146. {
  147. if (cell.Column.Key == "Chk") continue;
  148. if (cell.Column.CellActivation == Activation.AllowEdit)
  149. {
  150. cell.Activation = Activation.ActivateOnly;
  151. }
  152. }
  153. }
  154. }
  155. private void entityGrid1_AfterRowActivate(object sender, EventArgs e)
  156. {
  157. }
  158. private void entityGrid1_AfterRowInsert(object sender, RowEventArgs e)
  159. {
  160. e.Row.Cells["AllowArc"].Value = false;
  161. }
  162. private void entityGrid1_InitializeRow(object sender, InitializeRowEventArgs e)
  163. {
  164. if (e.Row.GetValue("Validflag") == "无效")
  165. {
  166. e.Row.Appearance.ForeColor = Color.Red;
  167. }
  168. }
  169. }
  170. }