| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289 |
- 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;
- namespace Pur.ck
- {
- public partial class ExcDeliveryChange : FrmPmsBase
- {
- private int tips;
- List<ExcDeliverySubM> listsb = new List<ExcDeliverySubM>();
- public int Tips
- {
- get { return tips; }
- set { tips = value; }
- }
- private ArrayList List;
- public ArrayList list
- {
- get { return List; }
- set { List = value; }
- }
- private string noticeId;
- public string NoticeId
- {
- get { return noticeId; }
- set { noticeId = value; }
- }
- private string newNoticeId;
- public string NewNoticeId
- {
- get { return newNoticeId; }
- set { newNoticeId = value; }
- }
- public ExcDeliveryChange()
- {
- InitializeComponent();
- }
- public ExcDeliveryChange(OpeBase ob, string NoticeId)
- {
- this.ob = ob;
- this.noticeId = NoticeId;
- InitializeComponent();
- }
- public ExcDeliveryChange(OpeBase ob, ArrayList list)
- {
- this.ob = ob;
- this.list = list;
- InitializeComponent();
- }
- private void ExcDeliveryChange_Load(object sender, EventArgs e)
- {
- this.tips = 0;
- init();
- }
- #region tooolbar工具区
- private void ultraToolbarsManager1_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
- {
- switch (e.Tool.Key)
- {
- case "doChange": // 提交
- doChange();
- break;
- case "Close": // 关闭当前页
- this.Close();
- break;
- }
- }
- #endregion
- #region toolbar事件
- /// <summary>
- /// 提交变更
- /// </summary>
- private void doChange()
- {
- String strsuppCode = ultraGrid1.Rows[0].Cells["suppCode"].Value.ToString().Trim();
- //String strnoticeId = ultraGrid1.Rows[0].Cells["noticeId"].Value.ToString().Trim();
- //校验数据
- ultraGrid3.UpdateData();
- foreach (UltraGridRow row in ultraGrid3.Rows)
- {
- String stroldQty = row.Cells["qty"].Value.ToString().Trim();
- String strnewQty = row.Cells["createQty"].Value.ToString().Trim();
- Double dboldQty = 0;
- Double dbnewQty = 0;
- if (!String.IsNullOrEmpty(stroldQty))
- {
- dboldQty = Convert.ToDouble(stroldQty);
- }
- if (!String.IsNullOrEmpty(strnewQty))
- {
- dbnewQty = Convert.ToDouble(strnewQty);
- }
- if (dboldQty != dbnewQty || dbnewQty==0)
- {
- MessageBox.Show("物料[" + row.Cells["itemCode"].Value.ToString() + "]未编制有效数量,请保证编制前和编制后总量一致", "提示");
- return;
- }
- }
- //数据准备(新旧一起)
- //旧送货子单主表ID(List)
- //新送货子单从表ID(list)
- List<RequirePlanD> listR=new List<RequirePlanD>();
- foreach (UltraGridRow uge in ultraGrid3.Rows.GetRowEnumerator(GridRowType.DataRow, null, null))
- {
- if (uge.HasParent())
- {
- if (Convert.ToBoolean(uge.Cells["isSelect"].Value) == true && Convert.ToDouble(uge.Cells["createQty"].Value)>0)
- {
- RequirePlanD rd = new RequirePlanD();
- rd.MrLineId = uge.Cells["mrLineId"].Value.ToString().Trim();
- rd.MrId = uge.Cells["MrId"].Value.ToString().Trim();
- rd.Qty = Convert.ToDouble(uge.Cells["createQty"].Value.ToString().Trim());
- listR.Add(rd);
- }
- }
- }
- if (MessageBox.Show("将变更送货子单号为【" + listsb[0].DeliverySubId + "】等" + List.Count + "个送货子单信息?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
- {
- return;
- }
- CoreResult re = this.execute<CoreResult>("com.hnshituo.pur.ck.service.ExcDeliverySubMService", "doChangeSub", new object[] { strsuppCode, listsb, listR });
- if (re.Resultcode != 0)
- {
- MessageBox.Show("变更失败:" + re.Resultmsg, "提示");
- return;
- }
- else
- {
- MessageBox.Show(re.Resultmsg, "提示");
- }
- }
- #endregion
- #region 初始化区域
- private void init()
- {
- try
- {
- dataTable1.Clear();
- dataTable2.Clear();
- dataTable5.Clear();
- dataTable6.Clear();
- foreach (object obj in List)
- {
- UltraGridRow rows = (UltraGridRow)obj;
- String strsubid = rows.Cells["deliverySubId"].Value.ToString();
- String strnoticeId = rows.Cells["noticeId"].Value.ToString();
- ExcDeliverySubM esm = new ExcDeliverySubM();
- esm.DeliverySubId = strsubid;
- esm.NoticeId = strnoticeId;
- esm.Validflag = "1";
- listsb.Add(esm);
- DataTable dt = this.execute<DataTable>("com.hnshituo.pur.ck.service.ExcDeliverySubMService", "get_ExcDeliverySubM", new object[] { esm });
- //DataTable dt = this.execute<DataTable>("com.hnshituo.pur.ck.service.ExcDeliverySubMService", "get_ExcDeliverySubM", new object[] { esm });
- dataTable1.ImportRow(dt.Rows[0]);
- ExcDeliverySubC EdSc = new ExcDeliverySubC();
- EdSc.DeliverySubId = strsubid;
- DataTable dt1 = this.execute<DataTable>("com.hnshituo.pur.ck.service.ExcDeliverySubCService", "Query_C", new object[] { EdSc });
- dt1.Columns.Add("Connectkey", typeof(string));
- foreach (DataRow rowf in dt1.Rows)
- {
- rowf["Connectkey"] = rowf["itemCode"].ToString() + rowf["itemAttrId"].ToString();
- dataTable2.ImportRow(rowf);
- //dataTable5.ImportRow(rowf);
- }
- }
- //汇编物料数量
- foreach (DataRow row in dataTable2.Rows)
- {
- String stritemCode = row["itemCode"].ToString().Trim();
- String stritemAttrId = row["itemAttrId"].ToString().Trim();
- DataRow[] arrayDR = dataTable5.Select("itemCode='" + stritemCode + "' and itemAttrId='" + stritemAttrId + "'");
- if (arrayDR.Count() <= 0)
- {
- dataTable5.ImportRow(row);
- }
- else
- {
- if (arrayDR[0]["qty"] == null || String.IsNullOrEmpty(arrayDR[0]["qty"].ToString().Trim()))
- {
- arrayDR[0]["qty"] = row["qty"];
- }
- else
- {
- if (row["qty"] != null && !String.IsNullOrEmpty(row["qty"].ToString().Trim()))
- {
- arrayDR[0]["qty"] = Convert.ToDouble(arrayDR[0]["qty"]) + Convert.ToDouble(row["qty"]);
- }
- }
- }
- }
- foreach (DataRow roww in dataTable5.Rows)
- {
- String stritemCode = roww["itemCode"].ToString().Trim();
- String stritemAttrId = roww["itemAttrId"].ToString().Trim();
- RequirePlanD rd = new RequirePlanD();
- rd.ItemCode = stritemCode;
- rd.ItemAttrId = stritemAttrId;
- rd.Validflag = "1";
- //加载需求明显信息
- DataTable dt2 = this.execute<DataTable>("com.hnshituo.pur.requireplan.service.RequirePlanDService", "get_RequirePlanDlike", new object[] { rd });
- dt2.Columns.Add("Connectkey", typeof(string));
- foreach (DataRow rowff in dt2.Rows)
- {
- rowff["Connectkey"] = rowff["itemCode"].ToString() + rowff["itemAttrId"].ToString();
- }
- GridHelper.CopyDataToDatatable(dt2, dataTable6, false);
- }
- ultraGrid1.Refresh();
- ultraGrid2.Refresh();
- }
- catch (Exception ex)
- {
- MessageBox.Show("初始化失败" + ex, "提示");
- }
- }
- #endregion
- #region 数据校验事件
- private void ultraGrid3_CellChange(object sender, CellEventArgs e)
- {
- if (e.Cell.Row.HasParent())
- {
- double Qb_newcellvalue = Convert.ToDouble(e.Cell.Value);
- double Qb_newParentVale = Convert.ToDouble(e.Cell.Row.ParentRow.Cells["Qty"].Value);
- ultraGrid3.UpdateData();
- if (e.Cell.Column.Key.Equals("createQty")||e.Cell.Column.Key.Equals("isSelect"))
- {
- double t1 = (e.Cell.Row.Cells["createQty"].Value==null||String.IsNullOrEmpty(e.Cell.Row.Cells["createQty"].Value.ToString().Trim()))?0:Convert.ToDouble(e.Cell.Row.Cells["createQty"].Value);
- double t2 = (e.Cell.Row.Cells["qtyPur"].Value==null||String.IsNullOrEmpty(e.Cell.Row.Cells["qtyPur"].Value.ToString().Trim()))?0:Convert.ToDouble(e.Cell.Row.Cells["qtyPur"].Value);
- if (t1 > t2)
- {
- //MessageUtil.ShowTips("编制量不能大于核准数量");
- //return;
- e.Cell.Value = Qb_newcellvalue;
- }
- double tempval1 = 0;
- foreach (UltraGridRow rows in e.Cell.Row.ParentRow.ChildBands[0].Rows)
- {
- if (rows.Cells["createQty"].Value != null && !String.IsNullOrEmpty(rows.Cells["createQty"].Value.ToString()) && Convert.ToBoolean(rows.Cells["isSelect"].Value) == true)
- {
- tempval1 = tempval1 + Convert.ToDouble(rows.Cells["createQty"].Value);
- }
- }
- //if (tempval1 > Qb_newParentVale)
- //{
- // e.Cell.Value = Qb_newcellvalue;
- //}
- //else
- //{
- // e.Cell.Row.ParentRow.Cells["SurQty"].Value = tempval1;
- //}
- e.Cell.Row.ParentRow.Cells["createQty"].Value = tempval1;
- }
- }
- }
- #endregion
- private void ultraGrid3_InitializeLayout(object sender, InitializeLayoutEventArgs e)
- {
- }
- }
- }
|