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.炼钢计划; using Core.StlMes.Client.PlnSaleOrd.炼钢计划.entity; using CoreFS.CA06; using Infragistics.Win; using Infragistics.Win.UltraWinEditors; using Infragistics.Win.UltraWinGrid; namespace Core.StlMes.Client.PlnSaleOrd { public partial class FrmPlnBasePlineLg : FrmBase { public FrmPlnBasePlineLg() { InitializeComponent(); } private void FrmPlnBasePlineLg_Load(object sender, EventArgs e) { EntityHelper.ShowGridCaption(ultraGridBaseLg.DisplayLayout.Bands[0]); BaseHelper.setOtherColumnReadOnly(ultraGridBaseLg, new string[] { "" }); BaseHelper.InitCellPosition(ultraGridBaseLg, new string[] { "EfMaxLife", "StdOutWt", "EfWtLeft", "StdWtEnd", "OutWtMax", "OutWtMin", "EfAgeNow" }); SteelHelper.InitPline(comPlineA, "A", this.ob); SteelHelper.InitProcess(comProcess, "A", this.ob); } public override void ToolBar_Click(object sender, string ToolbarKey) { switch (ToolbarKey.Trim()) { case "Query": Query(); break; case "Add": Add(); break; case "Update": Update(); break; case "Delete": Delete(); break; case "Close": this.Close(); break; default: break; } } private void Query() { List listSource = EntityHelper.GetData ("com.steering.pss.plnsaleord.steelMarkingPlan.FrmPlnBasePlineLg.query", new object[] { }, ob); plnBasePlineLgEntityBindingSource.DataSource = listSource; } private void Add() { string plineCode = comPlineA.Value == null ? "" : comPlineA.Value.ToString(); if (plineCode.Equals("")) { MessageUtil.ShowWarning("请选择电炉产线!"); return; } string plineName = comPlineA.Text; bool flag = ChcSpec(plineCode); if (flag) { MessageUtil.ShowWarning("电炉产线:" + plineName + "已经存在,不能新增!"); return; } string proceeCode = comProcess.Value == null ? "" : comProcess.Value.ToString(); string processDesc = comProcess.Text; string schedulecode = txtCode.Text.Trim(); string efMaxLife = txtMaxLife.Value == null ? "0" : txtMaxLife.Value.ToString(); string efAgeNow = txtNowage.Value == null ? "0" : txtNowage.Value.ToString(); string efWtLeft = txtLeft.Value == null ? "0" : txtLeft.Value.ToString(); string stdOutWt = txtStandSteel.Value == null ? "0" : txtStandSteel.Value.ToString(); string outWtMax = txtSteelMax.Value == null ? "0" : txtSteelMax.Value.ToString(); string outWtMin = txtMinSteel.Value == null ? "0" : txtMinSteel.Value.ToString(); if (MessageUtil.ShowYesNoAndQuestion("是否新增?") == DialogResult.No) { return; } ServerHelper.SetData("com.steering.pss.plnsaleord.steelMarkingPlan.FrmPlnBasePlineLg.add", new string[] { plineCode, plineName, proceeCode, processDesc, efMaxLife, stdOutWt, efWtLeft, outWtMax, outWtMin, efAgeNow, UserInfo.GetUserName(), schedulecode}, this.ob); MessageUtil.ShowTips("新增成功!"); Query(); if (ultraGridBaseLg.Rows.Count > 0) foreach (UltraGridRow ugr in ultraGridBaseLg.Rows) { if (ugr.Cells["PlineCode"].Value.ToString().Equals(plineCode)) { ugr.Activate(); } } } private void Delete() { UltraGridRow ugr = ultraGridBaseLg.ActiveRow; if (ugr == null) { MessageUtil.ShowWarning("请选择要删除的记录!"); return; } string PlineCodeB = ugr.Cells["PlineCode"].Text.Trim(); string PlineNameB = ugr.Cells["PlineName"].Text.Trim(); if (MessageUtil.ShowYesNoAndQuestion("是否删除电炉:" + PlineNameB + "基础数据?(此删除不可恢复)") == DialogResult.No) { return; } ServerHelper.SetData("com.steering.pss.plnsaleord.steelMarkingPlan.FrmPlnBasePlineLg.delete", new string[] { PlineCodeB }, this.ob); MessageUtil.ShowTips("删除成功!"); Query(); } private void Update() { string plineCode = comPlineA.Value == null ? "" : comPlineA.Value.ToString(); if (plineCode.Equals("")) { MessageUtil.ShowWarning("请选择电炉产线!"); return; } string plineName = comPlineA.Text; bool flag = ChcSpec(plineCode); if (!flag) { MessageUtil.ShowWarning("电炉产线:" + plineName + "不存在,不能修改!"); return; } string proceeCode = comProcess.Value == null ? "" : comProcess.Value.ToString(); string processDesc = comProcess.Text; string schedulecode = txtCode.Text.Trim(); string efMaxLife = txtMaxLife.Value == null ? "0" : txtMaxLife.Value.ToString(); string efAgeNow = txtNowage.Value == null ? "0" : txtNowage.Value.ToString(); string efWtLeft = txtLeft.Value == null ? "0" : txtLeft.Value.ToString(); string stdOutWt = txtStandSteel.Value == null ? "0" : txtStandSteel.Value.ToString(); string outWtMax = txtSteelMax.Value == null ? "0" : txtSteelMax.Value.ToString(); string outWtMin = txtMinSteel.Value == null ? "0" : txtMinSteel.Value.ToString(); if (MessageUtil.ShowYesNoAndQuestion("是否修改?") == DialogResult.No) { return; } ServerHelper.SetData("com.steering.pss.plnsaleord.steelMarkingPlan.FrmPlnBasePlineLg.update", new string[] { plineCode, plineName, proceeCode, processDesc, efMaxLife, stdOutWt, efWtLeft, outWtMax, outWtMin, efAgeNow, UserInfo.GetUserName(), schedulecode }, this.ob); MessageUtil.ShowTips("修改成功!"); Query(); if (ultraGridBaseLg.Rows.Count > 0) foreach (UltraGridRow ugr in ultraGridBaseLg.Rows) { if (ugr.Cells["PlineCode"].Value.ToString().Equals(plineCode)) { ugr.Activate(); } } } bool ChcSpec(string plineCode) { DataTable dt = ServerHelper.GetData("com.steering.pss.plnsaleord.steelMarkingPlan.FrmPlnBasePlineLg.checkPline", new string[] { plineCode }, this.ob); if (dt == null || dt.Rows.Count == 0) { return false; } else { if (dt.Rows[0][0].ToString().Equals("1")) { return true; } else { return false; } } } private void ultraGridBaseLg_AfterRowActivate(object sender, EventArgs e) { UltraGridRow ugr = ultraGridBaseLg.ActiveRow; if (ugr == null) { return; } PlnBasePlineLgEntity entity = (PlnBasePlineLgEntity)ugr.ListObject; comPlineA.Value = entity.PlineCode; comProcess.Value = entity.ProcessCode; txtCode.Value = entity.ScheduleCode; txtMaxLife.Value = entity.EfMaxLife; txtNowage.Value = entity.EfAgeNow; txtLeft.Value = entity.EfWtLeft; txtStandSteel.Value = entity.StdOutWt; txtSteelMax.Value = entity.OutWtMax; txtMinSteel.Value = entity.OutWtMin; } } }