using Core.Mes.Client.Comm.Format; using Core.Mes.Client.Comm.Server; using Core.Mes.Client.Comm.Tool; using Core.StlMes.Client.Mcp.Treatment.Entity; using CoreFS.CA06; using Infragistics.Win.UltraWinEditors; using Infragistics.Win.UltraWinGrid; 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; namespace Core.StlMes.Client.Mcp.Treatment.HeatTreatment { public partial class FrmHttSteelChange : FrmBase { public FrmHttSteelChange() { InitializeComponent(); } private void FrmHttCoupling_Load(object sender, EventArgs e) { EntityHelper.ShowGridCaption(ultraGrid1.DisplayLayout.Bands[0]); getDropdown(SteelComboEditor, ob, false, "com.steering.ydm.bc.BaseOperations.getSteel", "STEELCODE", "STEELNAME");// 查询钢级 } /// /// 下拉赋值 /// public bool getDropdown(UltraComboEditor cmb, OpeBase ob, bool hasBlankLine, String m, String v, String d) { DataTable dt = ServerHelper.GetData(m, new object[] { }, ob); if (hasBlankLine && dt != null && dt.Rows.Count > 0) { DataRow dr = dt.NewRow(); dt.Rows.InsertAt(dr, 0); } cmb.DataSource = dt; cmb.DisplayMember = d; cmb.ValueMember = v; return true; } /// /// 重写基类方法 /// /// /// public override void ToolBar_Click(object sender, string ToolbarKey) { switch (ToolbarKey) { case "DoQuery": doQuery(); break; case "DoSave": doAdd(); break; case "DoUpdate": doUpdate(); break; case "DoRecover": doNullifyOrRecover("1"); break; case "DoNullify": doNullifyOrRecover("0"); break; case "Close": this.Close(); break; } } private void doQuery() { String nullifyFlag = "1"; // 作废状态(1:有效) if (nullifyFlagSearch.Checked) { nullifyFlag = ""; } List listSource = EntityHelper.GetData( "com.steering.mes.mcp.heatTreatment.FcaHttSteelChange.doQuery", new object[] { nullifyFlag }, this.ob); httSteelChangeEntityBindingSource.DataSource = listSource; for (int i = 0; i < ultraGrid1.Rows.Count; i++) { UltraGridRow row = ultraGrid1.Rows[i]; if (row.Cells["validflag"].Value.ToString().Equals("0")) { row.Appearance.ForeColor = Color.Red; } } } private void doAdd() { this.ultraGrid1.UpdateData(); IQueryable checkMagRows = this.ultraGrid1.Rows.AsQueryable().Where(" CHK = 'True'"); if (checkMagRows.Count() == 0) { MessageUtil.ShowTips("请选择需要新增的信息!"); return; } ArrayList parmList = new ArrayList(); foreach (UltraGridRow row in checkMagRows) { HttSteelChangeEntity entity = row.ListObject as HttSteelChangeEntity; if (!String.IsNullOrEmpty(entity.Id)) continue; entity.SteelCode = row.Cells["SteelName"].Value.ToString(); entity.SteelName = row.Cells["SteelName"].Text; entity.CreateName = UserInfo.GetUserName(); string baseEntity = JSONFormat.Format(entity); parmList.Add(baseEntity); } if (parmList.Count > 0) { CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.mes.mcp.heatTreatment.FcaHttSteelChange"; ccp.MethodName = "doAdd"; ccp.ServerParams = new object[] { parmList }; ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { doQuery(); MessageUtil.ShowTips("新增成功!"); } } } private void doUpdate() { this.ultraGrid1.UpdateData(); IQueryable checkMagRows = this.ultraGrid1.Rows.AsQueryable().Where(" CHK = 'True'"); if (checkMagRows.Count() == 0) { MessageUtil.ShowTips("请选择需要修改的信息!"); return; } ArrayList parmList = new ArrayList(); foreach (UltraGridRow row in checkMagRows) { HttSteelChangeEntity entity = row.ListObject as HttSteelChangeEntity; if (String.IsNullOrEmpty(entity.Id)) continue; entity.SteelCode = SteelComboEditor.Value.ToString(); entity.SteelName = SteelComboEditor.Text.ToString(); entity.UpdateName = UserInfo.GetUserName(); string baseEntity = JSONFormat.Format(entity); parmList.Add(baseEntity); } if (parmList.Count > 0) { CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.mes.mcp.heatTreatment.FcaHttSteelChange"; ccp.MethodName = "doUpdate"; ccp.ServerParams = new object[] { parmList }; ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { doQuery(); MessageUtil.ShowTips("修改成功!"); } } } private void doNullifyOrRecover(string flag) { this.ultraGrid1.UpdateData(); IQueryable checkMagRows = this.ultraGrid1.Rows.AsQueryable().Where(" CHK = 'True'"); String info = "1".Equals(flag) ? "恢复" : "作废"; if (checkMagRows.Count() == 0) { MessageUtil.ShowTips("请选择需要" + info + "的信息!"); return; } ArrayList parmList = new ArrayList(); foreach (UltraGridRow row in checkMagRows) { HttSteelChangeEntity entity = row.ListObject as HttSteelChangeEntity; if (String.IsNullOrEmpty(entity.Id)) continue; entity.DeleteName = UserInfo.GetUserName(); entity.Validflag = flag; string baseEntity = JSONFormat.Format(entity); parmList.Add(baseEntity); } if (parmList.Count > 0) { CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.mes.mcp.heatTreatment.FcaHttSteelChange"; ccp.MethodName = "doNullifyOrRecover"; ccp.ServerParams = new object[] { parmList }; ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { doQuery(); MessageUtil.ShowTips(info + "成功"); } } } } }