| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187 |
- 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();
- /// <summary>
- /// 指示卡控件数据
- /// </summary>
- public McpPlanIO Value
- {
- get { return _planIO; }
- set
- {
- if(value != null)
- {
- this._planIO = value;
- UpdateData();
- }
-
- }
- }
- private PlanType _planType = PlanType.HTT;
- /// <summary>
- /// 计划类型
- /// </summary>
- 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;
- /// <summary>
- /// 投入产出类型
- /// </summary>
- 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;
- /// <summary>
- /// Grid编辑区
- /// </summary>
- 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;
- }
- /// <summary>
- /// 刷新控件数据显示
- /// </summary>
- 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);
- }
- }
- /// <summary>
- /// 控件编辑后更新已修改数据
- /// </summary>
- public new void Update()
- {
- ultraGrid1.UpdateData();
- }
- /// <summary>
- /// 控件数据编辑后更新数据源value
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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)
- {
- }
- }
- /// <summary>
- /// 设置全部只读
- /// </summary>
- public void SetAllColumnsActiveOnly()
- {
- GridHelper.SetAllColumnsActive(ultraGrid1);
- }
- /// <summary>
- /// 设置grid中一部分的编辑模式
- /// </summary>
- /// <param name="pamars">要设置的部分</param>
- /// <param name="activation"></param>
- 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;
- }
- }
- }
- }
- }
- }
|