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 Pur.Entity.configureEntity; using CoreFS.CA06;using Pur.Entity; using Core.Mes.Client.Comm.Tool; using Core.Mes.Client.Comm.Control; using Infragistics.Win.UltraWinGrid; using System.Collections; using Pur.require_plan; using Pur.Pop_upWindow; using Infragistics.Win; using com.hnshituo.pur.vo; using com.hnshituo.bpm.req.vo; using Bpm; using Infragistics.Win.UltraWinEditors; using System.Text.RegularExpressions; namespace Pur.pur_plan { public partial class frmPurPlanExamine : FrmPmsBase { public frmPurPlanExamine() { InitializeComponent(); this.IsLoadUserView = true; //ultraGrid1.DisplayLayout.Bands[0].Override.AllowUpdate = DefaultableBoolean.False; GridHelper.SetExcludeColumnsActive(ultraGrid1.DisplayLayout.Bands[0],new string[]{"CHK"}); ultraGrid2.DisplayLayout.Bands[0].Override.AllowUpdate = DefaultableBoolean.False; //ultraGrid2.DisplayLayout.Bands[1].Override.AllowUpdate = DefaultableBoolean.False; } //菜单按钮事件 public override void ToolBar_Click(object sender, string ToolbarKey) { switch (ToolbarKey) { case "Query": get_PUR_PLAN_M(getEnSelContion()); break; case "Examine": Examine(); break; case "show_Information": Process(); break; } } /// /// 查询采购计划主表 /// /// public void get_PUR_PLAN_M(EntityPurPlanM PurPlanMEntity) { dataTable1.Clear(); dataTable3.Clear(); dataTable2.Rows.Clear();//清空采购计划行 //查询未审批的 DataTable dt = new DataTable(); if (txt_Status.SelectedIndex == 1) { //PurPlanMEntity.Status = "12"; dt = this.execute("com.hnshituo.pur.purplan.service.PurPlanMService", "find_audit_status", new object[] { PurPlanMEntity }); } else if (txt_Status.SelectedIndex == 2) { //查询审批记录 //PurPlanMEntity.Status = "34"; dt = this.execute("com.hnshituo.pur.purplan.service.PurPlanMService", "find_audited_status", new object[] { PurPlanMEntity }); } else { //查询全部相关 dt = this.execute("com.hnshituo.pur.purplan.service.PurPlanMService", "getPurPlanM", new object[] { PurPlanMEntity }); } foreach (DataRow row in dt.Rows) { row["mrPeriodEnd"] = Convert.ToDateTime(row["mrPeriodEnd"]).ToString("yyyy/MM"); } GridHelper.CopyDataToDatatable(dt, dataTable1, true); ultraGrid1.DisplayLayout.Bands[0].PerformAutoResizeColumns(true, PerformAutoSizeType.AllRowsInBand); } /// /// 查询采购计划详表 /// /// public void get_PUR_PLAN_D(EntityPurPlanD PurPlanDEntity) { DataTable dt = this.execute("com.hnshituo.pur.purplan.service.PurPlanDService", "getPlanD", new object[] { PurPlanDEntity, 0, 0 }); GridHelper.CopyDataToDatatable(ref dt, ref dataTable2, true);//绑定采购计划行表 //DataTable dt_require = this.execute("com.hnshituo.pur.requireplan.service.RequirePlanDService", "getRequireByPlanD_ids", new object[] { ultraGrid1.ActiveRow.Cells["MRID"].Value.ToString() }); ////删除父表中没有的行 //for (int i = 0; i < dt_require.Rows.Count; ) //{ // if (!dataTable2.Rows.Contains(new object[] { dt_require.Rows[i]["BUYERDEPTCODE"].ToString(), dt_require.Rows[i]["ITEMUNIQUE"].ToString() })) // { // dt_require.Rows.RemoveAt(i); // } // else { i++; } //} //GridHelper.CopyDataToDatatable(ref dt_require, ref dataTable3, true);//绑定采购计划行子表 ultraGrid2.DisplayLayout.Bands[0].PerformAutoResizeColumns(true, PerformAutoSizeType.AllRowsInBand); } /// /// 激活采购计划主表行(未审批) /// /// /// private void ultraGrid1_AfterRowActivate(object sender, EventArgs e) { //dataTable3.Rows.Clear(); dataTable2.Clear(); message.Clear(); EntityPurPlanD PurPlanDEntity = new EntityPurPlanD(); if (ultraGrid1.ActiveRow == null) { return; } String strMrid = ultraGrid1.ActiveRow.Cells["MRID"].Value.ToString().Trim(); PurPlanDEntity.MrId = strMrid; if (strMrid == null || strMrid == "") { return; } PurPlanDEntity.Validflag = "1"; get_PUR_PLAN_D(PurPlanDEntity);//查询采购计划详表 //加载采购计划评审意见 getOrderReview(strMrid); } /// /// 获取查询条件 /// /// private EntityPurPlanM getEnSelContion() { EntityPurPlanM entity = new EntityPurPlanM(); if (txt_MrId.Text.Trim() != "")//采购计划主表 { entity.MrId = txt_MrId.Text.ToString().Trim(); } if (txt_Urgency.Value != null && txt_Urgency.Value.ToString() !="")//紧急程度 { entity.UrgencyType = txt_Urgency.Value.ToString().Trim(); } //if (txt_status.Value != null && txt_status.Value.ToString() != "")//状态 //{ //entity.Status = txt_status.Value.ToString(); //} //if (txt_MrPeriodEnd.Value != null && txt_MrPeriodEnd.Value.ToString() != "")//计划月份 //{ //entity.MrPeriodEnd = DateTime.Parse(txt_MrPeriodEnd.Value.ToString()); //} if (ck_Mtime.Checked) { if (String.IsNullOrEmpty(cop_planMouthStart.Text)) { DateTime Start1 = DateTime.Parse(Convert.ToDateTime(cop_planMouthStart.Value).ToString("yyyy/MM")); entity.MrPeriodStart = Start1; } if (String.IsNullOrEmpty(cop_planMouthEnd.Text)) { DateTime End1 = DateTime.Parse(Convert.ToDateTime(cop_planMouthEnd.Value).ToString("yyyy/MM")); entity.MrPeriodEnd = End1; } } entity.Validflag = "1"; entity.BpmUserId = UserInfo.GetUserID(); entity.ValidDataPurviewIds = this.ValidDataPurviewIds; return entity; } /// /// 审批 /// private void Examine() { ultraGrid1.UpdateData(); ArrayList list = new ArrayList(); foreach (UltraGridRow row in ultraGrid1.Rows) { if (Convert.ToBoolean(row.GetCellValue("CHK")) == true) { EntityPurPlanM pm = new EntityPurPlanM(); pm.MrId = row.GetCellValue("MRID").ToString().Trim(); pm.ReqOrgId = row.GetCellValue("BpmTaskId").ToString().Trim(); pm.DeleteUserid = UserInfo.GetUserID();//审批人ID list.Add(pm); } } if (list.Count <= 0) { MessageUtil.ShowTips("请选择需要审批的计划!"); return; } UltraGridRow uge = ultraGrid1.ActiveRow; // ArrayList al = setUserPlan(); frmExamineShowNew frm = new frmExamineShowNew(list,this.ob,"pur"); frm.ShowDialog(); if(frm.tips=="1") { get_PUR_PLAN_M(getEnSelContion()); } } /// /// 生成领用计划 /// private ArrayList setUserPlan() { ArrayList al = new ArrayList(); //查询采购单下相同科室提报的核准数量 DataTable dt_require = this.execute("com.hnshituo.pur.requireplan.service.RequirePlanDService", "getRequireByPlanD_ids_UserPlan", new object[] { ultraGrid1.ActiveRow.Cells["MRID"].Value.ToString() }); for (int i = 0; i < ultraGrid2.Rows.Count; i++) { for (int j = 0; j < dt_require.Rows.Count; j++) { if (ultraGrid2.Rows[i].Cells["MRLINEID"].Value.ToString() == dt_require.Rows[j]["BUYERDEPTCODE"].ToString()) { PurUserPlanEntity pup = new PurUserPlanEntity(); EntityPurPlanD ppd = new EntityPurPlanD(); ppd = this.execute("com.hnshituo.pur.purplan.service.PurPlanDService", "findById", new object[] { ultraGrid2.Rows[i].Cells["MRLINEID"].Value.ToString() }); pup = EntityHelper.CopyEntity(ppd); double b_QtyPur = 0; double.TryParse(dt_require.Rows[j]["QtyPur"].ToString(),out b_QtyPur); pup.QtyPur = b_QtyPur; pup.UsedQty = 0; pup.PurLineId = ppd.MrLineId; pup.ReqOrgId = dt_require.Rows[j]["DELETENAME"].ToString(); al.Add(pup); } } } return al; } /// /// 流程详情查看 /// 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_PLAN_AUDIT, mrId); detail.ShowDialog(); } private void frmPurPlanExamine_Load(object sender, EventArgs e) { DataTable dt1 = new DataTable(); dt1.Columns.AddRange(new DataColumn[] { new DataColumn("Code"), new DataColumn("Desc") }); dt1.Rows.Add("", "全部"); dt1.Rows.Add("1", "紧急"); dt1.Rows.Add("2", "常规"); txt_Urgency.DataSource = dt1; txt_Urgency.DisplayMember = "Desc"; txt_Urgency.ValueMember = "Code"; SetComboItemHeight(txt_Urgency);//设置comboxEditer高度 txt_Urgency.SelectedIndex = 0; txt_Status.SelectedIndex = 1; 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); get_PUR_PLAN_M(getEnSelContion()); } /// /// 设置UltraComboEditor中的中文和非中文统一高度。 /// /// public static void SetComboItemHeight(UltraComboEditor cmb) { foreach (ValueListItem item in cmb.Items) { if (item.DisplayText != null) { if (Regex.IsMatch(item.DisplayText, @"[\u4e00-\u9fa5]+")) { item.Appearance.FontData.SizeInPoints = 9.0F; } else { item.Appearance.FontData.SizeInPoints = 10.5F; } } } } private void frmPurPlanExamine_Shown(object sender, EventArgs e) { this.ToolBarItemEnable(this, "Query", true); this.ToolBarItemEnable(this, "Examine", true); this.ToolBarItemEnable(this, "show_Information", true); } private void txt_Status_ValueChanged(object sender, EventArgs e) { //ultraGrid1.UpdateData(); get_PUR_PLAN_M(getEnSelContion()); foreach (UltraGridRow row in ultraGrid1.Rows) { row.Cells["CHK"].Value = false; } if (txt_Status.SelectedIndex == 1)//待审批 { ultraGrid1.DisplayLayout.Bands[0].Columns["CHK"].Hidden = false; } else { ultraGrid1.DisplayLayout.Bands[0].Columns["CHK"].Hidden = true; } } 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 getOrderReview(string strMrid) { DataTable dt11 = this.execute("com.hnshituo.pur.order.service.OrderMService", "getReviewMsg", new object[] { strMrid }); GridHelper.CopyDataToDatatable(dt11, dataTable7, true); GridHelper.RefreshAndAutoSize(ultraGrid3); } private void ck_Mtime_CheckedChanged(object sender, EventArgs e) { cop_planMouthStart.Enabled=ck_Mtime.Checked; cop_planMouthEnd.Enabled = ck_Mtime.Checked; } } }