CtrlBaseStdRSpec.cs 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. using Core.Mes.Client.Comm.Tool;
  2. using CoreFS.CA06;
  3. using Infragistics.Win.UltraWinEditors;
  4. using Infragistics.Win.UltraWinGrid;
  5. using System;
  6. using System.Collections;
  7. using System.Data;
  8. using System.Drawing;
  9. using System.Linq;
  10. using System.Windows.Forms;
  11. namespace Core.StlMes.Client.Qcm
  12. {
  13. public partial class CtrlBaseStdRSpec : UserControl
  14. {
  15. private OpeBase _ob;
  16. public OpeBase Ob
  17. {
  18. get { return _ob; }
  19. set { _ob = value; }
  20. }
  21. private IQueryable<UltraGridRow> _queryableRows;
  22. public IQueryable<UltraGridRow> QueryableRows
  23. {
  24. get { return _queryableRows; }
  25. set { _queryableRows = value; }
  26. }
  27. private DtBaseStdRSpec _dtBaseStdRSpec;
  28. private BaseStdRSpecEntity _queryCondition;
  29. public BaseStdRSpecEntity QueryCondition
  30. {
  31. get { return _queryCondition; }
  32. set { _queryCondition = value; }
  33. }
  34. private UltraComboEditor[] _cmbs = new UltraComboEditor[2];
  35. public CtrlBaseStdRSpec(System.Windows.Forms.Control container, OpeBase ob)
  36. {
  37. InitializeComponent();
  38. _ob = ob;
  39. container.Controls.Add(this);
  40. this.Dock = DockStyle.Fill;
  41. _queryableRows = ultraGrid1.Rows.AsQueryable().Where("Chk = 'True'");
  42. _dtBaseStdRSpec = new DtBaseStdRSpec(this);
  43. LoadBaseData();
  44. }
  45. private void LoadBaseData()
  46. {
  47. for (int i = 0; i < 2; i++)
  48. {
  49. _cmbs[i] = new UltraComboEditor();
  50. _cmbs[i].Visible = false;
  51. this.Controls.Add(_cmbs[i]);
  52. }
  53. QcmBaseInfo.Fill_SpecType(_cmbs[0], false);
  54. DataTable dtSpecType = (DataTable)_cmbs[0].DataSource;
  55. dtSpecType.DefaultView.RowFilter = "ID <> 'D'";
  56. ultraGrid1.DisplayLayout.Bands[0].Columns["MscStyle"].EditorComponent = _cmbs[0];
  57. ultraGrid1.DisplayLayout.Bands[0].Columns["MscStyle"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList;
  58. QcmBaseQuery.NitializeSpec(_cmbs[1], "C", true, _ob);
  59. ultraGrid1.DisplayLayout.Bands[0].Columns["SpecCode"].EditorComponent = _cmbs[1];
  60. ultraGrid1.DisplayLayout.Bands[0].Columns["SpecCode"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList;
  61. }
  62. public void Query(BaseStdRSpecEntity queryCondition)
  63. {
  64. _queryCondition = queryCondition;
  65. _dtBaseStdRSpec.DoQuery("Query");
  66. }
  67. public void Save()
  68. {
  69. _dtBaseStdRSpec.DoAction(ActionType.Save);
  70. }
  71. public void Delete()
  72. {
  73. _dtBaseStdRSpec.DoAction(ActionType.Delete);
  74. }
  75. public void Resume()
  76. {
  77. _dtBaseStdRSpec.DoAction(ActionType.Resume);
  78. }
  79. public void Clear()
  80. {
  81. this.baseStdRSpecEntityBindingSource.Clear();
  82. }
  83. public ArrayList GetNoQueryParms(ActionType actionType, out string msg)
  84. {
  85. return _dtBaseStdRSpec.GetNoQueryParms(actionType, out msg);
  86. }
  87. private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e)
  88. {
  89. EntityHelper.ShowGridCaption<BaseStdRSpecEntity>(e.Layout.Bands[0]);
  90. }
  91. private void ultraGrid1_AfterRowInsert(object sender, RowEventArgs e)
  92. {
  93. BaseStdRSpecEntity baseStdRSpec = (BaseStdRSpecEntity)e.Row.ListObject;
  94. baseStdRSpec.StdCode = _queryCondition.StdCode.ToString();
  95. baseStdRSpec.StdName = _queryCondition.StdName.ToString();
  96. }
  97. private void ultraGrid1_BeforeRowInsert(object sender, BeforeRowInsertEventArgs e)
  98. {
  99. if (_queryCondition.ValidflagName.ToString() == "")
  100. {
  101. e.Cancel = true;
  102. }
  103. }
  104. private void ultraGrid1_InitializeRow(object sender, InitializeRowEventArgs e)
  105. {
  106. BaseStdRSpecEntity baseStdRSpec = (BaseStdRSpecEntity)e.Row.ListObject;
  107. if (baseStdRSpec.Validflag.ToString() == "0")
  108. {
  109. e.Row.Appearance.ForeColor = Color.Red;
  110. }
  111. else
  112. {
  113. e.Row.Appearance.ForeColor = Color.Black;
  114. }
  115. }
  116. public void ControlGridEdit(UltraGridRow row)
  117. {
  118. if (row.GetValue("Chk") == "True")
  119. {
  120. row.Cells["MinD"].Activation = Activation.AllowEdit;
  121. row.Cells["MaxD"].Activation = Activation.AllowEdit;
  122. row.Cells["MinH"].Activation = Activation.AllowEdit;
  123. row.Cells["MaxH"].Activation = Activation.AllowEdit;
  124. row.Cells["Memo"].Activation = Activation.AllowEdit;
  125. row.Cells["MscStyle"].Activation = Activation.AllowEdit;
  126. row.Cells["SpecCode"].Activation = Activation.AllowEdit;
  127. }
  128. else
  129. {
  130. row.Cells["MinD"].Activation = Activation.ActivateOnly;
  131. row.Cells["MaxD"].Activation = Activation.ActivateOnly;
  132. row.Cells["MinH"].Activation = Activation.ActivateOnly;
  133. row.Cells["MaxH"].Activation = Activation.ActivateOnly;
  134. row.Cells["Memo"].Activation = Activation.ActivateOnly;
  135. row.Cells["MscStyle"].Activation = Activation.ActivateOnly;
  136. row.Cells["SpecCode"].Activation = Activation.ActivateOnly;
  137. }
  138. if (row.GetValue("MscStyle") == "A" && row.GetValue("Chk") == "True")
  139. {
  140. row.Cells["MinD"].Activation = Activation.AllowEdit;
  141. row.Cells["MaxD"].Activation = Activation.AllowEdit;
  142. row.Cells["MinH"].Activation = Activation.AllowEdit;
  143. row.Cells["MaxH"].Activation = Activation.AllowEdit;
  144. row.Cells["SpecCode"].Activation = Activation.ActivateOnly;
  145. row.Cells["SpecCode"].Value = "";
  146. row.Cells["SpecName"].Value = "";
  147. }
  148. else if (row.GetValue("MscStyle") == "B" && row.GetValue("Chk") == "True")
  149. {
  150. row.Cells["MinD"].Activation = Activation.AllowEdit;
  151. row.Cells["MaxD"].Activation = Activation.AllowEdit;
  152. row.Cells["MinH"].Activation = Activation.ActivateOnly;
  153. row.Cells["MaxH"].Activation = Activation.ActivateOnly;
  154. row.Cells["SpecCode"].Activation = Activation.ActivateOnly;
  155. row.Cells["MinH"].Value = null;
  156. row.Cells["MaxH"].Value = null;
  157. row.Cells["SpecCode"].Value = "";
  158. row.Cells["SpecName"].Value = "";
  159. }
  160. else if (row.GetValue("MscStyle") == "C" && row.GetValue("Chk") == "True")
  161. {
  162. row.Cells["MinD"].Activation = Activation.ActivateOnly;
  163. row.Cells["MaxD"].Activation = Activation.ActivateOnly;
  164. row.Cells["MinH"].Activation = Activation.ActivateOnly;
  165. row.Cells["MaxH"].Activation = Activation.ActivateOnly;
  166. row.Cells["SpecCode"].Activation = Activation.AllowEdit;
  167. row.Cells["MinD"].Value = null;
  168. row.Cells["MaxD"].Value = null;
  169. row.Cells["MinH"].Value = null;
  170. row.Cells["MaxH"].Value = null;
  171. }
  172. }
  173. private void ultraGrid1_CellChange(object sender, CellEventArgs e)
  174. {
  175. this.ultraGrid1.UpdateData();
  176. if (e.Cell.Column.Key == "SpecCode")
  177. {
  178. e.Cell.Row.Cells["SpecName"].Value = e.Cell.Text;
  179. }
  180. ControlGridEdit(e.Cell.Row);
  181. }
  182. }
  183. }