using System; using System.Collections.Generic; using System.Linq; using Core.Mes.Client.Comm.Tool; using Core.StlMes.Client.LgClassModel; using Core.StlMes.Client.LgCommon; using Core.StlMes.Client.PnCost.Models; using Infragistics.Win.UltraWinGrid; using Infragistics.Win; using System.Data; using Core.Mes.Client.Comm.Server; using CoreFS.CA06; using System.Windows.Forms; namespace Core.StlMes.Client.PnCost { public partial class ucCf : ucNewResBase { public ucCf() { InitializeComponent(); ClsControlPack.SetUltraGridStyle(ugData, 1); } protected OpeBase Ob; public void SetBase(OpeBase ob) { Ob = ob; steelTypeCode(); setSgSign(); } public StlEafOptinfoEntity CurrentData = new StlEafOptinfoEntity(); protected override void OnLoad(EventArgs e) { base.OnLoad(e); EntityHelper.ShowGridCaption(ugData.DisplayLayout.Bands[0]); ugData.DisplayLayout.Bands[0].Override.HeaderClickAction = HeaderClickAction.Select; SetData(new List { new TqnqD01Entity() }); SetControlDelegate(); // ugData.DisplayLayout.Bands[0].Columns["SgSign"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDown; // ValueList v1 = steelTypeCode(); } protected virtual void SetControlDelegate() { ugData.AfterCellUpdate += new CellEventHandler(ugData_AfterCellUpdate); ugData.KeyDown += new KeyEventHandler(ugData_KeyDown); ugData.KeyPress += ugData_KeyPress; ugData.ClickCellButton += new CellEventHandler(ugData_ClickCellButton); } protected virtual void ugData_ClickCellButton(object sender, CellEventArgs e) { try { if (e.Cell.Column.DataType == typeof(Decimal) || e.Cell.Column.DataType == typeof(Decimal?)) { frmInputDecimal frm = new frmInputDecimal(Convert.ToString(e.Cell.Text)); frm.Location = ClsControlPack.GetChildWindowLocation(frm.Size); if (frm.ShowDialog() == DialogResult.OK) { if (!frm.ValueChanged) return; e.Cell.Value = frm.Value; ugData.UpdateData(); } } } catch { } } private void ugData_KeyPress(object sender, KeyPressEventArgs e) { try { UltraGridCell cell = ugData.ActiveCell; string strKey = this.ugData.ActiveCell.Column.ToString(); if (strKey.Equals("SgSign") || strKey.Equals("CIC") || strKey.Equals("CICGID") || strKey.Equals("InSteelTypeCode") || strKey.Equals("SmeltCode")) return; //if (e.KeyCode != Keys.Enter || cell.Column.CellActivation != Activation.AllowEdit) return; } catch { } } protected virtual void ugData_KeyDown(object sender, KeyEventArgs e) { try { UltraGridCell cell = ugData.ActiveCell; string strKey = this.ugData.ActiveCell.Column.ToString(); if (strKey.Equals("SgSign") || strKey.Equals("CIC") || strKey.Equals("CICGID") || strKey.Equals("InSteelTypeCode") || strKey.Equals("SmeltCode")) return; if (e.KeyCode != Keys.Enter || cell.Column.CellActivation != Activation.AllowEdit) return; } catch { } } protected virtual void ugData_AfterCellUpdate(object sender, CellEventArgs e) { try { string strKey = this.ugData.ActiveCell.Column.ToString(); if (!e.Cell.Column.Hidden && e.Cell.Column.CellActivation == Activation.AllowEdit) { UltraGridRow row = e.Cell.Row; if (strKey.Equals("SgSign", StringComparison.OrdinalIgnoreCase)) { string siSign = row.Cells["SgSign"].Text.ToString(); setCic(siSign); } else if (strKey.Equals("CIC", StringComparison.OrdinalIgnoreCase)) { string siSign = row.Cells["SgSign"].Text.ToString(); string cic = row.Cells["CiC"].Text.ToString(); setCraftNo(siSign,cic); } else if (strKey.Equals("CICGID", StringComparison.OrdinalIgnoreCase)) { string SmeltCode = row.Cells["SmeltCode"].Text.ToString(); string SgSign = row.Cells["SgSign"].Text.ToString(); string SgStd = row.Cells["SgStd"].Text.ToString(); string InSteelTypeCode = row.Cells["InSteelTypeCode"].Text.ToString(); string Cic = row.Cells["Cic"].Text.ToString(); string cicGid = row.Cells["cicGid"].Text.ToString(); // string cic = row.Cells["CiC"].Text.ToString(); setCf(SmeltCode,SgSign,SgStd,InSteelTypeCode,Cic,cicGid); } } } catch { } } public TqnqD01Entity TqnqD01Entity() { UltraGridRow row = ugData.Rows[0]; return (TqnqD01Entity)row.ListObject; } private void setCf(string SmeltCode,string SgSign,string SgStd,string InSteelTypeCode,string Cic,string cicGid) { if (cicGid.Equals("") || cicGid == null) return; if (SmeltCode.Equals("") || SmeltCode == null) return; if (SgSign.Equals("") || SgSign == null) return; if (SgStd.Equals("") || SgStd == null) return; if (InSteelTypeCode.Equals("") || InSteelTypeCode == null) return; if (Cic.Equals("") || Cic == null) return; if (cicGid.Equals("") || cicGid == null) return; List data = EntityHelper.GetData( "com.steering.mes.cost.FrmTqnqd01.QueryCf", new object[] { cicGid }, Ob); if (data != null && data.Count > 0) { ugData.DataSource = data; for (int i = 0; i < ugData.Rows.Count; i++) { ugData.Rows[i].Cells["SmeltCode"].Value = SmeltCode; ugData.Rows[i].Cells["SgSign"].Value = SgSign; ugData.Rows[i].Cells["SgStd"].Value = SgStd; ugData.Rows[i].Cells["InSteelTypeCode"].Value = InSteelTypeCode; ugData.Rows[i].Cells["Cic"].Value = Cic; ugData.Rows[i].Cells["cicGid"].Value = cicGid; } } // this.ugData.Rows[0].Activate(); } /// /// 钢种分类 /// private void steelTypeCode() { ValueList v1 = new ValueList(); v1.ValueListItems.Add("不锈钢"); v1.ValueListItems.Add("合金钢"); v1.ValueListItems.Add("非合金钢"); v1.ValueListItems.Add("高铬合金钢"); v1.ValueListItems.Add("低合金钢"); ugData.DisplayLayout.Bands[0].Columns["InSteelTypeCode"].ValueList = v1; ValueList v2 = new ValueList(); v2.ValueListItems.Add("一电炉一连铸"); v2.ValueListItems.Add("二电炉二连铸"); v2.ValueListItems.Add("二电炉三连铸"); ugData.DisplayLayout.Bands[0].Columns["SmeltCode"].ValueList = v2; } /// /// 牌号 /// private void setSgSign() { DataTable dt = ServerHelper.GetData("com.steering.mes.cost.FrmTqnqd01.QuerySgSign", null, Ob); if (dt.Rows.Count > 0) { ValueList v1 = new ValueList(); if (dt.Rows.Count > 0) { foreach (DataRow dr in dt.Rows) { v1.ValueListItems.Add(dr["BASECODE"].ToString(), dr["BASENAME"].ToString()); } } ugData.DisplayLayout.Bands[0].Columns["SGSIGN"].ValueList = v1; } } /// /// 索引号 /// private void setCic(string gradName) { ValueList v1 = new ValueList(); DataTable dt = ServerHelper.GetData("com.steering.mes.cost.FrmTqnqd01.Querycic", new object[] { gradName }, Ob); if (dt.Rows.Count > 0) { foreach (DataRow dr in dt.Rows) { v1.ValueListItems.Add(dr["CIC"].ToString()); } } ugData.DisplayLayout.Bands[0].Columns["CIC"].ValueList = v1; } /// /// 工艺卡号 /// private void setCraftNo(string gradName,string cic) { ValueList v1 = new ValueList(); DataTable dt = ServerHelper.GetData("com.steering.mes.cost.FrmTqnqd01.QueryCraftNo", new object[] { gradName, cic },Ob); if (dt.Rows.Count > 0) { foreach (DataRow dr in dt.Rows) { v1.ValueListItems.Add(dr["cicGid"].ToString()); } } ugData.DisplayLayout.Bands[0].Columns["CICGID"].ValueList = v1; } public StlEafOptinfoEntity GetStlEafOptinfoEntity(string strStoveNo) { try { //var list = // EntityHelper.GetData( // "Core.LgMes.Server.LgDeviceManager.PerformanceManage.SelectStlEafOptinfoEntity", // new object[] {strStoveNo}, Ob); //if ((list == null) || (list.Count <= 0)) // return new StlEafOptinfoEntity // { // StoveNo = strStoveNo, // Optdate = DateTime.Now // }; //return list.FirstOrDefault(); return null; } catch (Exception ex) { return new StlEafOptinfoEntity { StoveNo = strStoveNo, Optdate = DateTime.Now }; } } } }