ComBaseImpactCCtrl.cs 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. using Core.Mes.Client.Comm.Server;
  2. using Core.Mes.Client.Comm.Tool;
  3. using Core.StlMes.Client.Qcm.BLL;
  4. using Core.StlMes.Client.Qcm.model;
  5. using CoreFS.CA06;
  6. using CoreFS.SA06;
  7. using Infragistics.Win.UltraWinGrid;
  8. using System;
  9. using System.Collections.Generic;
  10. using System.Data;
  11. using System.Drawing;
  12. using System.Linq;
  13. using System.Windows.Forms;
  14. namespace Core.StlMes.Client.Qcm.Control
  15. {
  16. public partial class ComBaseImpactCCtrl : UserControl
  17. {
  18. private ComBaseImpactCBLL _impactCBLL;
  19. public ComBaseImpactCCtrl(System.Windows.Forms.Control container, OpeBase ob)
  20. {
  21. InitializeComponent();
  22. _impactCBLL = new ComBaseImpactCBLL(ob);
  23. this.Dock = DockStyle.Fill;
  24. container.Controls.Add(this);
  25. DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.DAL.ComBaseImpactDAL.getItemC",
  26. new object[] { }, ob);
  27. DataRow dr = dt.NewRow();
  28. dr["ITEM_CODE"] = "";
  29. dt.Rows.InsertAt(dr, 0);
  30. ultraComboEditor1.DataSource = dt;
  31. ultraComboEditor1.DisplayMember = "ITEM_NAME";
  32. ultraComboEditor1.ValueMember = "ITEM_CODE";
  33. ultraComboEditor1.DropDownListWidth = -1;
  34. ClsBaseInfo.SetComboItemHeight(ultraComboEditor1);
  35. }
  36. private string _id = "";
  37. private string _validflag = "";
  38. public void Query(string id, string validflag)
  39. {
  40. _id = id;
  41. _validflag = validflag;
  42. this.comBaseImpactCEntityBindingSource.DataSource = _impactCBLL.Query(id, validflag);
  43. foreach (var row in entityGrid1.Rows)
  44. {
  45. GridEdite(row);
  46. }
  47. }
  48. public List<ComBaseImpactCEntity> GetSaveParms()
  49. {
  50. var rows = entityGrid1.Rows.Where(a => a.GetValue("Chk") == "True");
  51. List<ComBaseImpactCEntity> parms = new List<ComBaseImpactCEntity>();
  52. foreach (var row in rows)
  53. {
  54. ComBaseImpactCEntity parm = EntityHelper.CopyEntity<ComBaseImpactCEntity>(row.ListObject);
  55. if (parm.ItemCodeC == "")
  56. {
  57. MessageUtil.ShowWarning("请选择试样尺寸!");
  58. row.SetCellActive("ItemCodeC");
  59. return null;
  60. }
  61. if (parm.ItemWidth == null)
  62. {
  63. MessageUtil.ShowWarning("请输入试样宽度!");
  64. row.SetCellActive("ItemWidth");
  65. return null;
  66. }
  67. if (parm.DeclineRatio == null)
  68. {
  69. MessageUtil.ShowWarning("请输入递减系数!");
  70. row.SetCellActive("DeclineRatio");
  71. return null;
  72. }
  73. parm.CreateName = CoreUserInfo.UserInfo.GetUserName();
  74. parm.UpdateName = CoreUserInfo.UserInfo.GetUserName();
  75. parms.Add(parm);
  76. }
  77. return parms;
  78. }
  79. public void UpdateValidflag(string validflag)
  80. {
  81. var rows = entityGrid1.Rows.AsQueryable().Where(a => a.GetValue("Chk") == "True")
  82. .Select(a => EntityHelper.CopyEntity<ComBaseImpactCEntity>(a.ListObject)).ToList();
  83. foreach (var row in rows)
  84. {
  85. row.DeleteName = CoreUserInfo.UserInfo.GetUserName();
  86. row.UpdateName = CoreUserInfo.UserInfo.GetUserName();
  87. }
  88. _impactCBLL.UpdateValidflag(rows, validflag);
  89. }
  90. private void entityGrid1_AfterRowInsert(object sender, Infragistics.Win.UltraWinGrid.RowEventArgs e)
  91. {
  92. e.Row.SetValue("Id", _id);
  93. }
  94. private void entityGrid1_CellChange(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e)
  95. {
  96. e.Cell.Row.Update();
  97. GridEdite(e.Cell.Row);
  98. }
  99. private void GridEdite(UltraGridRow row)
  100. {
  101. if (row.GetValue("Chk") == "True")
  102. {
  103. foreach (UltraGridCell cell in row.Cells)
  104. {
  105. if (cell.Column.CellActivation == Activation.AllowEdit)
  106. {
  107. cell.Activation = Activation.AllowEdit;
  108. }
  109. }
  110. }
  111. else
  112. {
  113. foreach (UltraGridCell cell in row.Cells)
  114. {
  115. if (cell.Column.Key == "Chk") continue;
  116. if (cell.Column.CellActivation == Activation.AllowEdit)
  117. {
  118. cell.Activation = Activation.ActivateOnly;
  119. }
  120. }
  121. }
  122. }
  123. private void entityGrid1_InitializeRow(object sender, InitializeRowEventArgs e)
  124. {
  125. if (e.Row.GetValue("Validflag") == "无效")
  126. {
  127. e.Row.Appearance.ForeColor = Color.Red;
  128. }
  129. }
  130. }
  131. }