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 FrmPurRequirePlan : FrmPmsBase { //初始化数据 string deliveryLocationCode = "";//地点编码 string strCoustomInfo = ""; public FrmPurRequirePlan() { InitializeComponent(); this.IsLoadUserView = true; } private void FrmPurRequirePlan_Load(object sender, EventArgs e)//Load { txt_LastDeliveryDate.Value = DateTime.Now.AddMonths(1).ToString(); strCoustomInfo=this.CustomInfo == null ? "" : this.CustomInfo.ToString(); //初始化1查询区域信息 ck_ctime.Checked = false; txtCreateTimeStart.Value = DateTime.Now.AddMonths(-2); txtCreateTimeEnd.Value = DateTime.Now.AddDays(2); txtCreateTimeStart.Enabled = false; txtCreateTimeEnd.Enabled = false; ck_Mtime.Checked = true; cop_planMouthStart.Value = DateTime.Now.AddMonths(-1); cop_planMouthEnd.Value = DateTime.Now < DateTime.Parse(DateTime.Now.ToString("yyyy/MM/26")) ? DateTime.Now.AddMonths(1): DateTime.Now.AddMonths(2); cop_UrgencyType.SelectedIndex = 0; ck_isAlldepart.Checked=true; //加载计划类型数据 DataTable dt1 = ServerHelper.GetData("com.hnshituo.pur.configure.service.impl.CoreBaseInfoNew.doQuery", new Object[] { "1221" }, this.ob); if (strCoustomInfo == "1")//生产厂 { txt_Status.SelectedIndex = 4; } else if (strCoustomInfo == "2")//供应部 { this.ToolBarItemEnable(this, "DoReceive", false); this.ToolBarItemEnable(this, "Process", false); txt_Status.SelectedIndex = 4; } else//厂区 { this.ToolBarItemEnable(this, "DoReceive", false); this.ToolBarItemEnable(this, "Process", false); txt_Status.SelectedIndex = 1; } //初始化2:GRID ultraGrid1.DisplayLayout.Bands[0].Override.AllowUpdate = DefaultableBoolean.False; GridHelper.SetExcludeColumnsActive(ultraGrid2.DisplayLayout.Bands[0], new string[] { "CHK", "qty","remark"}); //初始化3:行编辑区 txt_tipsForBudget.Visible = false; txt_tipsForDeliveryTime.Visible = false; Ck_IsJIT.Checked = true; //txt_deliveryLocation.Enabled = false; } #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 "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; case "doCopy": doCopy(); break; } } /// /// 查询 /// private void GetPUR_REQUIRE_PLAN()//刷新 { dataTable1.Clear(); dataTable2.Clear(); message.Clear(); clearkongjian(); try { this.Cursor = Cursors.WaitCursor; RequirePlanM RqPM = new RequirePlanM(); if (txt_Status.Value != null) { RqPM.Status = txt_Status.Value.ToString(); } if (ultraTextEditor1.Text != null) { RqPM.MrId = ultraTextEditor1.Text; } if (cop_UrgencyType.Value != null) { RqPM.UrgencyType = cop_UrgencyType.Value.ToString(); } if (ck_ctime.Checked == true) { if (txtCreateTimeStart.Text != "") { RqPM.CreateTime = Convert.ToDateTime(txtCreateTimeStart.Value); } if (txtCreateTimeEnd.Text != "") { RqPM.DeleteTime = Convert.ToDateTime(txtCreateTimeEnd.Value); } } //计划时间 if (ck_Mtime.Checked == true) { if (cop_planMouthStart.Text != "") { DateTime Start1 = DateTime.Parse(Convert.ToDateTime(cop_planMouthStart.Value).ToString("yyyy/MM")); RqPM.MrPeriodStart = Start1; } if (cop_planMouthEnd.Text != "") { DateTime End1 = DateTime.Parse(Convert.ToDateTime(cop_planMouthEnd.Value).ToString("yyyy/MM")); RqPM.MrPeriodEnd = End1; } } //生成厂 if (strCoustomInfo == "1") { RqPM.DeleteName = "1"; } //供应部 else if (strCoustomInfo == "2") { RqPM.DeleteName = "0"; } else { RqPM.DeleteName = "3"; } RqPM.Validflag = "1"; RqPM.ValidDataPurviewIds = this.ValidDataPurviewIds; RqPM.OperatorUserId = UserInfo.GetUserID(); RqPM.BpmUserId = UserInfo.GetUserID(); string strDataFlag = this.execute("com.hnshituo.pur.utils.service.UtilsService", "getRoleDataFlag", new object[] { UserInfo.GetUserID(), "Pur.require_plan.FrmPurRequirePlan" }); if (strDataFlag == "0")//没有数据权限 { if (ck_isAlldepart.Checked) { RqPM.CreateUserid = this.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); //查询可用定额 //getBudget(); } catch (Exception ex) { MessageUtil.ShowTips("加载数据失败:" + ex); } finally { this.Cursor = Cursors.Default; } } /// /// 撤销提报 /// private void RevPUR_REQUIRE_PLAN()//提报撤销 { 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,strCoustomInfo}); if (rt.Resultcode != 0) { MessageUtil.ShowTips("撤回失败!" + rt.Resultmsg); return; } MessageUtil.ShowTips("撤回成功!"); GetPUR_REQUIRE_PLAN(); comm.doActiveSelRow(ultraGrid1, "MrId", ReqM.MrId); } /// /// 复制需求行 /// private void doCopy() { UltraGridRow uge = ultraGrid1.ActiveRow; if (uge == null) { MessageUtil.ShowTips("请选择可操作的需求计划头!"); return; } String mrId = uge.Cells["MrId"].Value.ToString(); if (mrId == "") { MessageUtil.ShowTips("请选择可操作的需求计划头"); return; } try { frmPurRequirePlanMAdd frm = new frmPurRequirePlanMAdd(this.ob, strCoustomInfo, mrId); frm.Text = "复制需求计划[" + mrId + "]"; frm.ShowDialog(); if (frm.tips == "1") { string StrMrId = frm.requirePlanMId; GetPUR_REQUIRE_PLAN(); comm.doActiveSelRow(ultraGrid1, "MrId", StrMrId); } } catch (Exception e) { MessageUtil.ShowTips("复制失败!" + e); return; } } /// /// 提报 /// private void SubPUR_REQUIRE_PLAN()//提报需求 { 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,strCoustomInfo}); if (rt.Resultcode != 0) { MessageUtil.ShowTips("提报失败!" + rt.Resultmsg); return; } MessageUtil.ShowTips("提报成功!"); GetPUR_REQUIRE_PLAN(); comm.doActiveSelRow(ultraGrid1, "MrId", mrId); } /// /// 删除需求 /// private void DelPUR_REQUIRE_PLAN()//删除需求 { 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 (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", "doDeleteM_batch", new object[] { list, strCoustomInfo }); if (rt.Resultcode != 0) { MessageUtil.ShowTips("删除失败!" + rt.Resultmsg); return; } MessageUtil.ShowTips("删除成功!"); GetPUR_REQUIRE_PLAN(); } /// /// 新增 /// private void AddPUR_REQUIRE_PLAN()//新增需求 { try { frmPurRequirePlanMAdd frm = new frmPurRequirePlanMAdd(this.ob, strCoustomInfo); frm.ShowDialog(); if(frm.tips=="1") { string StrMrId =frm.requirePlanMId; GetPUR_REQUIRE_PLAN(); comm.doActiveSelRow(ultraGrid1, "MrId", StrMrId); } } catch (Exception e) { MessageUtil.ShowTips("新增失败!" + e); return; } } /// /// 导出Excel /// private void doExcel()// 导出Excel { 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; } } /// /// 需求计划接收准备汇总 /// 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(); //if (testReqMStatus(mrId, 6) == false) //{ // return; //} ProcInstDetail detail = new ProcInstDetail(BpmFlowConstants.PROCDEF_PUR_REQUIREPLAN_AUDIT, mrId); detail.ShowDialog(); } #endregion #region 界面事件 /// /// 要求交期验证 /// /// /// private void txt_LastDeliveryDate_ValueChanged(object sender, EventArgs e)// 要求交期验证 { if (txt_LastDeliveryDate.Text == "") { txt_tipsForDeliveryTime.Visible = true; } else { if (Convert.ToDateTime(txt_LastDeliveryDate.Value) < DateTime.Now.AddDays(10)) { txt_tipsForDeliveryTime.Visible = true; } else { txt_tipsForDeliveryTime.Visible = false; } } } /// /// 查询预算情况 /// /// /// private void txt_orgBudget_EditorButtonClick(object sender, EditorButtonEventArgs e)//查询预算情况 { DateTime dt = new DateTime(); String orgId = ""; if (ultraGrid1.ActiveRow == null) { dt = DateTime.Now.AddMonths(1); orgId = UserInfo.GetDeptid(); } else { UltraGridRow uge = ultraGrid1.ActiveRow; String YY = uge.Cells["mrId"].Value.ToString(); if (String.IsNullOrEmpty(YY)) { return; } RequirePlanM pd = this.execute("com.hnshituo.pur.requireplan.service.RequirePlanMService", "findById", new object[] { YY }); dt=(DateTime)pd.MrPeriodEnd; orgId = pd.ReqOrgId; } frmPopOrgBudgetDetail frm = new frmPopOrgBudgetDetail(this.ob, dt, orgId); frm.ShowDialog(); } /// /// 查询在库存库存 /// /// /// private void txt_inStockQty_EditorButtonClick(object sender, EditorButtonEventArgs e)//查询在库存库存 { string TabShow = "0";//tab默认为在库库存 UltraGridRow uge = ultraGrid2.ActiveRow; if (uge == null) return; String init_itemUnique = uge.Cells["itemUnique"].Value.ToString(); 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)//查询在途库存 { } private void ultraGrid1_InitializeRow(object sender, InitializeRowEventArgs e) { if (e.Row.Cells["status"].Value.ToString().StartsWith("审批不通过")) { e.Row.Appearance.ForeColor = Color.Red; } else { e.Row.Appearance.ForeColor = Color.Black; } } private void ultraGrid2_InitializeRow(object sender, InitializeRowEventArgs e) { if (e.Row.Cells["flagGeneratedPurPlan"].Value.ToString().StartsWith("已退回") || e.Row.Cells["flagGeneratedPurPlan"].Value.ToString().StartsWith("已删除")) { e.Row.Appearance.ForeColor = Color.Red; } else { e.Row.Appearance.ForeColor = Color.Black; } } /// /// 是否按照时间查询 /// /// /// 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 ck_Mtime_CheckedChanged(object sender, EventArgs e) { cop_planMouthStart.Enabled = ck_Mtime.Checked; cop_planMouthEnd.Enabled = ck_Mtime.Checked; } private void ultraGrid1_AfterRowActivate(object sender, EventArgs e) { dataTable2.Clear(); message.Clear(); clearkongjian(); if (ultraGrid1.ActiveRow == null) { return; } UltraGridRow uge = ultraGrid1.ActiveRow; String YY = uge.Cells["mrId"].Value.ToString(); if (String.IsNullOrEmpty(YY)) { return; } RequirePlanM pd = this.execute("com.hnshituo.pur.requireplan.service.RequirePlanMService", "findById", new object[] { YY }); getBudget((DateTime)pd.MrPeriodEnd, pd.ReqOrgId); 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); foreach (UltraGridRow ugr in ultraGrid2.Rows) { if (!String.IsNullOrEmpty(ugr.Cells["refuseReason"].Value.ToString().Trim())) { ugr.CellAppearance.ForeColor = System.Drawing.Color.FromArgb(255, 128, 0); } else { //ugr.CellAppearance.ForeColor = Color.Black; } } GridHelper.RefreshAndAutoSizeExceptColumns(ultraGrid2, new UltraGridColumn[] { ultraGrid2.DisplayLayout.Bands[0].Columns["CHK"], ultraGrid2.DisplayLayout.Bands[0].Columns["remark"] }); //加载评审意见 getOrderReview(YY); } private void ultraGrid2_AfterRowActivate(object sender, EventArgs e) { 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 }); //加载可用库存数量 getInStockQty(ppd.ItemUnique); } #endregion #region 行按钮 /// ///删除需求行 /// /// /// private void btn_delete_Click(object sender, EventArgs e) { UltraGridRow uge = ultraGrid1.ActiveRow; if (uge == null) { MessageUtil.ShowTips("请选择需要操作的需求计划头!"); return; } String mrId = uge.Cells["MrId"].Value.ToString().Trim(); //验证头状态 if (testReqMStatus(mrId, 1) == false) { return; } if (String.IsNullOrEmpty(mrId)) { MessageUtil.ShowTips("该需求计划头号为空!"); return; } ultraGrid2.UpdateData(); List list = new List(); foreach (UltraGridRow row in ultraGrid2.Rows) { if (Convert.ToBoolean(row.GetCellValue("CHK")) == true) { string strMrLineId = row.Cells["MrLineId"].Value.ToString().Trim(); if (String.IsNullOrEmpty(strMrLineId)) { MessageUtil.ShowTips("未获取第"+row.Index+"个的需求计划行号!"); return; } //验证是否有权利删改行 if (testReqCStatus(strMrLineId, 1) == false) { return; } RequirePlanD ReqD = new RequirePlanD(); //ReqD.MrId = mrId; ReqD.MrLineId = strMrLineId; ReqD.Validflag = "0"; ReqD.DeleteName = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName(); ReqD.DeleteUserid = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserID(); ReqD.DeleteTime = DateTime.Now; list.Add(ReqD); } } if (list.Count <= 0) { MessageUtil.ShowTips("未选择需求计划行"); return; } if (MessageUtil.ShowYesNoAndQuestion("是否确定删除需求计划行?") != DialogResult.Yes) { return; } CoreResult rt = this.execute("com.hnshituo.pur.requireplan.service.RequirePlanDService", "doDelete_batch", new object[] { list}); 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); } /// /// 保存需求行 /// /// /// private void btn_doSave_Click(object sender, EventArgs e) { if (testReqC() == false) { return; } 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; } List list = new List(); ultraGrid2.UpdateData(); foreach (UltraGridRow row in ultraGrid2.Rows) { if (Convert.ToBoolean(row.GetCellValue("CHK")) == true) { RequirePlanD ReqD = new RequirePlanD(); string strMrLineId = row.Cells["MrLineId"].Value.ToString().Trim(); string strmatCode = row.Cells["itemCode"].Value.ToString().Trim(); if (String.IsNullOrEmpty(strMrLineId)) { MessageUtil.ShowTips("未获取第" + row.Index + "个的需求计划行号!"); return; } if (String.IsNullOrEmpty(strmatCode)) { MessageUtil.ShowTips("未获取第" + row.Index + "个的物料编码!"); return; } //验证是否有权利删改行 if (testReqCStatus(strMrLineId, 1) == false) { return; } //校验数据 double qty = Convert.ToDouble(row.GetCellValue("qty")); ReqD.DeliveryLocationFlag = Ck_IsJIT.Checked ? "1" : "0"; ReqD.DeliveryLocation = txt_deliveryLocation.Text; ReqD.DeliveryLocationCode = deliveryLocationCode; if (ReqD.DeliveryLocationCode == "") { MessageUtil.ShowTips("送货的地址信息不能为空"); txt_deliveryLocation.Focus(); return; } ReqD.Remark = row.GetCellValue("remark") == null ? "" : row.GetCellValue("remark").ToString().Trim(); ReqD.ItemCode = strmatCode; ReqD.LastDeliveryDate = Convert.ToDateTime(txt_LastDeliveryDate.Value); ReqD.Qty = qty; ReqD.MrLineId = strMrLineId; ReqD.Validflag = "1"; ReqD.DeleteUserid = CoreFS.SA06.CoreUserInfo.UserInfo.GetDeptid(); ReqD.UpdateName = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName(); ReqD.UpdateUserid = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserID(); ReqD.UpdateTime = DateTime.Now; list.Add(ReqD); } } if (list.Count <= 0) { MessageUtil.ShowTips("未选择需求计划行"); return; } if (MessageUtil.ShowYesNoAndQuestion("确定修改上述需求计划行?") != DialogResult.Yes) { return; } CoreResult rt = this.execute("com.hnshituo.pur.requireplan.service.RequirePlanDService", "doUpdate_batch", new object[] { list }); if (rt.Resultcode != 0) { MessageUtil.ShowTips("操作失败!" + rt.Resultmsg); return; } Core.Mes.Client.Comm.Tool.MessageUtil.ShowTips("操作成功!"); GetPUR_REQUIRE_PLAN(); comm.doActiveSelRow(ultraGrid1, "MrId", mrId); 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); } //批量新增物料 private void btn_addItem_Click(object sender, EventArgs e) { //校验行数据 if (testReqC() == false) { return; } List list = new List(); if (ultraGrid1.ActiveRow == null) { MessageUtil.ShowTips("请选择需求计划头进行物料添加"); return; } UltraGridRow uge = ultraGrid1.ActiveRow; String mrId = uge.Cells["mrId"].Value.ToString(); //验证头状态 if (testReqMStatus(mrId, 1) == false) { return; } RequirePlanM pm = this.execute("com.hnshituo.pur.requireplan.service.RequirePlanMService", "findById", new object[] { mrId }); String strtenantId = pm.TenantId; FrmPurPlanMatNew mat = new FrmPurPlanMatNew(this.ob); mat.ShowDialog(); if (mat.list==null||mat.list.Count <= 0) { return; } foreach (RequirePlanD pd in mat.list) { if (strtenantId != pd.DeleteUserid&&strCoustomInfo!="2") { if (MessageUtil.ShowYesNoAndTips("物料:" + pd.ItemName + " 审批流程:" + pd.DeleteName + "和需求头审批流程:" + pm.TenantName + "不一致,是否忽略该物料继续?") != DialogResult.Yes) { return; } else { continue; } } pd.MrId = mrId; pd.DeliveryLocationFlag = Ck_IsJIT.Checked?"1":"0"; pd.DeliveryLocation = txt_deliveryLocation.Text; pd.DeliveryLocationCode = deliveryLocationCode; if (pd.DeliveryLocationCode == "") { MessageUtil.ShowTips("送货的地址信息不能为空"); txt_deliveryLocation.Focus(); return; } pd.LastDeliveryDate = Convert.ToDateTime(txt_LastDeliveryDate.Value); RequirePlanD ReqD = new RequirePlanD(); ReqD.ItemUnique = pd.ItemUnique; ReqD.DeliveryLocationFlag = pd.DeliveryLocationFlag; ReqD.DeliveryLocationCode = pd.DeliveryLocationCode; ReqD.MrId = mrId; 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; } if (pd.Qty == null || Convert.ToDouble(pd.Qty)<=0) { if (MessageUtil.ShowYesNoAndTips("物料:" + pd.ItemName + "未填写需求量,是否忽略该物料继续添加?") != DialogResult.Yes) { return; } else { continue; } } pd.BudgetAmt = pd.BugPrice * pd.Qty*pd.ItemUomConefficient; pd.CreateName = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName(); pd.CreateUserid = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserID(); pd.CreateTime = DateTime.Now; pd.Validflag = "1"; pd.FlagGeneratedPurPlan = "1";//默认未接受 pd.AuditFlag = ""; pd.DeleteUserid = UserInfo.GetDeptid();//部门ID if (String.IsNullOrEmpty(pd.ItemUom) || String.IsNullOrEmpty(pd.ItemUnique) || String.IsNullOrEmpty(pd.ItemUomId)) { if (MessageUtil.ShowYesNoAndTips("物料:" + pd.ItemName + "未获取到采购单位,是否忽略该物料继续添加?") != DialogResult.Yes) { return; } else { continue; } } list.Add(pd); } if (list.Count <= 0) { MessageUtil.ShowTips("未发现可新增物料"); return; } CoreResult rt = this.execute("com.hnshituo.pur.requireplan.service.RequirePlanDService", "doInsert_D_batch", new object[] { list }); if (rt.Resultcode != 0) { MessageUtil.ShowTips("新增行失败!" + rt.Resultmsg); return; } 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); comm.doActiveSelRow(ultraGrid2, "MrLineId", rt.Resultmsg); clearkongjian(); } /// /// 退回需求行重新提报 /// /// /// private void btn_back_re_Click(object sender, EventArgs e) { if (ultraGrid1.ActiveRow == null) { return; } UltraGridRow uge = ultraGrid1.ActiveRow; String YY = uge.Cells["mrId"].Value.ToString(); if (String.IsNullOrEmpty(YY)) { return; } List list = new List(); ultraGrid2.UpdateData(); foreach (UltraGridRow row in ultraGrid2.Rows) { if (Convert.ToBoolean(row.GetCellValue("CHK")) == true) { RequirePlanD ReqD = new RequirePlanD(); string strMrLineId = row.Cells["MrLineId"].Value.ToString().Trim(); if (String.IsNullOrEmpty(strMrLineId)) { MessageUtil.ShowTips("未获取第" + row.Index + "个的需求计划行号!"); return; } //验证是否有权利删改行 if (testReqCStatus(strMrLineId, 2) == false) { return; } ReqD.MrLineId = strMrLineId; ReqD.FlagGeneratedPurPlan = "2"; list.Add(ReqD); } } if (list.Count <= 0) { MessageUtil.ShowTips("未选择需求计划行"); return; } if (MessageUtil.ShowYesNoAndQuestion("确定直接提报上述需求计划行?") != DialogResult.Yes) { return; } CoreResult rt = this.execute("com.hnshituo.pur.requireplan.service.RequirePlanDService", "doBack_batch", new object[] { list }); if (rt.Resultcode != 0) { MessageUtil.ShowTips("操作失败!" + rt.Resultmsg); return; } Core.Mes.Client.Comm.Tool.MessageUtil.ShowTips("操作成功!"); GetPUR_REQUIRE_PLAN(); comm.doActiveSelRow(ultraGrid1, "MrId", YY); 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); } #endregion #region 行编辑区控制 /// /// JIT选择事件 /// /// /// private void Ck_IsJIT_CheckedChanged(object sender, EventArgs e)// JIT选择事件 { //if (Ck_IsJIT.Checked) //{ // txt_deliveryLocation.Enabled = true; //} //else //{ // txt_deliveryLocation.Enabled = false; //} txt_deliveryLocation.Clear(); } //编辑区地址选择 private void txt_deliveryLocation_EditorButtonClick(object sender, EditorButtonEventArgs e) { String strd = Ck_IsJIT.Checked?"1":"0";//是否全部地址 String str2 =Ck_IsJIT.Checked? "1":"0";//是否为JIT地址 if (strCoustomInfo == "2") { strd = "0"; } FrmPop_upDeliveryLocation Dz = new FrmPop_upDeliveryLocation(this.ob, strd, str2); Dz.ShowDialog(); if (Dz.tips != "1") { return; } txt_deliveryLocation.Text = Dz.DeliveryLocation; deliveryLocationCode = Dz.DeliveryLocationCode; } #endregion #region 公共函数 /// /// 需求行数据校验 /// /// private bool testReqC()// 需求行数据校验 { //if (UserInfo.GetUserID() != "tianf") //{ // if (txt_tipsForBudget.Visible == true || Convert.ToDouble(txt_orgBudget.Value) <= 0) // { // MessageUtil.ShowTips("请选择头信息或者已超出预算,请确定,或请刷新页面再操作!"); // txt_orgBudget.Focus(); // return false; // } //} if (txt_tipsForBudget.Visible == true || Convert.ToDouble(txt_orgBudget.Value) <= 0) { MessageUtil.ShowTips("请选择头信息或者已超出预算,请确定,或请刷新页面再操作!"); txt_orgBudget.Focus(); return false; } if (txt_LastDeliveryDate.Text == "" || txt_tipsForDeliveryTime.Visible == true || Convert.ToDateTime(txt_LastDeliveryDate.Value) < DateTime.Now.AddDays(10)) { MessageUtil.ShowTips("请输入有效的到货时间,并保证交货周期10天以上!"); txt_LastDeliveryDate.Focus(); return false; } if (deliveryLocationCode == ""||txt_deliveryLocation.Text.Trim()=="") { MessageUtil.ShowTips("请选择若JIT物料请选择JIT交付地址,非JIT物料请选择非JIT交付地址(若无可用交付地址,请联系供应部维护)"); txt_deliveryLocation.Focus(); return false; } return true; } /// /// 控件清空tab2 /// /// /// private void clearkongjian()//tab2控件值清空 { txt_inStockQty.Text = ""; txt_tipsForDeliveryTime.Visible = false; txt_tipsForBudget.Visible = false; //txt_LastDeliveryDate.Value = DateTime.Now.AddMonths(1).ToString(); } /// /// 获取评审意见 /// /// private void getOrderReview(string strOrderId) { DataTable dt11 = this.execute("com.hnshituo.pur.order.service.OrderMService", "getReviewMsg", new object[] { strOrderId }); GridHelper.CopyDataToDatatable(dt11, dataTable7, true); GridHelper.RefreshAndAutoSize(ultraGrid3); } #endregion #region 公共方法 /// /// 剩余预算计算 /// private void getBudget(DateTime dt, string orgId)//计算剩余预算 { //计算预算 String strorgId = orgId; String stryear = dt.Year.ToString(); String strmouth = dt.Month.ToString(); CoreResult re = this.execute("com.hnshituo.pur.configure.service.ConfigureOrgBudgetService", "doQueryBudgetRemain", new object[] { strorgId, stryear, strmouth, "" }); if (re.Resultcode != 0) { txt_orgBudget.Value = null; return; } else { txt_orgBudget.Value = Convert.ToDouble(re.Resultmsg); } } /// /// 可用在途库存 /// /// private void getInStockQty(String strItemUnique)//可用在途库存 { if (String.IsNullOrEmpty(strItemUnique)) { txt_inStockQty.Value = null; return; } CoreResult re = this.execute("com.hnshituo.pur.ck.service.CkStorageService", "getInStockQty", new object[] { strItemUnique }); if (re.Resultcode != 0) { txt_inStockQty.Value = null; return; } else { txt_inStockQty.Value = Convert.ToDouble(re.Resultmsg); } } /// /// 验证是否有权力操作行 /// /// /// /// 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 (pd.FlagGeneratedPurPlan != "3") { 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; } if (pd.IsAllowReturn != "1") { 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 = pm.TenantId; 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 + "的审批流程流程:" + matclass1.TenantName + "和需求计划头的审批流程:" + pm.TenantName + "不一致,请确定!"); 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 if (tips == 6) { //头是否处于查看流程 if (strCoustomInfo == "1") { if (pm.Status != "2" && pm.Status != "3" && pm.Status != "4") { MessageUtil.ShowTips("请先提报需求计划【" + mrId + "】!"); return false; } } else { MessageUtil.ShowTips("无流程信息"); return false; } } else { MessageUtil.ShowTips("未知参数,无法验证头表有效性"); return false; } return true; } #endregion } }