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 Infragistics.Win.UltraWinGrid; using System.Collections; using CoreFS.CA06;using Pur.Entity; using Core.Mes.Client.Comm.Control; using Pur.Entity.ck; using com.hnshituo.pur.vo; using Core.Mes.Client.Comm.Tool; using Pur.configure; using Infragistics.Win; using Core.Mes.Client.Comm.Server; using Pur.Entity.pur_orderEntiy; using Pur.require_plan; using Pur.Entity.configureEntity; using Pur.Pop_upWindow; using Pur.PublicTools; using Pur.order; using Core.Mes.Client.Comm.Format; namespace Pur.ck { public partial class PurExcDeliveryNoticeManagement : FrmPmsBase { string strDataFlag = "0"; public string basecode_pop = "";//物料大类编码 public ArrayList listMatCode = new ArrayList(); public ArrayList listMatName = new ArrayList(); public ArrayList listOrderCol = new ArrayList();//选择的合同行 public ArrayList listorder = new ArrayList();//权限控制 public String suppCodeSel = "";//选择的供应商 public String suppNameSel = "";//选择的供应商 public PurExcDeliveryNoticeManagement() { InitializeComponent(); this.IsLoadUserView = true; } /// /// 界面加载 /// /// /// private void PurExcDeliveryNoticeManagement_Load(object sender, EventArgs e)// 界面加载 { //合同tab ck_isAllReq.Checked = false; Get_DropDownList();//加载下拉框 txt_selectlocation.Visible = false; ultraGrid3.DisplayLayout.Bands[1].Columns["deliveryLocation"].EditorComponent = txt_selectlocation; //通知单tab ultraTabControl1.SelectedTab = ultraTabControl1.Tabs[0]; ck_ctime.Checked = true; Ck_Etime.Checked = false; txt_createTime.Value = DateTime.Now.AddMonths(-1); txt_endTime.Value = DateTime.Now.AddDays(2); txt_CreateTimeS.Value = DateTime.Now.AddMonths(-1); txt_CreateTimeE.Value = DateTime.Now.AddDays(2); txt_PlanedShipDateE.Value = DateTime.Now.AddDays(1); txt_PlanedShipDateS.Value = DateTime.Now.AddMonths(-1); txt_PlanedShipDateE.Enabled = false; txt_PlanedShipDateS.Enabled = false; txt_Allocation_rule.SelectedIndex = 1;//交期优先 //grid可编辑设置 //ultraGrid1.DisplayLayout.Bands[0].Override.AllowUpdate = DefaultableBoolean.False; ultraGrid2.DisplayLayout.Bands[0].Override.AllowUpdate = DefaultableBoolean.False; ultraGrid2.DisplayLayout.Bands[1].Override.AllowUpdate = DefaultableBoolean.False; GridHelper.SetExcludeColumnsActive(ultraGrid4.DisplayLayout.Bands[0], new string[] { "CHK" }); GridHelper.SetExcludeColumnsActive(ultraGrid5.DisplayLayout.Bands[0], new string[] { "CHK" }); GridHelper.SetExcludeColumnsActive(ultraGrid3.DisplayLayout.Bands[0], new string[] { "CHK", "deleteuserid" }); GridHelper.SetExcludeColumnsActive(ultraGrid3.DisplayLayout.Bands[1], new string[] { "CHK", "createQty", "deliveryLocation"}); GridHelper.SetExcludeColumnsActive(ultraGrid1.DisplayLayout.Bands[0], new string[] { "CHK" }); //接收方式 DataTable dt5 = ServerHelper.GetData("com.hnshituo.pur.configure.service.impl.CoreBaseInfoNew.doQuery", new Object[] { "1101" }, this.ob); this.ultraGrid3.DisplayLayout.ValueLists.Add("checkList1"); foreach (DataRow row in dt5.Rows) { if (row["validflag"].ToString().Trim() == "1") { this.ultraGrid3.DisplayLayout.ValueLists["checkList1"].ValueListItems.Add(row["baseCode"], row["baseName"].ToString()); } } this.ultraGrid3.DisplayLayout.ValueLists["checkList1"].DisplayStyle = ValueListDisplayStyle.DisplayText; this.ultraGrid3.DisplayLayout.Bands[0].Columns["deleteuserid"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList; this.ultraGrid3.DisplayLayout.Bands[0].Columns["deleteuserid"].ValueList = this.ultraGrid3.DisplayLayout.ValueLists["checkList1"]; ultraExpandableGroupBox1.Expanded = false; EntityHelper.ShowGridCaption(ultraGrid6.DisplayLayout.Bands[0]); //加载数据权限控制参数 // strDataFlag = this.execute("com.hnshituo.pur.utils.service.UtilsService", "getRoleDataFlag", new object[] { UserInfo.GetUserID(), "Pur.ck.PurExcDeliveryNoticeManagement" }); // ultraGrid5.Visible = false; //加载数据 //Get_PurexcdeliverynoticeM(0); } /// /// toolbar初始化 /// /// /// private void PurExcDeliveryNoticeManagement_Shown(object sender, EventArgs e)// toolbar初始化 { //if (toolMenu.Toolbars[0].Tools.Exists("doQuery")) { toolMenu.Toolbars[0].Tools["doQuery"].InstanceProps.Visible = DefaultableBoolean.True; } //if (toolMenu.Toolbars[0].Tools.Exists("doCreate")) { toolMenu.Toolbars[0].Tools["doCreate"].InstanceProps.Visible = DefaultableBoolean.False; } //if (toolMenu.Toolbars[0].Tools.Exists("cancelCreate")) { toolMenu.Toolbars[0].Tools["cancelCreate"].InstanceProps.Visible = DefaultableBoolean.True; } //if (toolMenu.Toolbars[0].Tools.Exists("doExcel")) { toolMenu.Toolbars[0].Tools["doExcel"].InstanceProps.Visible = DefaultableBoolean.True; } //if (toolMenu.Toolbars[0].Tools.Exists("doExit")) { toolMenu.Toolbars[0].Tools["doExit"].InstanceProps.Visible = DefaultableBoolean.True; } this.ToolBarItemEnable(this, "doQuery", true); this.ToolBarItemEnable(this, "doCreate", true); this.ToolBarItemEnable(this, "doCreateForce", true); this.ToolBarItemEnable(this, "cancelCreate", false); this.ToolBarItemEnable(this, "doCreateSub", false); this.ToolBarItemEnable(this, "doIssue", false); this.ToolBarItemEnable(this, "doUnIssue", false); this.ToolBarItemEnable(this, "doUpdate", false); this.ToolBarItemEnable(this, "doExit", true); } #region toolbar工具栏 /// /// 菜单栏 /// /// /// public override void ToolBar_Click(object sender, string ToolbarKey) { switch (ToolbarKey) { case "doQuery": //刷新 Get_PurexcdeliverynoticeM(0);//点击查询 break; case "doCreate": // 编制通知单 Add_PurexcdeliverynoticeM("0"); break; case "doCreateForce": // 编制通知单 Add_PurexcdeliverynoticeM("1"); break; case "doCreateSub": // 编制送货单 Add_PurexcdeliverySubM(); break; case "cancelCreate": // 撤销 Del_PurexcdeliverynoticeM(); break; case "doIssue": // 下发 doIssue(); break; case "doUnIssue": // 取消下发 doUnIssue(); break; case "doUpdate": // 修改 doUpdate(); break; case "doExcel": // 导出Excel doExcel(); break; case "doExit": // 退出 this.Close(); break; } } private void doUpdate() { PreTrackNoticeEntity preTrackNoticeEntity = new PreTrackNoticeEntity(); UltraGridRow row = this.ultraGrid6.ActiveRow; ArrayList array = new ArrayList(); preTrackNoticeEntity.IndexCode = row.Cells["indexCode"].Text.Trim(); preTrackNoticeEntity.NoticeNo = row.Cells["noticeNo"].Text.Trim(); preTrackNoticeEntity.ContractNo = row.Cells["contractNo"].Text.Trim(); preTrackNoticeEntity.IndexMatterName = row.Cells["IndexMatterName"].Text.Trim(); string json = JSONFormat.Format(preTrackNoticeEntity); array.Add(json); CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.hnshituo.pur.configure.service.impl.PreTrackNoticeService"; ccp.MethodName = "updateIndexName"; ccp.ServerParams = new object[] { array }; ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { MessageUtil.ShowTips("修改成功!"); Get_PurexcdeliverynoticeM(0); } else { throw new Exception("服务端处理失败!"); } } private void doUnIssue() { PreTrackNoticeEntity preTrackNoticeEntity = new PreTrackNoticeEntity(); UltraGridRow row = this.ultraGrid6.ActiveRow; ArrayList array = new ArrayList(); preTrackNoticeEntity.IndexCode = row.Cells["indexCode"].Text.Trim(); preTrackNoticeEntity.NoticeNo = row.Cells["noticeNo"].Text.Trim(); preTrackNoticeEntity.ContractNo = row.Cells["contractNo"].Text.Trim(); preTrackNoticeEntity.UpdateManNo = "cx"; preTrackNoticeEntity.UpdateManName = UserInfo.GetUserName() + "取消下发"; string json = JSONFormat.Format(preTrackNoticeEntity); array.Add(json); CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.hnshituo.pur.configure.service.impl.PreTrackNoticeService"; ccp.MethodName = "delete"; ccp.ServerParams = new object[] { array }; ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { MessageUtil.ShowTips("取消下发成功!"); Get_PurexcdeliverynoticeM(0); } else { throw new Exception("服务端处理失败!"); } } private void doIssue() { PreTrackNoticeEntity preTrackNoticeEntity = new PreTrackNoticeEntity(); UltraGridRow row = this.ultraGrid1.ActiveRow; RowsCollection rows = ultraGrid2.Rows; ArrayList array = new ArrayList(); foreach (var item in rows) { preTrackNoticeEntity.IndexCode = item.Cells["noticeLineSqe"].Text.Trim(); preTrackNoticeEntity.MatterNo = item.Cells["itemCode"].Text.Trim(); preTrackNoticeEntity.MatterName = item.Cells["itemName"].Text.Trim(); preTrackNoticeEntity.ContractNo = item.Cells["orderLineSqe"].Text.Trim(); preTrackNoticeEntity.CustomerSupplierNo = row.Cells["suppCode"].Text.Trim(); preTrackNoticeEntity.CustomerSupplierName = row.Cells["suppName"].Text.Trim(); //preTrackNoticeEntity.ReceivingUintName = ""; //preTrackNoticeEntity.ReceivingUintNo = ""; preTrackNoticeEntity.MeterTypeNo = "001006001"; preTrackNoticeEntity.MeterTypeName = "采购进厂"; preTrackNoticeEntity.LoadPointName = row.Cells["deliveryLocation"].Text.Trim(); preTrackNoticeEntity.LoadPointNo = row.Cells["deliveryLocationCode"].Text.Trim(); preTrackNoticeEntity.ValueFlag = "0"; preTrackNoticeEntity.CreateManNo = "cx"; preTrackNoticeEntity.CreateManName = UserInfo.GetUserName(); string json = JSONFormat.Format(preTrackNoticeEntity); List data = EntityHelper.GetData( "com.hnshituo.pur.configure.service.impl.PreTrackNoticeService.query", new Object[] { json }, ob); if (data.Count > 0) { MessageUtil.ShowTips(item.Cells["orderLineSqe"].Text.Trim() + "已下发!"); return; } array.Add(json); } CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.hnshituo.pur.configure.service.impl.PreTrackNoticeService"; ccp.MethodName = "insert"; ccp.ServerParams = new object[] { array }; ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { MessageUtil.ShowTips("下发成功!"); } else { throw new Exception("服务端处理失败!"); } } private List UltraGridGetCHKRows(UltraGrid grid, string columnName = "CHK") { grid.UpdateData(); List list = new List(); RowsCollection rows = grid.Rows; foreach (var item in rows) { try { if (Convert.ToBoolean(item.Cells[columnName].Value) == true && item.Hidden == false && item.IsFilteredOut == false) { list.Add(item); } } catch { } } return list; } /// /// 编制送货单 /// private void Add_PurexcdeliverySubM()// 编制送货单 { try { List arr = UltraGridGetCHKRows(ultraGrid1); if (arr.Count <= 0) { MessageUtil.ShowTips("请选择通知单行!"); return; } foreach (UltraGridRow ugr in arr) { String strNoticeId = ugr.Cells["NoticeId"].Value.ToString().Trim(); if (String.IsNullOrEmpty(strNoticeId)) { MessageUtil.ShowTips("选择的通知单行号:"+ strNoticeId + "为空!"); return; } if (testNoticeStatus(strNoticeId, 2) == false) { continue; } ExcCreateDeliveryM frm = new ExcCreateDeliveryM(this.ob, strNoticeId); frm.ShowDialog(); if (frm.Tips == 1) { Get_PurexcdeliverynoticeM(0); } } } catch (Exception e) { MessageUtil.ShowTips("操作失败:" + e); return; } } /// /// 删除 /// private void Del_PurexcdeliverynoticeM()//撤销 { try { UltraGridRow uge = ultraGrid1.ActiveRow; if (uge == null) { MessageUtil.ShowTips("请选择通知单行!"); return; } String strNoticeId = uge.Cells["NoticeId"].Value.ToString().Trim(); if (String.IsNullOrEmpty(strNoticeId)) { MessageUtil.ShowTips("选择的通知单行号为空!"); return; } ExcDeliveryNoticeM EdnM = new ExcDeliveryNoticeM(); if (testNoticeStatus(strNoticeId,1) == false) { return; } EdnM.NoticeId = strNoticeId; EdnM.Validflag = "0"; EdnM.Status = "9"; EdnM.DeleteName = UserInfo.GetUserName(); EdnM.DeleteUserid = UserInfo.GetUserID(); EdnM.DeleteTime = DateTime.Now; if (MessageUtil.ShowYesNoAndQuestion("确定撤销发货通知单:" + EdnM.NoticeId + "?") != DialogResult.Yes) { return; } CoreResult crt = this.execute("com.hnshituo.pur.ck.service.ExcDeliveryNoticeMService", "del_NoticeM", new object[] { EdnM }); if (crt.Resultcode != 0) { MessageUtil.ShowTips("操作失败:" + crt.Resultmsg); return; } MessageUtil.ShowTips("操作成功!"); Get_PurexcdeliverynoticeM(0); } catch (Exception e) { MessageUtil.ShowTips("操作失败:" + e); return; } } /// /// 导出发货通知单头 /// private void doExcel() { try { if (ultraTabControl1.SelectedTab.Key.Equals("0")) { this.Cursor = Cursors.WaitCursor; ArrayList alUltraGrid = new ArrayList(); alUltraGrid.Add(ultraGrid1); alUltraGrid.Add(ultraGrid2); ultraGrid2.DisplayLayout.Bands[1].Hidden = true; ArrayList alSheeft = new ArrayList(); alSheeft.Add("发货通知单头表"); alSheeft.Add("发货通知单行表"); if (ultraGrid1.Rows.Count > 0) { GridHelper.ulGridToExcel(alUltraGrid, alSheeft, "发货通知单");//导出excel } } else { this.Cursor = Cursors.WaitCursor; ArrayList alUltraGrid = new ArrayList(); alUltraGrid.Add(ultraGrid3); ArrayList alSheeft = new ArrayList(); alSheeft.Add("合同需求关系"); if (ultraGrid1.Rows.Count > 0) { GridHelper.ulGridToExcel(alUltraGrid, alSheeft, "合同需求关系");//导出excel } } } catch (Exception e) { MessageUtil.ShowTips("导出失败" + e.Message); } finally { ultraGrid2.DisplayLayout.Bands[1].Hidden = false; this.Cursor = Cursors.Default; } }//导出发货通知单头 /// /// 编制发货通知 /// private void Add_PurexcdeliverynoticeM(string flag)//编制 { try { this.Cursor = Cursors.WaitCursor; if (listOrderCol.Count<=0) { MessageUtil.ShowTips("请勾选合同!"); return; } String strOrderId = publicPms.ArrayListToString(listOrderCol); String strSuppCode = suppCodeSel; String strSuppName = suppNameSel; if (String.IsNullOrEmpty(strOrderId)) { MessageUtil.ShowTips("合同号为空!"); return; } if (testOrderStatus(listOrderCol) == false) { return; } if (testInPut() == false) { return; } ultraGrid3.UpdateData(); //新合同编制通知单 if (listOrderCol[0].ToString().StartsWith("HT")) { //验证是否编制有效数量 int j = 0; //foreach (UltraGridRow uge in ultraGrid1.Rows.GetRowEnumerator(GridRowType.DataRow, null, null)) foreach (UltraGridRow uge in ultraGrid3.Rows) { if (!uge.HasParent() && Convert.ToBoolean(uge.Cells["CHK"].Value) == true && Convert.ToDouble(uge.Cells["createQty"].Value) > 0) { if (Convert.ToDouble(uge.Cells["canUseQty"].Value) < Convert.ToDouble(uge.Cells["createQty"].Value)) { MessageUtil.ShowTips("物料:" + uge.GetCellValue("itemName") + "编制量不能大于可编制通知量!"); return; } j = j + 1; int i = 0; foreach (UltraGridRow ugc in uge.ChildBands[0].Rows) { if (ugc.GetCellValue("Id").ToString().Trim() == "") { MessageUtil.ShowTips("物料:" + uge.GetCellValue("itemName") + "下的第:" + ugc.Index + "个接收需求行主键为空!"); return; } if (ugc.GetCellValue("mrLineId").ToString().Trim() == "") { MessageUtil.ShowTips("物料:" + uge.GetCellValue("itemName") + "下的第:" + ugc.Index + "个接收需求行号为空!"); return; } if (ugc.HasParent() && Convert.ToBoolean(ugc.Cells["CHK"].Value) == true && Convert.ToDouble(ugc.Cells["createQty"].Value) > 0) { if (Convert.ToDouble(ugc.Cells["canUseQty"].Value) < Convert.ToDouble(ugc.Cells["createQty"].Value)) { MessageUtil.ShowTips("物料:" + uge.GetCellValue("itemName") + "下的接收需求行:" + ugc.GetCellValue("mrLineId") + "编制量不能大于可编制通知量!"); return; } if (ugc.GetCellValue("deliveryLocationCode").ToString().Trim() == "") { MessageUtil.ShowTips("物料:" + uge.GetCellValue("itemName") + "下的接收需求行:" + ugc.GetCellValue("mrLineId") + "需选择交货地址!"); return; } i = i + 1; } } if (i == 0) { MessageUtil.ShowTips("物料:" + uge.GetCellValue("itemName") + "编制的需求条数为0或者未编制有效数量"); return; } } } if (j == 0) { MessageUtil.ShowTips("合同行编制条数为0或者合同行未编制有效数量"); return; } //准备数据并提交 //按照list<需求行>和没有Id和地址的通知单头信息提交 List listR = new List(); foreach (UltraGridRow uge in ultraGrid3.Rows) { if (!uge.HasParent() && Convert.ToBoolean(uge.Cells["CHK"].Value) == true && Convert.ToDouble(uge.Cells["createQty"].Value) > 0) { String strOrderLineId = uge.GetCellValue("OrderLineSqe").ToString(); foreach (UltraGridRow ugc in uge.ChildBands[0].Rows) { if (ugc.HasParent() && Convert.ToBoolean(ugc.Cells["CHK"].Value) == true && Convert.ToDouble(ugc.Cells["createQty"].Value) > 0) { RequireReceive Rr = new RequireReceive(); Rr.Id = ugc.GetCellValue("Id").ToString().Trim(); Rr.Qty = Convert.ToDouble(ugc.GetCellValue("createQty"));//记录生成数量 Rr.DeliveryLocationCode = ugc.GetCellValue("deliveryLocationCode").ToString().Trim(); Rr.Purtype = uge.GetCellValue("deleteuserid").ToString().Trim(); DeliveryLocationDz cRt = this.execute("com.hnshituo.pur.configure.service.DeliveryLocationService", "findById", new object[] { Rr.DeliveryLocationCode }); if (cRt == null) { MessageUtil.ShowTips("未发现地址:" + Rr.DeliveryLocationCode + "信息,或请重新选择地址"); return; } if (cRt.IsJit == "1" ) { if (Rr.Purtype != "110107") { MessageUtil.ShowTips("物料:" + uge.GetCellValue("itemName") + "选择的为JIT交付地址,请选择JIT的接收方式"); return; } } if (cRt.IsJit == "0") { if (Rr.Purtype== "110107") { MessageUtil.ShowTips("物料:" + uge.GetCellValue("itemName") + "选择的为非JIT交付地址,请选择非JIT的接收方式"); return; } } Rr.Remark = strOrderLineId;//记录所属合同行号 listR.Add(Rr); } } } } ExcDeliveryNoticeM nm = new ExcDeliveryNoticeM(); nm.CreateName = UserInfo.GetUserName(); nm.CreateUserid = UserInfo.GetUserID(); nm.CreateTime = DateTime.Now; nm.SuppCode = strSuppCode; nm.SuppName = strSuppName; nm.OrderId = strOrderId; nm.Status = "1"; nm.Remark = txt_remark.Text.ToString().Trim(); nm.PlanedDeliveryDate = Convert.ToDateTime(txt_MRPERIODEND.Value);//交期-止 nm.PlanedShipDate = Convert.ToDateTime(txt_MRPERIODSTART.Value);//交期-起 nm.DeliveryCondition = txt_deliveryCondition.Value == null ? "" : txt_deliveryCondition.Value.ToString(); nm.DeliveryType = txt_deliveryType.Value == null ? "" : txt_deliveryType.Value.ToString(); nm.Validflag = "1"; nm.BuyerDeptCode = UserInfo.GetDeptid(); if (MessageUtil.ShowYesNoAndQuestion("确定生成发货通知单?") != DialogResult.Yes) { return; } CoreResult crt = this.execute("com.hnshituo.pur.ck.service.ExcDeliveryNoticeRpRService", "doInsert_Notice", new object[] { nm, listR, flag }); if (crt.Resultcode != 0) { MessageUtil.ShowTips("生成失败" + crt.Resultmsg); return; } MessageUtil.ShowTips(crt.Resultmsg); Get_PurexcdeliverynoticeM(0); publicPms.doActiveSelRow(ultraGrid4, "orderId", strOrderId); } else { //验证是否编制有效数量 int j = 0; foreach (UltraGridRow uge in ultraGrid3.Rows) { if (!uge.HasParent() && Convert.ToBoolean(uge.Cells["CHK"].Value) == true && Convert.ToDouble(uge.Cells["createQty"].Value) > 0) { if (Convert.ToDouble(uge.Cells["canUseQty"].Value) < Convert.ToDouble(uge.Cells["createQty"].Value)) { MessageUtil.ShowTips("合同物料:" + uge.GetCellValue("itemName") + "编制量不能大于可编制通知量!"); return; } j = j + 1; int i = 0; foreach (UltraGridRow ugc in uge.ChildBands[0].Rows) { if (ugc.HasParent() && Convert.ToBoolean(ugc.Cells["CHK"].Value) == true && Convert.ToDouble(ugc.Cells["createQty"].Value) > 0) { if (ugc.GetCellValue("deliveryLocationCode").ToString().Trim() == "") { MessageUtil.ShowTips("合同物料:" + uge.GetCellValue("itemName") + "请选择交付地址"); return; } if (ugc.GetCellValue("DELETEUSERID").ToString().Trim() == "") { MessageUtil.ShowTips("合同物料:" + uge.GetCellValue("itemName") + "请选择需求单位"); return; } i = i + 1; } } if (i == 0) { MessageUtil.ShowTips("合同物料:" + uge.GetCellValue("itemName") + "编制的需求条数为0或者未编制有效数量"); return; } } } if (j == 0) { MessageUtil.ShowTips("合同行编制条数为0或者合同行未编制有效数量"); return; } //准备数据并提交 //按照list<需求行>和没有Id和地址的通知单头信息提交 List listR = new List(); foreach (UltraGridRow uge in ultraGrid3.Rows) { if (!uge.HasParent() && Convert.ToBoolean(uge.Cells["CHK"].Value) == true && Convert.ToDouble(uge.Cells["createQty"].Value) > 0) { String strOrderLineId = uge.GetCellValue("OrderLineSqe").ToString(); foreach (UltraGridRow ugc in uge.ChildBands[0].Rows) { if (ugc.HasParent() && Convert.ToBoolean(ugc.Cells["CHK"].Value) == true && Convert.ToDouble(ugc.Cells["createQty"].Value) > 0) { RequireReceive Rr = new RequireReceive(); Rr.Qty = Convert.ToDouble(ugc.GetCellValue("createQty"));//记录生成 Rr.DeliveryLocationCode = ugc.GetCellValue("deliveryLocationCode").ToString().Trim(); Rr.DeliveryLocation = ugc.GetCellValue("deliveryLocation").ToString().Trim(); Rr.Remark = strOrderLineId;//记录所属合同行号 Rr.ItemAttr = ugc.GetCellValue("DELETEUSERID").ToString().Trim();//需求单位 Rr.Purtype = uge.GetCellValue("deleteuserid").ToString().Trim(); DeliveryLocationDz cRt = this.execute("com.hnshituo.pur.configure.service.DeliveryLocationService", "findById", new object[] { Rr.DeliveryLocationCode }); if (cRt == null) { MessageUtil.ShowTips("物料:" + uge.GetCellValue("itemName") + "未发现地址:" + Rr.DeliveryLocation + "信息,或请重新选择地址"); return; } if (cRt.IsJit == "1") { if (Rr.Purtype != "110107") { MessageUtil.ShowTips("物料:" + uge.GetCellValue("itemName") + "选择的为JIT交付地址,请选择JIT的接收方式"); return; } } if (cRt.IsJit == "0") { if (Rr.Purtype == "110107") { MessageUtil.ShowTips("物料:" + uge.GetCellValue("itemName") + "选择的为非JIT交付地址,请选择非JIT的接收方式"); return; } } listR.Add(Rr); } } } } ExcDeliveryNoticeM nm = new ExcDeliveryNoticeM(); nm.CreateName = UserInfo.GetUserName(); nm.CreateUserid = UserInfo.GetUserID(); nm.CreateTime = DateTime.Now; nm.SuppCode = strSuppCode; nm.SuppName = strSuppName; nm.OrderId = strOrderId; nm.Status = "1"; nm.Remark = txt_remark.Text.ToString().Trim(); nm.PlanedDeliveryDate = Convert.ToDateTime(txt_MRPERIODEND.Value);//交期-止 nm.PlanedShipDate = Convert.ToDateTime(txt_MRPERIODSTART.Value);//交期-起 nm.DeliveryCondition = txt_deliveryCondition.Value == null ? "" : txt_deliveryCondition.Value.ToString(); nm.DeliveryType = txt_deliveryType.Value == null ? "" : txt_deliveryType.Value.ToString(); nm.Validflag = "1"; nm.BuyerDeptCode = UserInfo.GetDeptid(); if (MessageUtil.ShowYesNoAndQuestion("确定生成发货通知单?") != DialogResult.Yes) { return; } CoreResult crt = this.execute("com.hnshituo.pur.ck.service.ExcDeliveryNoticeRpRService", "doInsert_Notice_OldOrder", new object[] { nm, listR, flag }); if (crt.Resultcode != 0) { MessageUtil.ShowTips("生成失败" + crt.Resultmsg); return; } MessageUtil.ShowTips(crt.Resultmsg); Get_PurexcdeliverynoticeM(0); publicPms.doActiveSelRow(ultraGrid4, "orderId", strOrderId); } } catch (Exception e) { Core.Mes.Client.Comm.Tool.MessageUtil.ShowTips("生成失败" + e); } finally { this.Cursor = Cursors.Default; } } /// /// 刷新 /// private void Get_PurexcdeliverynoticeM(int p)//查询通知单和待生成合同 { try { this.Cursor = Cursors.WaitCursor; clearInput(); //加载通知单 ExcDeliveryNoticeM EdnM = new ExcDeliveryNoticeM(); EdnM.OrderId = txt_OrderId.Text.ToString().Trim(); EdnM.NoticeId = txt_NoticeId.Text.ToString().Trim(); if (ck_ctime.Checked) { if (txt_CreateTimeS.Text != "") { EdnM.CreateTime = Convert.ToDateTime(txt_CreateTimeS.Value); } if (txt_CreateTimeE.Text != "") { EdnM.DeleteTime = Convert.ToDateTime(txt_CreateTimeE.Value); } } if (Ck_Etime.Checked) { if (txt_PlanedShipDateS.Text != "") { EdnM.PlanedShipDate = Convert.ToDateTime(txt_PlanedShipDateS.Value); } if (txt_PlanedShipDateE.Text != "") { EdnM.PlanedDeliveryDate = Convert.ToDateTime(txt_PlanedShipDateE.Value); } } //初始化和撤销时加载 //if (p == 0) //{ // dataSet3.Clear(); // //加载供应商dropdown // OrderM Odm = new OrderM(); // Odm.DeleteName = "0";//待编制的 // Odm.Validflag = "1"; // Odm.ValidDataPurviewIds = this.ValidDataPurviewIds;//角色的数据权限 // DataTable dt1 = this.execute("com.hnshituo.pur.order.service.OrderMService", "find_canUseOrderM", new object[] { Odm, 0, 0 }); // if (dt1 != null) // { // if (dt1.Rows.Count >= 1) // { // DataView dv = new DataView(dt1); // DataTable dt_supp = dv.ToTable(true, new string[] { "suppName", "suppCode" }); // publicPms.FilComboboxAdd(COP_SuppName, dt_supp, "suppCode", "suppName", "", true, "全部", ""); // COP_SuppName.SelectedIndex = 0; // } // } // listorder.Clear(); // foreach (DataRow row in dt1.Rows) // { // listorder.Add(row["orderId"]); // } // if (listorder.Count > 0) // { // //加载合同物料dropdown // OrderC odC = new OrderC(); // odC.DeleteName = "0";//待编制合同行 // odC.Validflag = "1"; // odC.OrderIdCol = (String[])listorder.ToArray(typeof(string));//权限控制 // DataTable dt2 = this.execute("com.hnshituo.pur.order.service.OrderCService", "doQueryOrderC", new object[] { odC }); // if (dt2 != null) // { // if (dt2.Rows.Count >= 1) // { // DataView dv1 = new DataView(dt2); // DataTable dt_item = dv1.ToTable(true, new string[] { "itemCode", "itemName" }); // GridHelper.CopyDataToDatatable(dt_item, dataTable7, true); // } // } // } //} if (ultraTabControl1.ActiveTab.Key == "1") { dataSet2.Clear(); String strSuppCode = COP_SuppName.Value == null ? "" : COP_SuppName.Value.ToString().Trim(); OrderM Odm1 = new OrderM(); Odm1.OrderId = COP_OrderId.Text.Trim(); Odm1.SuppName = txt_suppName_1.Text.Trim(); //Odm1.SuppCode = strSuppCode; Odm1.DeleteName = "0"; Odm1.Validflag = "1"; Odm1.ValidDataPurviewIds = this.ValidDataPurviewIds; //Odm1.ItemCodeCol = (String[])listMatCode.ToArray(typeof(string)); Odm1.UpdateUserid = txt_itemName_1.Text.Trim(); Odm1.StartDate = Convert.ToDateTime(txt_createTime.Value); Odm1.EndDate = Convert.ToDateTime(txt_endTime.Value); DataTable dt11 = this.execute("com.hnshituo.pur.order.service.OrderMService", "find_canUseOrderM", new object[] { Odm1, 0, 0 }); GridHelper.CopyDataToDatatable(dt11, dataTable6, true); GridHelper.RefreshAndAutoSize(ultraGrid4); } else if (ultraTabControl1.ActiveTab.Key == "0") { dataSet1.Clear(); EdnM.ValidDataPurviewIds = this.ValidDataPurviewIds; EdnM.UpdateUserid = txt_ItemCode.Text.Trim(); EdnM.SuppName = basecode_pop;//物料类别 EdnM.UpdateName = txt_itemName2.Text.Trim(); DataTable dt = this.execute("com.hnshituo.pur.ck.service.ExcDeliveryNoticeMService", "find_Exc", new object[] { EdnM }); GridHelper.CopyDataToDatatable(dt, dataTable1, true); GridHelper.RefreshAndAutoSize(ultraGrid1); } else if (ultraTabControl1.ActiveTab.Key == "2") { PreTrackNoticeEntity preTrackNoticeEntity = new PreTrackNoticeEntity(); preTrackNoticeEntity.MatterName = ultraTextEditor1.Text.Trim(); preTrackNoticeEntity.ContractNo = ultraTextEditor6.Text.Trim(); preTrackNoticeEntity.CustomerSupplierName = ultraTextEditor2.Text.Trim(); string json = JSONFormat.Format(preTrackNoticeEntity); string startTime = txt_startTime_n.Value.ToString("yyyy-MM-dd"); string endTime = txt_endTime_n.Value.ToString("yyyy-MM-dd"); List data = EntityHelper.GetData( "com.hnshituo.pur.configure.service.impl.PreTrackNoticeService.query", new Object[] { json, startTime, endTime }, ob); preTrackNoticeEntityBindingSource.DataSource = data; } } catch (Exception ex) { MessageUtil.ShowTips("加载数据异常:" + ex.Message); } finally { this.Cursor = Cursors.Default; } } #endregion #region 界面事件 /// /// 激活通知单头 /// /// /// private void ultraGrid1_ClickCell(object sender, ClickCellEventArgs e) { getDetail(); } /// /// 获取查询合同集合 /// /// /// private void ultraGrid4_CellChange(object sender, CellEventArgs e) { try { if (e.Cell.Column.Key == "CHK") { clearInput(); dataTable5.Clear(); dataTable4.Clear(); listOrderCol.Clear(); suppCodeSel = ""; suppNameSel = ""; ultraGrid4.UpdateData(); int i = 0; foreach (UltraGridRow row in ultraGrid4.Rows) { if (Convert.ToBoolean(row.GetCellValue("CHK")) == true) { String strSuppCode = row.Cells["suppCode"].Value.ToString(); String strSuppName = row.Cells["suppName"].Value.ToString(); String strOrderId = row.Cells["orderId"].Value.ToString(); if (!String.IsNullOrEmpty(strSuppCode)) { if (i == 0) { suppCodeSel = strSuppCode; suppNameSel=strSuppName; } else { if (suppCodeSel != strSuppCode) { MessageUtil.ShowTips("请选择相同供应商的合同编制发货通知单!"); e.Cell.Row.Cells["CHK"].Value = !Convert.ToBoolean(e.Cell.Row.GetCellValue("CHK")); return; } } //判断是否为同类合同 if (i != 0) { if (strOrderId.StartsWith("HT") != listOrderCol[0].ToString().StartsWith("HT")) { MessageUtil.ShowTips("新旧合同不能混合编制通知单! 备注:HT开头的合同编号为新合同"); return; } } listOrderCol.Add(strOrderId); i = i + 1; } } } if (this.ultraGrid4.Rows.AsQueryable() .Where(q => Convert.ToBoolean(q.GetCellValue("CHK")) == true && q.GetCellValue("OrderType").Equals("废钢采购(供应部)")) .GroupBy(a => a.GetCellValue("OrderId")) .Count() > 1) { MessageUtil.ShowTips("废钢值允许单个合同进行编制!"); e.Cell.Row.Cells["CHK"].Value = !Convert.ToBoolean(e.Cell.Row.GetCellValue("CHK")); return; } txt_supp.Text = suppNameSel + "(" + suppCodeSel + ")"; if (listOrderCol.Count > 0) { getOrderCAndCD(true); OrderM orderM = this.execute("com.hnshituo.pur.order.service.OrderMService", "findById", new object[] { listOrderCol[0]}); txt_deliveryCondition.Value = orderM.DeliveryCondition; txt_deliveryType.Value = orderM.DeliveryType; } } } catch (Exception ex) { MessageUtil.ShowTips("查询送货单行信息失败:" + ex.Message); } } /// /// 物料大类弹窗 /// /// /// private void Basename_pop_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)//物料大类弹窗 { FrmMatClassPop_ups PopMat = new FrmMatClassPop_ups(this.ob); PopMat.ShowDialog(); if (PopMat.Basecode == null) return; Basename_pop.Text = PopMat.Basename; basecode_pop = PopMat.Basecode; } /// /// 物料编码弹窗 /// /// /// private void txt_ItemName_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)// 物料编码 { ultraPopupControlContainer1.Show(ultraGroupBox7.PointToScreen(new Point(txt_itemName.Location.X, txt_itemName.Location.Y + 20))); //if (ultraGrid5.Visible == false) //{ // ultraGrid5.Visible = true; //} //else //{ // ultraGrid5.Visible = false; //} } /// /// 供应商弹窗 /// /// /// private void COP_SuppName_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)// 供应商弹窗 { Supp Sp = new Supp(); Sp.Validflag = "1"; //DataTable dt = this.execute("com.hnshituo.pur.configure.service.SuppService", "find", new object[] { Sp, 0, 0 }); frmSuppSel Sky = new frmSuppSel(this.ob); Sky.ShowDialog(); if (Sky.strSUPP_CODE == null) return; COP_SuppName.Text = Sky.strSUPP_NAME.ToString().Trim(); } /// /// 通知单创建时间控制 /// /// /// private void ck_ctime_CheckedChanged(object sender, EventArgs e)// 通知单创建时间控制 { txt_CreateTimeS.Enabled = ck_ctime.Checked; txt_CreateTimeE.Enabled = ck_ctime.Checked; } /// /// 通知单发货时间控制 /// /// /// private void Ck_Etime_CheckedChanged(object sender, EventArgs e)// 通知单发货时间控制 { txt_PlanedShipDateE.Enabled = Ck_Etime.Checked; txt_PlanedShipDateS.Enabled = Ck_Etime.Checked; } /// /// 控制交货行输入 /// /// /// private void ultraGrid3_CellChange(object sender, CellEventArgs e)//控制合同行和需求行编制行为 { if(e.Cell.Row.HasParent()) { //新合同 if (listOrderCol[0].ToString().StartsWith("HT")) { if (e.Cell.Column.Key == "CHK" && e.Cell.Row.HasParent()) { ultraGrid3.UpdateData(); double sumCreateQty = 0; foreach (UltraGridRow row in e.Cell.Row.ParentRow.ChildBands[0].Rows) { if (Convert.ToBoolean(row.Cells["CHK"].Value) == true) { sumCreateQty = sumCreateQty + Convert.ToDouble(row.Cells["createQty"].Value); } } double maxCanUseQty_order = Convert.ToDouble(e.Cell.Row.ParentRow.Cells["canUseQty"].Value); if (maxCanUseQty_order < sumCreateQty) { MessageUtil.ShowTips("已超过该合同物料的最大可编制通知量!"); e.Cell.Value = false; } else { e.Cell.Row.ParentRow.Cells["createQty"].Value = sumCreateQty; } } else if (e.Cell.Column.Key == "createQty") { double oldQty = Convert.ToDouble(e.Cell.Value); ultraGrid3.UpdateData(); double newQty = Convert.ToDouble(e.Cell.Value); double maxCanUseQty_Req = Convert.ToDouble(e.Cell.Row.Cells["canUseQty"].Value); if (newQty > maxCanUseQty_Req) { MessageUtil.ShowTips("已超过该送货地址的最大可编制通知量!"); e.Cell.Value = oldQty; return; } double sumCreateQty = 0; foreach (UltraGridRow row in e.Cell.Row.ParentRow.ChildBands[0].Rows) { if (Convert.ToBoolean(row.Cells["CHK"].Value) == true) { sumCreateQty = sumCreateQty + Convert.ToDouble(row.Cells["createQty"].Value); } } double maxCanUseQty_order = Convert.ToDouble(e.Cell.Row.ParentRow.Cells["canUseQty"].Value); if (maxCanUseQty_order < sumCreateQty) { MessageUtil.ShowTips("已超过合同可编制通知量!"); e.Cell.Value = oldQty; } else { e.Cell.Row.ParentRow.Cells["createQty"].Value = sumCreateQty; } } } //旧合同 else { if (e.Cell.Column.Key == "CHK" && e.Cell.Row.HasParent()) { ultraGrid3.UpdateData(); double sumCreateQty = 0; foreach (UltraGridRow row in e.Cell.Row.ParentRow.ChildBands[0].Rows) { if (Convert.ToBoolean(row.Cells["CHK"].Value) == true) { sumCreateQty = sumCreateQty + Convert.ToDouble(row.Cells["createQty"].Value == DBNull.Value ? 0 : row.Cells["createQty"].Value); } } double maxCanUseQty_order = Convert.ToDouble(e.Cell.Row.ParentRow.Cells["canUseQty"].Value); if (maxCanUseQty_order < sumCreateQty) { MessageUtil.ShowTips("已超过该合同物料的最大可编制通知量!"); e.Cell.Value = false; } else { e.Cell.Row.ParentRow.Cells["createQty"].Value = sumCreateQty; } } else if (e.Cell.Column.Key == "createQty") { double oldQty = Convert.ToDouble(e.Cell.Value == DBNull.Value ? 0 : e.Cell.Value); ultraGrid3.UpdateData(); double sumCreateQty = 0; foreach (UltraGridRow row in e.Cell.Row.ParentRow.ChildBands[0].Rows) { if (Convert.ToBoolean(row.Cells["CHK"].Value) == true) { sumCreateQty = sumCreateQty + Convert.ToDouble(row.Cells["createQty"].Value == DBNull.Value ? 0 : row.Cells["createQty"].Value); } } double maxCanUseQty_order = Convert.ToDouble(e.Cell.Row.ParentRow.Cells["canUseQty"].Value); if (maxCanUseQty_order < sumCreateQty) { MessageUtil.ShowTips("已超过合同可编制通知量!"); e.Cell.Value = oldQty; } else { e.Cell.Row.ParentRow.Cells["createQty"].Value = sumCreateQty; } } } } e.Cell.Row.Activated = true; } /// /// 合同行刷选 /// /// /// private void btn_orderSelect_Click(object sender, EventArgs e)// 合同行刷选 { getOrderCAndCD(false); } /// /// tab控制toolbar /// /// /// private void ultraTabControl1_SelectedTabChanged(object sender, Infragistics.Win.UltraWinTabControl.SelectedTabChangedEventArgs e)// tab控制toolbar { if (toolMenu == null) return; if (e.Tab.TabControl.SelectedTab.Key.Equals("0")) { //if (toolMenu.Toolbars[0].Tools.Exists("doQuery")) { toolMenu.Toolbars[0].Tools["doQuery"].InstanceProps.Visible = DefaultableBoolean.True; } //if (toolMenu.Toolbars[0].Tools.Exists("doCreate")) { toolMenu.Toolbars[0].Tools["doCreate"].InstanceProps.Visible = DefaultableBoolean.False; } //if (toolMenu.Toolbars[0].Tools.Exists("cancelCreate")) { toolMenu.Toolbars[0].Tools["cancelCreate"].InstanceProps.Visible = DefaultableBoolean.True; } //if (toolMenu.Toolbars[0].Tools.Exists("doExcel")) { toolMenu.Toolbars[0].Tools["doExcel"].InstanceProps.Visible = DefaultableBoolean.True; } //if (toolMenu.Toolbars[0].Tools.Exists("doExit")) { toolMenu.Toolbars[0].Tools["doExit"].InstanceProps.Visible = DefaultableBoolean.True; } this.ToolBarItemEnable(this, "doQuery", true); this.ToolBarItemEnable(this, "doCreate", false); this.ToolBarItemEnable(this, "doCreateForce", false); this.ToolBarItemEnable(this, "cancelCreate", true); this.ToolBarItemEnable(this, "doCreateSub", true); this.ToolBarItemEnable(this, "doIssue", true); this.ToolBarItemEnable(this, "doUnIssue", false); this.ToolBarItemEnable(this, "doUpdate", false); this.ToolBarItemEnable(this, "doExcel", true); this.ToolBarItemEnable(this, "doExit", true); } else if (e.Tab.TabControl.SelectedTab.Key.Equals("1")) { //if (toolMenu.Toolbars[0].Tools.Exists("doQuery")) { toolMenu.Toolbars[0].Tools["doQuery"].InstanceProps.Visible = DefaultableBoolean.True; } //if (toolMenu.Toolbars[0].Tools.Exists("doCreate")) { toolMenu.Toolbars[0].Tools["doCreate"].InstanceProps.Visible = DefaultableBoolean.True; } //if (toolMenu.Toolbars[0].Tools.Exists("cancelCreate")) { toolMenu.Toolbars[0].Tools["cancelCreate"].InstanceProps.Visible = DefaultableBoolean.False; } //if (toolMenu.Toolbars[0].Tools.Exists("doExcel")) { toolMenu.Toolbars[0].Tools["doExcel"].InstanceProps.Visible = DefaultableBoolean.False; } //if (toolMenu.Toolbars[0].Tools.Exists("doExit")) { toolMenu.Toolbars[0].Tools["doExit"].InstanceProps.Visible = DefaultableBoolean.True; } this.ToolBarItemEnable(this, "doQuery", true); this.ToolBarItemEnable(this, "doCreate", true); this.ToolBarItemEnable(this, "doCreateForce", true); this.ToolBarItemEnable(this, "cancelCreate", false); this.ToolBarItemEnable(this, "doCreateSub", false); this.ToolBarItemEnable(this, "doIssue", false); this.ToolBarItemEnable(this, "doUnIssue", false); this.ToolBarItemEnable(this, "doUpdate", false); this.ToolBarItemEnable(this, "doExcel", true); this.ToolBarItemEnable(this, "doExit", true); } else if (e.Tab.TabControl.SelectedTab.Key.Equals("2")) { this.ToolBarItemEnable(this, "doQuery", true); this.ToolBarItemEnable(this, "doCreate", false); this.ToolBarItemEnable(this, "doCreateForce", false); this.ToolBarItemEnable(this, "cancelCreate", false); this.ToolBarItemEnable(this, "doCreateSub", false); this.ToolBarItemEnable(this, "doIssue", false); this.ToolBarItemEnable(this, "doUnIssue", true); this.ToolBarItemEnable(this, "doUpdate", true); this.ToolBarItemEnable(this, "doExcel", false); this.ToolBarItemEnable(this, "doExit", true); } } /// /// 交付地址选择 /// /// /// private void txt_selectlocation_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e) { ultraGrid3.UpdateData(); UltraGridRow row = ultraGrid3.ActiveRow.ParentRow; UltraGridRow row1 = ultraGrid3.ActiveRow; String strReceiveType = row.GetCellValue("deleteuserid").ToString().Trim(); String isJit = strReceiveType == "110107" ? "1" : "0"; FrmPop_upDeliveryLocation frm = new FrmPop_upDeliveryLocation(this.ob, "0", isJit); frm.ShowDialog(); if (frm.tips == "1") { if (!String.IsNullOrEmpty(frm.DeliveryLocationCode) && !String.IsNullOrEmpty(frm.DeliveryLocation)) { row1.Cells["deliveryLocationCode"].Value = frm.DeliveryLocationCode; row1.Cells["deliveryLocation"].Value = frm.DeliveryLocation; } } } /// /// 需求部门选择 /// /// /// private void txt_selectDept_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e) { frmdepartment frm = new frmdepartment(this.ob); // frm.StartPosition = FormStartPosition.Manual; // frm.Location = publicPms.getShowLocation(frm); frm.ShowDialog(); String strdeptId = frm.BuyerUnitCode; String strDeptName = frm.Fulltext; if (!String.IsNullOrEmpty(strdeptId) && !String.IsNullOrEmpty(strDeptName)) { if (ultraGrid3.ActiveRow == null) { return; } else { UltraGridRow row = ultraGrid3.ActiveRow; row.Cells["DELETEUSERID"].Value = strdeptId; row.Cells["DELETENAME"].Value = strDeptName; } } } /// /// 选择物料 /// /// /// private void ultraGrid5_CellChange(object sender, CellEventArgs e) { if (e.Cell.Column.Key == "CHK") { refreshSelectMat(); } } /// /// 头事件 /// /// /// private void ultraGrid5_AfterHeaderCheckStateChanged(object sender, AfterHeaderCheckStateChangedEventArgs e) { if (e.Column.Key == "CHK") { refreshSelectMat(); } } /// /// 批量添加部门 /// /// /// private void req_dept_batch_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e) { frmdepartment frm = new frmdepartment(this.ob); //frm.StartPosition = FormStartPosition.Manual; //frm.Location = publicPms.getShowLocation(frm); frm.ShowDialog(); String strdeptId = frm.BuyerUnitCode; String strDeptName = frm.Fulltext; if (!String.IsNullOrEmpty(strdeptId) && !String.IsNullOrEmpty(strDeptName)) { req_dept_batch.Text = strDeptName; txt_dept_batch_id.Text = strdeptId; } } //批量添加地址 private void req_Location_batch_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e) { FrmPop_upDeliveryLocation frm = new FrmPop_upDeliveryLocation(this.ob, "0",""); frm.ShowDialog(); if (frm.tips == "1") { if (!String.IsNullOrEmpty(frm.DeliveryLocationCode) && !String.IsNullOrEmpty(frm.DeliveryLocation)) { req_Location_batch.Text= frm.DeliveryLocation; txt_locaton_batch_id.Text = frm.DeliveryLocationCode; } } } //添加部门和地址按钮 private void btn_dept_locaton_add_Click(object sender, EventArgs e) { String dept_batch=req_dept_batch.Text.Trim(); String locaton_batch=req_Location_batch.Text.Trim(); String dept_id_batch=txt_dept_batch_id.Text.Trim(); String location_id_batch=txt_locaton_batch_id.Text.Trim(); if (String.IsNullOrEmpty(locaton_batch) ||String.IsNullOrEmpty(location_id_batch)) { MessageUtil.ShowTips("交付地址编码和名称都不能为空"); return; } //旧合同 if (!listOrderCol[0].ToString().StartsWith("HT")) { if (String.IsNullOrEmpty(dept_batch)||String.IsNullOrEmpty(dept_id_batch)) { MessageUtil.ShowTips("需求部门编码和名称都不能为空"); return; } } ultraGrid3.UpdateData(); foreach (UltraGridRow row in ultraGrid3.Rows) { String orderLineSqe = row.GetCellValue("OrderLineSqe").ToString().Trim(); if (!row.HasParent() && Convert.ToBoolean(row.Cells["CHK"].Value) == true) { foreach (UltraGridRow ugc in row.ChildBands[0].Rows) { if (ugc.HasParent() && Convert.ToBoolean(ugc.Cells["CHK"].Value) == true) { //旧合同 if (!listOrderCol[0].ToString().StartsWith("HT")) { if (!String.IsNullOrEmpty(ugc.Cells["DELETEUSERID"].Value.ToString())) { if (MessageUtil.ShowYesNoAndQuestion("合同行:" + orderLineSqe + "第" + ugc.Index+1 + "个需求记录已存在需求单位是否覆盖?") != DialogResult.Yes) { ; } else { ugc.Cells["DELETEUSERID"].Value = dept_id_batch; ugc.Cells["DELETENAME"].Value = dept_batch; } } //旧合同+新合同 else { ugc.Cells["DELETEUSERID"].Value = dept_id_batch; ugc.Cells["DELETENAME"].Value = dept_batch; } } if (!String.IsNullOrEmpty(ugc.Cells["deliveryLocationCode"].Value.ToString())) { if (MessageUtil.ShowYesNoAndQuestion("合同行:" + orderLineSqe + " 下第" + ugc.Index+1 + "个需求记录已存在交付地址是否覆盖?") != DialogResult.Yes) { ; } else { ugc.Cells["deliveryLocationCode"].Value = location_id_batch; ugc.Cells["deliveryLocation"].Value = locaton_batch; } } else { ugc.Cells["deliveryLocationCode"].Value = location_id_batch; ugc.Cells["deliveryLocation"].Value = locaton_batch; } } } } } } #endregion #region 公共函数 /// /// 测试通知单状态 /// /// /// private bool testNoticeStatus(string strNoticeId,int p) { if (String.IsNullOrEmpty(strNoticeId)) { MessageUtil.ShowTips("通知单号为空!"); return false; } ExcDeliveryNoticeM noticeM = this.execute("com.hnshituo.pur.ck.service.ExcDeliveryNoticeMService", "findById", new object[] { strNoticeId }); if (noticeM == null) { MessageUtil.ShowTips("未发现通知单:" + strNoticeId + "信息记录!"); return false; } if (noticeM.Validflag != "1") { MessageUtil.ShowTips("通知单:" + strNoticeId + "信息记录可能已作废,或请刷新界面重新操作!"); return false; } if (p == 1) { if (noticeM.Status != "1") { MessageUtil.ShowTips("非“待送货”状态,无法删除!"); return false; } ExcDeliveryNoticeC noticeC = new ExcDeliveryNoticeC(); noticeC.NoticeId = strNoticeId; noticeC.Validflag = "1"; List listc = this.execute>("com.hnshituo.pur.ck.service.ExcDeliveryNoticeCService", "find", new object[] { noticeC, 0, 0 }); foreach (ExcDeliveryNoticeC nc in listc) { if (nc.Status != "1") { MessageUtil.ShowTips("通知单行:" + nc.NoticeLineSqe + "非“待编制”状态,无法删除!"); return false; } if (nc.CreatedQty != null) { if (nc.CreatedQty > 0) { MessageUtil.ShowTips("通知单行:" + nc.NoticeLineSqe + "已编制送货单,无法删除!"); return false; } } } } else if (p == 2) { if (noticeM.Status != "1" && noticeM.Status != "2") { MessageUtil.ShowTips("通知单:" + strNoticeId + "已编制完成!"); return false; } } else { MessageUtil.ShowTips("未知参数!"); return false; } return true; } //验证合同 private bool testOrderStatus(ArrayList listOrder) { foreach (String strOrderId in listOrder) { if (String.IsNullOrEmpty(strOrderId)) { MessageUtil.ShowTips("合同编号为空!"); return false; } OrderM Omg = this.execute("com.hnshituo.pur.order.service.OrderMService", "findById", new object[] { strOrderId }); if (Omg == null) { MessageUtil.ShowTips("未发现合同【" + strOrderId + "】的信息记录,可能已作废,或请刷新界面重新操作!"); return false; } //if (Omg.CreateUserid != UserInfo.GetUserID()) //{ // MessageUtil.ShowWarning("非提报该合同本人,无权限进行操作,或请刷新后再操作!"); // return false; //} if (Omg.Validflag != "1") { MessageUtil.ShowWarning("合同【" + strOrderId + "】可能已作废,或请刷新界面重新操作!"); return false; } } return true; } //请空通知单头编辑数据 private void clearInput() { txt_supp.Clear(); txt_MRPERIODEND.Value = DateTime.Now; txt_MRPERIODSTART.Value = DateTime.Now; txt_remark.Clear(); } //验证编制通知单数据的有效性 private bool testInPut() { //验证头信息 if (String.IsNullOrEmpty(txt_supp.Text)) { MessageUtil.ShowTips("供应商不能为空!"); txt_supp.Focus(); return false; } if (String.IsNullOrEmpty(suppNameSel)) { MessageUtil.ShowTips("供应商不能为空!"); txt_supp.Focus(); return false; } if (String.IsNullOrEmpty(suppCodeSel)) { MessageUtil.ShowTips("供应商不能为空!"); txt_supp.Focus(); return false; } //验证交期 if (String.IsNullOrEmpty(txt_MRPERIODEND.Text)) { MessageUtil.ShowTips("通知单要求交期-止不能为空!"); txt_MRPERIODEND.Focus(); return false; } if (String.IsNullOrEmpty(txt_MRPERIODSTART.Text)) { MessageUtil.ShowTips("通知单要求交期-起不能为空!"); txt_MRPERIODSTART.Focus(); return false; } if (Convert.ToDateTime(txt_MRPERIODEND.Value) <= Convert.ToDateTime(txt_MRPERIODSTART.Value)) { MessageUtil.ShowTips("要求交期-止不能小于要求交期-起!"); txt_MRPERIODSTART.Focus(); return false; } if (Convert.ToDateTime(txt_MRPERIODEND.Value) <= DateTime.Now) { MessageUtil.ShowTips("要求交期-止不能小于当前时间!"); txt_MRPERIODEND.Focus(); return false; } return true; } /// /// 加载合同类别 /// private void Get_DropDownList()//加载合同类别 { //DataTable dt1 = ServerHelper.GetData("com.hnshituo.pur.configure.service.impl.CoreBaseInfoNew.doQuery", new Object[] { "1200" }, this.ob); //CkClassCommon.FilComboboxAdd(COP_OrderType, dt1, "baseCode", "baseName", "validflag NOT in ('0')", true, "全部", ""); //COP_OrderType.SelectedIndex = 0; //加载运输条件 DataTable dt6 = ServerHelper.GetData("com.hnshituo.pur.configure.service.impl.CoreBaseInfoNew.doQuery", new Object[] { "1105" }, this.ob); publicPms.FilComboboxAdd(txt_deliveryCondition, dt6, "baseCode", "baseName", "validflag NOT in ('0')", true, "/", ""); txt_deliveryCondition.SelectedIndex = 0; //加载运输方式 DataTable dt7 = ServerHelper.GetData("com.hnshituo.pur.configure.service.impl.CoreBaseInfoNew.doQuery", new Object[] { "1102" }, this.ob); publicPms.FilComboboxAdd(txt_deliveryType, dt7, "baseCode", "baseName", "validflag NOT in ('0')", true, "/", ""); txt_deliveryType.SelectedIndex = 0; } /// /// 查询可编制数据 /// /// 是否初始化地址条件 private void getOrderCAndCD(bool tips)//查询可编制数据 { try { ultraGrid4.UpdateData(); this.Cursor = Cursors.WaitCursor; dataTable5.Clear(); dataTable4.Clear(); //最早要求到货时间 int times = 0; DateTime deliveryTime = DateTime.Now; DateTime tempEndDate = DateTime.Now; OrderC odC = new OrderC(); odC.Validflag = "1"; if (listOrderCol.Count <= 0) { MessageUtil.ShowTips("请选择合同头"); return; } odC.OrderIdCol = (String[])listOrderCol.ToArray(typeof(String)); //odC.ItemCodeCol = (String[])listMatCode.ToArray(typeof(String)); DataTable dt = this.execute("com.hnshituo.pur.order.service.OrderCService", "doQueryOrderC", new object[] { odC }); GridHelper.CopyDataToDatatable(dt, dataTable4, true); //publicPms.ShowExcludeColumns(ultraGrid3.DisplayLayout.Bands[1], new string[] {}); //判断是旧合同生成和新合同生成 if (!listOrderCol[0].ToString().StartsWith("HT")) { foreach (Object orderIds in listOrderCol) { if (orderIds.ToString().StartsWith("HT")) { MessageUtil.ShowTips("新旧合同不能混合操作"); return; } } ultraGrid3.DisplayLayout.Bands[1].Override.AllowAddNew = AllowAddNew.TemplateOnBottom; ultraGrid3.DisplayLayout.Bands[1].Columns["DELETENAME"].CellActivation = Activation.ActivateOnly; publicPms.HideExcludeColumns(ultraGrid3.DisplayLayout.Bands[1], new string[] { "CHK", "DELETENAME", "createQty", "deliveryLocation" }); foreach (UltraGridRow row in ultraGrid3.Rows) { double maxCanUseQty_order = Convert.ToDouble(row.GetCellValue("QTY")) - Convert.ToDouble(row.GetCellValue("CREATEDNOTICEQTY"));//合同可编制 if (maxCanUseQty_order < 0) { MessageUtil.ShowTips("物料:" + row.GetCellValue("itemName") + "数据异常,累计通知量大于合同量!"); return; } row.Cells["canUseQty"].Value = maxCanUseQty_order; } req_dept_batch.Enabled = true; return; } req_dept_batch.Enabled = false; req_dept_batch.Clear(); txt_dept_batch_id.Text = ""; ultraGrid3.DisplayLayout.Bands[1].Columns["DELETENAME"].CellActivation = Activation.Disabled; publicPms.HideExcludeColumns(ultraGrid3.DisplayLayout.Bands[1], new string[] { "CHK", "DELETENAME", "createQty", "deliveryLocation", "purtype", "itemDescE", "LASTDELIVERYDATE", "mrId", "oriQty", "qtyPur", "remark" }); foreach (DataRow rows in dt.Rows) { if (String.IsNullOrEmpty(rows["purLineId"].ToString())) { MessageUtil.ShowTips("物料:" + rows["itemName"].ToString() + "采购计划行号为空,无法查询到关联的需求计划行"); return; } //计算最大的最早的到货时间 if (String.IsNullOrEmpty(rows["EndDate"].ToString())) { MessageUtil.ShowTips("物料:" + rows["itemName"].ToString() + "要求到货时间为空!"); } tempEndDate = Convert.ToDateTime(rows["EndDate"]); if (times != 0) { if (tempEndDate < deliveryTime) { deliveryTime = tempEndDate; } } else { deliveryTime = tempEndDate; } times = times + 1; } RequireReceive rr = new RequireReceive(); //rr.ItemCodeCol = odC.ItemCodeCol; rr.OrderIdCol = odC.OrderIdCol; rr.DeliveryLocationCode=txt_deliveryLocation.SelectedIndex == -1 ? "" : txt_deliveryLocation.Value.ToString().Trim(); if (!ck_isAllReq.Checked) { rr.DeleteName="2";//查可编制的 } //加载接收需求计划表---所有预采和普采的都在里面 DataTable dt1 = this.execute("com.hnshituo.pur.requireplan.service.RequireReceiveService", "getRR_forOrder", new object[] { rr }); foreach (DataRow row2 in dt1.Rows) { row2["itemDescE"] = Convert.ToDateTime(row2["itemDescE"]).ToString("yyyy/MM"); } GridHelper.CopyDataToDatatable(dt1, dataTable5, true); ultraGrid3.DisplayLayout.Bands[1].Override.AllowAddNew = AllowAddNew.No; //初始化选择接收需求行 foreach (UltraGridRow row in ultraGrid3.Rows) { double maxCanUseQty_order = Convert.ToDouble(row.GetCellValue("QTY")) - Convert.ToDouble(row.GetCellValue("CREATEDNOTICEQTY"));//合同可编制 double maxCanUseQty_temp = maxCanUseQty_order; double maxNeedQty_JitReq = 0;//JIT需求量 int maxNeedNum_JitReq=0;//JIT需求个数 if (maxCanUseQty_order < 0) { MessageUtil.ShowTips("物料:" + row.GetCellValue("itemName") + "数据异常,累计通知量大于合同量!"); return; } row.Cells["canUseQty"].Value = maxCanUseQty_order; //----------------------------------------------------------------分配方案1:交期优先分配-------------------------------------------------------------------- if (txt_Allocation_rule.SelectedIndex == 1) { //条件 //1:需求的编制量----不能大于需求的可编制量 //2:合同行的编制量----不能大于合同的可编制量 //实现流程 //1:计算合同最大可编制 //2:循环分配需求 if (row.HasChild()) { foreach (UltraGridRow row1 in row.ChildBands[0].Rows) { double maxCanUseQty_Req = Convert.ToDouble(row1.GetCellValue("Qty")) - Convert.ToDouble(row1.GetCellValue("qtyNoticed"));//需求可编制 row1.Cells["canUseQty"].Value = maxCanUseQty_Req; row1.Cells["createQty"].Value = 0; if (maxCanUseQty_Req > 0)//需求可编制量只能大于0 { if (maxCanUseQty_temp > 0) { row1.Cells["CHK"].Value = true; row1.Cells["CHK"].Activation = Activation.AllowEdit; //row1.Appearance.BackColor = Color.White; if (maxCanUseQty_Req <= maxCanUseQty_temp)//需求可编制量少于合同可编制量----》需求可编制量全部编制,合同可编制量减少 { row1.Cells["createQty"].Value = maxCanUseQty_Req; maxCanUseQty_temp = maxCanUseQty_temp - maxCanUseQty_Req; } else//需求可编制量大于合同可编制量----》需求可编制量部分编制,合同可编制量全部用完 { row1.Cells["createQty"].Value = maxCanUseQty_temp; maxCanUseQty_temp = 0; } } else { //row1.Cells["CHK"].Value = false; //row1.Cells["CHK"].Activation = Activation.Disabled; //row1.Appearance.BackColor = Color.WhiteSmoke; row1.Cells["CHK"].Value = true; row1.Cells["CHK"].Activation = Activation.AllowEdit; //row1.Appearance.BackColor = Color.White; } } else if (maxCanUseQty_Req == 0) { row1.Cells["CHK"].Value = false; row1.Cells["CHK"].Activation = Activation.Disabled; //row1.Appearance.BackColor = Color.WhiteSmoke; } else { MessageUtil.ShowTips("接收需求行:" + row1.GetCellValue("mrLineId") + "数据异常,已通知通知量大于核准量!"); row1.Cells["CHK"].Value = false; row1.Cells["CHK"].Activation = Activation.Disabled; //row1.Appearance.BackColor = Color.WhiteSmoke; } } } if (maxCanUseQty_order > maxCanUseQty_temp) { row.Cells["createQty"].Value = maxCanUseQty_order - maxCanUseQty_temp; row.Cells["CHK"].Value = true; row.Cells["CHK"].Activation = Activation.AllowEdit; //row.Appearance.BackColor = Color.LightCyan; } else { row.Cells["createQty"].Value = 0; row.Cells["CHK"].Value = false; row.Cells["CHK"].Activation = Activation.Disabled; //row.Appearance.BackColor = Color.WhiteSmoke; } } else if (txt_Allocation_rule.SelectedIndex == 0) { //----------------------------------------------------------------分配方案2:优先满足JIT,JIT平均分配------------------------------------------------------------------- //条件 //1:需求的编制量----不能大于需求的可编制量 //2:合同行的编制量----不能大于合同的可编制量 //实现流程 //1:计算合同最大可编制 //2:计算JIT需求最大可编制量和个数 //3:平均分配JIT需求(1:,2:) //4:其它待定 if (row.HasChild()) { //计算JIT需求总量 foreach (UltraGridRow row1 in row.ChildBands[0].Rows) { double maxCanUseQty_Req = Convert.ToDouble(row1.GetCellValue("Qty")) - Convert.ToDouble(row1.GetCellValue("qtyNoticed"));//需求可编制 if (maxCanUseQty_Req <= 0) { maxCanUseQty_Req = 0; row1.Cells["CHK"].Value = false; row1.Cells["CHK"].Activation = Activation.Disabled; //row1.Appearance.BackColor = Color.WhiteSmoke; if (maxCanUseQty_Req < 0) { MessageUtil.ShowTips("接收需求行:" + row1.GetCellValue("mrLineId") + "数据异常,已通知通知量大于核准量!"); } } row1.Cells["canUseQty"].Value = maxCanUseQty_Req;//需求可编制 row1.Cells["createQty"].Value = 0;//默认需求编制量 if (row1.GetCellValue("DELIVERYLOCATIONFLAG").ToString().Trim() == "是") { maxNeedQty_JitReq = maxNeedQty_JitReq + maxCanUseQty_Req; maxNeedNum_JitReq=maxNeedNum_JitReq+1; } } //执行分配1---JIT需求小于合同需求---满足所有JIT需求 if (maxCanUseQty_order > maxNeedQty_JitReq) { foreach (UltraGridRow row1 in row.ChildBands[0].Rows) { if (maxCanUseQty_temp > 0) { if (row1.GetCellValue("DELIVERYLOCATIONFLAG").ToString().Trim() == "是") { row1.Cells["CHK"].Value = true; row1.Cells["CHK"].Activation = Activation.AllowEdit; // row1.Appearance.BackColor = Color.White; double maxCanUseQty_Req = Convert.ToDouble(row1.Cells["canUseQty"].Value); row1.Cells["createQty"].Value = maxCanUseQty_Req; maxCanUseQty_temp = maxCanUseQty_temp - maxCanUseQty_Req; } else { row1.Cells["CHK"].Value = true; row1.Cells["CHK"].Activation = Activation.AllowEdit; // row1.Appearance.BackColor = Color.White; double maxCanUseQty_Req = Convert.ToDouble(row1.Cells["canUseQty"].Value); if (maxCanUseQty_Req <= maxCanUseQty_temp)//需求可编制量少于合同可编制量----》需求可编制量全部编制,合同可编制量减少 { row1.Cells["createQty"].Value = maxCanUseQty_Req; maxCanUseQty_temp = maxCanUseQty_temp - maxCanUseQty_Req; } else//需求可编制量大于合同可编制量----》需求可编制量部分编制,合同可编制量全部用完 { row1.Cells["createQty"].Value = maxCanUseQty_temp; maxCanUseQty_temp = 0; } } } else { row1.Cells["CHK"].Value = false; row1.Cells["CHK"].Activation = Activation.AllowEdit; //row1.Appearance.BackColor = Color.White; } } } //执行分配2---JIT需求大于等于合同需求-----直接执行平均分配 else { foreach (UltraGridRow row1 in row.ChildBands[0].Rows) { if (maxCanUseQty_temp > 0) { if (row1.GetCellValue("DELIVERYLOCATIONFLAG").ToString().Trim() == "是") { double averageQty = 0; if (maxNeedNum_JitReq <= 1)//默认不取整数 { averageQty = maxCanUseQty_temp; } else { averageQty = (int)(maxCanUseQty_temp / maxNeedNum_JitReq);//截取整数 } row1.Cells["CHK"].Value = true; row1.Cells["CHK"].Activation = Activation.AllowEdit; double maxCanUseQty_Req = Convert.ToDouble(row1.Cells["canUseQty"].Value); if (maxCanUseQty_Req < averageQty) { row1.Cells["createQty"].Value = maxCanUseQty_Req; maxCanUseQty_temp = maxCanUseQty_temp - maxCanUseQty_Req; } else { //row1.Appearance.BackColor = Color.White; row1.Cells["createQty"].Value = averageQty; maxCanUseQty_temp = maxCanUseQty_temp - averageQty; } maxNeedNum_JitReq = maxNeedNum_JitReq - 1; } else { row1.Cells["CHK"].Value = true; row1.Cells["CHK"].Activation = Activation.AllowEdit; // row1.Appearance.BackColor = Color.White; double maxCanUseQty_Req = Convert.ToDouble(row1.Cells["canUseQty"].Value); if (maxCanUseQty_Req <= maxCanUseQty_temp)//需求可编制量少于合同可编制量----》需求可编制量全部编制,合同可编制量减少 { row1.Cells["createQty"].Value = maxCanUseQty_Req; maxCanUseQty_temp = maxCanUseQty_temp - maxCanUseQty_Req; } else//需求可编制量大于合同可编制量----》需求可编制量部分编制,合同可编制量全部用完 { row1.Cells["createQty"].Value = maxCanUseQty_temp; maxCanUseQty_temp = 0; } } } else { //row1.Cells["CHK"].Value = false; //row1.Cells["CHK"].Activation = Activation.Disabled; //row1.Appearance.BackColor = Color.WhiteSmoke; row1.Cells["CHK"].Value = false; row1.Cells["CHK"].Activation = Activation.AllowEdit; // row1.Appearance.BackColor = Color.White; } } } } if (maxCanUseQty_order > maxCanUseQty_temp) { row.Cells["createQty"].Value = maxCanUseQty_order - maxCanUseQty_temp; row.Cells["CHK"].Value = true; row.Cells["CHK"].Activation = Activation.AllowEdit; // row.Appearance.BackColor = Color.LightCyan; } else { row.Cells["createQty"].Value = 0; row.Cells["CHK"].Value = false; row.Cells["CHK"].Activation = Activation.Disabled; // row.Appearance.BackColor = Color.WhiteSmoke; } } else { MessageUtil.ShowTips("请选择需求分配方案!"); return; } } GridHelper.RefreshAndAutoSize(ultraGrid3); //统计地址与初始化头编辑区 if (tips == true) { //初始化头编辑区 if (deliveryTime > DateTime.Now) { txt_MRPERIODEND.Value = deliveryTime; } else { txt_MRPERIODEND.Value = DateTime.Now.AddDays(1); } //txt_supp.Text = strSuppName + "(" + strSuppCode + ")"; //初始化查询区域 DataTable dttest = dt1.Copy(); for (int i = 0; i < dttest.Rows.Count; i++) { String StrLocationCode = dttest.Rows[i]["deliveryLocationCode"].ToString().Trim(); int cou = 0; for (int j = dt1.Rows.Count - 1; j >= 0; j--) { //DataRow rowt = dt.Rows[j]; if (dt1.Rows[j]["deliveryLocationCode"].ToString().Trim() == StrLocationCode) { cou = cou + 1; if (cou == 1) { //rowt = dt.Rows[j]; } if (cou >= 2) { dt1.Rows.RemoveAt(j); } } } } CkClassCommon.FilComboboxAdd(txt_deliveryLocation, dt1, "deliveryLocationCode", "deliveryLocation", "validflag NOT in ('0')", true, "全部", ""); txt_deliveryLocation.SelectedIndex = 0; } } catch (Exception ex) { MessageUtil.ShowTips("获取该合同可编制数据失败:" + ex); } finally { this.Cursor = Cursors.Default; } } /// /// 获取合同行和需求行信息 /// private void getDetail()// 获取通知单和需求行信息 { try { UltraGridRow uge = ultraGrid1.ActiveRow; if (uge == null) { return; } dataTable3.Clear(); dataTable2.Clear(); ExcDeliveryNoticeC EdnC = new ExcDeliveryNoticeC(); EdnC.NoticeId = uge.Cells["NoticeId"].Value.ToString(); EdnC.Validflag = "1"; DataTable dt = this.execute("com.hnshituo.pur.ck.service.ExcDeliveryNoticeCService", "find_EdnC", new object[] { EdnC }); GridHelper.CopyDataToDatatable(dt, dataTable2, true); Hashtable map = new Hashtable(); map.Add("noticeId", uge.Cells["NoticeId"].Value.ToString()); DataTable dt1 = this.execute("com.hnshituo.pur.ck.service.ExcDeliveryNoticeRpRService", "doQueryList", new object[] { map }); foreach (DataRow row in dt1.Rows) { row["planedMouth"] = Convert.ToDateTime(row["planedMouth"]).ToString("yyyy/MM"); } GridHelper.CopyDataToDatatable(dt1, dataTable3, true); GridHelper.RefreshAndAutoSize(ultraGrid2); } catch (Exception ex) { MessageUtil.ShowTips("加载通知单行数据异常!" + ex.Message); } } /// /// 选择物料事件 /// private void refreshSelectMat() { ultraGrid5.UpdateData(); listMatCode.Clear(); listMatName.Clear(); foreach (UltraGridRow row in ultraGrid5.Rows) { if (Convert.ToBoolean(row.GetCellValue("CHK")) == true) { String strItemCode = row.GetCellValue("itemCode").ToString().Trim(); String strItemName = row.GetCellValue("itemName").ToString().Trim(); listMatCode.Add(strItemCode); listMatName.Add(strItemName); } } if (listMatCode.Count >= 0) { String[] ls = (String[])listMatName.ToArray(typeof(string)); String str1 = String.Join(";", ls); txt_itemName.Text = str1; } else { txt_itemName.Text = ""; } } #endregion private void COP_SuppName_ValueChanged(object sender, EventArgs e) { if(COP_SuppName.SelectedIndex==-1) { return; } dataTable7.Clear(); String strSuppCode = COP_SuppName.Value.ToString().Trim(); //加载合同物料dropdown String[] array = (String[])listorder.ToArray(typeof(string)); OrderC odC = new OrderC(); odC.DeleteName = "0";//待编制合同行 odC.Validflag = "1"; if (String.IsNullOrEmpty(strSuppCode)) { odC.OrderIdCol = array;//权限控制 } else { odC.SuppCode = strSuppCode; } DataTable dt2 = this.execute("com.hnshituo.pur.order.service.OrderCService", "doQueryOrderC", new object[] { odC }); DataView dv1 = new DataView(dt2); DataTable dt_item = dv1.ToTable(true, new string[] { "itemCode", "itemName" }); GridHelper.CopyDataToDatatable(dt_item, dataTable7, true); } } }