using Core.Mes.Client.Comm.Control; using Core.Mes.Client.Comm.Format; using Core.Mes.Client.Comm.Server; using Core.Mes.Client.Comm.Tool; using Core.StlMes.Client.ZGMil.Entity; using CoreFS.CA06; 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.Text.RegularExpressions; using System.Windows.Forms; namespace Core.StlMes.Client.ZGMil.Signature { public partial class FrmScrapStoveApplyDescion : FrmBase { public FrmScrapStoveApplyDescion() { InitializeComponent(); } private string departCode = "";//所属权 private void FrmScrapStoveApplyDescion_Load(object sender, EventArgs e) { dtBathYear.Value = DateTime.Parse(DateTime.Now.ToString("yyyy-MM")); EntityHelper.ShowGridCaption(ultraGrid1.DisplayLayout.Bands[0]); EntityHelper.ShowGridCaption(ultraGrid2.DisplayLayout.Bands[0]); EntityHelper.ShowGridCaption(ultraGrid3.DisplayLayout.Bands[0]); } /// /// 基类方法 /// /// /// public override void ToolBar_Click(object sender, string ToolbarKey) { switch (ToolbarKey) { case "Query": queryData(); break; case"QueryScrap": queryScrapData(); break; case "insertScrapMata": insertScrapMata(); break; case "insertWhiteBank": insertWhiteBank(); break; case"cancelScrapMata": cancelScrapMata(); break; case "Export": ExportData(); break; case "Close": this.Close(); break; } } /// /// 查询整炉废 /// private void queryScrapData() { string jugeNo = ""; string bathYear = this.dtBathYear.Value.ToString("yyyyMM"); string plineCode = this.ultraComboEditor1.Value.ToString(); if (this.ultraComboEditor1.Text.ToString() == "") { MessageUtil.ShowTips("请选择产线!"); return; } //departCode = ClsBaseInfo.GetDepartIdBySectionId(this.UserInfo.GetDeptid(), this.ob); if (this.chkHeatNo2.Checked) { if (this.txtHeatNo2.Text.Trim() == "") { MessageUtil.ShowTips("请输入炉号!"); } else { jugeNo = this.txtHeatNo2.Text.Trim(); } } ArrayList parmList = new ArrayList(); parmList.Add(jugeNo); parmList.Add(bathYear); parmList.Add(plineCode); List listSource = EntityHelper.GetData( "com.steering.mes.signature.FrmScrapStoveApplyDescion.doQueryMata", new object[] { parmList }, this.ob); PortMilBatchSampleResultEntity1bindingSource.DataSource = listSource; queryQcm(); } /// /// 查询白条信息 /// private void queryData() { string jugeNo = ""; string bathYear = this.dtBathYear.Value.ToString("yyyyMM"); string plineCode = this.ultraComboEditor1.Value.ToString(); if (this.ultraComboEditor1.Text.ToString() == "") { MessageUtil.ShowTips("请选择产线!"); return; } //departCode = ClsBaseInfo.GetDepartIdBySectionId(this.UserInfo.GetDeptid(), this.ob); if(this.chkHeatNo2.Checked) { if (this.txtHeatNo2.Text.Trim() == "") { MessageUtil.ShowTips("请输入炉号!"); } else { jugeNo = this.txtHeatNo2.Text.Trim(); } } ArrayList parmList = new ArrayList(); parmList.Add(jugeNo); parmList.Add(bathYear); parmList.Add(plineCode); List listSourceS = EntityHelper.GetData( "com.steering.mes.signature.FrmScrapStoveApplyDescion.doQueryBTMata", new object[] { parmList }, this.ob); PortMilBatchSampleResultEntitybindingSource.DataSource = listSourceS; queryQcm(); } /// /// 查询当月所有白条\ 整炉废判定数据 /// public void queryQcm() { string jugeNo = ""; string bathYear = this.dtBathYear.Value.ToString("yyyyMM"); string plineCode = this.ultraComboEditor1.Value.ToString(); if (this.ultraComboEditor1.Text.ToString() == "") { MessageUtil.ShowTips("请选择产线!"); return; } //departCode = ClsBaseInfo.GetDepartIdBySectionId(this.UserInfo.GetDeptid(), this.ob); if (this.chkHeatNo2.Checked) { if (this.txtHeatNo2.Text.Trim() == "") { MessageUtil.ShowTips("请输入炉号!"); } else { jugeNo = this.txtHeatNo2.Text.Trim(); } } ArrayList parmList = new ArrayList(); parmList.Add(jugeNo); parmList.Add(bathYear); parmList.Add(plineCode); List listSource = EntityHelper.GetData( "com.steering.mes.signature.FrmScrapStoveApplyDescion.doQueryQcmMata", new object[] { parmList }, this.ob); QcmZgJugdeApplyEntitybindingSource.DataSource = listSource; } /// /// 增加整炉判废判定记录 /// private void insertScrapMata() { this.ultraGrid3.UpdateData(); IQueryable checkMagRows = this.ultraGrid3.Rows.AsQueryable().Where(" CHK = 'True'"); if (checkMagRows.Count()==0) { MessageUtil.ShowTips("请选择需要整炉废信息"); return; } ArrayList parmList = new ArrayList(); foreach (UltraGridRow uRow in checkMagRows) { MilPlanEntity3 milPlanEntity = (MilPlanEntity3)uRow.ListObject; string mPlanTity = JSONFormat.Format(milPlanEntity); parmList.Add(mPlanTity); } CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.mes.signature.FrmScrapStoveApplyDescion"; ccp.MethodName = "doDecisionScrap"; ccp.ServerParams = new object[] { parmList, this.UserInfo.GetUserName() }; ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { if (ccp.ReturnInfo.Equals("送判成功!")) { queryScrapData(); MessageUtil.ShowTips(ccp.ReturnInfo); } else { MessageUtil.ShowTips(ccp.ReturnInfo); } } } /// /// 增加白条判定记录 /// private void insertWhiteBank() { 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 uRow in checkMagRows) { MilPlanEntity3 milPlanEntity = (MilPlanEntity3)uRow.ListObject; //if (!IsInt(milPlanEntity.ActCount.ToString())) //{ // MessageUtil.ShowTips("支数请输入整数!"); // return; //} //if (!IsNumber(milPlanEntity.ActWeight.ToString())) //{ // MessageUtil.ShowTips("重量请输入数字!"); // return; //} string mPlanTity = JSONFormat.Format(milPlanEntity); parmList.Add(mPlanTity); } CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.mes.signature.FrmScrapStoveApplyDescion"; ccp.MethodName = "insertWhiteBank"; ccp.ServerParams = new object[] { parmList, this.UserInfo.GetUserName() }; ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { if (ccp.ReturnInfo.Equals("送判成功!")) { queryData(); MessageUtil.ShowTips(ccp.ReturnInfo); } else { MessageUtil.ShowTips(ccp.ReturnInfo); } } } /// /// 检验是否为数字 /// /// 需要检验的字符串 /// 是否为数字:true代表是,false代表否 public static bool IsNumber(string str) { Regex rx = new Regex(@"^[+-]?[0123456789]*[.]?[0123456789]*$"); return rx.IsMatch(str); } /// /// 检验是否是整数 /// /// 需要检验的字符串 /// 是否为整数:true是整数,false非整数 public static bool IsInt(string str) { Regex rx = new Regex(@"^[0123456789]+$"); return rx.IsMatch(str); } /// /// 撤销整炉废 /// private void cancelScrapMata() { this.ultraGrid2.UpdateData(); UltraGridRow uRow = this.ultraGrid2.ActiveRow; if (uRow == null) { MessageUtil.ShowTips("请选择需要撤销的信息"); return; } QcmZgJugdeApplyEntity qcmEntity = (QcmZgJugdeApplyEntity)uRow.ListObject; string qcmZcTity = JSONFormat.Format(qcmEntity); CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.mes.signature.FrmScrapStoveApplyDescion"; ccp.MethodName = "cancelScrapMata"; ccp.ServerParams = new object[] { qcmZcTity}; ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { if (ccp.ReturnInfo.Equals("撤销成功!")) { queryData(); queryScrapData(); MessageUtil.ShowTips(ccp.ReturnInfo); } else { MessageUtil.ShowTips(ccp.ReturnInfo); } } } private void chkHeatNo2_CheckedChanged(object sender, EventArgs e) { txtHeatNo2.Enabled = this.chkHeatNo2.Checked; } /// /// 导出 /// private void ExportData() { GridHelper.ulGridToExcel(ultraGrid2, "虚数申请判定->整炉废(白条信息)"); } private void ultraGrid1_CellChange(object sender, CellEventArgs e) { this.ultraGrid1.UpdateData(); int strCountTex = 0; double strWgtTex = 0.000; if (e.Cell.Column.Key == "CHK") { IQueryable checkMagRows = this.ultraGrid1.Rows.AsQueryable().Where(" CHK = 'True'"); foreach (UltraGridRow uRow in checkMagRows) { strCountTex = strCountTex + int.Parse(uRow.Cells["ActCount"].Value.ToString3()); strWgtTex = strWgtTex + double.Parse(uRow.Cells["ActWeight"].Value.ToString3()); } this.ultraGroupBox1.Text = "可打白条信息" + " " + "已选支:" + strCountTex.ToString() + " " + "已选产量: " + strWgtTex.ToString(); } } } }