| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407 |
- 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<frm.num-1;i++)
- {
- if (dataTable2.Select("noticeLineSqe = '" + ultraGrid3.ActiveRow.Cells["noticeLineSqe"].Text.Trim() + "'").Length > 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 <dbCreateQty || dbCreateQty<=0)
- {
- MessageBox.Show("物料[" + row.Cells["itemCode"].Value.ToString() + "]的编制量不能大于可编制量且需大于0", "提示");
- return;
- }
- }
- }
- if (i <= 0)
- {
- MessageUtil.ShowTips("未编制物料!");
- return;
- }
- //准备数据写入
- ExcDeliverySubM sm = new ExcDeliverySubM();
- sm.NoticeId=tempEsm.NoticeId;
- sm.Status="1";
- sm.OrderId = tempEsm.OrderId;
- sm.DeliveryLocationCode = tempEsm.DeliveryLocationCode;
- sm.DeliveryLocation = tempEsm.DeliveryLocation;
- sm.SuppCode=tempEsm.SuppCode;
- sm.SuppName=tempEsm.SuppName;
- sm.PlanedDeliveryDate=tempEsm.PlanedDeliveryDate;
- sm.Validflag="1";
- sm.CreateName = UserInfo.GetUserName();
- sm.CreateUserid = UserInfo.GetUserID();
- sm.CreateTime=DateTime.Now;
- sm.DeliveryCondition=tempEsm.DeliveryCondition;
- sm.BuyerDeptCode = UserInfo.GetDeptid();
- if (txt_deliveryType.SelectedIndex == -1)
- {
- MessageUtil.ShowTips("请选择运输方式");
- txt_deliveryType.Focus();
- return;
- }
- if (txt_receive_type.SelectedIndex == -1)
- {
- MessageUtil.ShowTips("请选择接收方式");
- txt_receive_type.Focus();
- return;
- }
- sm.DeliveryType = txt_deliveryType.Value.ToString();
- sm.ReceiveType = txt_receive_type.Value.ToString();
- List<ExcDeliverySubC> list = new List<ExcDeliverySubC>();
- 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<ExcDeliveryNoticeC>("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<CoreResult>("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<ExcDeliveryNoticeM>("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;
- }
- }
- /// <summary>
- /// 加载行信息
- /// </summary>
- 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<DataTable>("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<ExcDeliveryNoticeC>("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;
- // }
- //}
- }
- }
|