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; using Core.Mes.Client.Comm.Control; using Pur.Entity.require_planEntiy; using Infragistics.Win.UltraWinGrid; using Core.Mes.Client.Comm.Tool; using Pur.Pop_upWindow; using com.hnshituo.bpm.req.vo; using com.hnshituo.pur.vo; using Infragistics.Win; using Bpm; namespace Pur.require_plan { public partial class FrmPurRequireApproval : FrmPmsBase { public FrmPurRequireApproval() { InitializeComponent(); this.IsLoadUserView = true; ultraGrid1.DisplayLayout.Bands[0].Override.AllowUpdate = DefaultableBoolean.False; ultraGrid2.DisplayLayout.Bands[0].Override.AllowUpdate = DefaultableBoolean.False; } private void FrmPurRequireApproval_Load(object sender, EventArgs e) { 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); txt_Status.SelectedIndex = 1;//审批中 ultraComboEditor2.SelectedIndex = 0; GetPUR_REQUIRE_PLAN(); GridHelper.SetExcludeColumnsActive(ultraGrid1.DisplayLayout.Bands[0],new string[]{ }); GridHelper.SetExcludeColumnsActive(ultraGrid2.DisplayLayout.Bands[0], new string[] { }); } //菜单按钮事件 public override void ToolBar_Click(object sender, string ToolbarKey) { switch (ToolbarKey) { case "Query": GetPUR_REQUIRE_PLAN(); break; case "Approval": AppPUR_REQUIRE_PLAN(); break; case "Process": ProPUR_REQUIRE_PLAN(); break; } } private void ProPUR_REQUIRE_PLAN() { 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(); } /// /// 审批 /// private void AppPUR_REQUIRE_PLAN() { UltraGridRow uge = ultraGrid1.ActiveRow; if (uge == null) { MessageUtil.ShowWarning("请选择待审批的需求计划!"); return; } String strMrId = uge.Cells["MrId"].Value.ToString(); if (String.IsNullOrEmpty(strMrId)) { MessageUtil.ShowWarning("选择的需求计划号为空!"); return; } RequirePlanM rpm = this.execute("com.hnshituo.pur.requireplan.service.RequirePlanMService", "findById", new object[] { strMrId }); if (rpm == null) { MessageUtil.ShowTips("未发现需求计划:" + strMrId+"信息记录!"); return; } if (rpm.Status!="2") { MessageUtil.ShowWarning("需求计划:" + strMrId + "尚未送审或已审批,请刷新后再操作!"); return; } frmExamineShow Fex = new frmExamineShow(); Fex.ShowDialog(); if (Fex.Status == null) { return; } //if (!Fex.Status.Equals("1")) //{ // MessageUtil.ShowTips("审批失败!"); // return; //} //if (!Fex.Status.Equals("2")) //{ // MessageUtil.ShowTips("审批失败!"); // return; //} try { //RequirePlanM RqPM = new RequirePlanM(); //RqPM.Status = "3"; //RqPM.MrId = uge.Cells["MrId"].Value.ToString(); //RqPM.UpdateName = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName(); //RqPM.UpdateTime = DateTime.Now; //RqPM.UpdateUserid = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserID(); //this.execute("com.hnshituo.pur.requireplan.service.RequirePlanMService", "update", new object[] { RqPM }); ReqCompleteTask req = new ReqCompleteTask(); req.OperatorUserId = UserInfo.GetUserID(); req.TaskId = uge.Cells["BpmTaskId"].Value.ToString(); if (Fex.Status.Equals("2")) { req.AuditData = true; req.AuditMessage = Fex.ExamineMessage; if (rpm.UrgencyType=="2"&&DateTime.Now > DateTime.Parse(DateTime.Now.ToString("yyyy/MM/26"))) { if (MessageUtil.ShowYesNoAndQuestion("已超出审批时限(每月25号截止),若审批通过则将默认归属于为" + DateTime.Now.AddMonths(2).ToString("yyyy/MM") + "的需求! 或请退回走紧急采购。") != DialogResult.Yes) { return; } CoreResult crt = this.execute("com.hnshituo.pur.requireplan.service.RequirePlanMService", "bpmAudit", new object[] { req }); if (crt.Resultcode == -1) { MessageUtil.ShowTips("需求计划:" + strMrId + "审批失败!" + crt.Resultmsg); return; } //更新计划月份 RequirePlanM ReqM = new RequirePlanM(); ReqM.MrId = strMrId; ReqM.MrPeriodEnd = DateTime.Parse(DateTime.Now.AddMonths(2).ToString("yyyy/MM")); ReqM.AuditedTime = DateTime.Now; CoreResult rt = this.execute("com.hnshituo.pur.requireplan.service.RequirePlanMService", "doUpdate", new object[] { ReqM }); } else { CoreResult crt = this.execute("com.hnshituo.pur.requireplan.service.RequirePlanMService", "bpmAudit", new object[] { req }); if (crt.Resultcode == -1) { MessageUtil.ShowTips("需求计划:" + strMrId + "审批失败!" + crt.Resultmsg); return; } } MessageUtil.ShowTips("操作成功"); GetPUR_REQUIRE_PLAN(); } else if (Fex.Status.Equals("1")) { req.AuditData = false; req.AuditMessage = Fex.ExamineMessage; CoreResult crt = this.execute("com.hnshituo.pur.requireplan.service.RequirePlanMService", "bpmAudit", new object[] { req }); if (crt.Resultcode == -1) { MessageUtil.ShowTips("需求计划:" + strMrId + "审批失败!" + crt.Resultmsg); return; } RequirePlanM ReqM = new RequirePlanM(); ReqM.MrId = strMrId; ReqM.Status = "4"; CoreResult rt = this.execute("com.hnshituo.pur.requireplan.service.RequirePlanMService", "doUpdate", new object[] { ReqM }); if (rt.Resultcode != 0) { MessageUtil.ShowTips("需求计划:" + strMrId + "审批失败!" + crt.Resultmsg); return; } MessageUtil.ShowTips("操作成功"); GetPUR_REQUIRE_PLAN(); } } catch (Exception e) { MessageUtil.ShowTips("需求计划:" + strMrId + "审批失败!" + e); } } /// /// 查询 /// private void GetPUR_REQUIRE_PLAN() { try { this.Cursor = Cursors.WaitCursor; message.Clear(); dataSet1.Clear(); dataSet2.Clear(); RequirePlanM RqPM = new RequirePlanM(); RqPM.MrId = ultraTextEditor1.Text.ToString().Trim(); if (ultraComboEditor2.SelectedIndex != -1) { RqPM.UrgencyType = ultraComboEditor2.Value.ToString(); } //计划时间 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; } } RqPM.Validflag = "1"; RqPM.BpmUserId = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserID(); RqPM.ValidDataPurviewIds = this.ValidDataPurviewIds; DataTable dt=new DataTable(); if (txt_Status.SelectedIndex == -1) { return; } if (txt_Status.Value.ToString().Trim() == "wait") { dt = this.execute("com.hnshituo.pur.requireplan.service.RequirePlanMService", "find_audit_status", new object[] { RqPM }); } else if (txt_Status.Value.ToString().Trim() == "did") { dt = this.execute("com.hnshituo.pur.requireplan.service.RequirePlanMService", "find_audited_status", new object[] { RqPM }); } else { 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); } catch (Exception ex) { MessageUtil.ShowTips("加载数据失败:"+ex.Message); } finally { this.Cursor = Cursors.Default; } } /// /// 未审批点击事件 /// /// /// private void ultraGrid1_AfterRowActivate(object sender, EventArgs e) { dataTable2.Clear(); message.Clear(); if (ultraGrid1.ActiveRow == null) { return; } String strMrId=ultraGrid1.ActiveRow.Cells["mrId"].Value.ToString(); getdetail(strMrId); //加载评审意见 getOrderReview(strMrId); } private void getdetail(String strMrId) { if (String.IsNullOrEmpty(strMrId)) { return; } RequirePlanM RqPM = new RequirePlanM(); RqPM.MrId = strMrId; RqPM.Validflag = "1"; DataTable dt1 = this.execute("com.hnshituo.pur.requireplan.service.RequirePlanDService", "get_RequirePlanDlike", new object[] { RqPM }); GridHelper.CopyDataToDatatable(dt1, dataTable2, true); GridHelper.RefreshAndAutoSize(ultraGrid2); } private void txt_Status_ValueChanged(object sender, EventArgs e) { GetPUR_REQUIRE_PLAN(); } /// /// 获取评审意见 /// /// 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); } private void ultraGrid1_InitializeRow(object sender, InitializeRowEventArgs e) { } } }