ComBaseSplineLengthCtrl.cs 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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;
  10. using System.Collections.Generic;
  11. using System.Data;
  12. using System.Drawing;
  13. using System.Linq;
  14. using System.Windows.Forms;
  15. namespace Core.StlMes.Client.Qcm.Control
  16. {
  17. public partial class ComBaseSplineLengthCtrl : UserControl
  18. {
  19. private ComBaseSplineLengthBLL _splineLengthBLL;
  20. public ComBaseSplineLengthCtrl(System.Windows.Forms.Control container, OpeBase ob)
  21. {
  22. InitializeComponent();
  23. _splineLengthBLL = new ComBaseSplineLengthBLL(ob);
  24. this.Dock = DockStyle.Fill;
  25. container.Controls.Add(this);
  26. ArrayList list = new ArrayList();
  27. list.Add("A");
  28. DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreMaterialItemMng.loadItem",
  29. new object[] { list }, ob);
  30. ultraComboEditor1.DataSource = dt;
  31. ultraComboEditor1.DisplayMember = "ITEM_NAME";
  32. ultraComboEditor1.ValueMember = "ITEM_CODE";
  33. ultraComboEditor1.DropDownListWidth = -1;
  34. ClsBaseInfo.SetComboItemHeight(ultraComboEditor1);
  35. list[0] = "C";
  36. dt = ServerHelper.GetData("com.steering.pss.qcm.CoreMaterialItemMng.loadItem",
  37. new object[] { list }, ob);
  38. ultraComboEditor2.DataSource = dt;
  39. ultraComboEditor2.DisplayMember = "ITEM_NAME";
  40. ultraComboEditor2.ValueMember = "ITEM_CODE";
  41. ultraComboEditor2.DropDownListWidth = -1;
  42. ClsBaseInfo.SetComboItemHeight(ultraComboEditor2);
  43. }
  44. private string _itemCodeC = "";
  45. private string _validflag = "";
  46. public void Query(string itemCodeC, string validflag)
  47. {
  48. _itemCodeC = itemCodeC;
  49. _validflag = validflag;
  50. comBaseSplineLengthEntityBindingSource.DataSource = _splineLengthBLL.Query(itemCodeC, validflag);
  51. foreach (var row in entityGrid1.Rows)
  52. {
  53. GridEdite(row);
  54. }
  55. }
  56. public void Save()
  57. {
  58. var rows = entityGrid1.Rows.Where(a => a.GetValue("Chk") == "True");
  59. if (rows.Count() == 0)
  60. {
  61. MessageUtil.ShowWarning("请选择一条记录!");
  62. return;
  63. }
  64. List<ComBaseSplineLengthEntity> parms = new List<ComBaseSplineLengthEntity>();
  65. string id = "";
  66. foreach (var row in rows)
  67. {
  68. if (entityGrid1.Rows.Where(a => a.GetValue("id") == row.GetValue("id")).Count() > 1)
  69. {
  70. MessageUtil.ShowWarning("优选顺序" + row.GetValue("id") + "在系统中已经存在!");
  71. return;
  72. }
  73. ComBaseSplineLengthEntity parm = EntityHelper.CopyEntity<ComBaseSplineLengthEntity>(row.ListObject);
  74. id = parm.Id;
  75. parm.CreateName = CoreUserInfo.UserInfo.GetUserName();
  76. parm.UpdateName = CoreUserInfo.UserInfo.GetUserName();
  77. parms.Add(parm);
  78. }
  79. if (MessageUtil.ShowYesNoAndQuestion("是否确认保存?") == DialogResult.No)
  80. {
  81. return;
  82. }
  83. _splineLengthBLL.Save(parms);
  84. MessageUtil.ShowTips("保存成功!");
  85. Relocate(id);
  86. }
  87. public void Relocate(string id)
  88. {
  89. Query(_itemCodeC, _validflag);
  90. var row = entityGrid1.Rows.AsQueryable().Where(a => a.GetValue("Id") == id).FirstOrDefault();
  91. if (row != null)
  92. {
  93. row.Activate();
  94. }
  95. }
  96. public void UpdateValidflag(string validflag)
  97. {
  98. entityGrid1.UpdateData();
  99. var rows = entityGrid1.Rows.AsQueryable().Where(a => a.GetValue("Chk") == "True")
  100. .Select(a => EntityHelper.CopyEntity<ComBaseSplineLengthEntity>(a.ListObject)).ToList();
  101. if (rows.Count() == 0)
  102. {
  103. MessageUtil.ShowWarning("请选择一条记录!");
  104. return;
  105. }
  106. string id = "";
  107. foreach (var row in rows)
  108. {
  109. row.DeleteName = CoreUserInfo.UserInfo.GetUserName();
  110. row.UpdateName = CoreUserInfo.UserInfo.GetUserName();
  111. id = row.Id;
  112. }
  113. if (MessageUtil.ShowYesNoAndQuestion("是否确认" + (validflag == "0" ? "作废" : "恢复") + "此记录?") == DialogResult.No)
  114. {
  115. return;
  116. }
  117. _splineLengthBLL.UpdateValidflag(rows, validflag);
  118. MessageUtil.ShowTips((validflag == "0" ? "作废" : "恢复") + "成功!");
  119. Relocate(id);
  120. }
  121. private void entityGrid1_InitializeRow(object sender, Infragistics.Win.UltraWinGrid.InitializeRowEventArgs e)
  122. {
  123. if (e.Row.GetValue("Validflag") == "无效")
  124. {
  125. e.Row.Appearance.ForeColor = Color.Red;
  126. }
  127. }
  128. private void entityGrid1_CellChange(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e)
  129. {
  130. e.Cell.Row.Update();
  131. GridEdite(e.Cell.Row);
  132. }
  133. private void GridEdite(UltraGridRow row)
  134. {
  135. if (row.GetValue("Chk") == "True")
  136. {
  137. foreach (UltraGridCell cell in row.Cells)
  138. {
  139. if (cell.Column.CellActivation == Activation.AllowEdit)
  140. {
  141. cell.Activation = Activation.AllowEdit;
  142. }
  143. }
  144. }
  145. else
  146. {
  147. foreach (UltraGridCell cell in row.Cells)
  148. {
  149. if (cell.Column.Key == "Chk") continue;
  150. if (cell.Column.CellActivation == Activation.AllowEdit)
  151. {
  152. cell.Activation = Activation.ActivateOnly;
  153. }
  154. }
  155. }
  156. }
  157. }
  158. }