| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721 |
- 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 frmUsePlanYB : FrmPmsBase
- {
- DataTable Qdt = null;//库区
- private string req_org_id = "";
- public frmUsePlanYB()
- {
- InitializeComponent();
- }
- private void frmUsePlanYB_Load(object sender, EventArgs e)
- {
- ck_attr.Checked = true;
- ck_Uom.Checked = true;
- ck_standard.Checked = true;
- 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" });
- }
- #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;
- }
- String strReason = "";
- frmPopReason frm = new frmPopReason(this.ob);
- frm.ShowDialog();
- if (frm.Tips == "1")
- {
- strReason = frm.Reason;
- }
- 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;
- 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 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 (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()
- {
- 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;
- }
- 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 });
- cob = EntityHelper.CopyEntity<CkOutBill>(pupe);
- cob.DeliverAddress = pm.DeliveryLocationCode;
- cob.Status = "1";
- 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 < ultraGrid3.Rows.Count; i++)
- {
- UltraGridRow row = ultraGrid3.Rows[i];
- if (Convert.ToBoolean(row.GetCellValue("Check")) == true)
- {
- double b_OutNum = 0;//出库量
- if (row.GetCellValue("itemUom").ToString() == "基吨")
- {
-
- double.TryParse(ultraGrid3.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(ultraGrid3.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 = ultraGrid3.Rows[i].Cells["INVPHYSIC"].Value.ToString();
- if (cobp.InvPhysic != pm.InvPhysic)
- {
- MessageUtil.ShowTips("请选择仓库:" + pm.InvPhysic + " 物料进行出库");
- return;
- }
- cobp.InvPosId = ultraGrid3.Rows[i].Cells["InvPosId"].Value.ToString();
- cobp.InvId = ultraGrid3.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_Update", new object[] {cob, al });
- 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 getInvPhysic()
- {
- 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;
- }
- PurCkStoragePosEntity ckp = new PurCkStoragePosEntity();
- ckp.UpdateName = ud.PurLineId;
- ckp.InvPhysic = um.InvPhysic;
- DataTable dt = this.execute<DataTable>("com.hnshituo.pur.ck.service.CkStoragePosService", "getCkStoragePos", new object[] { ckp });
- GridHelper.CopyDataToDatatable(ref dt, ref dataTable3, true);
- double canOutNum = (double)ud.Qty - (ud.QtyPur == null ? 0 : (double)ud.QtyPur);
- double tempCanUseQty = canOutNum;
- foreach (UltraGridRow row in ultraGrid3.Rows)
- {
- 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)
- {
- row.Cells["OUTNUM1"].Value = tempCanUseQty;//库存出库量
- row.Cells["OUTNUM"].Value = Math.Round(tempCanUseQty*dbItemUomConefficient,4);//采购出库量
- tempCanUseQty = 0;
- row.Cells["Check"].Value = true;
- }
- else
- {
- row.Cells["OUTNUM1"].Value = needQty;//库存出库量
- row.Cells["OUTNUM"].Value = Math.Round(needQty*dbItemUomConefficient, 4);//采购出库量
- tempCanUseQty = tempCanUseQty - needQty;
- row.Cells["Check"].Value = true;
- }
- }
- }
- 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)
- {
- row.Cells["OUTNUM"].Value = tempCanUseQty;
- row.Cells["OUTNUM1"].Value = Math.Round(tempCanUseQty / dbItemUomConefficient, 4, MidpointRounding.AwayFromZero);//采购出库量
- tempCanUseQty = 0;
- row.Cells["Check"].Value = true;
- }
- else
- {
- row.Cells["OUTNUM"].Value = needQty;
- row.Cells["OUTNUM1"].Value = Math.Round(needQty / dbItemUomConefficient, 4, MidpointRounding.AwayFromZero);//采购出库量
- tempCanUseQty = tempCanUseQty - needQty;
- row.Cells["Check"].Value = true;
- }
- }
-
- }
- }
- GridHelper.RefreshAndAutoSize(ultraGrid3);
- }
- 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, "提示");
- }
- }
- #endregion
- #region 界面事件
- private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
- {
- getUserPlanD();
- }
- /// <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;
- 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("请选择待出库物料");
- 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);
- if(e.Cell.Column.Key=="OUTNUM")//采购数量
- {
- 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 (b_OutNum_q > canUse)
- {
- MessageUtil.ShowTips("已大于领用单可编制量:"+canUse+"");
- 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);
- 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);
- }
- }
- ultraGrid3.UpdateData();
- }
- /// <summary>
- /// 激活领用单行
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ultraGrid2_AfterRowActivate(object sender, EventArgs e)
- {
- getInvPhysic();
- 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
- }
- }
|