| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300 |
- using com.hnshituo.pur.vo;
- using CoreFS.CA06;
- using Infragistics.Win.UltraWinEditors;
- using Infragistics.Win.UltraWinGrid;
- using Pur.Entity.configureEntity;
- using Pur.Entity.require_planEntiy;
- using Pur.require_plan;
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using Pur.PublicTools;
- using Pur.configure;
- using Pur.Pop_upWindow;
- using Pur.Entity;
- using Core.Mes.Client.Comm.Control;
- using Core.Mes.Client.Comm.Tool;
- namespace Pur.ck
- {
- public partial class frmUsePlanYBNew: FrmPmsBase
- {
- DataTable Qdt = null;//库区
- private string req_org_id = "";
- public frmUsePlanYBNew()
- {
- InitializeComponent();
- this.IsLoadUserView = true;
- }
- private void frmUsePlanYBNew_Load(object sender, EventArgs e)
- {
- txt_status.SelectedIndex = 1;
- ck_ctime.Checked = true;
- txtCreateTimeStart.Value = DateTime.Now.AddMonths(-1);
- txtCreateTimeEnd.Value = DateTime.Now.AddDays(2);
- GridHelper.SetColumnsActive(ultraGrid1.DisplayLayout.Bands[0]);
- GridHelper.SetColumnsActive(ultraGrid2.DisplayLayout.Bands[0]);
- GridHelper.SetExcludeColumnsActive(ultraGrid3.DisplayLayout.Bands[0], new String[] { "Check", "OUTNUM", "OUTNUM1" });
- GridHelper.SetExcludeColumnsActive(ultraGrid4.DisplayLayout.Bands[0], new String[] { "Check" });
- do_outBill.Enabled = true;
- cancel_outBill.Enabled = false;
- }
- #region toolbar工具栏
- public override void ToolBar_Click(object sender, string ToolbarKey)
- {
- switch (ToolbarKey)
- {
- case "Query":
- getUserPlanM("");
- break;
- case "doReceive":
- receiveUserPlanM();
- break;
- case "dofinish":
- finishUserPlanM();
- break;
- case "doReturn":
- returnUserPlanM();
- break;
- case "doExcel":
- doExcel();
- break;
- case "close":
- CloPUR_SUPP();
- break;
-
- }
- }
- /// 导出Excel
- /// </summary>
- private void doExcel()
- {
- try
- {
- this.Cursor = Cursors.Default;
- if (ultraGrid1.ActiveRow == null)
- {
- MessageUtil.ShowTips("请选择需导出明细的领用单头!");
- return;
- }
- //获取导出的采购计划行表
- ArrayList alUltraGrid = new ArrayList();
- alUltraGrid.Add(ultraGrid2);
- ArrayList alSheeft = new ArrayList();
- alSheeft.Add("物料明细");
- if (ultraGrid2.Rows.Count > 0)
- {
- GridHelper.ulGridToExcel(alUltraGrid, alSheeft, "领用单[" + ultraGrid1.ActiveRow.GetCellValue("mrId") + "]明细表");//导出excel
- }
- else
- {
- MessageUtil.ShowTips("领用单:" + ultraGrid1.ActiveRow.GetCellValue("mrId") + "无可导出明细!");
- }
- }
- catch (Exception e)
- {
- MessageUtil.ShowTips("导出失败" + e.Message);
- }
- finally
- {
- this.Cursor = Cursors.Default;
- }
- }
- /// <summary>
- /// 退回
- /// </summary>
- private void returnUserPlanM()
- {
- UltraGridRow uge = ultraGrid1.ActiveRow;
- if (uge == null)
- return;
- String strMrId = uge.Cells["MRID"].Value.ToString();
- if (String.IsNullOrEmpty(strMrId))
- {
- return;
- }
- if (testStatusM(strMrId, 2) == false)
- {
- return;
- }
- String strReason = "";
- frmPopReason frm = new frmPopReason(this.ob);
- frm.ShowDialog();
- if (frm.Tips == "1")
- {
- strReason = frm.Reason;
- }
- else
- {
- return;
- }
- UsePlanM um = new UsePlanM();
- um.MrId = strMrId;
- um.Status = "9";
- um.Quitreson = "[退回] "+strReason;
- um.UpdateName = UserInfo.GetUserName();
- um.UpdateUserid = UserInfo.GetUserID();
- um.UpdateTime = DateTime.Now;
- CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.requireplan.service.UsePlanMService", "doHandleM", new object[] { um });
- if (crt.Resultcode != 0)
- {
- MessageUtil.ShowTips("操作失败:" + crt.Resultmsg);
- return;
- }
- MessageUtil.ShowTips("操作成功");
- getUserPlanM(strMrId);
- }
- /// <summary>
- /// 查询领用单主表
- /// </summary>
- private void getUserPlanM(String strMrId)
- {
- LYM.Clear();
- LYD.Clear();
- stockPos.Clear();
- outStockDt.Clear();
- UsePlanM pupe = new UsePlanM();
- pupe.DeleteUserid = txt_status.Value == null ? "" : txt_status.Value.ToString().Trim();
- pupe.MrId = ultraTextEditor1.Text.Trim();
- pupe.ReqOrgId = req_org_id;
- if (ck_ctime.Checked == true)
- {
- if (txtCreateTimeStart.Text != "")
- {
- pupe.CreateTime = Convert.ToDateTime(txtCreateTimeStart.Value);
- }
- if (txtCreateTimeEnd.Text != "")
- {
- pupe.DeleteTime = Convert.ToDateTime(txtCreateTimeEnd.Value);
- }
- }
- DataTable dt = this.execute<DataTable>("com.hnshituo.pur.requireplan.service.UsePlanMService", "find_UsePlanM", new object[] { pupe });
- GridHelper.CopyDataToDatatable(dt, dataTable1, true);
- GridHelper.RefreshAndAutoSize(ultraGrid1);
- if (!String.IsNullOrEmpty(strMrId))
- {
- publicPms.doActiveSelRow(ultraGrid1, "mrId", strMrId);
- }
- }
- /// <summary>
- /// 完成领用
- /// </summary>
- private void finishUserPlanM()
- {
- UltraGridRow uge = ultraGrid1.ActiveRow;
- if (uge == null)
- return;
- String strMrId = uge.Cells["MRID"].Value.ToString();
- if (String.IsNullOrEmpty(strMrId))
- {
- return;
- }
- UsePlanM um = new UsePlanM();
- um.MrId = strMrId;
- um.Status = "5";
- um.UpdateName = UserInfo.GetUserName();
- um.UpdateUserid = UserInfo.GetUserID();
- um.UpdateTime = DateTime.Now;
- if(testStatusM(strMrId,1)==false)
- {
- return;
- }
- if (MessageUtil.ShowYesNoAndQuestion("确定完成该领用单出库:" + strMrId + "?") != DialogResult.Yes)
- {
- return;
- }
- CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.requireplan.service.UsePlanMService", "doHandleM", new object[] { um });
- if (crt.Resultcode != 0)
- {
- MessageUtil.ShowTips("操作失败:" + crt.Resultmsg);
- return;
- }
- MessageUtil.ShowTips("操作成功");
- getUserPlanM(strMrId);
- }
- /// <summary>
- /// 确认领用单
- /// </summary>
- private void receiveUserPlanM()
- {
- throw new NotImplementedException();
- }
- /// <summary>
- /// 关闭
- /// </summary>
- private void CloPUR_SUPP()
- {
- this.Close();
- }
- #endregion
- #region 库存操作
- /// <summary>
- /// 重新匹配
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void query_ckPos_Click(object sender, EventArgs e)
- {
- }
- /// <summary>
- /// 出库操作
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void do_outBill_Click(object sender, EventArgs e)
- {
- setOutCkBill();
- }
- /// <summary>
- /// 生成出库单
- /// </summary>
- private void setOutCkBill()
- {
- UltraGrid grid = new UltraGrid();
- String isNor = "1";//是否为有主需求出库
- if (ultraTabControl1.SelectedTab == ultraTabControl1.Tabs[0])
- {
- grid = ultraGrid3;
- isNor = "1";
- }
- else if (ultraTabControl1.SelectedTab == ultraTabControl1.Tabs[1])
- {
- grid = ultraGrid5;
- isNor = "0";
- }
- else
- {
- MessageUtil.ShowTips("请选择可出库数据");
- return;
- }
- grid.UpdateData();
- if (ultraGrid2.ActiveRow == null)
- {
- MessageUtil.ShowTips("请选择领用单行进行操作");
- return;
- }
- String strUseLineId = ultraGrid2.ActiveRow.Cells["MrLineId"].Value.ToString().Trim();
- if (String.IsNullOrEmpty(strUseLineId))
- {
- MessageUtil.ShowTips("请选择领用单行号为空");
- return;
- }
- CkOutBill cob = new CkOutBill();
- UsePlanD pupe = this.execute<UsePlanD>("com.hnshituo.pur.requireplan.service.UsePlanDService", "findById", new object[] { strUseLineId });
-
- if (pupe == null)
- {
- MessageUtil.ShowTips("未发现领用单行:" + strUseLineId + " 信息记录");
- return;
- }
- if (pupe.Validflag != "1")
- {
- MessageUtil.ShowTips("领用单行:" + strUseLineId + " 信息记录已经作废");
- return;
- }
- UsePlanM pm = this.execute<UsePlanM>("com.hnshituo.pur.requireplan.service.UsePlanMService", "findById", new object[] { pupe.MrId });
- if (pm == null)
- {
- MessageUtil.ShowTips("未发现领料单头:" + pupe.MrId + "信息记录");
- return;
- }
- if (pm.Validflag != "1")
- {
- MessageUtil.ShowTips("领料单头:" + pupe.MrId + "信息记录可能已作废");
- return;
- }
- if (pm.Status != "2" && pm.Status != "3")
- {
- MessageUtil.ShowTips("领料单头:" + pupe.MrId + "当前状态无法执行出库");
- return;
- }
- cob = EntityHelper.CopyEntity<CkOutBill>(pupe);
- cob.DeliverAddress = pm.DeliveryLocationCode;
- cob.Status = "1";
- if (isNor == "1")
- {
- cob.OutstockType = "4";//非JIT有主
- }
- else
- {
- cob.OutstockType = "6";//非JIT无主
- }
- cob.RefeId = strUseLineId;
- cob.CreateName = UserInfo.GetUserName();
- cob.CreateUserid = UserInfo.GetUserID();
- cob.CreateTime = DateTime.Now;
- cob.Validflag = "1";
- cob.ReleaseQty = 0;
- double bQTYUSE = 0;
- ArrayList al = new ArrayList();
- for (int i = 0; i < grid.Rows.Count; i++)
- {
- UltraGridRow row = grid.Rows[i];
- if (Convert.ToBoolean(row.GetCellValue("Check")) == true)
- {
- double b_OutNum = 0;//出库量
- if (row.GetCellValue("itemUom").ToString() == "基吨")
- {
- double.TryParse(grid.Rows[i].Cells["OUTNUM1"].Value.ToString(), out b_OutNum);//铁合金出库存
- if (b_OutNum <= 0)
- {
- MessageUtil.ShowTips("储位【" + row.Cells["INVPOS"].Value.ToString() + "】的出库量必须>0");
- return;
- }
- }
- else
- {
- double.TryParse(grid.Rows[i].Cells["OUTNUM"].Value.ToString(), out b_OutNum);//非铁合金出采购
- if (b_OutNum <= 0)
- {
- MessageUtil.ShowTips("储位【" + row.Cells["INVPOS"].Value.ToString() + "】的出库量必须>0");
- return;
- }
- }
- CkOutbillPosition cobp = new CkOutbillPosition();
- bQTYUSE += Math.Round(b_OutNum, 4, MidpointRounding.AwayFromZero);
- cobp.OutNum = Math.Round(b_OutNum, 4, MidpointRounding.AwayFromZero);//出库量
- //cob.ReleaseQty += b_OutNum;
- //cobp.Id = ultraGrid1.Rows[i].Cells["INVPOSID"].Value.ToString();
- //cobp.InvId = ultraGrid5.Rows[i].Cells["InvId"].Value.ToString();
- cobp.InvPhysic = grid.Rows[i].Cells["INVPHYSIC"].Value.ToString();
- if (cobp.InvPhysic != pm.InvPhysic)
- {
- MessageUtil.ShowTips("请选择仓库:" + pm.InvPhysic + " 物料进行出库");
- return;
- }
- cobp.InvPosId = grid.Rows[i].Cells["InvPosId"].Value.ToString();
- cobp.InvId = grid.Rows[i].Cells["InvId"].Value.ToString();
- if (String.IsNullOrEmpty(cobp.InvId))
- {
- MessageUtil.ShowTips("选择的出库信息的送货单行不能为空");
- return;
- }
- al.Add(cobp);
- }
- }
- if (al.Count == 0)
- {
- MessageUtil.ShowTips("至少有一个库位出库量>0");
- return;
- }
- cob.ReleaseQty = Math.Round(bQTYUSE, 4, MidpointRounding.AwayFromZero);
- double canUse1=Math.Round((double)pupe.Qty-(double)pupe.QtyPur,4);
- if (cob.ReleaseQty > canUse1)
- {
- MessageUtil.ShowTips("总出库数量:" + cob.ReleaseQty + "已经大于该领用单行可编制量:" + canUse1);
- return;
- }
- if (MessageUtil.ShowYesNoAndQuestion("确定对领用单行:" + strUseLineId + " 进行出库(备货)操作?") != DialogResult.Yes)
- {
- return;
- }
- CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.ck.service.CkOutBillService", "doInsert_UpdateNew", new object[] {cob, al,isNor});
- if (crt.Resultcode != 0)
- {
- MessageUtil.ShowTips("出库单生成失败!" + crt.Resultmsg);
- return;
- }
- Core.Mes.Client.Comm.Tool.MessageUtil.ShowTips("出库成功!单号:" + crt.Resultmsg);
- getUserPlanM(pupe.MrId);
- publicPms.doActiveSelRow(ultraGrid2, "MrLineId", strUseLineId);
- }
- /// <summary>
- /// 取消出库操作
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void cancel_outBill_Click(object sender, EventArgs e)
- {
- ultraGrid3.UpdateData();
- if (ultraGrid2.ActiveRow == null)
- {
- MessageUtil.ShowTips("请选择领用单行进行操作");
- return;
- }
- String strUseLineId = ultraGrid2.ActiveRow.Cells["MrLineId"].Value.ToString().Trim();
- if (String.IsNullOrEmpty(strUseLineId))
- {
- MessageUtil.ShowTips("请选择领用单行号为空");
- return;
- }
- ArrayList al = new ArrayList();
- for (int i = 0; i < ultraGrid4.Rows.Count; i++)
- {
- UltraGridRow row = ultraGrid4.Rows[i];
- if (Convert.ToBoolean(row.GetCellValue("Check")) == true)
- {
- CkOutbillPosition cobp = new CkOutbillPosition();
- cobp.OutStockNo = row.Cells["outStockno"].Value.ToString();
- cobp.Id = row.Cells["id"].Value.ToString();
- if (String.IsNullOrEmpty(cobp.Id))
- {
- MessageUtil.ShowTips("选择的撤销的出库单行行号不能为空");
- return;
- }
- cobp.DeleteName = UserInfo.GetUserName();
- cobp.DeleteUserid = UserInfo.GetUserID();
- cobp.DeleteTime= DateTime.Now;
- al.Add(cobp);
- }
- }
- if (al.Count == 0)
- {
- MessageUtil.ShowTips("至少有一个出库记录");
- return;
- }
- if (MessageUtil.ShowYesNoAndQuestion("确定对领用单行:" + strUseLineId + " 进行撤销出库(备货)操作?") != DialogResult.Yes)
- {
- return;
- }
- CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.ck.service.CkOutBillService", "doCancel_OutStock", new object[] { strUseLineId, al });
- if (crt.Resultcode != 0)
- {
- MessageUtil.ShowTips("撤销出库!" + crt.Resultmsg);
- return;
- }
- getUserPlanM(strUseLineId);
- }
- #endregion
- #region 公共函数
- /// <summary>
- /// 查询领用单行表
- /// </summary>
- private void getUserPlanD()
- {
- LYD.Clear();
- stockPos.Clear();
- outStockDt.Clear();
- UltraGridRow uge = ultraGrid1.ActiveRow;
- if (uge == null)
- return;
- UsePlanD pupe = new UsePlanD();
- pupe.MrId = uge.Cells["MRID"].Value.ToString();
- if (String.IsNullOrEmpty(pupe.MrId))
- {
- return;
- }
- pupe.Validflag = "1";
- DataTable dt = this.execute<DataTable>("com.hnshituo.pur.requireplan.service.UsePlanDService", "getUsePlanD", new object[] { pupe });
- foreach (DataRow row in dt.Rows)
- {
- if (row["ITEMUOM"].ToString() == "基吨")
- {
- row["ITEMUOM"] = "吨";
- }
- }
- GridHelper.CopyDataToDatatable(dt, dataTable2, true);
- GridHelper.RefreshAndAutoSize(ultraGrid2);
-
- }
- /// <summary>
- /// 查询有主出库库位
- /// </summary>
- private void getInvPhysicNor()
- {
- stockPos.Clear();
- UltraGridRow ugr = ultraGrid2.ActiveRow;
- if (ugr == null)
- {
- MessageUtil.ShowTips("请选择需出库的物料");
- return;
- }
- String strMrLineId=ugr.Cells["MRLINEID"].Value.ToString().Trim();
- if ( String.IsNullOrEmpty(strMrLineId))
- {
- MessageUtil.ShowTips("该领用单行号为空");
- return;
- }
- UsePlanD ud = this.execute<UsePlanD>("com.hnshituo.pur.requireplan.service.UsePlanDService", "findById", new object[] { strMrLineId });
- UsePlanM um = this.execute<UsePlanM>("com.hnshituo.pur.requireplan.service.UsePlanMService", "findById", new object[] { ud.MrId });
- if (String.IsNullOrEmpty(ud.PurLineId))
- {
- MessageUtil.ShowTips("领用单行:" + strMrLineId + "未关联采购计划号,无法查询库存信息");
- return;
- }
- if (String.IsNullOrEmpty(ud.PurRequireLineId))
- {
- MessageUtil.ShowTips("领用单行:" + strMrLineId + "未关联需求接收号,无法查询库存占用信息");
- return;
- }
- PurCkStoragePosEntity ckp = new PurCkStoragePosEntity();
- ckp.UpdateName = ud.PurLineId;
- ckp.DeleteName = ud.ReceiveId;
- ckp.InvPhysic = um.InvPhysic;
- ckp.UpdateUserid = "nor";//查询有主需求
- DataTable dt = this.execute<DataTable>("com.hnshituo.pur.ck.service.CkStoragePosService", "getCkStoragePosUse", new object[] { ckp });
- if (dt == null || dt.Rows.Count <= 0)
- {
- ultraTabControl1.SelectedTab = ultraTabControl1.Tabs[1];
- }
- else
- {
- ultraTabControl1.SelectedTab = ultraTabControl1.Tabs[0];
- }
- GridHelper.CopyDataToDatatable(ref dt, ref dataTable3, true);
- double canOutNum = (double)ud.Qty - (ud.QtyPur == null ? 0 : (double)ud.QtyPur);
- double canOutNum1 = (ud.QtyUnnormal == null ? 0 : (double)ud.QtyUnnormal) - (ud.QtyUnnormalPur == null ? 0 : (double)ud.QtyUnnormalPur);
- if (canOutNum1 > 0)
- {
- canOutNum = canOutNum - canOutNum1;
- }
- double tempCanUseQty = canOutNum;
- Hashtable table = new Hashtable();
- double norQtyNor = 0;
- double norQtyNorWeight = 0;
- foreach (UltraGridRow row in ultraGrid3.Rows)
- {
- String strInvId = row.GetCellValue("invId").ToString().Trim();
- double.TryParse(row.GetCellValue("qtyNor").ToString(), out norQtyNor);
- double.TryParse(row.GetCellValue("qtyNorWeight").ToString(), out norQtyNorWeight);
- double UseQtyInInv = 0;
- double createQty=0;
- if (table.ContainsKey(strInvId))
- {
- UseQtyInInv = (double)table[strInvId];
- }
- if (String.IsNullOrEmpty(strInvId))
- {
- continue;
- }
- if (row.GetCellValue("itemUom").ToString() == "基吨")
- {
- //row.Cells["itemUom"].Value = "吨";
- double needQty = 0;
- double dbItemUomConefficient = 1;
- double.TryParse(row.GetCellValue("INVQTYWEIGHT").ToString(), out needQty);//库存需出库量
- double.TryParse(row.GetCellValue("itemUomConefficient").ToString(), out dbItemUomConefficient);
- if (tempCanUseQty > 0 && needQty > 0)
- {
- if (needQty >= tempCanUseQty)
- {
- if (tempCanUseQty <= norQtyNorWeight - UseQtyInInv)
- {
- createQty=tempCanUseQty;
- row.Cells["OUTNUM1"].Value =createQty ;//库存出库量
- row.Cells["OUTNUM"].Value = Math.Round(createQty * dbItemUomConefficient, 4);//采购出库量
- tempCanUseQty = 0;
- row.Cells["Check"].Value = true;
- }
- else
- {
- createQty = (norQtyNorWeight - UseQtyInInv) < 0 ? 0 : (norQtyNorWeight - UseQtyInInv);
- if(createQty>0)
- {
- row.Cells["OUTNUM1"].Value = createQty;//库存出库量
- row.Cells["OUTNUM"].Value = Math.Round(createQty * dbItemUomConefficient, 4);//采购出库量
- tempCanUseQty = tempCanUseQty - createQty;
- row.Cells["Check"].Value = true;
- }
- }
- if (table.ContainsKey(strInvId))
- {
- table[strInvId] = UseQtyInInv + createQty;
- }
- }
- else//需要的小
- {
- if (needQty <= norQtyNorWeight - UseQtyInInv)
- {
- createQty = needQty;
- row.Cells["OUTNUM1"].Value = createQty;//库存出库量
- row.Cells["OUTNUM"].Value = Math.Round(createQty * dbItemUomConefficient, 4);//采购出库量
- tempCanUseQty = tempCanUseQty - createQty;
- row.Cells["Check"].Value = true;
- }
- else
- {
- createQty = (norQtyNorWeight - UseQtyInInv) < 0 ? 0 : (norQtyNorWeight - UseQtyInInv);
- if (createQty > 0)
- {
- row.Cells["OUTNUM1"].Value = createQty;//库存出库量
- row.Cells["OUTNUM"].Value = Math.Round(createQty * dbItemUomConefficient, 4);//采购出库量
- tempCanUseQty = tempCanUseQty - createQty;
- row.Cells["Check"].Value = true;
- }
- }
- if (table.ContainsKey(strInvId))
- {
- table[strInvId] = UseQtyInInv + createQty;
- }
- }
- }
- }
- else {
- double needQty = 0;
- double dbItemUomConefficient = 1;
- double.TryParse(row.GetCellValue("invqty").ToString(), out needQty);//采购需出库量
- double.TryParse(row.GetCellValue("itemUomConefficient").ToString(), out dbItemUomConefficient);
- if (tempCanUseQty > 0 && needQty > 0)
- {
- if (needQty >= tempCanUseQty)
- {
- if (tempCanUseQty <= norQtyNor - UseQtyInInv)
- {
- createQty = tempCanUseQty;
- row.Cells["OUTNUM"].Value = createQty;
- row.Cells["OUTNUM1"].Value = Math.Round(createQty / dbItemUomConefficient, 4, MidpointRounding.AwayFromZero);//采购出库量
- tempCanUseQty = 0;
- row.Cells["Check"].Value = true;
- }
- else
- {
- createQty = (norQtyNor - UseQtyInInv) < 0 ? 0 : (norQtyNor - UseQtyInInv);
- if (createQty > 0)
- {
- row.Cells["OUTNUM"].Value = createQty;//库存出库量
- row.Cells["OUTNUM1"].Value = Math.Round(createQty * dbItemUomConefficient, 4);//采购出库量
- tempCanUseQty = tempCanUseQty - createQty;
- row.Cells["Check"].Value = true;
- }
- }
- if (table.ContainsKey(strInvId))
- {
- table[strInvId] = UseQtyInInv + createQty;
- }
- }
- else
- {
- if (needQty <= norQtyNor - UseQtyInInv)
- {
- createQty = needQty;
- row.Cells["OUTNUM"].Value = needQty;
- row.Cells["OUTNUM1"].Value = Math.Round(createQty / dbItemUomConefficient, 4, MidpointRounding.AwayFromZero);//采购出库量
- tempCanUseQty = tempCanUseQty - createQty;
- row.Cells["Check"].Value = true;
- }
- else
- {
- createQty = (norQtyNor - UseQtyInInv) < 0 ? 0 : (norQtyNor - UseQtyInInv);
- if (createQty > 0)
- {
- row.Cells["OUTNUM1"].Value = createQty;//库存出库量
- row.Cells["OUTNUM"].Value = Math.Round(createQty * dbItemUomConefficient, 4);//采购出库量
- tempCanUseQty = tempCanUseQty - createQty;
- row.Cells["Check"].Value = true;
- }
- }
- if (table.ContainsKey(strInvId))
- {
- table[strInvId] = UseQtyInInv + createQty;
- }
- }
- }
-
- }
- }
- GridHelper.RefreshAndAutoSize(ultraGrid3);
- }
- /// <summary>
- /// 查询无主出库库位
- /// </summary>
- private void getInvPhysicUnnor()
- {
- stockPosUnnor.Clear();
- UltraGridRow ugr = ultraGrid2.ActiveRow;
- if (ugr == null)
- {
- MessageUtil.ShowTips("请选择需出库的物料");
- return;
- }
- String strMrLineId = ugr.Cells["MRLINEID"].Value.ToString().Trim();
- if (String.IsNullOrEmpty(strMrLineId))
- {
- MessageUtil.ShowTips("该领用单行号为空");
- return;
- }
- UsePlanD ud = this.execute<UsePlanD>("com.hnshituo.pur.requireplan.service.UsePlanDService", "findById", new object[] { strMrLineId });
- UsePlanM um = this.execute<UsePlanM>("com.hnshituo.pur.requireplan.service.UsePlanMService", "findById", new object[] { ud.MrId });
- if (String.IsNullOrEmpty(ud.PurLineId))
- {
- MessageUtil.ShowTips("领用单行:" + strMrLineId + "未关联采购计划号,无法查询库存信息");
- return;
- }
- if (String.IsNullOrEmpty(ud.PurRequireLineId))
- {
- MessageUtil.ShowTips("领用单行:" + strMrLineId + "未关联需求接收号,无法查询库存占用信息");
- return;
- }
- PurCkStoragePosEntity ckp = new PurCkStoragePosEntity();
- ckp.UpdateName = ud.PurLineId;
- ckp.DeleteName = ud.ReceiveId;
- ckp.InvPhysic = um.InvPhysic;
- ckp.UpdateUserid = "unNor";//查询有主需求
- DataTable dt = this.execute<DataTable>("com.hnshituo.pur.ck.service.CkStoragePosService", "getCkStoragePosUse", new object[] { ckp });
- GridHelper.CopyDataToDatatable(ref dt, ref dataTable5, true);
- double canOutNum = (ud.QtyUnnormal == null ? 0 : (double)ud.QtyUnnormal) - (ud.QtyUnnormalPur == null ? 0 : (double)ud.QtyUnnormalPur);
- canOutNum = canOutNum < 0 ? 0 : canOutNum;
- double tempCanUseQty = canOutNum;
- Hashtable table = new Hashtable();
- double unnorQtyNor = 0;
- double unnorQtyNorWeight = 0;
- foreach (UltraGridRow row in ultraGrid5.Rows)
- {
- String strInvId = row.GetCellValue("invId").ToString().Trim();
- double.TryParse(row.GetCellValue("qtyUnnor").ToString(), out unnorQtyNor);
- double.TryParse(row.GetCellValue("qtyUnnorWeight").ToString(), out unnorQtyNorWeight);
- double UseQtyInInv = 0;
- double createQty = 0;
- if (table.ContainsKey(strInvId))
- {
- UseQtyInInv = (double)table[strInvId];
- }
- if (row.GetCellValue("itemUom").ToString() == "基吨")
- {
- //row.Cells["itemUom"].Value = "吨";
- double needQty = 0;
- double dbItemUomConefficient = 1;
- double.TryParse(row.GetCellValue("INVQTYWEIGHT").ToString(), out needQty);//库存需出库量
- double.TryParse(row.GetCellValue("itemUomConefficient").ToString(), out dbItemUomConefficient);
- if (tempCanUseQty > 0 && needQty > 0)
- {
- if (needQty >= tempCanUseQty)
- {
- if (tempCanUseQty <= unnorQtyNorWeight - UseQtyInInv)
- {
- createQty = tempCanUseQty;
- row.Cells["OUTNUM1"].Value = createQty;//库存出库量
- row.Cells["OUTNUM"].Value = Math.Round(createQty * dbItemUomConefficient, 4);//采购出库量
- tempCanUseQty = 0;
- row.Cells["Check"].Value = true;
- }
- else
- {
- createQty = (unnorQtyNorWeight - UseQtyInInv) < 0 ? 0 : (unnorQtyNorWeight - UseQtyInInv);
- if (createQty > 0)
- {
- row.Cells["OUTNUM1"].Value = createQty;//库存出库量
- row.Cells["OUTNUM"].Value = Math.Round(createQty * dbItemUomConefficient, 4);//采购出库量
- tempCanUseQty = tempCanUseQty - createQty;
- row.Cells["Check"].Value = true;
- }
- }
- if (table.ContainsKey(strInvId))
- {
- table[strInvId] = UseQtyInInv + createQty;
- }
- }
- else
- {
- if (needQty <= unnorQtyNorWeight - UseQtyInInv)
- {
- createQty = needQty;
- row.Cells["OUTNUM1"].Value = createQty;//库存出库量
- row.Cells["OUTNUM"].Value = Math.Round(createQty * dbItemUomConefficient, 4);//采购出库量
- tempCanUseQty = tempCanUseQty - createQty;
- row.Cells["Check"].Value = true;
- }
- else
- {
- createQty = (unnorQtyNorWeight - UseQtyInInv) < 0 ? 0 : (unnorQtyNorWeight - UseQtyInInv);
- if (createQty > 0)
- {
- row.Cells["OUTNUM1"].Value = createQty;//库存出库量
- row.Cells["OUTNUM"].Value = Math.Round(createQty * dbItemUomConefficient, 4);//采购出库量
- tempCanUseQty = tempCanUseQty - createQty;
- row.Cells["Check"].Value = true;
- }
- }
- if (table.ContainsKey(strInvId))
- {
- table[strInvId] = UseQtyInInv + createQty;
- }
- }
- }
- }
- else
- {
- double needQty = 0;
- double dbItemUomConefficient = 1;
- double.TryParse(row.GetCellValue("invqty").ToString(), out needQty);//采购需出库量
- double.TryParse(row.GetCellValue("itemUomConefficient").ToString(), out dbItemUomConefficient);
- if (tempCanUseQty > 0 && needQty > 0)
- {
- if (needQty >= tempCanUseQty)
- {
- if (tempCanUseQty <= unnorQtyNor - UseQtyInInv)
- {
- createQty = tempCanUseQty;
- row.Cells["OUTNUM"].Value = createQty;
- row.Cells["OUTNUM1"].Value = Math.Round(createQty / dbItemUomConefficient, 4, MidpointRounding.AwayFromZero);//采购出库量
- tempCanUseQty = 0;
- row.Cells["Check"].Value = true;
- }
- else
- {
- createQty = (unnorQtyNor - UseQtyInInv) < 0 ? 0 : (unnorQtyNor - UseQtyInInv);
- if (createQty > 0)
- {
- row.Cells["OUTNUM"].Value = createQty;
- row.Cells["OUTNUM1"].Value = Math.Round(createQty / dbItemUomConefficient, 4, MidpointRounding.AwayFromZero);//采购出库量
- tempCanUseQty = tempCanUseQty - createQty;
- row.Cells["Check"].Value = true;
- }
- }
- if (table.ContainsKey(strInvId))
- {
- table[strInvId] = UseQtyInInv + createQty;
- }
- }
- else
- {
- if (needQty <= unnorQtyNor - UseQtyInInv)
- {
- createQty = needQty;
- row.Cells["OUTNUM"].Value = createQty;
- row.Cells["OUTNUM1"].Value = Math.Round(createQty / dbItemUomConefficient, 4, MidpointRounding.AwayFromZero);//采购出库量
- tempCanUseQty = tempCanUseQty - createQty;
- row.Cells["Check"].Value = true;
- }
- else
- {
- createQty = (unnorQtyNor - UseQtyInInv) < 0 ? 0 : (unnorQtyNor - UseQtyInInv);
- if (createQty > 0)
- {
- row.Cells["OUTNUM"].Value = createQty;
- row.Cells["OUTNUM1"].Value = Math.Round(createQty / dbItemUomConefficient, 4, MidpointRounding.AwayFromZero);//采购出库量
- tempCanUseQty = tempCanUseQty - createQty;
- row.Cells["Check"].Value = true;
- }
- }
- if (table.ContainsKey(strInvId))
- {
- table[strInvId] = UseQtyInInv + createQty;
- }
- }
- }
- }
- }
- GridHelper.RefreshAndAutoSize(ultraGrid5);
- }
- private void getOutBillPos()
- {
- try
- {
- outStockDt.Clear();
- UltraGridRow ugr = ultraGrid2.ActiveRow;
- if (ugr == null)
- {
- MessageUtil.ShowTips("请选择需出库的物料");
- return;
- }
- String strMrLineId = ugr.Cells["MRLINEID"].Value.ToString().Trim();
- if (String.IsNullOrEmpty(strMrLineId))
- {
- MessageUtil.ShowTips("该领用单行号为空");
- return;
- }
- UsePlanD ud = this.execute<UsePlanD>("com.hnshituo.pur.requireplan.service.UsePlanDService", "findById", new object[] { strMrLineId });
- UsePlanM um = this.execute<UsePlanM>("com.hnshituo.pur.requireplan.service.UsePlanMService", "findById", new object[] { ud.MrId });
- if (String.IsNullOrEmpty(ud.PurLineId))
- {
- MessageUtil.ShowTips("领用单行:" + strMrLineId + "未关联采购计划号,无法查询库存信息");
- return;
- }
- CkOutbillPosition cp = new CkOutbillPosition();
- cp.UpdateName = strMrLineId;
- DataTable dt = this.execute<DataTable>("com.hnshituo.pur.ck.service.CkOutbillPositionService", "doQueryCkOutbillPosition", new object[] { cp });
- if (dt != null && dt.Rows.Count >= 1)
- {
- GridHelper.CopyDataToDatatable(ref dt, ref dataTable4, true);
- GridHelper.RefreshAndAutoSize(ultraGrid4);
- }
- }
- catch (Exception ex)
- {
- MessageBox.Show("操作失败:" + ex.Message, "提示");
- }
- }
- /// <summary>
- /// 校验状态
- /// </summary>
- /// <param name="strMrId"></param>
- /// <returns></returns>
- private bool testStatusM(string strMrId, int i)
- {
- UsePlanM up = this.execute<UsePlanM>("com.hnshituo.pur.requireplan.service.UsePlanMService", "findById", new object[] { strMrId });
- if (up == null)
- {
- MessageUtil.ShowTips("未发现领料单头:" + strMrId + "信息记录");
- return false;
- }
- if (up.Validflag != "1")
- {
- MessageUtil.ShowTips("领料单头:" + strMrId + "信息记录可能已作废");
- return false;
- }
- //完成领用
- if (i == 1)
- {
- if (up.Status == "2" || up.Status == "1" || up.Status=="9")
- {
- MessageUtil.ShowTips("还未备货,无法确认出库");
- return false;
- }
- else if (up.Status == "5" || up.Status == "6")
- {
- MessageUtil.ShowTips("已出库,无需重复操作");
- return false;
- }
- else if (up.Status == "3")
- {
- if (MessageUtil.ShowYesNoAndQuestion("还未全部备货,确定执行出库?") != DialogResult.Yes)
- {
- return false;
- }
- }
- }
- else if (i == 2)
- {
- if (up.Status!= "2")
- {
- MessageUtil.ShowTips("不在待确认状态,无法退回!若有出库(备货),请先取消出库(备货)!");
- return false;
- }
- }
- else
- {
- MessageUtil.ShowTips("参数异常");
- }
- return true;
- }
- #endregion
- #region 界面事件
- private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
- {
- getUserPlanD();
- }
- /// <summary>
- /// 填写出库量
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ultraGrid5_CellChange(object sender, CellEventArgs e)
- {
- object o = e.Cell.Value;
- ultraGrid5.UpdateData();
- double canUse = 0;
- double canUseUom = 0;
- double canUseWeight = 0;
- double conf = 0;
- double norQtyNor = 0;
- double norQtyNorWeight = 0;
- if (ultraGrid2.ActiveRow != null)
- {
- double b_QTY = 0;//领用量
- double.TryParse(ultraGrid2.ActiveRow.Cells["QTY"].Value.ToString(), out b_QTY);
- double b_QTY_pur = 0;//领用量
- double.TryParse(ultraGrid2.ActiveRow.Cells["QTYPUR"].Value.ToString(), out b_QTY_pur);
- canUse = Math.Round((b_QTY - b_QTY_pur), 4, MidpointRounding.AwayFromZero);
- }
- else
- {
- MessageUtil.ShowTips("请选择待出库物料");
- e.Cell.Value = o;
- return;
- }
- double.TryParse(e.Cell.Row.GetCellValue("invqty").ToString(), out canUseUom);
- double.TryParse(e.Cell.Row.GetCellValue("INVQTYWEIGHT").ToString(), out canUseWeight);
- double.TryParse(e.Cell.Row.GetCellValue("itemUomConefficient").ToString(), out conf);
- double.TryParse(e.Cell.Row.GetCellValue("qtyUnnor").ToString(), out norQtyNor);
- double.TryParse(e.Cell.Row.GetCellValue("qtyUnnorWeight").ToString(), out norQtyNorWeight);
- String strInvId = e.Cell.Row.GetCellValue("invId").ToString().Trim();
- if (String.IsNullOrEmpty(strInvId))
- {
- MessageUtil.ShowTips("请选择待出库库存的库存记录号不能为空");
- e.Cell.Value = o;
- return;
- }
- if (e.Cell.Column.Key == "OUTNUM")//采购数量
- {
- double b_OutNum_nor_q = 0;//库存有主需求出库量总
- double b_OutNum_q = 0;//出库总量
- double OutNum = 0;//出库量
- double.TryParse(e.Cell.Row.GetCellValue("OUTNUM").ToString(), out OutNum);
- for (int i = 0; i < ultraGrid5.Rows.Count; i++)
- {
- double b_OutNum = 0;//出库量
- double.TryParse(ultraGrid5.Rows[i].Cells["OUTNUM"].Value.ToString(), out b_OutNum);
- b_OutNum_q += Math.Round(b_OutNum, 4, MidpointRounding.AwayFromZero);
- if (ultraGrid5.Rows[i].Cells["invId"].Value.ToString().Trim() == strInvId)
- {
- b_OutNum_nor_q = b_OutNum_nor_q + b_OutNum;
- }
- }
- if (b_OutNum_q > canUse)
- {
- MessageUtil.ShowTips("已大于领用单可编制量:" + canUse + "");
- e.Cell.Value = o;
- return;
- }
- if (b_OutNum_nor_q > norQtyNor)
- {
- MessageUtil.ShowTips("库存记录总编制量已大于该单位在该库存记录下的无主库存量(采购单位)");
- e.Cell.Value = o;
- return;
- }
- if (OutNum > canUseUom)
- {
- MessageUtil.ShowTips("已大于在库量(采购单位):" + canUseUom + "");
- e.Cell.Value = o;
- return;
- }
- if (e.Cell.Row.GetCellValue("itemUom").ToString() == "基吨")
- {
- e.Cell.Row.Cells["OUTNUM1"].Value = Math.Round(OutNum / conf, 4, MidpointRounding.AwayFromZero);
- }
- else
- {
- e.Cell.Row.Cells["OUTNUM1"].Value = Math.Round(conf * OutNum, 4, MidpointRounding.AwayFromZero);
- }
- }
- else if (e.Cell.Column.Key == "OUTNUM1")//库存数量
- {
- double OutNum1 = 0;//库存单位出库量
- double.TryParse(e.Cell.Row.GetCellValue("OUTNUM1").ToString(), out OutNum1);
- double b_OutNum_nor_q = 0;//库存有主需求出库量总
- for (int i = 0; i < ultraGrid5.Rows.Count; i++)
- {
- double b_OutNum = 0;//出库量
- double.TryParse(ultraGrid5.Rows[i].Cells["OUTNUM1"].Value.ToString(), out b_OutNum);
- if (ultraGrid5.Rows[i].Cells["invId"].Value.ToString().Trim() == strInvId)
- {
- b_OutNum_nor_q = b_OutNum_nor_q + b_OutNum;
- }
- }
- if (OutNum1 > canUseWeight)
- {
- MessageUtil.ShowTips("已大于在库量(库存单位):" + canUseWeight + "");
- e.Cell.Value = o;
- return;
- }
- if (e.Cell.Row.GetCellValue("itemUom").ToString() == "基吨")
- {
- e.Cell.Row.Cells["OUTNUM"].Value = Math.Round(OutNum1 * conf, 4, MidpointRounding.AwayFromZero);
- }
- else
- {
- e.Cell.Row.Cells["OUTNUM"].Value = Math.Round(OutNum1 / conf, 4, MidpointRounding.AwayFromZero);
- }
- }
- ultraGrid5.UpdateData();
- }
- /// <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();
- double canUse=0;
- double canUseUom = 0;
- double canUseWeight = 0;
- double conf = 0;
- double norQtyNor = 0;
- double norQtyNorWeight = 0;
- if (ultraGrid2.ActiveRow != null)
- {
- double b_QTY = 0;//领用量
- double.TryParse(ultraGrid2.ActiveRow.Cells["QTY"].Value.ToString(), out b_QTY);
- double b_QTY_pur = 0;//领用量
- double.TryParse(ultraGrid2.ActiveRow.Cells["QTYPUR"].Value.ToString(), out b_QTY_pur);
- canUse = Math.Round((b_QTY - b_QTY_pur), 4, MidpointRounding.AwayFromZero);
- }
- else
- {
- MessageUtil.ShowTips("请选择待出库物料");
- e.Cell.Value = o;
- return;
- }
- double.TryParse(e.Cell.Row.GetCellValue("invqty").ToString(), out canUseUom);
- double.TryParse(e.Cell.Row.GetCellValue("INVQTYWEIGHT").ToString(), out canUseWeight);
- double.TryParse(e.Cell.Row.GetCellValue("itemUomConefficient").ToString(), out conf);
- double.TryParse(e.Cell.Row.GetCellValue("qtyNor").ToString(), out norQtyNor);
- double.TryParse(e.Cell.Row.GetCellValue("qtyNorWeight").ToString(), out norQtyNorWeight);
- String strInvId = e.Cell.Row.GetCellValue("invId").ToString().Trim();
- if (String.IsNullOrEmpty(strInvId))
- {
- MessageUtil.ShowTips("请选择待出库库存的库存记录号不能为空");
- e.Cell.Value = o;
- return;
- }
- if(e.Cell.Column.Key=="OUTNUM")//采购数量
- {
- double b_OutNum_nor_q = 0;//库存有主需求出库量总
- double b_OutNum_q = 0;//出库总量
- double OutNum = 0;//出库量
- double.TryParse(e.Cell.Row.GetCellValue("OUTNUM").ToString(), out OutNum);
- for(int i=0;i<ultraGrid3.Rows.Count;i++)
- {
- double b_OutNum = 0;//出库量
- double.TryParse(ultraGrid3.Rows[i].Cells["OUTNUM"].Value.ToString(), out b_OutNum);
- b_OutNum_q += Math.Round(b_OutNum, 4, MidpointRounding.AwayFromZero);
- if (ultraGrid3.Rows[i].Cells["invId"].Value.ToString().Trim() == strInvId)
- {
- b_OutNum_nor_q = b_OutNum_nor_q + b_OutNum_q;
- }
- }
- if (b_OutNum_nor_q > norQtyNor)
- {
- MessageUtil.ShowTips("库存记录总编制量已大于该单位在该库存记录下的占用量(计量单位)");
- e.Cell.Value = o;
- return;
- }
- if (OutNum > canUseUom)
- {
- MessageUtil.ShowTips("已大于在库量(采购单位):" + canUseUom + "");
- e.Cell.Value = o;
- return;
- }
- if (e.Cell.Row.GetCellValue("itemUom").ToString() == "基吨")
- {
- e.Cell.Row.Cells["OUTNUM1"].Value = Math.Round(OutNum/conf , 4, MidpointRounding.AwayFromZero);
- }
- else {
- if (b_OutNum_q > canUse)
- {
- MessageUtil.ShowTips("已大于领用单可编制量:" + canUse + "");
- e.Cell.Value = o;
- return;
- }
- e.Cell.Row.Cells["OUTNUM1"].Value = Math.Round(conf * OutNum, 4, MidpointRounding.AwayFromZero);
- }
- }
- else if (e.Cell.Column.Key == "OUTNUM1")//库存数量
- {
- double OutNum1 = 0;//库存单位出库量
- double.TryParse(e.Cell.Row.GetCellValue("OUTNUM1").ToString(), out OutNum1);
- double b_OutNum_nor_q = 0;//库存有主需求出库量总(库存)
- double b_OutNum_q = 0;//出库总量(库存)
- for (int i = 0; i < ultraGrid3.Rows.Count; i++)
- {
- double b_OutNum = 0;//出库量
- double.TryParse(ultraGrid3.Rows[i].Cells["OUTNUM1"].Value.ToString(), out b_OutNum);
- b_OutNum_q += Math.Round(b_OutNum, 4, MidpointRounding.AwayFromZero);
- if (ultraGrid3.Rows[i].Cells["invId"].Value.ToString().Trim() == strInvId)
- {
- b_OutNum_nor_q = b_OutNum_nor_q + b_OutNum_q;
- }
- }
- if (b_OutNum_nor_q > norQtyNorWeight)
- {
- MessageUtil.ShowTips("库存记录总编制量已大于该单位在该库存记录下的占用量(库存单位)");
- e.Cell.Value = o;
- return;
- }
- //校验编制量不能大于库存量
- if (OutNum1 > canUseWeight)
- {
- MessageUtil.ShowTips("已大于在库量(库存单位):" + canUseWeight + "");
- e.Cell.Value = o;
- return;
- }
- if (e.Cell.Row.GetCellValue("itemUom").ToString() == "基吨")
- {
- if (b_OutNum_q > canUse)
- {
- MessageUtil.ShowTips("已大于领用单可编制量:" + canUse + "");
- e.Cell.Value = o;
- return;
- }
- e.Cell.Row.Cells["OUTNUM"].Value = Math.Round(OutNum1*conf, 4, MidpointRounding.AwayFromZero);
- }
- else
- {
- e.Cell.Row.Cells["OUTNUM"].Value = Math.Round(OutNum1 / conf, 4, MidpointRounding.AwayFromZero);
- }
- }
- ultraGrid3.UpdateData();
- }
- /// <summary>
- /// 激活领用单行
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ultraGrid2_AfterRowActivate(object sender, EventArgs e)
- {
- getInvPhysicNor();
- getInvPhysicUnnor();
- getOutBillPos();
- }
- private void ultraGrid2_InitializeLayout(object sender, InitializeLayoutEventArgs e)
- {
- }
- private void ck_ctime_CheckedChanged(object sender, EventArgs e)
- {
- if (ck_ctime.Checked == false)
- {
- txtCreateTimeEnd.Enabled = false;
- txtCreateTimeStart.Enabled = false;
- }
- else
- {
- txtCreateTimeEnd.Enabled = true;
- txtCreateTimeStart.Enabled = true;
- }
- }
- private void txt_REQ_ORG_EditorButtonClick(object sender, EditorButtonEventArgs e)
- {
- frmdepartment frm = new frmdepartment(this.ob);
- frm.StartPosition = FormStartPosition.Manual;
- frm.Location = publicPms.getShowLocation(frm);
- frm.ShowDialog();
- String strdeptId = frm.BuyerUnitCode;
- String strDeptName = frm.Fulltext;
- if (!String.IsNullOrEmpty(strdeptId) && !String.IsNullOrEmpty(strDeptName))
- {
- txt_REQ_ORG.Text = strDeptName;
- req_org_id = strdeptId;
- }
- }
- #endregion
- private void ultraTabControl1_SelectedTabChanged(object sender, Infragistics.Win.UltraWinTabControl.SelectedTabChangedEventArgs e)
- {
- if (ultraTabControl1.SelectedTab == ultraTabControl1.Tabs[2])
- {
- do_outBill.Enabled = false;
- cancel_outBill.Enabled = true;
- }
- else
- {
- do_outBill.Enabled = true;
- cancel_outBill.Enabled = false;
- }
- }
- }
- }
|