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 Pur.Entity.configureEntity; using Infragistics.Win.UltraWinGrid; using System.Collections; using Pur.Entity.require_planEntiy; using Pur.configure; using Core.Mes.Client.Comm.Tool; using com.hnshituo.pur.vo; using Pur.Pop_upWindow; using Bpm; using Pur.Entity; using Infragistics.Win; using Core.Mes.Client.Comm.Server; using Infragistics.Win.UltraWinEditors; namespace Pur.require_plan { public partial class FrmPurRequirePlanOld : FrmPmsBase { public FrmPurRequirePlanOld() { InitializeComponent(); } private void FrmPurRequirePlanOld_Load(object sender, EventArgs e)//Load { strCoustomInfo=this.CustomInfo == null ? "" : this.CustomInfo.ToString(); //初始化查询区域信息 ck_ctime.Checked = true; txtCreateTimeStart.Value = DateTime.Now.AddMonths(-2); txtCreateTimeEnd.Value = DateTime.Now.AddDays(2); //状态 txt_Status.SelectedIndex = 0; Ck_IsJIT.Checked = false; txt_deliveryLocation.Enabled = false; //紧急程度 cop_UrgencyType.SelectedIndex = 0; //审批流程 txt_auditType.SelectedIndex = -1; txt_MRPERIODEND.Enabled = false; //加载计划类型数据 DataTable dt1 = ServerHelper.GetData("com.hnshituo.pur.configure.service.impl.CoreBaseInfoNew.doQuery", new Object[] { "1221" }, this.ob); if (strCoustomInfo == "1")//生产厂 { comm.FilComboboxAdd(txt_RequeType, dt1, "baseCode", "baseName", "validflag NOT in ('0') and baseCode in ('122101')", false, "", ""); txt_auditType.Visible = true; txt_auditType_lab.Visible = true; txt_itemAuditType_lab.Visible = true; txt_itemAuditType.Visible = true; } else if (strCoustomInfo == "2")//供应部 { comm.FilComboboxAdd(txt_RequeType, dt1, "baseCode", "baseName", "validflag NOT in ('0') and baseCode in ('122103','122101')", false, "", ""); this.ToolBarItemEnable(this, "DoReceive", false); this.ToolBarItemEnable(this, "Process", false); //ultraTabControl2.Tabs[1].Visible = false; txt_auditType.Visible = false; txt_auditType_lab.Visible = false; txt_itemAuditType_lab.Visible = false; txt_itemAuditType.Visible = false; } else//厂区 { comm.FilComboboxAdd(txt_RequeType, dt1, "baseCode", "baseName", "validflag NOT in ('0') and baseCode in ('122104')", false, "", ""); //this.ToolBarItemEnable(this, "Query", true); //this.ToolBarItemEnable(this, "Add", true); //this.ToolBarItemEnable(this, "Update", true); //this.ToolBarItemEnable(this, "Delete", true); //this.ToolBarItemEnable(this, "Revocation", true); //this.ToolBarItemEnable(this, "Submittal", true); //this.ToolBarItemEnable(this, "doExcel", true); this.ToolBarItemEnable(this, "DoReceive", false); this.ToolBarItemEnable(this, "Process", false); ultraTabControl2.Tabs[1].Visible = false; txt_auditType.Visible = true; txt_auditType_lab.Visible = true; txt_itemAuditType_lab.Visible = true; txt_itemAuditType.Visible = true; } //加载流程类型 DataTable dt8 = ServerHelper.GetData("com.hnshituo.pur.configure.service.impl.CoreBaseInfoNew.doQuery", new Object[] { "122601" }, this.ob); comm.FilComboboxAdd(txt_auditType, dt8, "baseCode", "baseName", "validflag NOT in ('0')", false, "", ""); //加载数据 GetPUR_REQUIRE_PLAN(); ultraTabControl1.SelectedTab = ultraTabControl1.Tabs[0]; ultraExpandableGroupBox2.Expanded = false; ultraGrid1.DisplayLayout.Bands[0].Override.AllowUpdate = DefaultableBoolean.False; ultraGrid2.DisplayLayout.Bands[0].Override.AllowUpdate = DefaultableBoolean.False; ultraGrid3.DisplayLayout.Bands[0].Override.AllowUpdate = DefaultableBoolean.False; } //初始化数据 string init_itemUomId="";//物料单位换算ID string init_itemStandardsId = "";//采购标准ID string init_itemAttrId = "";//物料属性编码 string init_auditFlag = "";//审批标识 string init_itemUnique = "";//物料唯一码 string deliveryLocationCode="";//地点编码 string init_itemAutitTypeId = "";//物料审批流程ID string PRICE_TYPE = ""; private string m_szCurPath = ""; //启动路径 string strCoustomInfo = ""; #region toolbar工具栏事件 /// /// toolbar /// /// /// public override void ToolBar_Click(object sender, string ToolbarKey)//菜单toolbar按钮 { switch (ToolbarKey) { case "Query": GetPUR_REQUIRE_PLAN(); break; case "Add": AddPUR_REQUIRE_PLAN(); break; case "Update": UpdPUR_REQUIRE_PLAN(); break; case "Delete": DelPUR_REQUIRE_PLAN(); break; case "Submittal": SubPUR_REQUIRE_PLAN(); break; case "Revocation": RevPUR_REQUIRE_PLAN(); break; case "DoReceive": ReceivePUR_REQUIRE_PLAN(); break; case "Process": Process(); break; case "doExcel": doExcel(); break; } } /// /// 撤销提报 /// private void RevPUR_REQUIRE_PLAN()//提报撤销 { if (ultraTabControl2.SelectedTab == ultraTabControl2.Tabs[1]) { MessageUtil.ShowTips("未发现可撤销的需求计划头!"); return; } UltraGridRow uge = ultraGrid1.ActiveRow; if (uge == null) { MessageUtil.ShowTips("请选择可操作的需求计划头!"); return; } String mrId = uge.Cells["MrId"].Value.ToString(); if ( mrId == "") { MessageUtil.ShowTips("请选择可操作的需求计划头"); return; } //头是否处于可撤回状态 if (testReqMStatus(mrId, 3) == false) { return; } ArrayList list = new ArrayList(); RequirePlanM ReqM = this.execute("com.hnshituo.pur.requireplan.service.RequirePlanMService", "findById", new object[] { mrId }); if (strCoustomInfo != "2") { if (ReqM.Status == "-1") { ReqM.Status = "-2"; } else { ReqM.Status = "1"; } } else//供应部直接撤回(直接有已审批3-》1) { ReqM.Status = "31"; } ReqM.UpdateUserid = UserInfo.GetUserID(); if (MessageUtil.ShowYesNoAndQuestion("确定撤回该需求计划头?") == DialogResult.No) { return; } CoreResult rt = this.execute("com.hnshituo.pur.requireplan.service.RequirePlanMService", "submit", new object[] { ReqM }); if (rt.Resultcode != 0) { MessageUtil.ShowTips("撤回失败!" + rt.Resultmsg); return; } MessageUtil.ShowTips("撤回成功!"); GetPUR_REQUIRE_PLAN(); comm.doActiveSelRow(ultraGrid1, "MrId", ReqM.MrId); } /// /// 提报 /// private void SubPUR_REQUIRE_PLAN()//提报需求 { if (ultraTabControl2.SelectedTab == ultraTabControl2.Tabs[0]) { UltraGridRow uge = ultraGrid1.ActiveRow; if (uge == null) { MessageUtil.ShowTips("请选择需操作的需求计划头!"); return; } String mrId = uge.Cells["MrId"].Value.ToString().Trim(); if (mrId == "") { MessageUtil.ShowTips("请选择需操作的需求计划头!"); return; } //验证是否可以提报 if (testReqMStatus(mrId, 2) == false) { return; } RequirePlanM ReqM = this.execute("com.hnshituo.pur.requireplan.service.RequirePlanMService", "findById", new object[] { mrId }); if (strCoustomInfo != "2") { if (ReqM.Status == "-2") { ReqM.Status = "-1";//子计划提交 } else { ReqM.Status = "2";//主计划提报 } } else { ReqM.Status = "13";//供应部默认直接审批并接受(由1知道到3) } ReqM.UpdateUserid = UserInfo.GetUserID(); if (MessageUtil.ShowYesNoAndQuestion("确定提报该需求计划头?") == DialogResult.No) { return; } CoreResult rt = this.execute("com.hnshituo.pur.requireplan.service.RequirePlanMService", "submit", new object[] { ReqM}); if (rt.Resultcode != 0) { MessageUtil.ShowTips("提报失败!" + rt.Resultmsg); return; } MessageUtil.ShowTips("提报成功!"); GetPUR_REQUIRE_PLAN(); comm.doActiveSelRow(ultraGrid1, "MrId", mrId); } else { UltraGridRow uge = ultraGrid3.ActiveRow; if (uge == null) { MessageUtil.ShowTips("未选择需提报的退回需求计划行!"); return; } String strMrLineId = uge.Cells["MrLineId"].Value.ToString().Trim(); if (strMrLineId=="") { MessageUtil.ShowWarning("未获取到该需求计划行的需求计划行号!"); return; } if (testReqCStatus(strMrLineId, 2) == false) { return; } ArrayList list = new ArrayList(); RequirePlanD ReqD = new RequirePlanD(); ReqD.MrLineId = strMrLineId; ReqD.FlagGeneratedPurPlan = "1"; ReqD.UpdateName = UserInfo.GetUserName(); ReqD.UpdateUserid = UserInfo.GetUserID(); ReqD.UpdateTime = DateTime.Now; list.Add(ReqD); if (MessageUtil.ShowYesNoAndQuestion("确定重新提报?") == DialogResult.No) { return; } CoreResult rt = new CoreResult(); if (strCoustomInfo == "2") { rt = this.execute("com.hnshituo.pur.requireplan.service.RequirePlanDService", "doReceive", new object[] { list, "32" });//供应部直接提报(3—>2) } else { rt = this.execute("com.hnshituo.pur.requireplan.service.RequirePlanDService", "doReceive", new object[] { list, "4" });//生成厂提报 } if (rt.Resultcode != 0) { MessageUtil.ShowTips("提报失败!" + rt.Resultmsg); return; } MessageUtil.ShowTips("提报成功!"); GetPUR_REQUIRE_PLAN(); comm.doActiveSelRow(ultraGrid3, "MrLineId", ReqD.MrLineId); } } /// /// 删除需求 /// private void DelPUR_REQUIRE_PLAN()//删除需求 { //删除非退回需求 if (ultraTabControl2.SelectedTab == ultraTabControl2.Tabs[0]) { UltraGridRow uge = ultraGrid1.ActiveRow; if (uge == null) { MessageUtil.ShowTips("请选择需要操作的需求计划头!"); return; } String mrId=uge.Cells["MrId"].Value.ToString().Trim(); if (String.IsNullOrEmpty(mrId)) { MessageUtil.ShowTips("该需求计划头号为空!"); return; } //删除头 if (ultraTabControl1.SelectedTab == ultraTabControl1.Tabs[0]) { //验证是否有权利删除头 if (testReqMStatus(mrId,1) == false) { return; } ArrayList list = new ArrayList(); RequirePlanM ReqM = new RequirePlanM(); ReqM.MrId = mrId; ReqM.Validflag = "0"; ReqM.DeleteName = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName(); ReqM.DeleteUserid = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserID(); ReqM.DeleteTime = DateTime.Now; list.Add(ReqM); if (MessageUtil.ShowYesNoAndQuestion("确定删除该需求计划头?") == DialogResult.No) { return; } CoreResult rt = this.execute("com.hnshituo.pur.requireplan.service.RequirePlanMService", "doDelete_batch", new object[] { list, strCoustomInfo }); if (rt.Resultcode != 0) { MessageUtil.ShowTips("删除失败!" + rt.Resultmsg); return; } MessageUtil.ShowTips("删除成功!"); GetPUR_REQUIRE_PLAN(); } //删除行 else if (ultraTabControl1.SelectedTab == ultraTabControl1.Tabs[1]) { UltraGridRow uRe = ultraGrid2.ActiveRow; if (uRe == null) { MessageUtil.ShowTips("请选择需删除的需求计划行!"); return; } string strMrLineId = uRe.Cells["MrLineId"].Value.ToString().Trim(); if (String.IsNullOrEmpty(strMrLineId)) { MessageUtil.ShowTips("未获取到该需求计划行号!"); return; } //验证是否有权利删改行 if (testReqCStatus(strMrLineId,1) == false) { return; } RequirePlanD ReqD = new RequirePlanD(); ReqD.MrLineId = strMrLineId; ReqD.Validflag = "0"; ReqD.DeleteName = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName(); ReqD.DeleteUserid = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserID(); ReqD.DeleteTime = DateTime.Now; if (MessageUtil.ShowYesNoAndQuestion("是否确定删除该需求计划行?") != DialogResult.Yes) { return; } CoreResult rt = this.execute("com.hnshituo.pur.requireplan.service.RequirePlanDService", "doUpdate", new object[] { ReqD }); if (rt.Resultcode != 0) { MessageUtil.ShowTips("删除失败!" + rt.Resultmsg); return; } Core.Mes.Client.Comm.Tool.MessageUtil.ShowTips("删除成功!"); GetPUR_REQUIRE_PLAN(); comm.doActiveSelRow(ultraGrid1, "MrId", mrId); String YY = mrId; RequirePlanD rpd1 = new RequirePlanD(); rpd1.MrLineId = YY; rpd1.Validflag = "1"; DataTable dt1 = this.execute("com.hnshituo.pur.requireplan.service.RequirePlanDService", "get_RequirePlanDlike", new object[] { rpd1 }); GridHelper.CopyDataToDatatable(dt1, dataTable2, true); clearkongjian(); } } //删除退回需求行 else { UltraGridRow uRe = ultraGrid3.ActiveRow; if (uRe == null) { MessageUtil.ShowTips("请选择需作废的退回需求计划行!"); return; } String strMrLineId = uRe.Cells["MrLineId"].Value.ToString(); if (String.IsNullOrEmpty(strMrLineId)) { MessageUtil.ShowTips("需求计划行号为空!"); return; } //判断是否有权力修改 if (testReqCStatus(strMrLineId, 2) == false) { return; } ArrayList list = new ArrayList(); RequirePlanD ReqD = new RequirePlanD(); ReqD.MrLineId = strMrLineId; ReqD.FlagGeneratedPurPlan = "9"; ReqD.UpdateName = UserInfo.GetUserName(); ReqD.UpdateUserid = UserInfo.GetUserID(); ReqD.UpdateTime = DateTime.Now; list.Add(ReqD); if (MessageUtil.ShowYesNoAndQuestion("确定作废该退回的需求计划行?") == DialogResult.No) { return; } CoreResult rt = this.execute("com.hnshituo.pur.requireplan.service.RequirePlanDService", "doReceive", new object[] { list, "5" }); if (rt.Resultcode != 0) { MessageUtil.ShowTips("操作失败!" + rt.Resultmsg); return; } MessageUtil.ShowTips("操作成功!"); GetPUR_REQUIRE_PLAN(); } } /// /// 修改 /// private void UpdPUR_REQUIRE_PLAN()//更新需求 { //修改非退回需求 if (ultraTabControl2.SelectedTab.Text == ultraTabControl2.Tabs[0].Text) { UltraGridRow uge = ultraGrid1.ActiveRow; String mrId = uge.Cells["mrId"].Value.ToString(); if (uge == null || mrId=="") { MessageUtil.ShowTips("未选择需求订单"); return; } ////判断是否处于可增删改的状态 //if (!uge.Cells["Status"].Value.Equals("待编制") && !uge.Cells["Status"].Value.Equals("待提报") && !uge.Cells["Status"].Value.Equals("审批不通过")) //{ // MessageUtil.ShowWarning("需求计划头【" + uge.Cells["MrId"].Value.ToString() + "】为已编制、审批中或已审批状态之一,无权限增删改,或请刷新后再操作!"); // return; //} if (ultraTabControl1.SelectedTab == ultraTabControl1.Tabs[0]) { //验证是否有权力修改头 if (testReqMStatus(mrId, 4) == false) { return; } //验证输入的数据 if (testReqM() == false) { return; } RequirePlanM ReqM = new RequirePlanM(); ReqM.UpdateName = UserInfo.GetUserName(); ReqM.UpdateUserid = UserInfo.GetUserID(); ReqM.UpdateTime = DateTime.Now; ReqM.MrId = mrId; ReqM.ReqOrgName = UserInfo.GetDepartment();//申请者机构名称 ReqM.ReqOrgId = UserInfo.GetDeptid();//申请者机构ID if (txt_MRPERIODEND.Enabled == false) { ReqM.MrPeriodEnd = DateTime.Now < DateTime.Parse(DateTime.Now.ToString("yyyy/MM/26")) ? DateTime.Parse(DateTime.Now.AddMonths(1).ToString("yyyy/MM")) : DateTime.Parse(DateTime.Now.AddMonths(2).ToString("yyyy/MM")); } else { ReqM.MrPeriodEnd = Convert.ToDateTime(txt_MRPERIODEND.Value); } ReqM.UrgencyType = txt_URGENCYTYPE.Value.ToString().Trim().Trim(); ReqM.RequireType = txt_RequeType.Value.ToString().Trim(); ReqM.TenantId = strCoustomInfo != "2" ? txt_auditType.Value.ToString().Trim() : null; ReqM.TenantName = strCoustomInfo != "2" ? txt_auditType.Text.Trim() : null; if (MessageUtil.ShowYesNoAndQuestion("确定要修改该需求计划头?") == DialogResult.No) { return; } CoreResult rt = this.execute("com.hnshituo.pur.requireplan.service.RequirePlanMService", "doUpdate", new object[] { ReqM }); if (rt.Resultcode != 0) { MessageUtil.ShowTips("修改失败!" + rt.Resultmsg); return; } MessageUtil.ShowTips("修改成功!"); GetPUR_REQUIRE_PLAN(); comm.doActiveSelRow(ultraGrid1, "MrId", mrId); clearkongjian1(); } else if (ultraTabControl1.SelectedTab == ultraTabControl1.Tabs[1])//需求计划行修改 { UltraGridRow uged = ultraGrid2.ActiveRow; if (uged == null) { MessageUtil.ShowWarning("未选择需求计划行"); return; } String strMrLineId = uged.GetCellValue("MrLineId").ToString().Trim(); if (String.IsNullOrEmpty(strMrLineId) || String.IsNullOrEmpty(mrId)) { MessageUtil.ShowTips("未获取到需求计划号或者需求计划行号!"); return; } //判断是否有权力进行操作行 if (testReqCStatus(strMrLineId, 1) == false) { return; } if (uged.GetCellValue("itemCode") == null) { MessageUtil.ShowWarning("需求计划行物料编码为空物"); return; } if (testReqC() == false) { return; } RequirePlanD ReqD = new RequirePlanD(); ReqD.MrId = mrId; ReqD.Validflag = "1"; ReqD.ItemUnique = init_itemUnique; //2016年2月28新增leitao if (Ck_IsJIT.Checked) { ReqD.DeliveryLocationFlag = "1"; ReqD.DeliveryLocation = txt_deliveryLocation.Text; ReqD.DeliveryLocationCode = deliveryLocationCode; if (ReqD.DeliveryLocationCode == "") { MessageUtil.ShowTips("JIT送货的地址信息不能为空"); txt_deliveryLocation.Focus(); return; } } else { ReqD.DeliveryLocationFlag = "0"; ReqD.DeliveryLocation = ""; ReqD.DeliveryLocationCode = ""; } DataTable dt2 = this.execute("com.hnshituo.pur.requireplan.service.RequirePlanDService", "get_RequirePlanDlike", new object[] { ReqD }); for(int ii=0;ii("com.hnshituo.pur.requireplan.service.RequirePlanDService", "doUpdate_D", new object[] { ReqD }); if (rt.Resultcode != 0) { MessageUtil.ShowTips("修改失败! " + rt.Resultmsg); return; } Core.Mes.Client.Comm.Tool.MessageUtil.ShowTips("修改成功!"); GetPUR_REQUIRE_PLAN(); comm.doActiveSelRow(ultraGrid1, "MrId", mrId); comm.doActiveSelRow(ultraGrid2, "MrLineId", ReqD.MrLineId); RequirePlanD rpd1 = new RequirePlanD(); rpd1.MrLineId = mrId; rpd1.Validflag = "1"; DataTable dt1 = this.execute("com.hnshituo.pur.requireplan.service.RequirePlanDService", "get_RequirePlanDlike", new object[] { rpd1 }); GridHelper.CopyDataToDatatable(dt1, dataTable2, true); clearkongjian(); } } //退回需求计划行修改 else { UltraGridRow uged = ultraGrid3.ActiveRow; if (uged == null) { MessageUtil.ShowWarning("未选择退回需求计划行"); return; } String strMrlineId = uged.GetCellValue("MrLineId").ToString().Trim(); String strMrId = uged.GetCellValue("MrId").ToString().Trim(); if(String.IsNullOrEmpty(strMrlineId)||String.IsNullOrEmpty(strMrId)) { MessageUtil.ShowTips("未获取到需求计划号或者需求计划行号!"); return; } //判断是否有权力修改 //判断是否有权力进行操作行 if (testReqCStatus(strMrlineId, 2) == false) { return; } if (testReqC() == false) { return; } if (uged.GetCellValue("itemCode") == null) { MessageUtil.ShowWarning("需求计划行物料编码为空物"); return; } if (uged.GetCellValue("itemCode").ToString().Trim() != txt_ItemCode.Value.ToString().Trim()) { MessageUtil.ShowWarning("退回物料不予许修改需求物料编码"); return; } RequirePlanD ReqD = new RequirePlanD(); ReqD.MrId = strMrId; ReqD.Validflag = "1"; ReqD.ItemUnique = init_itemUnique; //2016年2月28新增leitao if (Ck_IsJIT.Checked) { ReqD.DeliveryLocationFlag = "1"; ReqD.DeliveryLocation = txt_deliveryLocation.Text; ReqD.DeliveryLocationCode = deliveryLocationCode; if (ReqD.DeliveryLocationCode == "") { MessageUtil.ShowTips("JIT送货的地址信息不能为空"); txt_deliveryLocation.Focus(); return; } } else { ReqD.DeliveryLocationFlag = "0"; ReqD.DeliveryLocation = ""; ReqD.DeliveryLocationCode = ""; } DataTable dt2 = this.execute("com.hnshituo.pur.requireplan.service.RequirePlanDService", "get_RequirePlanDlike", new object[] { ReqD }); for (int ii = 0; ii < dt2.Rows.Count; ii++) { if (dt2.Rows[ii]["mrLIneId"].ToString().Trim() != strMrlineId) { MessageUtil.ShowWarning("已存在相同需求计划行【" + dt2.Rows[ii]["MrLineId"].ToString() + "】"); return; } } ReqD.MrLineId = strMrlineId; ReqD.ItemCode = txt_ItemCode.Text.Trim(); ReqD.ItemName = txt_ItemName.Text.Trim(); ReqD.Remark = txt_Remark.Text.Trim(); ReqD.ItemAttr = txt_item_Attr.Text.Trim();//属性名称 if (txt_BUGPRICE.Text.Trim() != "") { ReqD.BugPrice = Convert.ToDouble(txt_BUGPRICE.Text.Trim()); } double dbItemUomConefficien; if (txt_ItemUom.Text.ToString().Trim() == "" || txt_WEIGHTUNIT.Text.ToString().Trim() == "" || !Double.TryParse(txt_ItemUomConefficient.Value.ToString().ToString().Trim(), out dbItemUomConefficien)) { MessageUtil.ShowTips("采购单位、库存单位、单位转化系数都不能为空!"); return; } ReqD.ItemUom = txt_ItemUom.Text.ToString().Trim();//采购单位 ReqD.WeightUnit = txt_WEIGHTUNIT.Text.ToString().Trim();//库存单位 ReqD.ItemUomConefficient = dbItemUomConefficien;//转化系数 ReqD.Qty = Convert.ToDouble(txt_QTY.Value); ReqD.BudgetAmt = Convert.ToDouble(txt_BUDGETAMT.Text); ReqD.UpdateName = UserInfo.GetUserName(); ReqD.UpdateUserid = UserInfo.GetUserID(); ReqD.UpdateTime = DateTime.Now; ReqD.LastDeliveryDate = Convert.ToDateTime(txt_LastDeliveryDate.Value); ReqD.ItemStandardsCode = txt_itemStandardsCode.Text.ToString().Trim(); ReqD.ItemStandardsId = init_itemStandardsId; ReqD.ItemUomId = init_itemUomId; ReqD.ItemAttrId = init_itemAttrId; ReqD.AuditFlag = "0"; //this.execute("com.hnshituo.pur.requireplan.service.RequirePlanDService", "update", new object[] { ReqD }); if (MessageUtil.ShowYesNoAndQuestion("确定修改该需求计划行(退回):" + strMrlineId + "?") == DialogResult.No) { return; } CoreResult rt = this.execute("com.hnshituo.pur.requireplan.service.RequirePlanDService", "doUpdate_D", new object[] { ReqD }); if (rt.Resultcode != 0) { MessageUtil.ShowTips("操作失败!" + rt.Resultmsg); return; } MessageUtil.ShowTips("操作成功!"); GetPUR_REQUIRE_PLAN(); comm.doActiveSelRow(ultraGrid3, "MrLineId", ReqD.MrLineId); clearkongjian(); } } /// /// 新增 /// private void AddPUR_REQUIRE_PLAN()//新增需求 { //退回标签页不允许新增 if (ultraTabControl2.SelectedTab == ultraTabControl2.Tabs[1]) { MessageUtil.ShowTips("未发现可新增项"); return; } UltraGridRow uge = ultraGrid1.ActiveRow; //需求头标签页可以新增 try { if (ultraTabControl1.SelectedTab == ultraTabControl1.Tabs[0])//新增头信息 { if (testReqM() == false) { return; } RequirePlanM ReqM = new RequirePlanM(); ReqM.CreateName = UserInfo.GetUserName(); ReqM.CreateUserid = UserInfo.GetUserID(); ReqM.CreateTime = DateTime.Now; if (txt_MRPERIODEND.Enabled == false) { ReqM.MrPeriodEnd = DateTime.Now < DateTime.Parse(DateTime.Now.ToString("yyyy/MM/26")) ? DateTime.Parse(DateTime.Now.AddMonths(1).ToString("yyyy/MM")) : DateTime.Parse(DateTime.Now.AddMonths(2).ToString("yyyy/MM")); } else { ReqM.MrPeriodEnd = Convert.ToDateTime(txt_MRPERIODEND.Value); } ReqM.UrgencyType = txt_URGENCYTYPE.Value.ToString(); ReqM.ReqOrgName = UserInfo.GetDepartment();//申请者机构名称 ReqM.ReqOrgId = UserInfo.GetDeptid();//申请者机构ID ReqM.Validflag = "1"; ReqM.RequireType = txt_RequeType.Value.ToString(); ReqM.Status = "1"; ReqM.TenantId = strCoustomInfo!="2"?txt_auditType.Value.ToString().Trim():null; ReqM.TenantName = strCoustomInfo!= "2" ? txt_auditType.Text.Trim() : null; if (ReqM.RequireType == "122104") { ReqM.Status = "-2";//子计划 } CoreResult crt = this.execute("com.hnshituo.pur.requireplan.service.RequirePlanMService", "insert_id", new object[] { ReqM, strCoustomInfo}); if (crt.Resultcode != 0) { MessageUtil.ShowTips("新增头失败! " + crt.Resultmsg); return; } MessageUtil.ShowTips("操作成功! 新增头:" + crt.Resultmsg); GetPUR_REQUIRE_PLAN(); comm.doActiveSelRow(ultraGrid1, "MrId", crt.Resultmsg); clearkongjian1(); } else if (ultraTabControl1.SelectedTab.Text == ultraTabControl1.Tabs[1].Text)//新增需求行信息 { String strMrId = uge.Cells["mrId"].Value.ToString(); if (uge == null || strMrId == "") { MessageUtil.ShowTips("请选择可操作的需求计划头"); } if (testReqC() == false) { return; } //判断是否有权力新增 if (testReqMStatus(strMrId, 1) == false) { return; } //是否新增了相同的物料 RequirePlanD ReqD = new RequirePlanD(); ReqD.MrId = strMrId; ReqD.Validflag = "1"; ReqD.ItemUnique = init_itemUnique; //2016年2月28新增leitao if (Ck_IsJIT.Checked) { ReqD.DeliveryLocationFlag = "1"; ReqD.DeliveryLocation = txt_deliveryLocation.Text; ReqD.DeliveryLocationCode = deliveryLocationCode; if (ReqD.DeliveryLocationCode == "") { MessageUtil.ShowTips("JIT送货的地址信息不能为空"); txt_deliveryLocation.Focus(); return; } } else { ReqD.DeliveryLocationFlag = "0"; ReqD.DeliveryLocation = ""; ReqD.DeliveryLocationCode = ""; } DataTable dt2 = this.execute("com.hnshituo.pur.requireplan.service.RequirePlanDService", "get_RequirePlanDlike", new object[] { ReqD }); if (dt2.Rows.Count>0) { MessageUtil.ShowWarning("已存在相同需求计划行【"+dt2.Rows[0]["MrLineId"].ToString() + "】"); return; } ReqD.ItemCode = txt_ItemCode.Text;//物料编码 ReqD.ItemName = txt_ItemName.Text.Trim();//物料名称 ReqD.Remark = txt_Remark.Text;//备注 ReqD.BugPrice = Convert.ToDouble(txt_BUGPRICE.Text);//预算价 ReqD.ItemAttr = txt_item_Attr.Text;//属性名称 double dbItemUomConefficien; if (txt_ItemUom.Text.ToString().Trim() == "" || txt_WEIGHTUNIT.Text.ToString().Trim() == "" || !Double.TryParse(txt_ItemUomConefficient.Value.ToString().ToString().Trim(), out dbItemUomConefficien)) { MessageUtil.ShowTips("采购单位、库存单位、单位转化系数都不能为空"); return; } ReqD.ItemUom = txt_ItemUom.Text.ToString().Trim();//采购单位 ReqD.WeightUnit =txt_WEIGHTUNIT.Text.ToString().Trim();//库存单位 ReqD.ItemUomConefficient = dbItemUomConefficien;//转化系数 ReqD.Validflag = "1"; ReqD.Qty = Convert.ToDouble(txt_QTY.Value); ReqD.BudgetAmt = Convert.ToDouble(txt_BUDGETAMT.Text);//消耗预算 ReqD.CreateName = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName(); ReqD.CreateUserid = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserID(); ReqD.CreateTime = DateTime.Now; ReqD.FlagGeneratedPurPlan = "1";//默认未接受 ReqD.LastDeliveryDate = Convert.ToDateTime(txt_LastDeliveryDate.Value); ReqD.ItemStandardsCode = txt_itemStandardsCode.Text.ToString().Trim(); ReqD.ItemStandardsId = init_itemStandardsId; ReqD.ItemUomId = init_itemUomId; ReqD.ItemAttrId = init_itemAttrId; ReqD.AuditFlag = ""; ReqD.DeleteUserid = UserInfo.GetDeptid();//部门ID CoreResult rt = this.execute("com.hnshituo.pur.requireplan.service.RequirePlanDService", "doInsert_D", new object[] { ReqD }); if (rt.Resultcode != 0) { MessageUtil.ShowTips("新增失败!" + rt.Resultmsg); return; } MessageUtil.ShowTips("新增行信息成功!"); GetPUR_REQUIRE_PLAN(); comm.doActiveSelRow(ultraGrid1, "MrId", strMrId); String YY = strMrId; RequirePlanD rpd1 = new RequirePlanD(); rpd1.MrLineId = YY; rpd1.Validflag = "1"; DataTable dt1 = this.execute("com.hnshituo.pur.requireplan.service.RequirePlanDService", "get_RequirePlanDlike", new object[] { rpd1 }); GridHelper.CopyDataToDatatable(dt1, dataTable2, true); comm.doActiveSelRow(ultraGrid2, "MrLineId", rt.Resultmsg); clearkongjian(); } } catch (Exception e) { MessageUtil.ShowTips("新增失败!" + e); return; } } /// /// 导出Excel /// private void doExcel()// 导出Excel { try { this.Cursor = Cursors.Default; if (ultraTabControl2.SelectedTab == ultraTabControl2.Tabs[0]) { 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") + "无可导出明细!"); } } else { ArrayList alUltraGrid = new ArrayList(); alUltraGrid.Add(ultraGrid3); ArrayList alSheeft = new ArrayList(); alSheeft.Add("物料明细"); if (ultraGrid3.Rows.Count > 0) { GridHelper.ulGridToExcel(alUltraGrid, alSheeft, "退回需求行明细表");//导出excel } else { MessageUtil.ShowTips("无可导出退回需求计划行明细!"); } } } catch (Exception e) { MessageUtil.ShowTips("导出失败" + e.Message); } finally { this.Cursor = Cursors.Default; } } /// /// 查询 /// private void GetPUR_REQUIRE_PLAN()//刷新 { clearkongjian(); clearkongjian1(); dataTable1.Clear(); dataTable2.Clear(); dataTable3.Clear(); try { this.Cursor = Cursors.WaitCursor; //string str = Core.Mes.Client.Comm.Tool.EntityHelper.StrGetControlvalueFromMod("tg_128_st", "cxuser", "cxuser", "PUR_REQUIRE_PLAN_M", "suppone_entity", new string[] { "txt_" }, true, txt_MRID.Parent); //str = Core.Mes.Client.Comm.Tool.EntityHelper.StrGetControlvalueFromMod("tg_128_st", "cxuser", "cxuser", "PUR_REQUIRE_PLAN_D", "suppone_entity", new string[] { "txt_" }, true, txt_MRLINEID.Parent); RequirePlanM RqPM = new RequirePlanM(); RequirePlanD rpd = new RequirePlanD(); if (txt_Status.Value != null) { RqPM.Status = txt_Status.Value.ToString(); } if (ultraTextEditor1.Text != null) { RqPM.MrId = ultraTextEditor1.Text; rpd.MrId = ultraTextEditor1.Text; } if (cop_UrgencyType.Value != null) { RqPM.UrgencyType = cop_UrgencyType.Value.ToString(); } if (ck_ctime.Checked==true) { if (txtCreateTimeStart.Text != "") { RqPM.MrPeriodStart = Convert.ToDateTime(txtCreateTimeStart.Value); rpd.CreateTime = Convert.ToDateTime(txtCreateTimeStart.Value); } if (txtCreateTimeEnd.Text != "") { RqPM.MrPeriodEnd = Convert.ToDateTime(txtCreateTimeEnd.Value); rpd.UpdateTime = Convert.ToDateTime(txtCreateTimeEnd.Value); } } //生成厂 if (strCoustomInfo == "1") { RqPM.DeleteName = "1"; rpd.DeleteName = "1"; } //供应部 else if (strCoustomInfo == "2") { RqPM.DeleteName = "0"; rpd.DeleteName = "0"; } else { RqPM.DeleteName = "3"; rpd.DeleteName = "3"; } //RqPM.Status = txt_Status.Value.ToString(); //RqPM.MrId = ultraTextEditor1.Text; //RqPM.UrgencyType = ultraComboEditor2.Value.ToString(); //RqPM.MrPeriodStart = Convert.ToDateTime(txtMrPeriodStart.Value); //RqPM.MrPeriodEnd = Convert.ToDateTime(txtMrPeriodEnd.Value); RqPM.Validflag = "1"; RqPM.ValidDataPurviewIds = this.ValidDataPurviewIds; RqPM.OperatorUserId = UserInfo.GetUserID(); DataTable dt = this.execute("com.hnshituo.pur.requireplan.service.RequirePlanMService", "find_status", new object[] { RqPM }); foreach (DataRow row in dt.Rows) { row["mrPeriodEnd"] = Convert.ToDateTime(row["mrPeriodEnd"]).ToString("yyyy/MM"); } GridHelper.CopyDataToDatatable(dt, dataTable1, true); GridHelper.RefreshAndAutoSize(ultraGrid1); //查询的退回需求信息 rpd.Validflag = "1"; rpd.FlagGeneratedPurPlan = "3"; rpd.ValidDataPurviewIds = this.ValidDataPurviewIds; DataTable dt2 = this.execute("com.hnshituo.pur.requireplan.service.RequirePlanDService", "get_RequirePlanDlike", new object[] { rpd }); foreach (DataRow row in dt2.Rows) { row["itemDescE"] = Convert.ToDateTime(row["itemDescE"]).ToString("yyyy/MM"); } GridHelper.CopyDataToDatatable(dt2, dataTable3, true); GridHelper.RefreshAndAutoSize(ultraGrid3); } catch (Exception ex) { MessageUtil.ShowTips("加载数据失败:" + ex); } finally { this.Cursor = Cursors.Default; } } /// /// 需求计划接收准备汇总 /// private void ReceivePUR_REQUIRE_PLAN() { string[] strViews=this.ValidDataPurviewIds; FrmPurRequirePlanReceive2 frm = new FrmPurRequirePlanReceive2(this.ob, strViews,strCoustomInfo); frm.ShowDialog(); if (frm.tips == "1") { GetPUR_REQUIRE_PLAN(); } } /// /// 查看流程详情 /// private void Process()//查看流程详情 { UltraGridRow uge = ultraGrid1.ActiveRow; if (uge == null) { MessageUtil.ShowWarning("请选择一条记录"); return; } string mrId = uge.Cells["mrId"].Value.ToString(); ProcInstDetail detail = new ProcInstDetail(BpmFlowConstants.PROCDEF_PUR_REQUIREPLAN_AUDIT, mrId); detail.ShowDialog(); } #endregion #region 界面事件 /// /// 文件上传 /// /// /// private void ultraButton1_Click(object sender, EventArgs e)//文件上传 { m_szCurPath = "Image/pss/sale/order"; // PlanFile.FlileUpload(m_szCurPath); } /// /// 文件查看 /// /// /// private void ultraTextEditor2_DoubleClick(object sender, EventArgs e)//文件查看 { OpenFileDialog ofd = new OpenFileDialog(); ofd.ShowDialog(); //ultraTextEditor2.Value = ofd.FileName; //选择文件夹 //FolderBrowserDialog fbd = new FolderBrowserDialog(); //fbd.ShowDialog(); //MessageBox.Show(fbd.SelectedPath); } /// /// 需求数量变化事件 /// /// /// private void txt_QTY_ValueChanged(object sender, EventArgs e)//需求数量变化事件 { if (!string.IsNullOrEmpty(txt_QTY.Value.ToString())) { double useBuget = Convert.ToDouble(txt_BUGPRICE.Value) * Convert.ToDouble(txt_QTY.Value) * Convert.ToDouble(txt_ItemUomConefficient.Value); txt_BUDGETAMT.Value = useBuget; if (!string.IsNullOrEmpty(txt_ItemUomConefficient.Text)) { ultraTextEditor6.Value = Convert.ToDouble(txt_ItemUomConefficient.Value) * Convert.ToDouble(txt_QTY.Value); } double canUseBuget = Convert.ToDouble(txt_orgBudget.Value); if (useBuget > canUseBuget) { if (CK_isBugCtrl.Checked == true) { txt_tipsForBudget.Visible = true; txt_orgBudget.Appearance.ForeColor = Color.Red; } } else { txt_tipsForBudget.Visible = false; } } else { txt_BUDGETAMT.Text = ""; ultraTextEditor6.Text = ""; } } /// /// 要求交期验证 /// /// /// private void txt_LastDeliveryDate_ValueChanged(object sender, EventArgs e)// 要求交期验证 { if (txt_LastDeliveryDate.Text == "") { txt_tipsForDate.Text = "*无效交期"; txt_tipsForDate.ForeColor = Color.Red; txt_tipsForDate.Visible = true; } else { DateTime inputDate = Convert.ToDateTime(txt_LastDeliveryDate.Value); DateTime timeNow = DateTime.Now; if (inputDate <= timeNow) { txt_tipsForDate.Text = "*无效交期"; txt_tipsForDate.ForeColor = Color.Red; txt_tipsForDate.Visible = true; } else { txt_tipsForDate.Visible = false; } } } /// /// 需求数量校验 /// /// /// private void txt_QTY_KeyPress(object sender, KeyPressEventArgs e)//需求数量校验 { if (!char.IsNumber(e.KeyChar) && e.KeyChar != (char)8) { e.Handled = true; } } /// /// 切换Tab1 /// /// /// private void ultraGrid1_Click(object sender, EventArgs e)//切换Tab0 { this.ultraTabControl1.SelectedTab = ultraTabControl1.Tabs[0]; } /// /// 切换Tab1 /// /// /// private void ultraGrid2_Click(object sender, EventArgs e)//切换Tab1 { this.ultraTabControl1.SelectedTab = ultraTabControl1.Tabs[1]; } /// /// 切换Tab0 /// /// /// private void ultraGrid1_ClickCell(object sender, ClickCellEventArgs e)//切换Tab0 { this.ultraTabControl1.SelectedTab = ultraTabControl1.Tabs[0]; clearkongjian1(); clearkongjian(); UltraGridRow uge = ultraGrid1.ActiveRow; if (uge == null) return; txt_MRID.Text = uge.Cells["MRID"].Value.ToString(); txt_MRPERIODEND.Value = uge.Cells["MRPERIODEND"].Value;//计划期间-结束 txt_REQORGNAME.Text = UserInfo.GetDepartment();//申请者机构名称 txt_URGENCYTYPE.Text = uge.Cells["URGENCYTYPE"].Value.ToString();//紧急程度类型 txt_RequeType.Text = uge.Cells["REQUIRETYPE"].Value.ToString().Trim();//需求计划类型 txt_auditType.Value = uge.Cells["tenantId"].Value.ToString().Trim();//审批流程计划类型 String YY = uge.Cells["mrId"].Value.ToString(); RequirePlanD rpd = new RequirePlanD(); rpd.Validflag = "1"; rpd.MrId = YY; DataTable dt1 = this.execute("com.hnshituo.pur.requireplan.service.RequirePlanDService", "get_RequirePlanDlike", new object[] { rpd }); GridHelper.CopyDataToDatatable(dt1, dataTable2, true); GridHelper.RefreshAndAutoSize(ultraGrid2); } /// /// 切换Tab1 /// /// /// private void ultraGrid2_ClickCell(object sender, ClickCellEventArgs e)//切换Tab1 { this.ultraTabControl1.SelectedTab = ultraTabControl1.Tabs[1]; clearkongjian(); UltraGridRow uge = ultraGrid2.ActiveRow; if (uge == null) return; String strMrLineId = uge.Cells["MRLINEID"].Value.ToString(); RequirePlanD ppd = this.execute("com.hnshituo.pur.requireplan.service.RequirePlanDService", "findById", new object[] { strMrLineId }); txt_ItemUomConefficient.Text = uge.Cells["ItemUomConefficient"].Value.ToString(); txt_WEIGHTUNIT.Text = uge.Cells["WEIGHTUNIT"].Value.ToString(); txt_WEIGHTUNIT1.Text = uge.Cells["WEIGHTUNIT"].Value.ToString(); txt_WEIGHTUNIT2.Text = uge.Cells["WEIGHTUNIT"].Value.ToString(); txt_ItemUom.Text = uge.Cells["ItemUom"].Value.ToString(); txt_deliveryLocation.Text = uge.Cells["deliveryLocation"].Value.ToString(); deliveryLocationCode = uge.Cells["deliveryLocationCode"].Value.ToString(); txt_MRLINEID.Text = strMrLineId; txt_Remark.Text = uge.Cells["Remark"].Value.ToString();//备注 txt_ItemCode.Text = uge.Cells["ItemCode"].Value.ToString();//物料编码 PurmatclassEntity matclass1 = this.execute("com.hnshituo.pur.configure.service.MatClassService", "findByItem", new object[] { txt_ItemCode.Text }); if (matclass1 != null) { init_itemAutitTypeId = matclass1.TenantId; txt_itemAuditType.Text = matclass1.TenantName; } txt_ItemName.Text = uge.Cells["ItemName"].Value.ToString();//物料名称 txt_MRLINEID.Text = uge.Cells["MRLINEID"].Value.ToString();//申请单行号 txt_item_Attr.Text = uge.Cells["itemAttr"].Value.ToString();//属性名称 txt_BUGPRICE.Text = uge.Cells["BUGPRICE"].Value.ToString(); txt_BUDGETAMT.Text = uge.Cells["BUDGETAMT"].Value.ToString(); txt_QTY.Value = uge.Cells["QTY"].Value.ToString(); txt_LastDeliveryDate.Text = uge.Cells["LastDeliveryDate"].Value.ToString(); //2016年2月28日新增字段leitao txt_itemStandardsCode.Text = uge.Cells["itemStandardsCode"].Value.ToString();//采购标准值 txt_inStockQty.Text = "10000";//在库库存 txt_pipeLineStock.Text = "100";//在途库存 init_itemAttrId = ppd.ItemAttrId;//属性编码 init_itemStandardsId = ppd.ItemStandardsId;//采购标准编码 init_itemUomId = ppd.ItemUomId;//单位换算编码 init_auditFlag = ppd.AuditFlag;//审批标识 if (ppd.DeliveryLocationFlag == "1")//JIT标识 { Ck_IsJIT.Checked = true; } else { Ck_IsJIT.Checked = false; } init_itemUnique = ppd.ItemUnique; //加载是否定额控制 getBugCtrl(uge.Cells["ItemCode"].Value.ToString(), "2"); //剩余预算 getBudget(strMrLineId); //加载可用库存数量 getInStockQty(ppd.ItemUnique); //加载可用在途库存数量 getPipeLineStock(ppd.ItemUnique); } /// /// 点击退回需求 /// /// /// private void ultraGrid3_ClickCell(object sender, ClickCellEventArgs e)// 点击退回需求 { clearkongjian(); UltraGridRow uge = ultraGrid3.ActiveRow; if (uge == null) return; String strMrLineId = uge.Cells["MRLINEID"].Value.ToString(); RequirePlanD ppd = this.execute("com.hnshituo.pur.requireplan.service.RequirePlanDService", "findById", new object[] { strMrLineId }); txt_ItemUomConefficient.Text = uge.Cells["ItemUomConefficient"].Value.ToString(); txt_WEIGHTUNIT.Text = uge.Cells["WEIGHTUNIT"].Value.ToString(); txt_WEIGHTUNIT1.Text = uge.Cells["WEIGHTUNIT"].Value.ToString(); txt_WEIGHTUNIT2.Text = uge.Cells["WEIGHTUNIT"].Value.ToString(); txt_ItemUom.Text = uge.Cells["ItemUom"].Value.ToString(); txt_deliveryLocation.Text = uge.Cells["deliveryLocation"].Value.ToString(); deliveryLocationCode = uge.Cells["deliveryLocationCode"].Value.ToString(); txt_MRLINEID.Text = strMrLineId; txt_Remark.Text = uge.Cells["Remark"].Value.ToString();//备注 txt_ItemCode.Text = uge.Cells["ItemCode"].Value.ToString();//物料编码 PurmatclassEntity matclass1 = this.execute("com.hnshituo.pur.configure.service.MatClassService", "findByItem", new object[] { txt_ItemCode.Text }); if (matclass1 != null) { init_itemAutitTypeId = matclass1.TenantId; txt_itemAuditType.Text = matclass1.TenantName; } txt_ItemName.Text = uge.Cells["ItemName"].Value.ToString();//物料名称 txt_MRLINEID.Text = uge.Cells["MRLINEID"].Value.ToString();//申请单行号 txt_item_Attr.Text = uge.Cells["itemAttr"].Value.ToString();//属性名称 txt_BUGPRICE.Text = uge.Cells["BUGPRICE"].Value.ToString(); txt_BUDGETAMT.Text = uge.Cells["BUDGETAMT"].Value.ToString(); txt_QTY.Value = uge.Cells["QTY"].Value.ToString(); txt_LastDeliveryDate.Text = uge.Cells["LastDeliveryDate"].Value.ToString(); //2016年2月28日新增字段leitao txt_itemStandardsCode.Text = uge.Cells["itemStandardsCode"].Value.ToString();//采购标准值 txt_inStockQty.Text = "10000";//在库库存 txt_pipeLineStock.Text = "100";//在途库存 getBudget(strMrLineId);//剩余预算 init_itemAttrId = ppd.ItemAttrId;//属性编码 init_itemStandardsId = ppd.ItemStandardsId;//采购标准编码 init_itemUomId = ppd.ItemUomId;//单位换算编码 init_auditFlag = ppd.AuditFlag;//审批标识 if (ppd.DeliveryLocationFlag == "1")//JIT标识 { Ck_IsJIT.Checked = true; } else { Ck_IsJIT.Checked = false; } init_itemUnique = ppd.ItemUnique; } private void ultraTextEditor5_MouseClick(object sender, MouseEventArgs e) { } /// /// 部门信息弹出事件 /// /// /// private void textBox1_MouseClick(object sender, MouseEventArgs e)//部门信息弹出 { frmdepartment fdt = new frmdepartment(ob); fdt.ShowDialog(); if (fdt.BuyerUnitDesc == null) return; txt_REQORGNAME.Text = fdt.BuyerUnitDesc; } /// /// 需求列表和退回需求行切换 /// /// /// private void ultraTabControl2_SelectedTabChanged(object sender, Infragistics.Win.UltraWinTabControl.SelectedTabChangedEventArgs e)//需求列表和退回需求行切换 { // 切换到需求列表 if(ultraTabControl2.SelectedTab == ultraTabControl2.Tabs[0]) { clearkongjian(); ultraTabControl1.Tabs[0].Visible = true; txt_Status.Enabled = true; cop_UrgencyType.Enabled = true; ultraTabControl1.SelectedTab = ultraTabControl1.Tabs[0]; this.ToolBarItemEnable(this, "Add", true); this.ToolBarItemEnable(this, "Process", true); this.ToolBarItemEnable(this, "Revocation", true); txt_ItemName.Enabled = true; } //切换到退回需求计划 if(ultraTabControl2.SelectedTab == ultraTabControl2.Tabs[1]) { clearkongjian(); ultraTabControl1.SelectedTab=ultraTabControl1.Tabs[1]; ultraTabControl1.Tabs[0].Visible=false; txt_Status.Enabled = false; cop_UrgencyType.Enabled = false; this.ToolBarItemEnable(this, "Add", false); this.ToolBarItemEnable(this, "Process", false); this.ToolBarItemEnable(this, "Revocation", false); txt_ItemName.Enabled = false; } } /// /// 库存数量校验 /// /// /// private void ultraTextEditor6_KeyPress(object sender, KeyPressEventArgs e)//库存数量校验 { if (!char.IsNumber(e.KeyChar) && e.KeyChar != (char)8) { e.Handled = true; } } /// /// 物料弹窗 /// /// /// private void txt_ItemName_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)//物料弹窗 { FrmPurPlanMat mat = new FrmPurPlanMat(this.ob, init_itemUnique); mat.ShowDialog(); if (mat.getItemCode() == null) return; txt_ItemCode.Value = mat.getItemCode().ToString(); txt_ItemName.Value = mat.getItemName().ToString(); txt_item_Attr.Text = mat.ItemAttr;//属性名称 PRICE_TYPE = mat.getPriceType().ToString(); txt_BUGPRICE.Value = mat.getBugPrice().ToString(); //if (mat.getItemUseUom().ToString() == "是" || mat.getItemUseUom().ToString()=="1") //{ txt_ItemUomConefficient.Text = mat.getItemUomConefficient().ToString().Trim(); txt_WEIGHTUNIT.Text = mat.getWeightUnit().ToString(); txt_WEIGHTUNIT1.Text = mat.getWeightUnit().ToString(); txt_WEIGHTUNIT2.Text = mat.getWeightUnit().ToString(); txt_ItemUom.Text = mat.UomName; txt_QTY.Value = 0; ultraTextEditor6.Text = ""; txt_BUDGETAMT.Text = ""; txt_Remark.Text = ""; //2016年2月28新增leitao init_itemAttrId = mat.ItemAttrId;//属性编码 init_itemStandardsId = mat.ItemStandardsId;//采购标准编码 init_itemUomId = mat.ItemUomId;//单位换算编码 init_auditFlag = "0";//审批标识 init_itemUnique = mat.ItemUnique; txt_itemStandardsCode.Text = mat.StandardsCode; init_itemAutitTypeId = mat.TenantId; txt_itemAuditType.Text = mat.TenantName; //加载可用库存数量 getInStockQty(mat.ItemUnique); //加载可用在途库存数量 getPipeLineStock(mat.ItemUnique); //确定是否预算控制 getBugCtrl(mat.getItemCode().Trim(), mat.IsBudgetCtrl); } /// /// 机构弹窗 /// /// /// private void txt_REQORGNAME_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)//机构弹窗 { frmdepartment fdt = new frmdepartment(ob); fdt.ShowDialog(); if (fdt.BuyerUnitDesc == null) return; txt_REQORGNAME.Text = fdt.BuyerUnitDesc; } /// /// 交付地点弹窗 /// /// /// private void txt_deliveryLocation_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)// 交付地点弹窗 { frmPopActualSeat Dz = new frmPopActualSeat(this.ob,"1"); //FrmPop_upDeliveryLocation Dz = new FrmPop_upDeliveryLocation(this.ob); Dz.ShowDialog(); if (Dz.DeliveryLocationCode == null) { return; } txt_deliveryLocation.Text = Dz.DeliveryLocation; deliveryLocationCode = Dz.DeliveryLocationCode; //txt_URGENCYTYPE.SelectAll(); } /// /// 查询预算情况 /// /// /// private void txt_orgBudget_EditorButtonClick(object sender, EditorButtonEventArgs e)//查询预算情况 { frmPopOrgBudgetDetail frm = new frmPopOrgBudgetDetail(this.ob); frm.ShowDialog(); } /// /// 查询在库存库存 /// /// /// private void txt_inStockQty_EditorButtonClick(object sender, EditorButtonEventArgs e)//查询在库存库存 { string TabShow = "0";//tab默认为在库库存 if (String.IsNullOrEmpty(init_itemUnique)) { MessageUtil.ShowTips("未选择物料!"); return; } frmPopInStockQtyDetail frm = new frmPopInStockQtyDetail(this.ob,init_itemUnique,TabShow); frm.ShowDialog(); } /// /// 查询在途库存 /// /// /// private void txt_pipeLineStock_EditorButtonClick(object sender, EditorButtonEventArgs e)//查询在途库存 { string TabShow = "1";//tab默认为在途库存 if (String.IsNullOrEmpty(init_itemUnique)) { MessageUtil.ShowTips("未选择物料!"); return; } frmPopInStockQtyDetail frm = new frmPopInStockQtyDetail(this.ob, init_itemUnique,TabShow); frm.ShowDialog(); } /// /// 是否按照时间查询 /// /// /// 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_URGENCYTYPE_ValueChanged(object sender, EventArgs e)// 紧急采购允许输入月份 { if (txt_URGENCYTYPE.SelectedIndex == 1) { txt_MRPERIODEND.Enabled = true; } else { txt_MRPERIODEND.Enabled = false; txt_MRPERIODEND.Value = DateTime.Now < DateTime.Parse(DateTime.Now.ToString("yyyy/MM/26")) ? DateTime.Parse(DateTime.Now.AddMonths(1).ToString("yyyy/MM")) : DateTime.Parse(DateTime.Now.AddMonths(2).ToString("yyyy/MM")); } } #endregion #region 公共方法 /// /// 控件清空tab2 /// /// /// private void clearkongjian()//tab2控件值清空 { txt_item_Attr.Text = ""; txt_MRLINEID.Text = ""; txt_Remark.Text = ""; txt_ItemCode.Text = ""; txt_ItemName.Text = ""; txt_MRLINEID.Text = ""; txt_BUGPRICE.Text = ""; txt_BUDGETAMT.Text = ""; txt_QTY.Value = 0; ultraTextEditor6.Text = ""; txt_ItemUom.Text = ""; txt_WEIGHTUNIT.Text = ""; txt_WEIGHTUNIT1.Text = ""; txt_WEIGHTUNIT2.Text = ""; txt_ItemUomConefficient.Text = ""; txt_inStockQty.Text = "-"; txt_pipeLineStock.Text= "-"; //2016.2.28新增leitao txt_inStockQty.Text = ""; txt_itemStandardsCode.Text = ""; txt_pipeLineStock.Text = ""; CK_isBugCtrl.Checked = false; getBudget(""); init_itemAttrId = "";//属性编码 init_itemStandardsId = "";//采购标准编码 init_itemUomId = "";//单位换算编码 init_auditFlag = "";//审批标识 //init_deliveryLocationFlag = "";//JIT标识 init_itemUnique = ""; init_itemAutitTypeId = ""; txt_itemAuditType.Text = ""; //Ck_IsJIT.Checked = false; //deliveryLocationCode = "";//地点编码 txt_tipsForDate.Visible = false; txt_tipsForBudget.Visible = false; txt_orgBudget.Appearance.ForeColor = Color.Black; txt_LastDeliveryDate.Value = DateTime.Now.AddMonths(1).ToString(); } /// /// 控件清空1 /// /// /// private void clearkongjian1()//tab1控件值清空 { txt_RequeType.SelectedIndex = 0; txt_MRID.Text = ""; txt_URGENCYTYPE.SelectedIndex = 0; txt_auditType.SelectedIndex = 0; txt_MRPERIODEND.Enabled = false; txt_REQORGNAME.Text = CoreFS.SA06.CoreUserInfo.UserInfo.GetDepartment(); if (DateTime.Now < DateTime.Parse(DateTime.Now.ToString("yyyy/MM/26"))) { txt_MRPERIODEND.Value = DateTime.Parse(DateTime.Now.AddMonths(1).ToString("yyyy/MM")); } else { txt_MRPERIODEND.Value = DateTime.Parse(DateTime.Now.AddMonths(2).ToString("yyyy/MM")); } } /// /// 获取需求计划行编码 /// /// /// public string getCodeId(string str)//获取需求计划行编码 { String YY = ultraGrid1.ActiveRow.Cells["mrId"].Value.ToString(); RequirePlanD rpd = new RequirePlanD(); rpd.MrLineId = YY; DataTable dt1 = this.execute("com.hnshituo.pur.requireplan.service.RequirePlanDService", "get_RequirePlanDlike", new object[] { rpd }); string strChild = ""; int intChild = dt1.Rows.Count; intChild++; strChild = intChild.ToString(); while (strChild.Length < 3) { strChild = "0" + strChild; } return str + "-" + strChild; } /// /// JIT选择事件 /// /// /// private void Ck_IsJIT_CheckedChanged(object sender, EventArgs e)// JIT选择事件 { if (Ck_IsJIT.Checked) { txt_deliveryLocation.Enabled = true; } else { txt_deliveryLocation.Enabled = false; } } /// /// 剩余预算计算 /// private void getBudget(String mrLIneId)//计算剩余预算 { //计算预算 String strorgId=UserInfo.GetDeptid(); String stryear=DateTime.Now.Year.ToString(); String strmouth = DateTime.Now.Month.ToString(); CoreResult re = this.execute("com.hnshituo.pur.configure.service.ConfigureOrgBudgetService", "doQueryBudgetRemain", new object[] { strorgId, stryear, strmouth, mrLIneId}); if (re.Resultcode != 0) { txt_orgBudget.Value = 0; return; } else { txt_orgBudget.Value = Convert.ToDouble(re.Resultmsg); } } /// /// 可用在途库存 /// /// /// private void getPipeLineStock(String strItemUnique)//可用在途库存 { if (String.IsNullOrEmpty(strItemUnique)) { txt_pipeLineStock.Text = "-"; return; } OrderC orderc = new OrderC(); orderc.ItemUnique = strItemUnique; orderc.Validflag = "1"; orderc.DeleteName = "1";//仅查询在途库存大于0的 CoreResult re = this.execute("com.hnshituo.pur.order.service.OrderCService", "getPipeLineStockQty", new object[] { orderc }); if (re.Resultcode != 0) { txt_pipeLineStock.Text = "-"; return; } else { txt_pipeLineStock.Text = re.Resultmsg; } } /// /// 可用在途库存 /// /// private void getInStockQty(String strItemUnique)//可用在途库存 { if (String.IsNullOrEmpty(strItemUnique)) { txt_inStockQty.Text = "-"; return; } CoreResult re = this.execute("com.hnshituo.pur.ck.service.CkStorageService", "getInStockQty", new object[] { strItemUnique }); if (re.Resultcode != 0) { txt_inStockQty.Text = "-"; return; } else { txt_inStockQty.Text = re.Resultmsg; } } /// /// 查询物料是否预算控制 /// /// /// 是否预算控制1:控制,0不控制,2未知 private void getBugCtrl(string itemCode, string p2) { if (p2 == "0") { CK_isBugCtrl.Checked = false; } else if (p2 == "1") { CK_isBugCtrl.Checked = true; } else { if (String.IsNullOrEmpty(itemCode)) { MessageUtil.ShowTips("物料编码为空,无法判断该物料是否为预算控制物料"); return; } MatEntity mAT = this.execute("com.hnshituo.pur.configure.service.MatService", "findById", new object[] { itemCode }); if (mAT == null) { MessageUtil.ShowTips("物料【" + itemCode + "】不存在,请确定"); return; } if (mAT.IsBudgetCtrl == "1") { CK_isBugCtrl.Checked = true; } else { CK_isBugCtrl.Checked = false; } } } /// /// 需求行数据校验 /// /// private bool testReqC()// 需求行数据校验 { if (txt_ItemCode.Text.ToString().Trim()=="") { MessageUtil.ShowWarning("物料编码不能为空!"); return false; } if (txt_QTY.Value == null) { MessageUtil.ShowWarning("需求数量不能为空!"); return false; } if (Convert.ToDouble(txt_QTY.Value) == 0) { MessageUtil.ShowWarning("需求数量不能为0"); return false; } if (txt_tipsForBudget.Visible == true) { MessageUtil.ShowTips("超出预算,请确定,或请刷新页面再操作!"); txt_QTY.Focus(); return false; } if (txt_LastDeliveryDate.Text == "" || txt_tipsForDate.Visible == true) { MessageUtil.ShowTips("请输入有效的到货时间!"); txt_LastDeliveryDate.Focus(); return false; } if (ultraTabControl2.SelectedTab == ultraTabControl2.Tabs[0] && strCoustomInfo != "2") { string strtenantId = ultraGrid1.ActiveRow.GetCellValue("tenantId").ToString(); if (strtenantId != init_itemAutitTypeId) { MessageUtil.ShowTips("该物料审批流程和需求计划头流程不一致!"); txt_itemAuditType.Focus(); return false; } } return true; } /// /// 需求头信息校验 /// /// private bool testReqM()// 需求头信息校验 { if (txt_MRPERIODEND.Text == "") { MessageUtil.ShowTips("计划月份不能为空!"); txt_MRPERIODEND.Focus(); return false; } if (txt_MRPERIODEND.Enabled==false&&(DateTime.Now > DateTime.Parse(DateTime.Now.ToString("yyyy/MM/26")))) { if (MessageUtil.ShowYesNoAndQuestion("需求提报截止日期为每月25号,若提交将默认为下月需求计划。确定新增?") != DialogResult.Yes) { txt_MRPERIODEND.Focus(); return false; } } if (txt_RequeType.Value == null) { MessageUtil.ShowTips("请选择需求计划类型!"); txt_RequeType.Focus(); return false; } if (txt_URGENCYTYPE.SelectedIndex == -1) { MessageUtil.ShowTips("请选择紧急程度类型!"); txt_URGENCYTYPE.Focus(); return false; } if (strCoustomInfo != "2") { if (txt_auditType.SelectedIndex == -1) { MessageUtil.ShowTips("请选择审批流程类型!"); txt_auditType.Focus(); return false; } } return true; } /// /// 验证是否有权力操作行 /// /// /// /// private Boolean testReqCStatus(String strMrLineId, int tips)// 验证是否有权力操作行 { RequirePlanD pd = this.execute("com.hnshituo.pur.requireplan.service.RequirePlanDService", "findById", new object[] { strMrLineId }); if (pd.CreateUserid != UserInfo.GetUserID()) { MessageUtil.ShowTips("无权限,只能操作自己的提交的需求计划行"); return false; } //是否待提报是否有权力进行删改 if (tips == 1) { //行计划为未接收和已退回下是才能修改和删除 //if (!(pd.FlagGeneratedPurPlan == "1") && !(pd.FlagGeneratedPurPlan == "3")) //{ // MessageUtil.ShowTips("行计划为“未接收”和“已退回”下才能删改,或请刷新再操作"); // return; //} //验证是否有权力操作头 if (testReqMStatus(pd.MrId, 1) == false) { return false; } if (!(pd.FlagGeneratedPurPlan == "1")) { MessageUtil.ShowTips("行计划为“未接收”下才能删改,或请刷新再操作"); return false; } } //判断退回需求行是否可以提报和删改 else if (tips == 2) { if (pd.FlagGeneratedPurPlan != "3") { MessageUtil.ShowTips("行计划为非“已退回”状态,无权限删改或提报,或请刷新再操作"); return false; } } else { MessageUtil.ShowTips("未知参数,无法验证行信息有效性"); return false; } return true; } /// /// 验证是否有权力操作头 /// /// /// /// private Boolean testReqMStatus(String mrId, int tips)// 验证是否有权力操作头 { if (strCoustomInfo != "1" && strCoustomInfo != "2" && strCoustomInfo != "3") { MessageUtil.ShowTips("界面CoustomInfo参数配置错误,1:生产厂,2:供应部,3:科室厂区"); return false; } RequirePlanM pm = this.execute("com.hnshituo.pur.requireplan.service.RequirePlanMService", "findById", new object[] { mrId }); if (pm.CreateUserid != UserInfo.GetUserID()) { MessageUtil.ShowTips("无权限,只能操作自己的提交的需求计划"); return false; } //判断是否有权力进行增删改 if (tips == 1) { //头是否处于可删该的状态 if (pm.Status == "-1"||pm.Status == "0" || pm.Status == "2" || pm.Status == "3") { MessageUtil.ShowTips("需求计划头【" + mrId + "】不在“待提交”、“待提报”和“审批不通过”状态,暂无权限进行增删改,或请刷新后再操作!"); return false; } } //判断是否有权力进行修改 else if (tips == 4) { //头是否处于可删该的状态 if (pm.Status == "-1" || pm.Status == "0" || pm.Status == "2" || pm.Status == "3") { MessageUtil.ShowTips("需求计划头【" + mrId + "】不在“待提交”、“待提报”和“审批不通过”状态,暂无权限进行增删改,或请刷新后再操作!"); return false; } //判断是流程是否一致 if (strCoustomInfo != "2") { String itemAutitTypeId = txt_auditType.Value.ToString().Trim(); RequirePlanD testpd = new RequirePlanD(); testpd.MrId = mrId; testpd.Validflag = "1"; List dtPd = this.execute>("com.hnshituo.pur.requireplan.service.RequirePlanDService", "find", new object[] { testpd, 0, 0 }); if (dtPd.Count > 0) { foreach (RequirePlanD rpd in dtPd) { String strItemCode = rpd.ItemCode; PurmatclassEntity matclass1 = this.execute("com.hnshituo.pur.configure.service.MatClassService", "findByItem", new object[] { strItemCode }); if (matclass1 != null) { if (matclass1.TenantId != itemAutitTypeId) { MessageUtil.ShowTips("和该需求头下物料:" + strItemCode + "的流程不一致,请确定!"); txt_auditType.Focus(); return false; } } } } } } //判断是否可以提报 else if (tips == 2) { if (!(pm.Status == "1") && !(pm.Status == "4") && !(pm.Status == "-2")) { MessageUtil.ShowTips("需求计划头【" + mrId + "】只能在“待提交”、“待提报”和“审批不通过”状态下才有权限进行提报,或请刷新后再操作!"); return false; } //判断是否有行信息 RequirePlanD testpd =new RequirePlanD(); testpd.MrId=mrId; testpd.Validflag="1"; DataTable dtPd= this.execute("com.hnshituo.pur.requireplan.service.RequirePlanDService", "find", new object[] { testpd,0,0 }); if (dtPd.Rows.Count<=0) { MessageUtil.ShowWarning("需求计划头【" + mrId + "】无需求计划行,请添加物料后再提报!"); return false; } } //是否有权利撤回 else if (tips == 3) { //头是否处于可撤回状态 if (strCoustomInfo != "2") { if (!(pm.Status == "2") && !(pm.Status == "-1")) { MessageUtil.ShowTips("需求计划头【" + mrId + "】当前状态不能撤销,无权限,或请刷新后再操作!"); return false; } } else { if (!(pm.Status == "3")) { MessageUtil.ShowTips("需求计划头【" + mrId + "】当前状态不能撤销,无权限,或请刷新后再操作!"); return false; } } } else { MessageUtil.ShowTips("未知参数,无法验证头表有效性"); return false; } return true; } #endregion } }