| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909 |
- 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.require_planEntiy;
- using Core.Mes.Client.Comm.Control;
- using Core.Mes.Client.Comm.Tool;
- using Infragistics.Win.UltraWinGrid;
- using com.hnshituo.pur.vo;
- using System.Collections;
- using Pur.Entity.configureEntity;
- using Pur.configure;
- using Pur.require_plan;
- using Pur.PublicTools;
- using Pur.Pop_upWindow;
- using Pur.Entity;
- namespace Pur.ck
- {
- public partial class frmPurUsePlanNew : FrmPmsBase
- {
- private string showType="1";//默认生产厂
- public frmPurUsePlanNew()
- {
- InitializeComponent();
- this.IsLoadUserView = true;
- }
- /// <summary>
- /// 界面初始化
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void frmPurUsePlanNew_Load(object sender, EventArgs e)
- {
- showType = this.CustomInfo;
- if (String.IsNullOrEmpty(showType))
- {
- MessageUtil.ShowTips("界面配置错误,请指定界面使用者[1:生产厂,2:供应部]");
- return;
- }
- txt_status_LY.SelectedIndex = 1;
- ck_ctime.Checked = true;
- txtCreateTimeStart.Value = DateTime.Now.AddMonths(-1);
- txtCreateTimeEnd.Value = DateTime.Now.AddDays(2);
- GridHelper.SetExcludeColumnsActive(ultraGrid1.DisplayLayout.Bands[0], new string[] { "check", "REMARKUSE" });
- GridHelper.SetExcludeColumnsActive(ultraGrid1.DisplayLayout.Bands[1], new string[] { "useQtyReq" });
- GridHelper.SetExcludeColumnsActive(ultraGrid3.DisplayLayout.Bands[0], new string[] { "CHK"});
- GridHelper.SetExcludeColumnsActive(ultraGrid2.DisplayLayout.Bands[0], new string[] { });
- getUserPlanM("");
- }
- #region toolbar事件
- /// <summary>
- /// toolbar
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="ToolbarKey"></param>
- public override void ToolBar_Click(object sender, string ToolbarKey)//菜单toolbar按钮
- {
- switch (ToolbarKey)
- {
- case "Query":
- getUserPlan("");
- break;
- case "addPlanUserMD"://生成领用单
- addPlanProgram();
- break;
- case "sendPlanUserMD"://提交领用单
- sendPlanProgram();
- break;
- case "backPlanUserMD"://撤回领用单
- backPlanProgram();
- break;
- case "surePlanUserMD"://确认领用
- surePlanProgram();
- break;
- case "cancelPlanUserMD"://删除领用单
- cancelPlanProgram();
- break;
- case "printPlanUserMD"://删除领用单
- printPlanProgram();
- break;
- case "Quit"://退出
- this.Close();
- break;
- case "doExcel"://退出
- doExcel();
- break;
- }
- }
- /// <summary>
- /// 确认领用
- /// </summary>
- private void surePlanProgram()
- {
- UltraGridRow uge = ultraGrid2.ActiveRow;
- if (uge == null)
- return;
- String strMrId = uge.Cells["MRID"].Value.ToString();
- if (String.IsNullOrEmpty(strMrId))
- {
- return;
- }
- if (testStatusM(strMrId, 6) == false)
- {
- return;
- }
- UsePlanM um = new UsePlanM();
- um.MrId = strMrId;
- um.Status = "6";
- 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>
- /// 导出Excel
- /// </summary>
- private void doExcel()
- {
- try
- {
- this.Cursor = Cursors.Default;
- if (ultraGrid2.ActiveRow == null)
- {
- MessageUtil.ShowTips("请选择需导出明细的领用单头!");
- return;
- }
- //获取导出的采购计划行表
- ArrayList alUltraGrid = new ArrayList();
- alUltraGrid.Add(ultraGrid3);
- ArrayList alSheeft = new ArrayList();
- alSheeft.Add("物料明细");
- if (ultraGrid2.Rows.Count > 0)
- {
- GridHelper.ulGridToExcel(alUltraGrid, alSheeft, "领用单[" + ultraGrid2.ActiveRow.GetCellValue("mrId") + "]明细表");//导出excel
- }
- else
- {
- MessageUtil.ShowTips("领用单:" + ultraGrid2.ActiveRow.GetCellValue("mrId") + "无可导出明细!");
- }
- }
- catch (Exception e)
- {
- MessageUtil.ShowTips("导出失败" + e.Message);
- }
- finally
- {
- this.Cursor = Cursors.Default;
- }
- }
- /// <summary>
- /// 添加领用单头
- /// </summary>
- private void addPlanProgram()
- {
- try
- {
- frmUsePlanMAdd frm = new frmUsePlanMAdd(this.ob, showType);
- frm.ShowDialog();
- if (frm.tips == "1")
- {
- string StrMrId = frm.mrId;
- getUserPlanM(StrMrId);
- }
- }
- catch (Exception e)
- {
- MessageUtil.ShowTips("新增失败!" + e);
- return;
- }
- }
- /// <summary>
- /// 查询领用计划
- /// </summary>
- private void getUserPlan(String strMrId)
- {
- getUserPlanM(strMrId);
- }
- /// <summary>
- /// 打印领用单
- /// </summary>
- private void printPlanProgram()
- {
- MessageUtil.ShowTips("开发中");
- }
- /// <summary>
- /// 撤回领用大
- /// </summary>
- private void backPlanProgram()
- {
- UltraGridRow uge = ultraGrid2.ActiveRow;
- if (uge == null)
- return;
- String strMrId = uge.Cells["MRID"].Value.ToString();
- if (String.IsNullOrEmpty(strMrId))
- {
- return;
- }
- if (testStatusM(strMrId, 11) == false)
- {
- return;
- }
- UsePlanM um = new UsePlanM();
- um.MrId = strMrId;
- um.Status = "1";
- 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 cancelPlanProgram()
- {
- UltraGridRow uge = ultraGrid2.ActiveRow;
- if (uge == null)
- return;
- String strMrId = uge.Cells["MRID"].Value.ToString();
- if (String.IsNullOrEmpty(strMrId))
- {
- return;
- }
- if (testStatusM(strMrId, 10) == false)
- {
- return;
- }
- UsePlanM um = new UsePlanM();
- um.MrId = strMrId;
- um.Status = "-1";
- 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("操作成功");
- getUserPlan(strMrId);
- }
- /// <summary>
- /// 发送领用单
- /// </summary>
- private void sendPlanProgram()
- {
- UltraGridRow uge = ultraGrid2.ActiveRow;
- if (uge == null)
- return;
- String strMrId = uge.Cells["MRID"].Value.ToString();
- if (String.IsNullOrEmpty(strMrId))
- {
- return;
- }
- if (testStatusM(strMrId, 2) == false)
- {
- return;
- }
- UsePlanM um = new UsePlanM();
- um.MrId = strMrId;
- um.Status = "2";
- 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);
- }
- #endregion
- #region 界面事件
- /// <summary>
- /// 输入领用数量,计算总价
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ultraGrid1_CellChange(object sender, CellEventArgs e)
- {
- UltraGridRow row = e.Cell.Row;
- if (e.Cell.Column.Key == "useQtyReq" && e.Cell.Row.HasParent())
- {
- double bQtyOld = 0;
- double.TryParse(e.Cell.Value.ToString(), out bQtyOld);
- ultraGrid1.UpdateData();
- //if (txt_InvPhysic.SelectedIndex==-1||txt_InvPhysic.SelectedIndex==0)
- //{
- // MessageUtil.ShowTips("请选择待领料的仓库");
- // txt_InvPhysic.Focus();
- // e.Cell.Value = bQtyOld;
- // return;
- //}
- //if (txt_ItemClass.SelectedIndex == -1 || txt_ItemClass.SelectedIndex ==0)
- //{
- // MessageUtil.ShowTips("请选择待领用物料中类");
- // txt_ItemClass.Focus();
- // e.Cell.Value = bQtyOld;
- // return;
- //}
- double canUseQty = 0;
- double canUseQty1 = 0;
- double noticeQtyReq = 0;
- double singleNormalQty = 0;
- double.TryParse(row.ParentRow.GetCellValue("canUseQty").ToString(), out canUseQty);
- double.TryParse(row.ParentRow.GetCellValue("canUseQtyUnnor").ToString(), out canUseQty1);
- double.TryParse(row.GetCellValue("QTYYCUSEABLE").ToString(), out noticeQtyReq);
- double.TryParse(row.GetCellValue("normalQty").ToString(), out singleNormalQty);
- double bQtyNew = 0;
- double.TryParse(e.Cell.Value.ToString(), out bQtyNew);
- //if (noticeQtyReq < bQtyNew)
- //{
- // MessageUtil.ShowTips("不能大于需求计划的可领用量");
- // e.Cell.Value = bQtyOld;
- // return;
- //}
- double allUseQty = 0;//全部编制量
- double allUseQty1 = 0;//无主需求总编制量
- foreach (UltraGridRow row1 in row.ParentRow.ChildBands[0].Rows)
- {
- double singleQty = 0;//编制量
- //double singleUnQty=0;//无主需求量
- double singlenorQty = 0;//有主需求量
- //double.TryParse(row1.GetCellValue("QTYYCUSEABLE").ToString(), out singleCanUseQty);
- double.TryParse(row1.GetCellValue("useQtyReq").ToString(), out singleQty);
- //double.TryParse(row1.GetCellValue("unNormalQty").ToString(), out singleUnQty);
- double.TryParse(row1.GetCellValue("normalQty").ToString(), out singlenorQty);
- if (singlenorQty - singleQty < 0)
- {
- allUseQty1 = allUseQty1 + singleQty - singlenorQty;
- }
- allUseQty = allUseQty + singleQty;
- }
- //if (canUseQty < allUseQty)
- //{
- // MessageUtil.ShowTips("不能大于采购计划的最大可编制量");
- // e.Cell.Value = bQtyOld;
- // return;
- //}
- if (canUseQty1 < allUseQty1)
- {
- MessageUtil.ShowTips("无主库存编制量不能大于采购计划的无主需求量");
- e.Cell.Value = bQtyOld;
- return;
- }
- if (singleNormalQty - bQtyNew < 0)
- {
- row.Cells["unNormalQtyUse"].Value = bQtyNew - singleNormalQty;
- }
- row.ParentRow.Cells["UseQty"].Value = allUseQty;
- row.ParentRow.Cells["UseQty1"].Value = allUseQty1;
- double bBugprice = 0;//计划价
- double.TryParse(row.ParentRow.Cells["Bugprice"].Value.ToString(), out bBugprice);
- double bPriceaverage = 0;//采购平均价
- double.TryParse(row.ParentRow.Cells["BUDGETAMT"].Value.ToString(), out bPriceaverage);
- row.ParentRow.Cells["bugpriceamt"].Value = allUseQty * bBugprice;
- row.ParentRow.Cells["priceaverageAMT"].Value = allUseQty * bPriceaverage;
- }
- else if (e.Cell.Column.Key == "REMARKUSE")
- {
- //if (txt_InvPhysic.Value == null)
- //{
- // MessageUtil.ShowTips("请选择待领料的仓库");
- // txt_InvPhysic.Focus();
- // return;
- //}
- //if (txt_ItemClass.SelectedIndex == -1)
- //{
- // MessageUtil.ShowTips("请选择待领用物料中类");
- // txt_ItemClass.Focus();
- // return;
- //}
- }
- e.Cell.Row.Activated = true;
- }
- /// <summary>
- /// 查询领用单数据
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ultraGrid2_AfterRowActivate(object sender, EventArgs e)
- {
- UltraGridRow uge = ultraGrid2.ActiveRow;
- if (uge == null)
- return;
- UsePlanD pupe = new UsePlanD();
- pupe.MrId = uge.Cells["MRID"].Value.ToString();
- pupe.Validflag = "1";
- if (String.IsNullOrEmpty(pupe.MrId))
- {
- return;
- }
- 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, dataTable3, true);
- GridHelper.RefreshAndAutoSize(ultraGrid3);
- //UsePlanM up = this.execute<UsePlanM>("com.hnshituo.pur.requireplan.service.UsePlanMService", "findById", new object[] { pupe.MrId });
- //if (up == null)
- //{
- // MessageUtil.ShowTips("未发现领料单头:" + pupe.MrId + "信息记录");
- // return;
- //}
- //txt_InvPhysic.Value = up.InvPhysic;
- //txt_ItemClass.Value = up.ItemClass;
- getCanUseData();
- }
- /// <summary>
- /// 查询时间控制
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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;
- }
- }
- #endregion
- #region 公共函数
- /// <summary>
- /// 查询可领用数据
- /// </summary>
- private void getCanUseData()
- {
- dataSet1.Clear();
- UltraGridRow uge = ultraGrid2.ActiveRow;
- if (uge == null)
- return;
- UsePlanD pupe = new UsePlanD();
- String strMrid = uge.Cells["MRID"].Value.ToString();
- UsePlanM up = this.execute<UsePlanM>("com.hnshituo.pur.requireplan.service.UsePlanMService", "findById", new object[] { strMrid });
- if (up == null)
- {
- MessageUtil.ShowTips("未发现领料单头:" + strMrid + "信息记录");
- return;
- }
- //txt_InvPhysic.Value = up.InvPhysic;
- //txt_ItemClass.Value = up.ItemClass;
- EntityPurPlanD pd = new EntityPurPlanD();
- if (String.IsNullOrEmpty(up.ItemClass))
- {
- //MessageUtil.ShowTips("领用单物料类别不能为空");
- return;
- }
- if (String.IsNullOrEmpty(up.InvPhysic))
- {
- MessageUtil.ShowTips("领用单库区不能为空");
- return;
- }
- if (String.IsNullOrEmpty(up.ReqOrgId))
- {
- MessageUtil.ShowTips("领用单需求部门不能为空");
- return;
- }
- if (showType == "1")
- {
- pd.UpdateName = up.ReqOrgId;
- }
- pd.ItemDescE = up.ItemClass;
- pd.DeleteName = up.InvPhysic;
- pd.ItemCode = txt_itemCode.Text.Trim();
- pd.ItemName = txt_itemName.Text.Trim();
- DataTable dt = this.execute<DataTable>("com.hnshituo.pur.purplan.service.PurPlanDService", "getCanOutBillPlanDNew", new object[] { pd });
- DataTable dt2 = this.execute<DataTable>("com.hnshituo.pur.purplan.service.PurPlanDService", "getCanOutBillPlanRe1New", new object[] { pd });
- GridHelper.CopyDataToDatatable(dt, dataTable1, true);
- GridHelper.CopyDataToDatatable(dt2, dataTable4, true);
- foreach (DataRow rowq in dataTable1.Rows)
- {
- double QtyPur = 0;
- double QtyInstock = 0;
- double QtyNormal = 0;
- double QtyUnNormal = 0;
- double QtyUse = 0;
- double QtyWill = 0;
- double.TryParse(rowq["qty"].ToString(), out QtyPur);//采购计划数量
- double.TryParse(rowq["instockQty"].ToString(), out QtyInstock);//库存量
- double.TryParse(rowq["normalQty"].ToString(), out QtyNormal);//有主需求
- double.TryParse(rowq["unNormalQty"].ToString(), out QtyUnNormal);//无主需求
- double.TryParse(rowq["qtyYcUsed"].ToString(), out QtyUse);//已经领用量(所有部门)
- double.TryParse(rowq["QTYPURED"].ToString(), out QtyWill);//待领用量(所有部门)
- //double.TryParse(rowq["QTYLK"].ToString(), out QtyReqPur);//采购核准量
- double canUseQty = QtyInstock - QtyWill;//------供应部可以全部编制
- if (canUseQty <= 0)
- {
- rowq["canUseQty"] = 0;
- }
- else
- {
- rowq["canUseQty"] = canUseQty;
- }
- if (rowq["itemuom"].ToString() == "基吨")
- {
- rowq["itemuom"] = "吨";
- }
- }
- GridHelper.RefreshAndAutoSizeExceptColumns(ultraGrid1, new UltraGridColumn[] { ultraGrid1.DisplayLayout.Bands[0].Columns["check"], ultraGrid1.DisplayLayout.Bands[0].Columns["UseQty"], ultraGrid1.DisplayLayout.Bands[0].Columns["REMARKUSE"] });
- }
- /// <summary>
- /// 查询领用单主表
- /// </summary>
- private void getUserPlanM(String strMrId)
- {
- dataSet1.Clear();
- LYM.Clear();
- LYC.Clear();
- UsePlanM pupe = new UsePlanM();
- pupe.Status = txt_status_LY.Value == null ? "" : txt_status_LY.Value.ToString().Trim();
- pupe.MrId = txt_mrId_LY.Text.Trim();
- if (showType == "1")
- {
- pupe.ApplyReqOrgId = UserInfo.GetDeptid();
- }
- 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, dataTable2, true);
- GridHelper.RefreshAndAutoSize(ultraGrid2);
- if (!String.IsNullOrEmpty(strMrId))
- {
- publicPms.doActiveSelRow(ultraGrid2, "mrId", strMrId);
- }
- }
- /// <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 (up.CreateUserid != UserInfo.GetUserID())
- {
- MessageUtil.ShowTips("非本人创建领料单,无权限进行操作");
- return false;
- }
- //新增行
- if (i == 1)
- {
- if (up.Status != "1" && up.Status != "9")
- {
- MessageUtil.ShowTips("非提报和退回状态无法增删改");
- return false;
- }
- //UltraGridRow uge = ultraGrid2.ActiveRow;
- //if (uge == null)
- //{
- // MessageUtil.ShowTips("请选择领料单头");
- // return false;
- //}
- //String strinv = uge.Cells["invPhysic"].Value.ToString();
- //String strclass = uge.Cells["ITEMCLASS"].Value.ToString();
- //if (up.InvPhysic != strInvPhysic)
- //{
- // MessageUtil.ShowTips("非库区:" + strinv + "[" + up.InvPhysic + "] 物料,无法添加");
- // return false;
- //}
- //if (up.ItemClass != strItemClass)
- //{
- // MessageUtil.ShowTips("非物料类别:" + strclass + "[" + up.ItemClass + "] 物料,无法添加");
- // return false;
- //}
- }
- //完成移库操作
- else if (i == 6)
- {
- if (up.Status != "5")
- {
- MessageUtil.ShowTips("库房未出库,无法确认领用");
- return false;
- }
- }
- //撤回操作
- else if (i == 11)
- {
- if (up.Status != "2")
- {
- MessageUtil.ShowTips("不在待确认状态,无法撤回");
- return false;
- }
- }
- //删除操作
- else if (i == 10)
- {
- if (up.Status != "1" && up.Status != "9")
- {
- MessageUtil.ShowTips("不在待提报或者退回状态,无法删除");
- return false;
- }
- }
- //提报
- else if (i == 2)
- {
- if (up.Status != "1" && up.Status != "9")
- {
- MessageUtil.ShowTips("不在待提报状态,无法删除");
- return false;
- }
- UsePlanD pupe = new UsePlanD();
- pupe.MrId = strMrId;
- pupe.Validflag = "1";
- int count = this.execute<int>("com.hnshituo.pur.requireplan.service.UsePlanDService", "count", new object[] { pupe });
- if (count <= 0)
- {
- MessageUtil.ShowTips("请编制有效的行信息,无法删除");
- return false;
- }
- }
- else
- {
- MessageUtil.ShowTips("未知参数");
- return false;
- }
- return true;
- }
- #endregion
- #region 领用单行编辑区
- /// <summary>
- /// 查询按钮
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btn_doQuery_canUse_Click(object sender, EventArgs e)
- {
- getCanUseData();
- }
- /// <summary>
- /// 添加按钮
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btn_add_d_Click(object sender, EventArgs e)
- {
- try
- {
-
- UltraGridRow row = ultraGrid2.ActiveRow;
- if (row == null)
- return;
- String strMrId = row.Cells["MRID"].Value.ToString();
- if (String.IsNullOrEmpty(strMrId))
- {
- return;
- }
- UsePlanM up = this.execute<UsePlanM>("com.hnshituo.pur.requireplan.service.UsePlanMService", "findById", new object[] { strMrId });
- if (up == null)
- {
- MessageUtil.ShowTips("未发现领料单头:" + strMrId + "信息记录");
- return;
- }
- if (testStatusM(strMrId, 1)==false)
- {
- return;
- }
- ultraGrid1.UpdateData();
- //领用计划主表
- ArrayList al = new ArrayList();
- foreach (UltraGridRow uge in ultraGrid1.Rows)
- {
- if (!(bool)uge.Cells["Check"].Value)
- {
- continue;
- }
- int i = 0;
- foreach (UltraGridRow ugc in uge.ChildBands[0].Rows)
- {
- String strpurlineid = uge.Cells["mrLineId"].Value.ToString();
- String strReceiveId = ugc.Cells["ITEMSTANDARDSID"].Value.ToString();
- String strRequireId = ugc.Cells["ITEMUOMID"].Value.ToString();
- if (String.IsNullOrEmpty(strpurlineid))
- {
- MessageUtil.ShowTips("物料【" + uge.Cells["ITEMNAME"].Value.ToString() + "】的采购计划行为空");
- return;
- }
- if (String.IsNullOrEmpty(strRequireId))
- {
- MessageUtil.ShowTips("物料【" + uge.Cells["ITEMNAME"].Value.ToString() + "】的需求计划行号为空");
- return;
- }
- if (String.IsNullOrEmpty(strReceiveId))
- {
- MessageUtil.ShowTips("物料【" + uge.Cells["ITEMNAME"].Value.ToString() + "】的需求标识为空");
- return;
- }
- double bQty = 0;
- double.TryParse(ugc.Cells["useQtyReq"].Value.ToString(), out bQty);
- if (bQty <= 0)
- {
- continue;
- }
- double bQtyUnnor = 0;
- double.TryParse(ugc.Cells["unNormalQtyUse"].Value.ToString(), out bQtyUnnor);
- i = i + 1;
- double bBugprice = 0;//计划价
- double.TryParse(uge.Cells["Bugprice"].Value.ToString(), out bBugprice);
- double bPriceaverage = 0;//采购平均价
- double.TryParse(uge.Cells["BUDGETAMT"].Value.ToString(), out bPriceaverage);
- UsePlanD Upd = new UsePlanD();
- Upd.PurLineId = strpurlineid;
- Upd.Qty = bQty;//申请量
- Upd.QtyUnnormal = bQtyUnnor;//无主需求
- Upd.QtyUnnormalPur = 0;
- Upd.QtyUse = bQty;//统计量
- Upd.QtyPur = 0;//领用量
- Upd.Status = "1";//未出库
- Upd.PriceWithoutTaxAverage = bPriceaverage;
- Upd.ReceiveId = strReceiveId;
- Upd.PurRequireLineId = strRequireId;
- Upd.Validflag = "1";
- Upd.CreateName = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName();
- Upd.CreateTime = DateTime.Now;
- Upd.CreateUserid = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserID();
- Upd.RemarkUse = uge.Cells["RemarkUse"].Value.ToString();
- al.Add(Upd);//添加领用单行标
- }
- if (i <= 0)
- {
- MessageUtil.ShowTips("物料【" + uge.Cells["ITEMNAME"].Value.ToString() + "】的未编制有效需求领用量");
- return;
- }
-
- }
- if (al.Count < 1)
- {
- Core.Mes.Client.Comm.Tool.MessageUtil.ShowTips("请勾选需领用的物料");
- return;
- }
- if (MessageUtil.ShowYesNoAndQuestion("确定给领用单:" + strMrId + " 新增物料?") != DialogResult.Yes)
- {
- return;
- }
- CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.requireplan.service.UsePlanDService", "insert_D", new object[] { strMrId,al });
- if (crt.Resultcode != 0)
- {
- Core.Mes.Client.Comm.Tool.MessageUtil.ShowTips("添加失败:" + crt.Resultmsg);
- return;
- }
- Core.Mes.Client.Comm.Tool.MessageUtil.ShowTips("添加成功!");
- getUserPlan(strMrId);
- getCanUseData();
- }
- catch (Exception ex)
- {
- MessageUtil.ShowTips("领用单生成失败!" + ex);
- return;
- }
- }
- /// <summary>
- /// 删除按钮
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btn_delete_d_Click(object sender, EventArgs e)
- {
- try
- {
- UltraGridRow row = ultraGrid2.ActiveRow;
- if (row == null)
- return;
- String strMrId = row.Cells["MRID"].Value.ToString();
- UsePlanM up = this.execute<UsePlanM>("com.hnshituo.pur.requireplan.service.UsePlanMService", "findById", new object[] { strMrId });
- if (up == null)
- {
- MessageUtil.ShowTips("未发现领料单头:" + strMrId + "信息记录");
- return;
- }
- if (String.IsNullOrEmpty(strMrId))
- {
- return;
- }
- ultraGrid3.UpdateData();
- //领用计划主表
- ArrayList al = new ArrayList();
- foreach (UltraGridRow uge in ultraGrid3.Rows)
- {
- if (!(bool)uge.Cells["CHK"].Value)
- {
- continue;
- }
- String strpurlineid = uge.Cells["mrLineId"].Value.ToString();
- if (String.IsNullOrEmpty(strpurlineid))
- {
- MessageUtil.ShowTips("物料【" + uge.Cells["ITEMNAME"].Value.ToString() + "】的领用单行号为空");
- return;
- }
- UsePlanD Upd = new UsePlanD();
- Upd.MrLineId = strpurlineid;
- Upd.Validflag = "0";
- Upd.DeleteName = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName();
- Upd.DeleteTime = DateTime.Now;
- Upd.DeleteUserid= CoreFS.SA06.CoreUserInfo.UserInfo.GetUserID();
- al.Add(Upd);//添加领用单行标
- }
- if (al.Count < 1)
- {
- Core.Mes.Client.Comm.Tool.MessageUtil.ShowTips("请勾选需领用的物料");
- return;
- }
- if (MessageUtil.ShowYesNoAndQuestion("确定删除上述共:"+al.Count+"条行信息?") != DialogResult.Yes)
- {
- return;
- }
- CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.requireplan.service.UsePlanDService", "delete_D", new object[] { strMrId,al });
- if (crt.Resultcode != 0)
- {
- Core.Mes.Client.Comm.Tool.MessageUtil.ShowTips("删除失败!" + crt.Resultmsg);
- return;
- }
- Core.Mes.Client.Comm.Tool.MessageUtil.ShowTips("删除成功!");
- getUserPlan(strMrId);
- getCanUseData();
- }
- catch (Exception ex)
- {
- MessageUtil.ShowTips("删除领用单行失败!" + ex);
- return;
- }
- }
- #endregion
- }
- }
|