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 Core.Mes.Client.Comm.Format; using Core.Mes.Client.Comm.Server; using Core.Mes.Client.Comm.Tool; using Core.StlMes.Client.PlnSaleOrd.BaseMethod; using Core.StlMes.Client.PlnSaleOrd.Entity; using CoreFS.CA06; using Infragistics.Win.UltraWinGrid; namespace Core.StlMes.Client.PlnSaleOrd { public partial class FrmBaseMaterialDPl : FrmBase { private string _inMaterialNo = ""; private string _outMaterialNo = ""; private string _inMaterialDesc = ""; private string _outMaterialDesc = ""; private string _plineCode = ""; public FrmBaseMaterialDPl() { InitializeComponent(); } public FrmBaseMaterialDPl(string inMaterialNo, string outMaterialNo, string plineCode, OpeBase ob) { this._inMaterialNo = inMaterialNo; this._outMaterialNo = outMaterialNo; this._plineCode = plineCode; this.ob = ob; InitializeComponent(); this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; } private void FrmBaseMaterialDPl_Load(object sender, EventArgs e) { EntityHelper.ShowGridCaption(ultraGridZg.DisplayLayout.Bands[0]); BaseHelper.setColumnBackColor(ultraGridZg, new string[] { "HrCapcty", "PrdRate", "DisableFl", "WasteRate", "PlineCode", "PlineLevel", "DblLenMax", "cropHead", "CropEnd", "RolLenMin", "RolLenMax", "MandrelSize", "TubeEndRatio" }); BaseHelper.InitCellPosition(ultraGridZg, new string[] { "HrCapcty", "PrdRate", "WasteRate", "PlineCode", "DblLenMax", "CropEnd", "RolLenMin", "RolLenMax", "MandrelSize", "TubeEndRatio" }); InitMaterial(); //如果在基础镦拔扩找不到,则不执行 if (_inMaterialDesc.Equals("")) { ultraGridZg.Enabled = false; return; } Query(); } private void InitMaterial() { DataTable dt = ServerHelper.GetData("com.steering.pss.plnsaleord.processOrder.FrmBaseMaterialDPl.getBaseMaterialD", new object[] { _inMaterialNo, _outMaterialNo }, this.ob); if (dt != null && dt.Rows.Count > 0) { _inMaterialDesc = dt.Rows[0]["IN_MATERIAL_DESC"].ToString(); _outMaterialDesc = dt.Rows[0]["OUT_MATERIAL_DESC"].ToString(); } } public void Query() { List materialFPlEntityList = EntityHelper.GetData( "com.steering.pss.plnsaleord.processOrder.FrmBaseMaterialDPl.getBaseMaterialDPl", new object[] { _inMaterialNo, _outMaterialNo }, ob); slmBaseMaterialDPlEntityBindingSource.DataSource = materialFPlEntityList; if (!_plineCode.Equals("")) { IQueryable chcRows = ultraGridZg.Rows.AsQueryable().Where(a => a.GetValue("PlineCode") == _plineCode); if (chcRows != null && chcRows.Count() != 0) { chcRows.First().Activate(); chcRows.First().Cells["CHC"].Value = true; } } } private void update() { try { ultraGridZg.UpdateData(); IQueryable chcRows = ultraGridZg.Rows.AsQueryable().Where(a => a.GetValue("CHC") == "True"); if (chcRows == null || chcRows.Count() == 0) { MessageUtil.ShowTips("请选择记录!"); return; } ArrayList param = new ArrayList(); foreach (UltraGridRow ugr in chcRows) { SlmBaseMaterialDPlEntity entity = (SlmBaseMaterialDPlEntity)ugr.ListObject; entity.UpdateName = UserInfo.GetUserName(); string jsonStr = JSONFormat.Format(entity); param.Add(jsonStr); } if (MessageUtil.ShowYesNoAndQuestion("是否修改记录?") == DialogResult.No) { return; } ServerHelper.SetData("com.steering.pss.plnsaleord.processOrder.FrmBaseMaterialDPl.updateBaseMaterialDPl", new object[] { param }, this.ob); Query(); MessageUtil.ShowTips("修改成功!"); } catch (Exception e) { MessageUtil.ShowTips(e.Message+" 数据异常,请重新操作!"); } } private void ultraGridZg_InitializeRow(object sender, InitializeRowEventArgs e) { BaseHelper.ControlCellEdit(e.Row); } private void ultraToolbarsManager1_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e) { switch (e.Tool.Key) { case "Query": Query(); break; case "Update": update(); break; case "Close": this.Close(); break; default: break; } } } }