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 Infragistics.Win;
using Infragistics.Win.UltraWinGrid;
using Infragistics.Win.UltraWinDataSource;
using Core.Mes.Client.Comm.Control;
using com.steering.mes.mcp.entity;
using Core.Mes.Client.Comm.Tool;
using CoreFS.CA06;
using Core.Mes.Client.Comm.Server;
namespace Core.StlMes.Client.Mcp.Control
{
public partial class PlanExpanQuery : UserControl
{
private string actnum = "";
private string actwt = "";
public string danum = "";
// private InstructionCard _card = new InstructionCard();
private VrpLoadingResultEntity _load = new VrpLoadingResultEntity();
private OpeBase ob;
public OpeBase Ob
{
get { return ob; }
set { ob = value; }
}
private string judNo;
public string JudNo
{
get { return judNo; }
set { judNo = value; }
}
private string plineCode;
public string PlineCode
{
get { return plineCode; }
set { plineCode = value; }
}
private string batchNo;
public string BatchNo
{
get { return batchNo; }
set { batchNo = value; }
}
private string groupNo;
public string GroupNo
{
get { return groupNo; }
set { groupNo = value; }
}
private string jianZhi;
public string JianZhi
{
get { return jianZhi; }
set { jianZhi = value; }
}
public VrpLoadingResultEntity Value
{
get { return _load; }
set
{
if(value != null)
{
this._load = value;
UpdateData();
}
}
}
private Infragistics.Win.UltraWinGrid.UltraGrid _grid = null;
///
/// 编辑区GRID
///
public Infragistics.Win.UltraWinGrid.UltraGrid Grid
{
get { return _grid; }
}
public PlanExpanQuery()
{
InitializeComponent();
GridHelper.InitCardGrid(ultraDataSource1, ultraGrid1);
_grid = this.ultraGrid1;
}
///
/// 刷新控件数据显示
///
public void UpdateData()
{
// if (JianZhi.Equals("1"))
// {
// ultraGrid1.DisplayLayout.Bands[0].Columns["Producer"].CellActivation = Infragistics.Win.UltraWinGrid.Activation.AllowEdit;
// }
// else
// {
// ultraGrid1.DisplayLayout.Bands[0].Columns["Producer"].CellActivation = Infragistics.Win.UltraWinGrid.Activation.ActivateOnly;
// }
if (_load != null)
{
ultraDataSource1.Rows[0]["Producer"] = _load.Producer;
ultraDataSource1.Rows[0]["ProducerTime"] = _load.ProducerTime;
ultraDataSource1.Rows[0]["ProNum"] = _load.ProNum;
ultraDataSource1.Rows[0]["ProWt"] = _load.ProWt;
ultraDataSource1.Rows[0]["LoadShift"] = _load.LoadShift;
ultraDataSource1.Rows[0]["LoadGroup"] = _load.LoadGroup;
ultraDataSource1.Rows[0]["LoadUser"] = _load.LoadUser;
ultraDataSource1.Rows[0]["LoadTime"] = _load.LoadTime;
//ultraDataSource1.Rows[0]["OnlineWegit"] = _load.LoadWeghit;
actnum = _load.ProNum;
actwt = _load.ProWt;
}
else
{
GridHelper.InitCardGrid(ultraDataSource1,ultraGrid1);
}
this.ultraGrid1.UpdateData();
ultraGrid1.PerformAction(UltraGridAction.ExitEditMode);
ultraGrid1.PerformAction(UltraGridAction.EnterEditMode);
}
///
/// 控件编辑后更新已修改数据
///
public void CompleteEdit()
{
ultraGrid1.UpdateData();
}
private void ultraGrid1_AfterCellUpdate(object sender, CellEventArgs e)
{
try
{
if (e.Cell.Column.Key.Equals("ProNum"))
{
Value.ProNum = e.Cell.Value.ToString();
}
if (e.Cell.Column.Key.Equals("LoadUser"))
{
Value.LoadUser = e.Cell.Value.ToString();
}
if (e.Cell.Column.Key.Equals("LoadTime"))
{
Value.LoadTime = e.Cell.Value.ToString();
}
if (e.Cell.Column.Key.Equals("ProWt"))
{
Value.ProWt = e.Cell.Value.ToString();
}
if (e.Cell.Column.Key.Equals("LoadShift"))
{
Value.LoadShift = e.Cell.Value.ToString();
}
if (e.Cell.Column.Key.Equals("LoadGroup"))
{
Value.LoadGroup = e.Cell.Value.ToString();
}
if (e.Cell.Column.Key.Equals("Producer"))
{
Value.Producer = e.Cell.Value.ToString();
}
if (e.Cell.Column.Key.Equals("ProducerTime"))
{
Value.ProducerTime = e.Cell.Value.ToString();
}
}
catch (Exception ex)
{
}
}
///
/// 验证格试
///
public bool ValidInput1()
{
ultraGrid1.UpdateData();
string TestingNum = ultraDataSource1.Rows[0]["ProNum"].ToString();
string TestingWt = ultraDataSource1.Rows[0]["ProWt"].ToString();
if (!StringUtil.IsInt(TestingNum))
{
MessageBox.Show("上料支数 请输入整数", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return false;
}
if (!StringUtil.IsDouble(TestingWt))
{
MessageBox.Show("上料重量 请输入重量", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return false;
}
return true;
}
private void ultraGrid1_CellChange(object sender, CellEventArgs e)
{
ultraGrid1.UpdateData();
if (e.Cell.Column.Key.Equals("ProNum"))
{
if (ultraDataSource1.Rows[0]["ProNum"].ToString().Equals(""))
{
ultraDataSource1.Rows[0]["ProNum"] = "0";
}
DataTable dt = ServerHelper.GetData("com.steering.mes.mcp.Vrp.FrmVrpLoading.getQueryWeight", new object[] { ultraDataSource1.Rows[0]["ProNum"].ToString(), JudNo, BatchNo, GroupNo, PlineCode }, this.Ob);
//double ctwt = double.Parse(ultraDataSource1.Rows[0]["ProNum"].ToString()) * (double.Parse(actwt) / double.Parse(actnum));
//ultraDataSource1.Rows[0]["ProWt"] = ctwt.ToString();
//Value.ProWt = ultraDataSource1.Rows[0]["ProWt"].ToString();
if (dt.Rows.Count > 0)
{
ultraDataSource1.Rows[0]["ProWt"] = dt.Rows[0]["ACT_WEIGHT"].ToString();
Value.ProWt= ultraDataSource1.Rows[0]["ProWt"].ToString();
}
if (Convert.ToInt32(ultraDataSource1.Rows[0]["ProNum"].ToString())>Convert.ToInt32(danum))
{
MessageUtil.ShowTips("上料支数不允许大于待上料支数!");
ultraDataSource1.Rows[0]["ProNum"] = actnum;
Value.ProNum = ultraDataSource1.Rows[0]["ProNum"].ToString();
ultraDataSource1.Rows[0]["ProWt"] = actwt;
Value.ProWt = ultraDataSource1.Rows[0]["ProWt"].ToString();
return;
}
}
}
}
}