using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using CoreFS.CA06;using Pur.Entity;
using System.Collections;
using Core.Mes.Client.Comm.Tool;
using Pur.Entity.configureEntity;
using Core.Mes.Client.Comm.Control;
using com.hnshituo.pur.vo;
using Infragistics.Win;
using Pur.Entity;
namespace Pur.ck
{
public partial class frmPopCheckRec : FrmPmsBase
{
object Qb_newcellvalue = null;
public frmPopCheckRec(OpeBase ob, DataTable dt)
{
InitializeComponent();
this.ob = ob;
GridHelper.CopyDataToDatatable(ref dt, ref dataTable1, true);//绑定物料分类表frmCheckItem
GridHelper.SetExcludeColumnsActive(ultraGrid1.DisplayLayout.Bands[0], "RECNOTPASSQTY", "RECPASSQTY");
initRec();
}
///
/// 初始化合格量为收货量
///
private void initRec()
{
for (int i = 0; i < ultraGrid1.Rows.Count; i++)
{
ultraGrid1.Rows[i].Cells["RecNotPassQty"].Value = 0; ;//不合格量
ultraGrid1.Rows[i].Cells["RecPassQty"].Value = ultraGrid1.Rows[i].Cells["RECQTY"].Value; ;//不合格量
}
}
///
/// 值改变同时计算出相应的单元格值
///
///
///
private void ultraGrid1_CellChange(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e)
{
Qb_newcellvalue = e.Cell.Value;
ultraGrid1.UpdateData();
if (e.Cell.Value != null)
{
double b_newcellvalue = double.Parse(e.Cell.Value.ToString());
if (e.Cell.Column.Key == "RECPASSQTY")//合格量
{
double bRECQTY = double.Parse(e.Cell.Row.Cells["RECQTY"].Value.ToString());//收货量
double bRECNOTPASSQTY =0;
double.TryParse(e.Cell.Row.Cells["RECNOTPASSQTY"].Value.ToString(),out bRECNOTPASSQTY);//不合格量
if (bRECNOTPASSQTY != bRECQTY - b_newcellvalue)//若不相等则计算不合格量
{
bRECNOTPASSQTY = bRECQTY - b_newcellvalue;
if (bRECNOTPASSQTY < 0)
{
e.Cell.Value = Qb_newcellvalue;//不允许大于收获量
}
else
{
e.Cell.Row.Cells["RECNOTPASSQTY"].Value = bRECQTY - b_newcellvalue;
}
}
}
else if (e.Cell.Column.Key == "RECNOTPASSQTY")//不合格量
{
double bRECQTY = double.Parse(e.Cell.Row.Cells["RECQTY"].Value.ToString());//收货量
double bRECPASSQTY = 0;
double.TryParse(e.Cell.Row.Cells["RECPASSQTY"].Value.ToString(), out bRECPASSQTY);//合格量
if (bRECPASSQTY != bRECQTY - b_newcellvalue)//若不相等则计算合格量
{
bRECPASSQTY = bRECQTY - b_newcellvalue;
if (bRECPASSQTY < 0)
{
e.Cell.Value = Qb_newcellvalue;//不允许大于收获量
}
else
{
e.Cell.Row.Cells["RECPASSQTY"].Value = bRECQTY - b_newcellvalue;
}
}
}
}
}
///
/// 开始初检
///
private void checkRec()
{
ultraGrid1.UpdateData();
ArrayList alCkRecBillEntity = new ArrayList();
for (int i = 0; i < ultraGrid1.Rows.Count; i++)
{
PurCkRecBillEntity CkRecBillEntity = new PurCkRecBillEntity();
CkRecBillEntity.RecId = ultraGrid1.Rows[i].Cells["RecId"].Value.ToString();
CkRecBillEntity.RecPassQty = double.Parse(ultraGrid1.Rows[i].Cells["RecPassQty"].Value.ToString());//合格量
CkRecBillEntity.Status = "2";
alCkRecBillEntity.Add(CkRecBillEntity);
}
CoreResult crt = this.execute("com.hnshituo.pur.ck.service.CkRecBillService", "checkRec", new object[] { alCkRecBillEntity });
if (crt.Resultcode != 0)
{
MessageUtil.ShowTips("初检失败 " + crt.Resultmsg);
return;
}
MessageUtil.ShowTips("初检成功");
this.Close();
}
///
/// 按钮控件
///
///
///
private void barsManagerButon_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
{
switch (e.Tool.Key.ToString())
{
case "Query":
{
}
break;
case "conFirmation":
{
checkRec();
}
break;
case "ESC":
{
this.Close();
}
break;
}
}
}
}