FrmBaseQcm.cs 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. using Core.Mes.Client.Comm.Control;
  2. using CoreFS.CA06;
  3. using Infragistics.Win.UltraWinGrid;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Data;
  7. using System.Drawing;
  8. namespace Core.StlMes.Client.Qcm
  9. {
  10. /// <summary>
  11. /// 已被弃用。
  12. /// </summary>
  13. public class FrmBaseQcm : FrmBase
  14. {
  15. public DtBaseQcm _dtBaseQcm = null;
  16. /// <summary>
  17. /// 用于其他界面引用的时候,调用加载方法。
  18. /// </summary>
  19. public void QcmLoad()
  20. {
  21. base.OnLoad(EventArgs.Empty);
  22. }
  23. public override void ToolBar_Click(object sender, string ToolbarKey)
  24. {
  25. bool actionResult = false;
  26. base.ToolBar_Click(sender, ToolbarKey);
  27. switch (ToolbarKey)
  28. {
  29. case "Query":
  30. _dtBaseQcm.DoQuery("DefaultQuery");
  31. break;
  32. case "Add":
  33. BeginDoAction(ActionType.Add);
  34. actionResult = _dtBaseQcm.DoAction(ActionType.Add);
  35. if (actionResult == true)
  36. {
  37. SuccessDoAction(ActionType.Add);
  38. }
  39. break;
  40. case "Save":
  41. BeginDoAction(ActionType.Save);
  42. actionResult = _dtBaseQcm.DoAction(ActionType.Save);
  43. if (actionResult == true)
  44. {
  45. SuccessDoAction(ActionType.Save);
  46. }
  47. break;
  48. case "Modify":
  49. BeginDoAction(ActionType.Modify);
  50. actionResult = _dtBaseQcm.DoAction(ActionType.Modify);
  51. if (actionResult == true)
  52. {
  53. SuccessDoAction(ActionType.Modify);
  54. }
  55. break;
  56. case "Audit":
  57. BeginDoAction(ActionType.Audit);
  58. actionResult = _dtBaseQcm.DoAction(ActionType.Audit);
  59. if (actionResult == true)
  60. {
  61. SuccessDoAction(ActionType.Audit);
  62. }
  63. break;
  64. case "Delete":
  65. BeginDoAction(ActionType.Delete);
  66. actionResult = _dtBaseQcm.DoAction(ActionType.Delete);
  67. if (actionResult == true)
  68. {
  69. SuccessDoAction(ActionType.Delete);
  70. }
  71. break;
  72. case "Resume":
  73. BeginDoAction(ActionType.Resume);
  74. actionResult = _dtBaseQcm.DoAction(ActionType.Resume);
  75. if (actionResult == true)
  76. {
  77. SuccessDoAction(ActionType.Resume);
  78. }
  79. break;
  80. case "Refresh":
  81. LoadBaseInfo();
  82. break;
  83. case "Close":
  84. this.Close();
  85. break;
  86. }
  87. }
  88. /// <summary>
  89. /// 开始执行非查询时所要调用的方法
  90. /// </summary>
  91. /// <param name="actionType">非查询类型</param>
  92. protected virtual void BeginDoAction(ActionType actionType)
  93. { }
  94. /// <summary>
  95. /// 执行非查询成功时所要调用的方法
  96. /// </summary>
  97. /// <param name="actionType">非查询类型</param>
  98. protected virtual void SuccessDoAction(ActionType actionType)
  99. { }
  100. /// <summary>
  101. /// 加载基础信息
  102. /// </summary>
  103. protected virtual void LoadBaseInfo()
  104. { }
  105. public void SetDeleteColor(InitializeRowEventArgs e, string strDeleteKey, string strDeleteValue)
  106. {
  107. if (e.Row.Cells[strDeleteKey].Value.ToString() == strDeleteValue)
  108. {
  109. e.Row.Appearance.ForeColor = Color.Red;
  110. }
  111. else
  112. {
  113. e.Row.Appearance.ForeColor = Color.Black;
  114. }
  115. }
  116. public void ControlGridSelectEdit(InitializeRowEventArgs e, List<string> listNoEdit, List<string> listDrop, string CkbKey)
  117. {
  118. if (e.Row.Cells[CkbKey].Value.ToString() == "True")
  119. {
  120. foreach (UltraGridCell cell in e.Row.Cells)
  121. {
  122. if (cell.Column.Header.Caption == "选择") continue;
  123. if (listNoEdit.Contains(cell.Column.Header.Caption))
  124. {
  125. cell.Activation = Activation.ActivateOnly;
  126. }
  127. else if (listDrop.Contains(cell.Column.Header.Caption))
  128. {
  129. cell.Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList;
  130. cell.Activation = Activation.AllowEdit;
  131. }
  132. else
  133. {
  134. cell.Activation = Activation.AllowEdit;
  135. }
  136. }
  137. }
  138. else
  139. {
  140. foreach (UltraGridCell cell in e.Row.Cells)
  141. {
  142. if (cell.Column.Header.Caption == "选择") continue;
  143. if (listDrop.Contains(cell.Column.Header.Caption))
  144. {
  145. cell.Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDown;
  146. cell.Activation = Activation.ActivateOnly;
  147. }
  148. else
  149. {
  150. cell.Activation = Activation.ActivateOnly;
  151. }
  152. }
  153. }
  154. }
  155. public void SetGridRowActiveWithKey(UltraGrid grid, string key, string value)
  156. {
  157. UltraGridRow[] rows = GridHelper.GetRowsWithKey(grid,
  158. new string[] { key }, new string[] { value });
  159. if (rows.Length > 0)
  160. {
  161. rows[0].Activate();
  162. }
  163. }
  164. public void SetGridRowActiveWithKey(UltraGrid grid, string key, string createNameKey, string createTimeKey)
  165. {
  166. DataTable dt = ((DataSet)grid.DataSource).Tables[grid.DataMember];
  167. DataRow[] drs = dt.Select(createNameKey + "= '" + UserInfo.GetUserName() + "'", createTimeKey + " DESC");
  168. if (drs.Length > 0)
  169. {
  170. string value = drs[0][key].ToString();
  171. SetGridRowActiveWithKey(grid, key, value);
  172. }
  173. }
  174. }
  175. }