CtrlMscRBlSpec.cs 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  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.Data;
  7. using System.Drawing;
  8. using System.Linq;
  9. using System.Windows.Forms;
  10. namespace Core.StlMes.Client.Qcm
  11. {
  12. public partial class CtrlMscRBlSpec : UserControl
  13. {
  14. private OpeBase _ob;
  15. public OpeBase Ob
  16. {
  17. get { return _ob; }
  18. set { _ob = value; }
  19. }
  20. private IQueryable<UltraGridRow> _queryableRows;
  21. public IQueryable<UltraGridRow> QueryableRows
  22. {
  23. get { return _queryableRows; }
  24. set { _queryableRows = value; }
  25. }
  26. private ComMscRBlSpecEntity _queryCondition;
  27. public ComMscRBlSpecEntity QueryCondition
  28. {
  29. get { return _queryCondition; }
  30. set { _queryCondition = value; }
  31. }
  32. private DtMscRBlSpec _dtMscRBlSpec;
  33. private UltraComboEditor _cmbSpec;
  34. public UltraComboEditor CmbSpec
  35. {
  36. get { return _cmbSpec; }
  37. set { _cmbSpec = value; }
  38. }
  39. public CtrlMscRBlSpec(System.Windows.Forms.Control container, OpeBase ob)
  40. {
  41. InitializeComponent();
  42. _ob = ob;
  43. container.Controls.Add(this);
  44. _queryableRows = ultraGrid1.Rows.AsQueryable().Where("Chk = 'True'");
  45. _dtMscRBlSpec = new DtMscRBlSpec(this);
  46. this.Dock = DockStyle.Fill;
  47. InitUi();
  48. }
  49. protected override void OnLoad(EventArgs e)
  50. {
  51. base.OnLoad(e);
  52. _cmbSpec.AutoCompleteMode = Infragistics.Win.AutoCompleteMode.SuggestAppend;
  53. }
  54. private void InitUi()
  55. {
  56. _cmbSpec = new UltraComboEditor();
  57. _cmbSpec.Visible = false;
  58. _cmbSpec.DropDownListWidth = -1;
  59. QcmBaseQuery.NitializeSpec(_cmbSpec, "C", false, _ob);
  60. this.Controls.Add(_cmbSpec);
  61. ultraGrid1.DisplayLayout.Bands[0].Columns["SpecCode"].EditorComponent = _cmbSpec;
  62. ultraGrid1.DisplayLayout.Bands[0].Columns["SpecCode"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDown;
  63. EntityHelper.ShowGridCaption<ComMscRBlSpecEntity>(ultraGrid1.DisplayLayout.Bands[0]);
  64. }
  65. public void Query(ComMscRBlSpecEntity queryCondition)
  66. {
  67. _queryCondition = queryCondition;
  68. _dtMscRBlSpec.DoQuery("Get");
  69. }
  70. public void QueryHead(ComMscRBlSpecEntity queryCondition)
  71. {
  72. _queryCondition = queryCondition;
  73. _dtMscRBlSpec.DoQuery("GetHead");
  74. }
  75. public void Save()
  76. {
  77. _dtMscRBlSpec.DoAction(ActionType.Save);
  78. }
  79. public void Delete()
  80. {
  81. _dtMscRBlSpec.DoAction(ActionType.Delete);
  82. }
  83. public void Resume()
  84. {
  85. _dtMscRBlSpec.DoAction(ActionType.Resume);
  86. }
  87. public void Clear()
  88. {
  89. mscRBlSpecSrc.Clear();
  90. }
  91. private void ultraGrid1_CellChange(object sender, CellEventArgs e)
  92. {
  93. ultraGrid1.UpdateData();
  94. ControlUltraGrid1Edit(e.Cell.Row);
  95. }
  96. public void ControlUltraGrid1Edit(UltraGridRow row)
  97. {
  98. if (row.Band.Columns["Chk"].Hidden == false)
  99. {
  100. if (row.GetValue("Chk") == "True")
  101. {
  102. row.Cells["SpecCode"].Activation = Activation.AllowEdit;
  103. row.Cells["MinD"].Activation = Activation.AllowEdit;
  104. row.Cells["MaxD"].Activation = Activation.AllowEdit;
  105. row.Cells["MinH"].Activation = Activation.AllowEdit;
  106. row.Cells["MaxH"].Activation = Activation.AllowEdit;
  107. row.Cells["Memo"].Activation = Activation.AllowEdit;
  108. }
  109. else
  110. {
  111. row.Cells["SpecCode"].Activation = Activation.ActivateOnly;
  112. row.Cells["MinD"].Activation = Activation.ActivateOnly;
  113. row.Cells["MaxD"].Activation = Activation.ActivateOnly;
  114. row.Cells["MinH"].Activation = Activation.ActivateOnly;
  115. row.Cells["MaxH"].Activation = Activation.ActivateOnly;
  116. row.Cells["Memo"].Activation = Activation.ActivateOnly;
  117. }
  118. }
  119. }
  120. public void SetInvalidColor(UltraGridRow row)
  121. {
  122. if (row.GetValue("Validflag") == "0")
  123. {
  124. row.Appearance.ForeColor = Color.Red;
  125. }
  126. else
  127. {
  128. row.Appearance.ForeColor = Color.Black;
  129. }
  130. }
  131. private void ultraTextEditor8_EditorButtonClick(object sender, EditorButtonEventArgs e)
  132. {
  133. if (ultraGrid1.ActiveCell.Column.Key == "SpecName")
  134. {
  135. string specs = ultraGrid1.GetActiveRowValue("SPECCODE");
  136. PopupSpecificationsBasics popup = new PopupSpecificationsBasics(specs, _ob);
  137. DialogResult result = popup.ShowDialog();
  138. if (result == DialogResult.OK)
  139. {
  140. string specCodes = "";
  141. string specDescs = "";
  142. foreach (string[] strs in popup.ChoiceSpecs)
  143. {
  144. if (specCodes == "")
  145. {
  146. specCodes += strs[0];
  147. specDescs += strs[1];
  148. }
  149. else
  150. {
  151. specCodes += ";" + strs[0];
  152. specDescs += ";" + strs[1];
  153. }
  154. }
  155. ultraGrid1.ActiveRow.Cells["specCode"].Value = specCodes;
  156. ultraGrid1.ActiveRow.Cells["specName"].Value = specDescs;
  157. }
  158. }
  159. else if (ultraGrid1.ActiveCell.Column.Key == "ModelDesc")
  160. {
  161. UltraGridRow row = this.ultraGrid1.DisplayLayout.ActiveRow;
  162. FrmModel frms = new FrmModel();
  163. frms.Desc = row.Cells["ModelDesc"].Value.ToString();
  164. frms.FrmOb = _ob;
  165. frms.ShowDialog();
  166. row.Cells["ModelCode"].Value = frms.Code;
  167. row.Cells["ModelDesc"].Value = frms.Desc;
  168. }
  169. ultraGrid1.ActiveRow.Update();
  170. }
  171. private void ultraGrid1_AfterRowInsert(object sender, RowEventArgs e)
  172. {
  173. e.Row.Cells["MinD"].Value = null;
  174. e.Row.Cells["MaxD"].Value = null;
  175. e.Row.Cells["MinH"].Value = null;
  176. e.Row.Cells["MaxH"].Value = null;
  177. }
  178. }
  179. }