| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250 |
- 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;
- }
- /// <summary>
- /// 按钮控件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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;
- }
- }
- /// <summary>
- /// 界面初始化
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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<DataTable>("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<ultraGrid3.Rows.Count;)
- {
- //if (!ultraGrid3.Rows[i].HasChild())
- //{
- // ultraGrid3.Rows[i].Delete(false);
- //}
- //else
- {
- double bweightqTY = 0;
- double bINNUM = 0;
- double.TryParse(ultraGrid3.Rows[i].Cells["INNUM"].Value.ToString(),out bINNUM);
- double.TryParse(ultraGrid3.Rows[i].Cells["weightqTY"].Value.ToString(), out bweightqTY);
- string strItemUom = ultraGrid3.Rows[i].Cells["itemUom"].Value.ToString().Trim();
- if ("基吨" == strItemUom)
- {
- bINNUM = bweightqTY;
- }
- double bsum = 0;
- string strReceivetype = "";//入库类型
- if (ultraGrid3.Rows[i].ChildBands[0].Rows.Count <= 1)
- {
- ultraGrid3.Rows[i].ChildBands[0].Rows[0].Cells["useQty"].Value = bINNUM;
- }
- else
- {
- foreach (UltraGridRow ugr in ultraGrid3.Rows[i].ChildBands[0].Rows)
- {
- double bUseQty = 0;
- double.TryParse(ugr.Cells["useQty"].Value.ToString(), out bUseQty);
- bsum += bUseQty;
- strReceivetype = ugr.Cells["receivetype"].Value.ToString();
- }
- double bsumR = Math.Round(bsum, 3);
- bINNUM = Math.Round(bINNUM, 3);
- if (bsumR != bINNUM)
- {
- if (strReceivetype == "110107")//JIT入库
- {
- ultraGrid3.Rows[i].CellAppearance.ForeColor = Color.Red;
- }
- }
- }
- i++;
- }
- }
- ultraGrid3.UpdateData();
- //控制输入
- GridHelper.SetExcludeColumnsActive(ultraGrid3.DisplayLayout.Bands[0]);
- //GridHelper.SetExcludeColumnsActive(ultraGrid3.DisplayLayout.Bands[0], "useQty");
- }
- /// <summary>
- /// 确认入库
- /// </summary>
- 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();
- }
- /// <summary>
- /// 改变值
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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;
- }
- }
-
- }
- }
- }
|