ComBaseStdRTestCtrl.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. using Core.Mes.Client.Comm.Format;
  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 ComBaseStdRTestCtrl : UserControl
  17. {
  18. private ComBaseStdRTestBLL _comBaseStdRTestBLL;
  19. private OpeBase _ob;
  20. //查询条件
  21. private string _phyNameMin = "";
  22. private string _validflag = "";
  23. public ComBaseStdRTestCtrl(System.Windows.Forms.Control container, OpeBase ob)
  24. {
  25. InitializeComponent();
  26. _ob = ob;
  27. _comBaseStdRTestBLL = new ComBaseStdRTestBLL(ob);
  28. container.Controls.Add(this);
  29. this.Dock = DockStyle.Fill;
  30. EntityHelper.ShowGridCaption<ComBaseStdRTestEntity>(ultraGrid1.DisplayLayout.Bands[0]);
  31. }
  32. public void Query(string phyNameMin, string validflag)
  33. {
  34. _validflag = validflag;
  35. _phyNameMin = phyNameMin;
  36. comBaseStdRTestEntityBindingSource.DataSource = _comBaseStdRTestBLL.Query(phyNameMin, validflag);
  37. foreach (UltraGridRow row in ultraGrid1.Rows)
  38. {
  39. GridEdite(row);
  40. }
  41. }
  42. public void Relocate(string phyCodeMin)
  43. {
  44. Query(_phyNameMin, _validflag);
  45. var row = ultraGrid1.Rows.AsQueryable().Where(a => a.GetValue("PhyCodeMin") == phyCodeMin).FirstOrDefault();
  46. if (row != null)
  47. {
  48. row.Activate();
  49. }
  50. }
  51. public void Save()
  52. {
  53. var rows = ultraGrid1.Rows.AsQueryable().Where(a => a.GetValue("Chk") == "True");
  54. if (rows.Count() == 0)
  55. {
  56. MessageUtil.ShowWarning("请选择一条记录!");
  57. return;
  58. }
  59. List<ComBaseStdRTestEntity> parms = new List<ComBaseStdRTestEntity>();
  60. foreach (var row in rows)
  61. {
  62. ComBaseStdRTestEntity stdRTestEntity = EntityHelper.CopyEntity<ComBaseStdRTestEntity>(row.ListObject);
  63. if (stdRTestEntity.PhyCodeMin == "")
  64. {
  65. MessageUtil.ShowWarning("请选择试样组!");
  66. row.SetCellActive("PhyNameMin");
  67. return;
  68. }
  69. if (stdRTestEntity.StdCodeTest == "")
  70. {
  71. MessageUtil.ShowWarning("请选择试验标准!");
  72. row.SetCellActive("StdNameTest");
  73. return;
  74. }
  75. if (_comBaseStdRTestBLL.GetRepateCnt(stdRTestEntity.StdCodeTest,
  76. stdRTestEntity.PhyCodeMin, stdRTestEntity.Pk) > 0)
  77. {
  78. MessageUtil.ShowWarning("系统已存在 试样组:" + stdRTestEntity.PhyNameMin
  79. + " + 试验标准:" + stdRTestEntity.StdNameTest + "的组合!");
  80. return;
  81. }
  82. if (stdRTestEntity.LevelTest == null)
  83. {
  84. stdRTestEntity.LevelTest = 1;
  85. }
  86. stdRTestEntity.CreateName = CoreUserInfo.UserInfo.GetUserName();
  87. stdRTestEntity.UpdateName = CoreUserInfo.UserInfo.GetUserName();
  88. parms.Add(stdRTestEntity);
  89. }
  90. if (MessageUtil.ShowYesNoAndQuestion("是否确认保存?") == DialogResult.No)
  91. {
  92. return;
  93. }
  94. _comBaseStdRTestBLL.Save(parms);
  95. MessageUtil.ShowTips("保存成功!");
  96. Relocate(parms[0].PhyCodeMin);
  97. }
  98. public List<string> GetSaveParms()
  99. {
  100. ultraGrid1.UpdateData();
  101. var rows = ultraGrid1.Rows.AsQueryable().Where(a => a.GetValue("Chk") == "True");
  102. List<string> parms = new List<string>();
  103. foreach (var row in rows)
  104. {
  105. ComBaseStdRTestEntity stdRTestEntity = EntityHelper.CopyEntity<ComBaseStdRTestEntity>(row.ListObject);
  106. if (stdRTestEntity.StdNameTest == "")
  107. {
  108. MessageUtil.ShowWarning("请选择试验标准!");
  109. row.SetCellActive("StdNameTest");
  110. return null;
  111. }
  112. else if (stdRTestEntity.PhyNameMin == "")
  113. {
  114. MessageUtil.ShowWarning("请选择试样组!");
  115. row.SetCellActive("PhyNameMin");
  116. return null;
  117. }
  118. else if (stdRTestEntity.LevelTest == null)
  119. {
  120. MessageUtil.ShowWarning("请输入优先级!");
  121. row.SetCellActive("LevelTest");
  122. return null;
  123. }
  124. stdRTestEntity.CreateName = CoreUserInfo.UserInfo.GetUserName();
  125. stdRTestEntity.UpdateName = CoreUserInfo.UserInfo.GetUserName();
  126. parms.Add(JSONFormat.Format(stdRTestEntity));
  127. }
  128. return parms;
  129. }
  130. public void UpdateValidflag(string validflag)
  131. {
  132. var rows = ultraGrid1.Rows.AsQueryable().Where(a => a.GetValue("Chk") == "True");
  133. if (rows.Count() == 0)
  134. {
  135. MessageUtil.ShowWarning("请选择记录!");
  136. return;
  137. }
  138. List<ComBaseStdRTestEntity> parms = new List<ComBaseStdRTestEntity>();
  139. foreach (var row in rows)
  140. {
  141. ComBaseStdRTestEntity stdRTestEntity = EntityHelper.CopyEntity<ComBaseStdRTestEntity>(row.ListObject);
  142. stdRTestEntity.DeleteName = CoreUserInfo.UserInfo.GetUserName();
  143. stdRTestEntity.UpdateName = CoreUserInfo.UserInfo.GetUserName();
  144. parms.Add(stdRTestEntity);
  145. }
  146. if (MessageUtil.ShowYesNoAndQuestion("是否确认" +
  147. (validflag == "0" ? "作废" : "恢复") + "选择的记录?") == DialogResult.No)
  148. {
  149. return;
  150. }
  151. _comBaseStdRTestBLL.UpdateValidflag(parms, validflag);
  152. MessageUtil.ShowTips((validflag == "0" ? "作废" : "恢复") + "成功!");
  153. Relocate(parms[0].PhyCodeMin);
  154. }
  155. public List<string> GetUpdateValidflagParms()
  156. {
  157. ultraGrid1.UpdateData();
  158. var rows = ultraGrid1.Rows.AsQueryable().Where(a => a.GetValue("Chk") == "True");
  159. List<string> parms = new List<string>();
  160. foreach (var row in rows)
  161. {
  162. ComBaseStdRTestEntity stdRTestEntity = EntityHelper.CopyEntity<ComBaseStdRTestEntity>(row.ListObject);
  163. stdRTestEntity.DeleteName = CoreUserInfo.UserInfo.GetUserName();
  164. stdRTestEntity.UpdateName = CoreUserInfo.UserInfo.GetUserName();
  165. parms.Add(JSONFormat.Format(stdRTestEntity));
  166. }
  167. return parms;
  168. }
  169. private void ultraGrid1_InitializeRow(object sender, Infragistics.Win.UltraWinGrid.InitializeRowEventArgs e)
  170. {
  171. if (e.Row.GetValue("Validflag") == "无效")
  172. {
  173. e.Row.Appearance.ForeColor = Color.Red;
  174. }
  175. }
  176. private void ultraGrid1_AfterRowInsert(object sender, Infragistics.Win.UltraWinGrid.RowEventArgs e)
  177. {
  178. ultraGrid1.UpdateData();
  179. }
  180. private void ultraTextEditor1_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
  181. {
  182. if (ultraGrid1.ActiveCell.Column.Key == "StdNameTest")
  183. {
  184. //DataTable dt = _comBaseStdRTestBLL.GetComBaseStdS();
  185. //dt.Columns["STD_NAME"].Caption = "试验标准";
  186. //BaseInfoPopup baseInfoPopup = new BaseInfoPopup(dt, "STD_NAME", "STD_CODE");
  187. //baseInfoPopup.LabelTextBox1.Caption = "试验标准";
  188. //var row = baseInfoPopup.UltraGrid1.Rows.AsQueryable().Where(
  189. // a => a.GetValue("STD_CODE") == ultraGrid1.ActiveRow.GetValue("StdCodeTest")).FirstOrDefault();
  190. //if (row != null)
  191. //{
  192. // row.Activate();
  193. //}
  194. //if (baseInfoPopup.ShowDialog() == DialogResult.OK)
  195. //{
  196. // ultraGrid1.ActiveRow.SetValue("StdCodeTest", baseInfoPopup.ChoicedRow.GetValue("STD_CODE"));
  197. // ultraGrid1.ActiveRow.SetValue("StdNameTest", baseInfoPopup.ChoicedRow.GetValue("STD_NAME"));
  198. //}
  199. string stdCodes = ultraGrid1.ActiveRow.GetValue("StdCodeTest");
  200. ComBaseStdChoice baseStdChoice = new ComBaseStdChoice(new string[] { "S" }, stdCodes, _ob);
  201. if (baseStdChoice.ShowDialog() == DialogResult.OK)
  202. {
  203. ultraGrid1.ActiveRow.SetValue("StdCodeTest", baseStdChoice.ChoiceStdCodes);
  204. ultraGrid1.ActiveRow.SetValue("StdNameTest", baseStdChoice.ChoiceStdNames);
  205. }
  206. }
  207. else if (ultraGrid1.ActiveCell.Column.Key == "PhyNameMin")
  208. {
  209. DataTable dt = _comBaseStdRTestBLL.GetComBasePhyC();
  210. dt.Columns["PHY_TYPE"].Caption = "试样组";
  211. BaseInfoPopup baseInfoPopup = new BaseInfoPopup(dt, "PHY_TYPE", "PHY_CODE");
  212. baseInfoPopup.LabelTextBox1.Caption = "试样组";
  213. var row = baseInfoPopup.UltraGrid1.Rows.AsQueryable().Where(
  214. a => a.GetValue("PHY_CODE") == ultraGrid1.ActiveRow.GetValue("PhyCodeMin")).FirstOrDefault();
  215. if (row != null)
  216. {
  217. row.Activate();
  218. }
  219. if (baseInfoPopup.ShowDialog() == DialogResult.OK)
  220. {
  221. ultraGrid1.ActiveRow.SetValue("PhyCodeMin", baseInfoPopup.ChoicedRow.GetValue("PHY_CODE"));
  222. ultraGrid1.ActiveRow.SetValue("PhyNameMin", baseInfoPopup.ChoicedRow.GetValue("PHY_TYPE"));
  223. }
  224. }
  225. }
  226. private void GridEdite(UltraGridRow row)
  227. {
  228. if (row.GetValue("Chk") == "True")
  229. {
  230. foreach (UltraGridCell cell in row.Cells)
  231. {
  232. if (cell.Column.CellActivation == Activation.AllowEdit)
  233. {
  234. cell.Activation = Activation.AllowEdit;
  235. }
  236. }
  237. }
  238. else
  239. {
  240. foreach (UltraGridCell cell in row.Cells)
  241. {
  242. if (cell.Column.Key == "Chk") continue;
  243. if (cell.Column.CellActivation == Activation.AllowEdit)
  244. {
  245. cell.Activation = Activation.ActivateOnly;
  246. }
  247. }
  248. }
  249. }
  250. private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e)
  251. {
  252. }
  253. private void ultraGrid1_CellChange(object sender, CellEventArgs e)
  254. {
  255. e.Cell.Row.Update();
  256. GridEdite(e.Cell.Row);
  257. }
  258. }
  259. }