PlanIOControl.cs 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Drawing;
  5. using System.Data;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using Core.Mes.Client.Comm.Control;
  10. using com.steering.mes.mcp.entity;
  11. using Infragistics.Win.UltraWinGrid;
  12. namespace Core.StlMes.Client.Mcp.Control
  13. {
  14. public partial class McpPlanIOControl : UserControl
  15. {
  16. private McpPlanIO _planIO = new McpPlanIO();
  17. /// <summary>
  18. /// 指示卡控件数据
  19. /// </summary>
  20. public McpPlanIO Value
  21. {
  22. get { return _planIO; }
  23. set
  24. {
  25. if(value != null)
  26. {
  27. this._planIO = value;
  28. UpdateData();
  29. }
  30. }
  31. }
  32. private PlanType _planType = PlanType.HTT;
  33. /// <summary>
  34. /// 计划类型
  35. /// </summary>
  36. public PlanType PlanType
  37. {
  38. get { return _planType; }
  39. set
  40. {
  41. _planType = value;
  42. if (value == PlanType.COUP)
  43. {
  44. ultraGrid1.DisplayLayout.Bands[0].Columns["Pieces"].Header.Caption = "个";
  45. }
  46. else
  47. {
  48. ultraGrid1.DisplayLayout.Bands[0].Columns["Pieces"].Header.Caption = "支";
  49. }
  50. }
  51. }
  52. private PlanIOType _planIOType = PlanIOType.INPUT;
  53. /// <summary>
  54. /// 投入产出类型
  55. /// </summary>
  56. public PlanIOType PlanIOType
  57. {
  58. get { return _planIOType; }
  59. set
  60. {
  61. _planIOType = value;
  62. if (value == PlanIOType.INPUT)
  63. {
  64. ultraGrid1.DisplayLayout.Bands[0].Columns["MaterialName"].Header.Caption = "投入物料";
  65. }
  66. else if(value == PlanIOType.OUTPUT)
  67. {
  68. ultraGrid1.DisplayLayout.Bands[0].Columns["MaterialName"].Header.Caption = "产出物料";
  69. }
  70. if (Value != null)
  71. {
  72. Value.IoType = (int)value;
  73. }
  74. }
  75. }
  76. private Infragistics.Win.UltraWinGrid.UltraGrid _grid = null;
  77. /// <summary>
  78. /// Grid编辑区
  79. /// </summary>
  80. public Infragistics.Win.UltraWinGrid.UltraGrid Grid
  81. {
  82. get { return _grid; }
  83. }
  84. public McpPlanIOControl()
  85. {
  86. InitializeComponent();
  87. GridHelper.InitCardGrid(this.ultraDataSource1, this.ultraGrid1);
  88. ////GridHelper.SetGridActivationExceptCol(this.ultraGrid1, Infragistics.Win.UltraWinGrid.Activation.NoEdit, null);
  89. _grid = this.ultraGrid1;
  90. }
  91. /// <summary>
  92. /// 刷新控件数据显示
  93. /// </summary>
  94. public void UpdateData()
  95. {
  96. if (Value != null && ultraGrid1.Rows != null && ultraGrid1.Rows.Count > 0)
  97. {
  98. ultraDataSource1.Rows[0]["PlanNo"] = Value.PlanNo;
  99. ultraDataSource1.Rows[0]["MaterialCode"] = Value.MaterialCode;
  100. ultraDataSource1.Rows[0]["MaterialName"] = Value.MaterialName;
  101. ultraDataSource1.Rows[0]["Standard"] = Value.Standard;
  102. ultraDataSource1.Rows[0]["Pieces"] = Value.Pieces;
  103. ultraDataSource1.Rows[0]["Tons"] = Value.Weight;
  104. ultraDataSource1.Rows[0]["LengthMin"] = Value.LengthMin;
  105. ultraDataSource1.Rows[0]["LengthMax"] = Value.LengthMax;
  106. }
  107. else
  108. {
  109. GridHelper.InitCardGrid(ultraDataSource1, ultraGrid1);
  110. }
  111. }
  112. /// <summary>
  113. /// 控件编辑后更新已修改数据
  114. /// </summary>
  115. public new void Update()
  116. {
  117. ultraGrid1.UpdateData();
  118. }
  119. /// <summary>
  120. /// 控件数据编辑后更新数据源value
  121. /// </summary>
  122. /// <param name="sender"></param>
  123. /// <param name="e"></param>
  124. private void ultraGrid1_AfterCellUpdate(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e)
  125. {
  126. try
  127. {
  128. //计划控件不需要编辑,不用更新value
  129. //if (e.Cell.Column.Key.Equals("Pieces"))
  130. //{
  131. // value.Pieces = uint.Parse(e.Cell.Value.ToString());
  132. //}
  133. }
  134. catch (Exception ex)
  135. {
  136. }
  137. }
  138. /// <summary>
  139. /// 设置全部只读
  140. /// </summary>
  141. public void SetAllColumnsActiveOnly()
  142. {
  143. GridHelper.SetAllColumnsActive(ultraGrid1);
  144. }
  145. /// <summary>
  146. /// 设置grid中一部分的编辑模式
  147. /// </summary>
  148. /// <param name="pamars">要设置的部分</param>
  149. /// <param name="activation"></param>
  150. public void SetGridActivation(Object[] pamars, Activation activation)
  151. {
  152. if (pamars != null)
  153. {
  154. foreach (string column in pamars)
  155. {
  156. // this.ultraGrid1.DisplayLayout.Override.CellAppearance
  157. this.ultraGrid1.DisplayLayout.Bands[0].Columns[column].CellActivation = activation;
  158. // Infragistics.Win.UltraWinGrid.CellEventArgs e = new CellEventArgs(this.ultraGrid1.Selected.Cells);
  159. //e.Cell.Column.CellActivation.ToString() = activation;
  160. if (activation == Activation.AllowEdit)
  161. {
  162. this.ultraGrid1.DisplayLayout.Bands[0].Columns[column].CellAppearance.BackColor = Color.White;
  163. }
  164. else
  165. {
  166. this.ultraGrid1.DisplayLayout.Bands[0].Columns[column].CellAppearance.BackColor = Color.Gray;
  167. }
  168. }
  169. }
  170. }
  171. }
  172. }