using System; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using com.hnshituo.pur.vo; using Core.Mes.Client.Comm.Control; using Core.Mes.Client.Comm.Tool; using CoreFS.CA06; using Pur.Entity; using Pur.Entity.configureEntity; namespace Pur.Pop_upWindow { public partial class frmPopAddReceive : FrmPmsBase { public String tips = "0"; ArrayList list = new ArrayList();//待编制的需求行 public frmPopAddReceive() { InitializeComponent(); } public frmPopAddReceive(OpeBase OB, ArrayList list1) { InitializeComponent(); this.list = list1; this.ob = OB; this.Text = "选择采购计划----总【" + list1 .Count+ "】条待编制接收需求计划行"; } private void frmPopAddReceive_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); doQuery(); } private void ultraToolbarsManager1_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e) { switch (e.Tool.Key) { case "doQuery": // 刷新 doQuery(); break; case "doSure": // 添加 doSure(); break; case "doClose": // 关闭 this.Close(); break; } } private void doSure() { if (ultraGrid1.ActiveRow == null) { MessageUtil.ShowTips("请选择采购计划"); return; } String strMrId = ultraGrid1.ActiveRow.Cells["MRID"].Value.ToString(); if (String.IsNullOrEmpty(strMrId)) { MessageUtil.ShowTips("请选择采购计划号为空"); return; } EntityPurPlanM M_PurPlanM = new EntityPurPlanM(); M_PurPlanM = this.execute("com.hnshituo.pur.purplan.service.PurPlanMService", "findById", new object[] { strMrId }); if (M_PurPlanM== null) { MessageUtil.ShowTips("未发现采购计划:" + strMrId+" 信息记录"); return; } if (M_PurPlanM.CreateUserid != UserInfo.GetUserID()) { MessageUtil.ShowTips("非本人创建采购计划"); return; } if (M_PurPlanM.Status != "1" && M_PurPlanM.Status != "4") { MessageUtil.ShowTips("采购计划不在待提报和审批不通过状态无法添加行"); return; } if (this.list.Count <= 0) { MessageUtil.ShowTips("未发现可添加接收需求计划行"); return; } EntityPurPlanM PurPlanM = new EntityPurPlanM(); PurPlanM.MrId = strMrId; PurPlanM.CreateUserid = UserInfo.GetUserID(); PurPlanM.CreateTime = DateTime.Now; PurPlanM.CreateName = UserInfo.GetUserName(); if (MessageUtil.ShowYesNoAndQuestion("确定添加需求计划到采购计划:" + strMrId + " ?") == DialogResult.No) { return; } CoreResult rt = this.execute("com.hnshituo.pur.purplan.service.PurPlanMService", "addRow", new object[] { PurPlanM, this.list }); if (rt.Resultcode != 0) { MessageUtil.ShowTips("操作失败:" + rt.Resultmsg); this.tips = "0"; return; } else { MessageUtil.ShowTips("操作成功"); this.tips = "1"; this.Close(); return; } } private void doQuery() { dataTable1.Clear(); EntityPurPlanM entity = new EntityPurPlanM(); if (ultraTextEditor5.Text.Trim() != "") { entity.MrId = ultraTextEditor5.Text.ToString().Trim(); } entity.DeleteName = "add"; if (ck_Mtime.Checked == true) { if (cop_planMouthStart.Text != "") { DateTime Start1 = DateTime.Parse(Convert.ToDateTime(cop_planMouthStart.Value).ToString("yyyy/MM")); entity.MrPeriodStart = Start1; } if (cop_planMouthEnd.Text != "") { DateTime End1 = DateTime.Parse(Convert.ToDateTime(cop_planMouthEnd.Value).ToString("yyyy/MM")); entity.MrPeriodEnd = End1; } } //entity.DeleteName = "1";//判断是否需要查待编的,1不显示,0显示 entity.Validflag = "1"; entity.ValidDataPurviewIds = this.ValidDataPurviewIds; entity.OperatorUserId = UserInfo.GetUserID(); entity.BpmUserId = UserInfo.GetUserID(); //判断当前拥有此页面功能的角色是否启用数据权限,//0未启用 string QstrDataFlag = this.execute("com.hnshituo.pur.utils.service.UtilsService", "getRoleDataFlag", new object[] { UserInfo.GetUserID(), "Pur.pur_plan.FrmPur_Plan" }); if (QstrDataFlag == "0")//0未启用 { entity.CreateUserid = this.UserInfo.GetUserID(); } DataTable dt = this.execute("com.hnshituo.pur.purplan.service.PurPlanMService", "getPurPlanM", new object[] { entity }); foreach (DataRow row in dt.Rows) { row["mrPeriodEnd"] = Convert.ToDateTime(row["mrPeriodEnd"]).ToString("yyyy/MM"); } //按创建时间降序 if (dt.Rows.Count > 0) { dt.DefaultView.Sort = "CREATETIME DESC"; dt = dt.DefaultView.ToTable(); } GridHelper.CopyDataToDatatable(ref dt, ref dataTable1, true); } private void ck_Mtime_CheckedChanged(object sender, EventArgs e) { cop_planMouthStart.Enabled = ck_Mtime.Checked; cop_planMouthEnd.Enabled = ck_Mtime.Checked; } } }