using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Data; using System.Linq; using System.Text; using System.Windows.Forms; using Core.Mes.Client.Comm.Control; using com.steering.mes.mcp.entity; using Infragistics.Win.UltraWinGrid; namespace Core.StlMes.Client.Mcp.Control { public partial class McpPlanIOControl : UserControl { private McpPlanIO _planIO = new McpPlanIO(); /// /// 指示卡控件数据 /// public McpPlanIO Value { get { return _planIO; } set { if(value != null) { this._planIO = value; UpdateData(); } } } private PlanType _planType = PlanType.HTT; /// /// 计划类型 /// public PlanType PlanType { get { return _planType; } set { _planType = value; if (value == PlanType.COUP) { ultraGrid1.DisplayLayout.Bands[0].Columns["Pieces"].Header.Caption = "个"; } else { ultraGrid1.DisplayLayout.Bands[0].Columns["Pieces"].Header.Caption = "支"; } } } private PlanIOType _planIOType = PlanIOType.INPUT; /// /// 投入产出类型 /// public PlanIOType PlanIOType { get { return _planIOType; } set { _planIOType = value; if (value == PlanIOType.INPUT) { ultraGrid1.DisplayLayout.Bands[0].Columns["MaterialName"].Header.Caption = "投入物料"; } else if(value == PlanIOType.OUTPUT) { ultraGrid1.DisplayLayout.Bands[0].Columns["MaterialName"].Header.Caption = "产出物料"; } if (Value != null) { Value.IoType = (int)value; } } } private Infragistics.Win.UltraWinGrid.UltraGrid _grid = null; /// /// Grid编辑区 /// public Infragistics.Win.UltraWinGrid.UltraGrid Grid { get { return _grid; } } public McpPlanIOControl() { InitializeComponent(); GridHelper.InitCardGrid(this.ultraDataSource1, this.ultraGrid1); ////GridHelper.SetGridActivationExceptCol(this.ultraGrid1, Infragistics.Win.UltraWinGrid.Activation.NoEdit, null); _grid = this.ultraGrid1; } /// /// 刷新控件数据显示 /// public void UpdateData() { if (Value != null && ultraGrid1.Rows != null && ultraGrid1.Rows.Count > 0) { ultraDataSource1.Rows[0]["PlanNo"] = Value.PlanNo; ultraDataSource1.Rows[0]["MaterialCode"] = Value.MaterialCode; ultraDataSource1.Rows[0]["MaterialName"] = Value.MaterialName; ultraDataSource1.Rows[0]["Standard"] = Value.Standard; ultraDataSource1.Rows[0]["Pieces"] = Value.Pieces; ultraDataSource1.Rows[0]["Tons"] = Value.Weight; ultraDataSource1.Rows[0]["LengthMin"] = Value.LengthMin; ultraDataSource1.Rows[0]["LengthMax"] = Value.LengthMax; } else { GridHelper.InitCardGrid(ultraDataSource1, ultraGrid1); } } /// /// 控件编辑后更新已修改数据 /// public new void Update() { ultraGrid1.UpdateData(); } /// /// 控件数据编辑后更新数据源value /// /// /// private void ultraGrid1_AfterCellUpdate(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e) { try { //计划控件不需要编辑,不用更新value //if (e.Cell.Column.Key.Equals("Pieces")) //{ // value.Pieces = uint.Parse(e.Cell.Value.ToString()); //} } catch (Exception ex) { } } /// /// 设置全部只读 /// public void SetAllColumnsActiveOnly() { GridHelper.SetAllColumnsActive(ultraGrid1); } /// /// 设置grid中一部分的编辑模式 /// /// 要设置的部分 /// public void SetGridActivation(Object[] pamars, Activation activation) { if (pamars != null) { foreach (string column in pamars) { // this.ultraGrid1.DisplayLayout.Override.CellAppearance this.ultraGrid1.DisplayLayout.Bands[0].Columns[column].CellActivation = activation; // Infragistics.Win.UltraWinGrid.CellEventArgs e = new CellEventArgs(this.ultraGrid1.Selected.Cells); //e.Cell.Column.CellActivation.ToString() = activation; if (activation == Activation.AllowEdit) { this.ultraGrid1.DisplayLayout.Bands[0].Columns[column].CellAppearance.BackColor = Color.White; } else { this.ultraGrid1.DisplayLayout.Bands[0].Columns[column].CellAppearance.BackColor = Color.Gray; } } } } } }