| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386 |
- 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 Infragistics.Win;
- using Infragistics.Win.UltraWinGrid;
- using Pur.Entity.configureEntity;
- using Pur.Entity.require_planEntiy;
- using Pur.Pop_upWindow;
- namespace Pur.require_plan
- {
- public partial class FrmRePlanChange : FrmPmsBase
- {
- //变量
- public ArrayList list;//变更的需求行信息
- public DataTable dtOld;//变更前数据备份
- public DataTable dtNew;//变更后的数据备份
- public FrmRePlanChange()
- {
- InitializeComponent();
- }
- public FrmRePlanChange(ArrayList List, OpeBase Ob)
- {
- InitializeComponent();
- this.ob = Ob;
- this.list = List;
- }
- private void FrmRePlanChange_Load(object sender, EventArgs e)
- {
- init();
- }
- /// <summary>
- /// 加载需要变更的数据
- /// </summary>
- private void init()
- {
- //加载待编辑数据
- if (list.Count > 0)
- {
- dtOld = this.execute<DataTable>("com.hnshituo.pur.requireplan.service.RequirePlanDService", "getJoinedByIds", new object[] { list });
- GridHelper.CopyDataToDatatable(dtOld, dataTable1, true);
- ultraGrid1.DisplayLayout.Bands[0].Override.AllowUpdate = DefaultableBoolean.False;
- ultraGrid2.DisplayLayout.Bands[0].Override.AllowUpdate = DefaultableBoolean.False;
- }
- else
- {
- MessageUtil.ShowTips("无待修改数据");
- }
- }
- /// <summary>
- /// 加载物料信息
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
- {
- clearTab();
- if (ultraGrid1.ActiveRow != null)
- {
- UltraGridRow uge = ultraGrid1.ActiveRow;
- String strmatCode = uge.GetCellValue("itemCode").ToString();
- txt_matCode.Text = strmatCode;
- String strmatName = uge.GetCellValue("itemName").ToString();
- txt_matName.Text = strmatName;
- getItemAttr();//获取物料属性
- getMatStandard();// 获取物料标准编号
- getMatUOM();// 获取单位转换
- string stritemUomId = uge.GetCellValue("itemUomId").ToString();
- string stritemStandardsId = uge.GetCellValue("itemStandardsId").ToString();
- string stritemAttrId = uge.GetCellValue("itemAttrId").ToString();
- setGridCheck(ultraGrid5, "itemUomId", stritemUomId);
- setGridCheck(ultraGrid3, "itemAttrId", stritemAttrId);
- setGridCheck(ultraGrid4, "itemStandardsId", stritemStandardsId);
- }
- }
- /// <summary>
- /// 清楚编辑区信息
- /// </summary>
- private void clearTab()
- {
- txt_matCode.Text = "";
- txt_matName.Text = "";
- dataTable5.Clear();
- dataTable6.Clear();
- dataTable7.Clear();
- }
- /// <summary>
- /// 获取物料属性
- /// </summary>
- /// <param name="parm"></param>
- private void getItemAttr()
- {
- dataTable5.Rows.Clear();
- Dictionary<string, object> param = new Dictionary<string, object>();
- param.Add("ItemCode", ultraGrid1.ActiveRow.Cells["ITEMCODE"].Value.ToString());
- param.Add("Validflag", "1");
- DataTable dt_mat = this.execute<DataTable>("com.hnshituo.pur.configure.service.MatAttrsService", "find", new object[] { param, 0, 0 });
- GridHelper.CopyDataToDatatable(ref dt_mat, ref dataTable5, true);//获取物料属性
- }
- /// <summary>
- /// 获取物料标准编号
- /// </summary>
- private void getMatStandard()
- {
- dataTable6.Rows.Clear();
- if (ultraGrid1.ActiveRow != null)
- {
- PurMatStandardsEntity PurMatStandards_Entity = new PurMatStandardsEntity();
- PurMatStandards_Entity.Validflag = "1";
- PurMatStandards_Entity.ItemCode = ultraGrid1.ActiveRow.Cells["ITEMCODE"].Value.ToString();
- DataTable dt_matStandards = this.execute<DataTable>("com.hnshituo.pur.configure.service.MatStandardsService", "find", new object[] { PurMatStandards_Entity, 0, 0 });
- GridHelper.CopyDataToDatatable(ref dt_matStandards, ref dataTable6, true);//绑定物料规格
- }
- }
- /// <summary>
- /// 获取单位转换
- /// </summary>
- private void getMatUOM()
- {
- dataTable7.Rows.Clear();
- if (ultraGrid1.ActiveRow != null)
- {
- PurMatUomsEntity MatUomsEntity = new PurMatUomsEntity();
- MatUomsEntity.ItemCode = ultraGrid1.ActiveRow.Cells["ITEMCODE"].Value.ToString();
- MatUomsEntity.Validflag = "1";
- DataTable dt_matUOM = this.execute<DataTable>("com.hnshituo.pur.configure.service.MatUomsService", "find", new object[] { MatUomsEntity, 0, 0 });
- GridHelper.CopyDataToDatatable(ref dt_matUOM, ref dataTable7, true);//绑定物料规格
- }
- }
- /// <summary>
- /// 设置Check点击
- /// </summary>
- /// <param name="ultraGrid1"></param>
- /// <param name="p"></param>
- /// <param name="stritemUomId"></param>
- private void setGridCheck(UltraGrid ultraGrid, string p, string stritemUomId)
- {
- foreach (UltraGridRow row in ultraGrid.Rows)
- {
- if (row.GetCellValue(p).ToString() == stritemUomId)
- {
- row.Cells["Check"].Value = true;
- row.Activated = true;
- }
- else
- {
- row.Cells["Check"].Value = false;
- row.Activated = false;
- }
- }
- }
- /// <summary>
- /// ultraGrid3的Check选择事件1
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ultraGrid3_CellChange(object sender, CellEventArgs e)
- {
-
- foreach (UltraGridRow row in ultraGrid3.Rows)
- {
- if (row == e.Cell.Row)
- {
- row.Cells["Check"].Value = true;
- }
- else
- {
- row.Cells["Check"].Value = false;
- }
- }
- ultraGrid3.UpdateData();
- }
- /// <summary>
- /// ultraGrid4的Check选择事件1
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ultraGrid4_CellChange(object sender, CellEventArgs e)
- {
-
- foreach (UltraGridRow row in ultraGrid4.Rows)
- {
- if (row == e.Cell.Row)
- {
- row.Cells["Check"].Value = true;
- }
- else
- {
- row.Cells["Check"].Value = false;
- }
- }
- ultraGrid4.UpdateData();
- }
- /// <summary>
- /// ultraGrid5的Check选择事件1
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ultraGrid5_CellChange(object sender, CellEventArgs e)
- {
-
- foreach (UltraGridRow row in ultraGrid5.Rows)
- {
- if (row == e.Cell.Row)
- {
- row.Cells["Check"].Value = true;
- }
- else
- {
- row.Cells["Check"].Value = false;
- }
- }
- ultraGrid5.UpdateData();
- }
- private void ultraToolbarsManager1_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
- {
- switch (e.Tool.Key)
- {
- case "doSure": // ButtonTool
- doSure();
- break;
- case "doCancel": // ButtonTool
- this.Close();
- break;
- case "doChage": // ButtonTool
- doChange();
- break;
- }
- }
- /// <summary>
- ///
- /// </summary>
- private void doSure()
- {
- if (ultraGrid2.Rows.Count >= 1)
- {
- UltraGridRow uge=ultraGrid2.Rows[0];
- RequirePlanD rd = new RequirePlanD();
- rd.MrLineId = uge.GetCellValue("mrLineId").ToString().Trim();
- rd.NewItemUnique=uge.GetCellValue("newItemUnique").ToString().Trim();
- rd.NewItemUomId=uge.GetCellValue("newItemUomId").ToString().Trim();
- rd.NewItemStandardsId=uge.GetCellValue("newItemStandardsId").ToString().Trim();
- rd.NewItemStandardsCode=uge.GetCellValue("newItemStandardsCode").ToString().Trim();
- rd.NewItemAttrId=uge.GetCellValue("newItemAttrId").ToString().Trim();
- rd.ItemAttr=uge.GetCellValue("itemAttr").ToString().Trim();
- rd.WeightUnit=uge.GetCellValue("weightUnit").ToString().Trim();
- rd.ItemUomConefficient=Convert.ToDouble(uge.GetCellValue("itemUomConefficient"));
- rd.ItemUom=uge.GetCellValue("itemUom").ToString().Trim();
- rd.UpdateName = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName();
- rd.UpdateUserid = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserID();
- rd.UpdateTime = DateTime.Now;
- if (MessageUtil.ShowYesNoAndQuestion("是否确定要修改?") == DialogResult.No)
- {
- return;
- }
- CoreResult rt = this.execute<CoreResult>("com.hnshituo.pur.requireplan.service.RequirePlanDService", "doUpdate", new object[] { rd });
- if (rt.Resultcode != 0)
- {
- MessageUtil.ShowTips("修改失败!" + rt.Resultmsg);
- return;
- }
- else
- {
- MessageUtil.ShowTips("修改成功!" + rt.Resultmsg);
- this.Close();
- return;
- }
- }
- else
- {
- MessageUtil.ShowTips("无待提交的修改数据");
- return;
- }
- }
- /// <summary>
- ///
- /// </summary>
- private void doChange()
- {
- if (ultraGrid1.ActiveRow == null)
- {
- MessageUtil.ShowTips("请选择需要修改的行");
- return;
- }
- ultraGrid3.UpdateData();
- ultraGrid4.UpdateData();
- ultraGrid5.UpdateData();
- UltraGridRow uge3 = ultraGrid3.ActiveRow;//属性
- UltraGridRow uge4 = ultraGrid4.ActiveRow;//标准编号
- UltraGridRow uge5 = ultraGrid5.ActiveRow;//单位
- String itemCode = ultraGrid1.ActiveRow.Cells["itemCode"].Value.ToString().Trim();
- String itemUniqueOld = ultraGrid1.ActiveRow.Cells["itemUnique"].Value.ToString().Trim();
- String newitemUniqueOld = ultraGrid1.ActiveRow.Cells["newItemUnique"].Value.ToString().Trim();
- String itemAttrId="";
- String itemStandardsId="";
- String itemUomId="";
- String itemAttr = "";
- String itemAttrCode = "";
- String standardsId = "";
- String standardsCode = "";
- String weightUnit="";
- String weightUnitCode ="";
- String itemUomConefficient = "";
- String uomCode = "";
- String uomName = "";
- if (uge3 != null)//属性
- {
- itemAttr = uge3.Cells["itemAttr"].Value.ToString().Trim();
- itemAttrCode = uge3.Cells["ITEMATTRCODE"].Value.ToString().Trim();
- itemAttrId = uge3.Cells["itemAttrId"].Value.ToString().Trim();
- }
- if (uge4 != null)//标准编号
- {
- itemStandardsId = uge4.Cells["itemStandardsId"].Value.ToString().Trim();
- standardsId = uge4.Cells["standardsId"].Value.ToString().Trim();
- standardsCode = uge4.Cells["standardsCode"].Value.ToString().Trim();
- }
- if (uge5 != null)//采购单位
- {
- itemUomId = uge5.Cells["itemUomId"].Value.ToString().Trim();
- weightUnit = uge5.Cells["weightUnit"].Value.ToString().Trim();
- weightUnitCode = uge5.Cells["weightUnitCode"].Value.ToString().Trim();
- itemUomConefficient = uge5.Cells["itemUomConefficient"].Value.ToString();
- uomCode = uge5.Cells["uomCode"].Value.ToString().Trim();
- uomName = uge5.Cells["uomName"].Value.ToString().Trim();
- }
- //所选物料唯一标识值
- String ItemUnique = itemCode + itemAttrId + itemStandardsId + itemUomId;
- if (itemUniqueOld == ItemUnique || newitemUniqueOld == ItemUnique)
- {
- MessageUtil.ShowTips("未发现有修改,请确定");
- return;
- }
- DataTable dtOld1 = dtOld.Copy();
- DataRow myDr = dtOld1.Rows[0];
- myDr["newItemUnique"] = ItemUnique;
- myDr["newItemUomId"] = itemUomId;
- myDr["newItemStandardsId"] = itemStandardsId;
- myDr["newItemStandardsCode"] = standardsCode;
- myDr["newItemAttrId"] = itemAttrId;
- myDr["itemAttr"] = itemAttr;
- myDr["weightUnit"] = weightUnit;
- myDr["itemUomConefficient"] = itemUomConefficient;
- myDr["itemUom"] = uomName;
- //删除重复行
- if (dtNew == null)
- {
- dtNew = dtOld.Clone();
- dtNew.Rows.Add(myDr.ItemArray);
- }
- else
- {
- if (dtNew.Rows.Count > 0)
- {
- for (int i = dtNew.Rows.Count - 1; i >= 0; i--)
- {
- if (dtNew.Rows[i]["itemUnique"] == myDr["itemUnique"])
- {
- dtNew.Rows.RemoveAt(i);
- }
- }
- }
- //加行
- dtNew.Rows.Add(myDr.ItemArray);
- }
- GridHelper.CopyDataToDatatable(dtNew, dataTable2, true);
- }
- }
- }
|