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 CoreFS.CA06;using Pur.Entity; using Infragistics.Win.UltraWinGrid; using Pur.Entity.ck; using Pur.Entity.require_planEntiy; using Core.Mes.Client.Comm.Tool; using Core.Mes.Client.Comm.Server; using Pur.order; namespace Pur.ck { public partial class ExcCreateDeliveryM : FrmPmsBase { private int tips; private string noticeId=""; ExcDeliveryNoticeM tempEsm; public int Tips { get { return tips; } set { tips = value; } } public ExcCreateDeliveryM(OpeBase ob, string strNoticeId) { this.ob = ob; this.noticeId = strNoticeId; InitializeComponent(); } private void ExcCreateDeliveryM_Load(object sender, EventArgs e) { getDropDown(); this.tips = 0; GridHelper.SetExcludeColumnsActive(ultraGrid3.DisplayLayout.Bands[0], new String[] { "CHK","createQty", "carNum", "batchNo" }); init(); } #region tooolbar工具区 private void ultraToolbarsManager1_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e) { switch (e.Tool.Key) { case "doRefresh": // 提交 doRefresh(); break; case "doChange": // 提交 doCreate(); break; case "Close": // 关闭当前页 this.Close(); break; case "doSpit": // 拆分装车 doSpit(); break; } } //拆分装车 private void doSpit() { ultraGrid3.UpdateData(); UltraGridRow uge = ultraGrid3.ActiveRow; if (uge == null) { MessageUtil.ShowTips("请选择通知单行进行操作"); return; } frmPopNoticeItemSpit frm = new frmPopNoticeItemSpit(this.ob); frm.ShowDialog(); if (frm.tips == "1" && frm.num>=2) { int qtySpit=0; for(int i=0;i 0) { DataRow row = dataTable2.Select("noticeLineSqe = '" + ultraGrid3.ActiveRow.Cells["noticeLineSqe"].Text.Trim() + "'")[0]; if (i == 0) { try { double dbCanUseQty = Convert.ToDouble(row["canUseQty"]); double dbcreateQty = Convert.ToDouble(row["createQty"]); if (dbCanUseQty == dbcreateQty) { qtySpit = (int)(Convert.ToDouble(row["canUseQty"]) / frm.num); } else { qtySpit = 0; } } catch (Exception) { qtySpit=0; } } row["createQty"] = qtySpit; dataTable2.ImportRow(row); } } dataTable2.DefaultView.Sort = "noticeLineSqe desc"; GridHelper.CopyDataToDatatable(dataTable2.DefaultView.ToTable(),dataTable2,true); //ultraGrid3.DataSource = dataTable2.DefaultView.ToTable(); } } //刷新数据 private void doRefresh() { init(); } //提交数据 private void doCreate() { ultraGrid3.UpdateData(); //校验数据 int i=0; foreach (UltraGridRow row in ultraGrid3.Rows) { if (Convert.ToBoolean(row.Cells["CHK"].Value) == true) { i = i + 1; double dbcanUseQty = Convert.ToDouble(row.Cells["canUseQty"].Value); double dbCreateQty = Convert.ToDouble(row.Cells["createQty"].Value); if (dbcanUseQty list = new List(); foreach (UltraGridRow row in ultraGrid3.Rows) { if (Convert.ToBoolean(row.Cells["CHK"].Value) == true) { double dbCreateQty = Convert.ToDouble(row.Cells["createQty"].Value); String strNoticeLineSqe=row.GetCellValue("noticeLineSqe").ToString().Trim(); if(String.IsNullOrEmpty(strNoticeLineSqe)) { MessageUtil.ShowTips("送货单行编辑区第"+row.Index+"条数据通知单行号为空"); return; } ExcDeliveryNoticeC tempEsc = this.execute("com.hnshituo.pur.ck.service.ExcDeliveryNoticeCService", "findById", new object[] {strNoticeLineSqe}); ExcDeliverySubC sc = new ExcDeliverySubC(); sc.NoticeId = tempEsm.NoticeId; sc.OrderId = tempEsc.OrderId; sc.OrderLineSqe = tempEsc.OrderLineSqe; sc.NoticeLineSqe = tempEsc.NoticeLineSqe; sc.ItemCode = tempEsc.ItemCode; sc.ItemDesc=tempEsc.ItemDesc; sc.ItemDescE=tempEsc.ItemDescE; sc.ItemName=tempEsc.ItemName; sc.ItemUom=tempEsc.ItemUom; sc.WeightUnit=tempEsc.WeightUnit; sc.ItemUomConefficient=tempEsc.ItemUomConefficient; sc.ItemUseUom=tempEsc.ItemUseUom; sc.ItemAttr=tempEsc.ItemAttr;//物料属性 sc.ItemAttrId=tempEsc.ItemAttrId;//属性编码 sc.ItemStandardsCode=tempEsc.ItemStandardsCode; sc.ItemStandardsId=tempEsc.ItemStandardsId; sc.ItemUnique=tempEsc.ItemUnique; sc.ItemUomId = tempEsc.ItemUomId; sc.Qty=dbCreateQty;//送货数量 String strBatchNo = row.GetCellValue("batchNo")==null?"":row.GetCellValue("batchNo").ToString().Trim(); if (tempEsc.BatchFlag == "1")//批次控制 { if (String.IsNullOrEmpty(strBatchNo)) { MessageUtil.ShowTips("物料:" + tempEsc.ItemName + "为批次控制物料,请输入生产批次号!"); return; } } sc.BatchNo = strBatchNo; String strCarNumC = row.GetCellValue("carNum") == null ? "" : row.GetCellValue("carNum").ToString().Trim(); if (String.IsNullOrEmpty(strCarNumC)) { //MessageUtil.ShowTips("请输入物料:" + tempEsc.ItemName + "的运输车号!"); //return; } sc.CarNum = strCarNumC; if (sm.ReceiveType != tempEsc.ReceiveType) { if (MessageUtil.ShowYesNoAndQuestion("通知单行:" + tempEsc.NoticeLineSqe + " 接收方式和本次编制的接收方式不一致,确定是否继续?") != DialogResult.Yes) { return; } } sc.ReceiveType = sm.ReceiveType; sc.BuyerName=tempEsc.BuyerName; sc.MeteringFlag=tempEsc.MeteringFlag; sc.BatchFlag=tempEsc.BatchFlag; sc.PcFlag=tempEsc.PcFlag; sc.Ismeter = "0"; sc.CreateName = UserInfo.GetUserName(); sc.CreateUserid = UserInfo.GetUserID(); sc.CreateTime = DateTime.Now; sc.Validflag="1"; sc.Status="1";//待收货 sc.ShippedQty = 0; sc.ShipQty=0; sc.ReceivedQty=0; sc.PackageType=tempEsc.PackageType; list.Add(sc); } } if (MessageUtil.ShowYesNoAndQuestion("确定生成【" + tempEsm.SuppName + "】的新送货单?")!=DialogResult.Yes) { return; } CoreResult re = this.execute("com.hnshituo.pur.ck.service.ExcDeliverySubMService", "insert_PC", new object[] { sm, list }); if (re.Resultcode == 0) { MessageUtil.ShowTips("新增成功,已生成送货单:" + re.Resultmsg); tips = 1; this.Close(); } else { MessageUtil.ShowTips("操作失败:" + re.Resultmsg); tips = 0; } } #endregion #region 初始化区域 private void init() { try { this.Cursor = Cursors.WaitCursor; dataSet1.Clear(); //加载通知单头 if (String.IsNullOrEmpty(noticeId)) { MessageUtil.ShowTips("通知单号为空,无法获取通知单信息"); return; } tempEsm = this.execute("com.hnshituo.pur.ck.service.ExcDeliveryNoticeMService", "findById", new object[] { noticeId }); if (tempEsm == null) { MessageUtil.ShowTips("未发现通知单:" + noticeId + "信息记录,无法获取通知单信息"); return; } //加载头编辑区 txt_supp.Text = tempEsm.SuppName + "(" + tempEsm.SuppCode + ")"; txt_deliveryLocation.Text = tempEsm.DeliveryLocation + "(" + tempEsm.DeliveryLocationCode + ")"; txt_deliveryTime.Value = tempEsm.PlanedDeliveryDate; txt_orderId.Text = tempEsm.OrderId; txt_deliveryCondition.Value = tempEsm.DeliveryCondition; txt_deliveryType.Value = tempEsm.DeliveryType; //加载通知单行信息 getNoticeC(); } catch (Exception ex) { MessageBox.Show("初始化失败" + ex, "提示"); } finally { this.Cursor = Cursors.Default; } } /// /// 加载行信息 /// private void getNoticeC() { ExcDeliveryNoticeC EdnC = new ExcDeliveryNoticeC(); EdnC.NoticeId = noticeId; EdnC.Validflag = "1"; EdnC.DeleteUserid = "0"; if (txt_receive_type.SelectedIndex == -1) { MessageUtil.ShowTips("请选择接收方式"); txt_receive_type.Focus(); return; } EdnC.ReceiveType = txt_receive_type.Value.ToString().Trim(); DataTable dt = this.execute("com.hnshituo.pur.ck.service.ExcDeliveryNoticeCService", "find_EdnC", new object[] { EdnC }); if (dt == null) { return; } //String strNoticeLineSqe = dt.Rows[0]["noticeLineSqe"].ToString().Trim(); //String strReceiveType = ""; //ExcDeliveryNoticeC nc = this.execute("com.hnshituo.pur.ck.service.ExcDeliveryNoticeCService", "findById", new object[] { strNoticeLineSqe }); //if (nc != null) //{ // strReceiveType = nc.ReceiveType; // txt_receive_type.Value = nc.ReceiveType; //} //汇编物料数量 dt.Columns.Add("canUseQty", Type.GetType("System.String")); //dt.Columns.Add("createQty", Type.GetType("System.String")); foreach (DataRow row in dt.Rows) { double dbcreateQty = Convert.ToDouble(row["createdQty"].ToString().Trim()); double dbQty = Convert.ToDouble(row["qty"].ToString().Trim()); row["createQty"] = dbQty - dbcreateQty; row["canUseQty"] = dbQty - dbcreateQty; } dt.DefaultView.Sort = "noticeLineSqe desc"; GridHelper.CopyDataToDatatable(dt.DefaultView.ToTable(), dataTable2, true); foreach (UltraGridRow roww in ultraGrid3.Rows) { roww.Cells["CHK"].Value = true; } ultraGrid3.UpdateData(); GridHelper.RefreshAndAutoSize(ultraGrid3); } #endregion #region 初始化 private void getDropDown() { //加载运输条件 DataTable dt6 = ServerHelper.GetData("com.hnshituo.pur.configure.service.impl.CoreBaseInfoNew.doQuery", new Object[] { "1105" }, this.ob); comm.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); comm.FilComboboxAdd(txt_deliveryType, dt7, "baseCode", "baseName", "validflag NOT in ('0')", true, "/", ""); txt_deliveryType.SelectedIndex = 0; //加载接收方式 DataTable dt5 = ServerHelper.GetData("com.hnshituo.pur.configure.service.impl.CoreBaseInfoNew.doQueryByNoticeId", new Object[] { "1101", noticeId }, this.ob); comm.FilComboboxAdd(txt_receive_type, dt5, "baseCode", "baseName", "validflag NOT in ('0')", false, "/", ""); txt_receive_type.SelectedIndex = 0; } #endregion private void txt_receive_type_SelectionChanged(object sender, EventArgs e) { getNoticeC(); } //private void txt_deliveryType_ValueChanged(object sender, EventArgs e) //{ // if (txt_deliveryType.SelectedIndex != -1) // { // if (txt_deliveryType.Value.ToString().Trim() == "110203") // { // txt_carNum.Clear(); // txt_carNum.ReadOnly = true; // ultraGrid3.DisplayLayout.Bands[0].Columns["carNum"].Hidden = false; // } // else // { // txt_carNum.ReadOnly = false; // ultraGrid3.DisplayLayout.Bands[0].Columns["carNum"].Hidden = true; // } // } // else // { // txt_carNum.ReadOnly = false; // ultraGrid3.DisplayLayout.Bands[0].Columns["carNum"].Hidden = true; // } //} } }