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 Core.Mes.Client.Comm.Control;
using Infragistics.Win.UltraWinGrid;
using System.Collections;
using Core.Mes.Client.Comm.Tool;
using Pur.Entity.configureEntity;
using Pur.Entity.ck;
using Pur.Entity.require_planEntiy;
namespace Pur.Pop_upWindow
{
public partial class frmPopSetCkInBillOutNum : FrmBase
{
ArrayList al_ExcDeliverySubC = null;
public Hashtable ht = null;
DataTable oldDt = new DataTable();
public string strTips = "0";
public frmPopSetCkInBillOutNum(OpeBase ob, DataTable dt, ArrayList al_ExcDeliverySubC)
{
InitializeComponent();
this.ob = ob;
this.oldDt = dt;
this.al_ExcDeliverySubC = al_ExcDeliverySubC;
}
///
/// 按钮控件
///
///
///
private void barsManagerButon_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
{
switch (e.Tool.Key.ToString())
{
case "Query":
{
}
break;
case "conFirmation":
{
conFirmation();
}
break;
case "ESC":
{
this.Close();
}
break;
}
}
///
/// 界面初始化
///
///
///
private void frmPopSetCkInBillOutNum_Load(object sender, EventArgs e)
{
PurCkInBillEntity CkInBillEntity = new PurCkInBillEntity();//入库单表
string[] strs=new string[al_ExcDeliverySubC.Count];
for (int i = 0; i < al_ExcDeliverySubC.Count; i++)
{
strs[i] = ((ExcDeliverySubC)al_ExcDeliverySubC[i]).DeliverySubLineSqe;
}
for (int i = oldDt.Rows.Count-1; i >= 0; i--)
{
if (!strs.Contains(oldDt.Rows[i]["DELIVERYSUBLINESQE"].ToString().Trim()))
{
oldDt.Rows.RemoveAt(i);
}
}
GridHelper.CopyDataToDatatable(oldDt, dataTable4, true);
ultraGrid3.DisplayLayout.Bands[0].PerformAutoResizeColumns(true, PerformAutoSizeType.AllRowsInBand);
//CkInBillEntity.ReceiveType = "1";//1,JIT 2,非JIT
CkInBillEntity.DeliverySubLineSqes = strs;
DataTable dt = this.GetJsonService().execute("com.hnshituo.pur.ck.service.CkInBillService", "GetCkInBillOutNum", new object[] { CkInBillEntity });
if (dt==null || dt.Rows.Count == 0)
{
MessageUtil.ShowTips("未能加载送货单行的关联需求计划,无法进行库存分配");
strTips = "0";
return;
}
GridHelper.CopyDataToDatatable(dt, dataTable1, true);
ultraGrid3.UpdateData();
//删除没有子行的送货单
for(int i=0;i
/// 确认入库
///
private void conFirmation()
{
ultraGrid3.UpdateData();
Hashtable ht = new Hashtable();
//获取领用和出库单
foreach(UltraGridRow ugr in ultraGrid3.Rows)
{
if (ugr.CellAppearance.ForeColor == Color.Red)
{
MessageUtil.ShowTips("标记为红色的送货单表示入库数量和领用出库数量对应不上,需重新填写");
return;
}
foreach (UltraGridRow ugrChid in ugr.ChildBands[0].Rows)
{
ArrayList al = new ArrayList();
UsePlanD upd = new UsePlanD();
upd.ReqOrgId = ugrChid.Cells["ReqOrgId"].Value.ToString();
upd.Remark = ugrChid.Cells["reqorgname"].Value.ToString();
if(String.IsNullOrEmpty(upd.ReqOrgId)||String.IsNullOrEmpty(upd.Remark))
{
MessageUtil.ShowTips("需求计划的:" + ugrChid.Cells["mrlineid"].Value.ToString() + "的申请单为空!");
return;
}
double bUseQty = 0;
double.TryParse(ugrChid.Cells["useQty"].Value.ToString(), out bUseQty);
upd.QtyPur =Math.Round(bUseQty,3);
upd.ReceiveId = ugrChid.Cells["id"].Value.ToString();
upd.PurRequireLineId = ugrChid.Cells["mrlineid"].Value.ToString();
if (bUseQty>0)
{
if (ht.ContainsKey(ugrChid.Cells["deliverysublinesqe"].Value.ToString()))
{
al = (ArrayList)ht[ugrChid.Cells["deliverysublinesqe"].Value.ToString()];
al.Add(upd);
ht[ugrChid.Cells["deliverysublinesqe"].Value.ToString()] = al;
}
else
{
al.Add(upd);
ht.Add(ugrChid.Cells["deliverysublinesqe"].Value.ToString(), al);
}
}
}
}
if (MessageUtil.ShowYesNoAndQuestion("确定入库?").Equals(DialogResult.No))
{
return;
}
strTips = "2";
this.ht = ht;
this.Close();
}
///
/// 改变值
///
///
///
private void ultraGrid3_CellChange(object sender, CellEventArgs e)
{
object o = e.Cell.Value;
ultraGrid3.UpdateData();
if (e.Cell.Column.Key == "useQty")
{
UltraGridRow ugr = e.Cell.Row.ParentRow;
double bINNUM = 0;
double bweightqTY = 0;
double.TryParse(ugr.Cells["INNUM"].Value.ToString(), out bINNUM);
double.TryParse(ugr.Cells["weightqTY"].Value.ToString(), out bweightqTY);
string strItemUom = ugr.Cells["itemUom"].Value.ToString().Trim();
if ("基吨" == strItemUom)
{
bINNUM = bweightqTY;
}
double bsum = 0;
string strReceivetype = "";//入库类型
foreach (UltraGridRow ugr1 in ugr.ChildBands[0].Rows)
{
double bUseQty = 0;
double.TryParse(ugr1.Cells["useQty"].Value.ToString(), out bUseQty);
bsum += bUseQty;
}
bsum = Math.Round(bsum, 3);
bINNUM = Math.Round(bINNUM, 3);
if (bsum != bINNUM)
{
if (strReceivetype == "110107")//JIT入库
{
ugr.CellAppearance.ForeColor = Color.Red;
}
}
else
{
ugr.CellAppearance.ForeColor = Color.Black;
}
}
}
}
}