using com.steering.mes.zgmil.entity; 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.Common; using Core.StlMes.Client.ZGMil.Entity; using Core.StlMes.Client.ZGMil.NodeResultQuery; using Core.StlMes.Client.ZGMil.Popup; using Core.StlMes.Client.ZGMil.Report; using Core.StlMes.Client.ZGMil.ResultConrtrol; 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.Windows.Forms; namespace Core.StlMes.Client.ZGMil.Signature { public partial class FrmOfflineProcess : FrmBase { private string Process = "";//参数 private string[] arrId;//数据权限 private string[] plineCodes = { }; private DataTable _dtPline = null; private string basecodeSamll = "";//停机小类值 private string basecodeReason = "";//停机原因值 public FrmOfflineProcess() { InitializeComponent(); } private void FrmOfflineProcess_Load(object sender, EventArgs e) { DateTime now = DateTime.Now; DateTime dt1 = new DateTime(now.Year, now.Month, 1);//当月第一天 DateTime dt2 = dt1.AddMonths(1).AddDays(-1);//当月最后一天 this.StartTime2.Value = DateTime.Parse(dt1.ToString("yyyy-MM-dd") + " 00:00:00"); this.EndTime2.Value = DateTime.Parse(dt2.ToString("yyyy-MM-dd") + " 23:59:59"); EntityHelper.ShowGridCaption(ultraGrid1.DisplayLayout.Bands[0]); plineCodes = BaseMethod.GetPlineCode(ValidDataPurviewIds, ob); Process = this.CustomInfo.ToString();//参数 _dtPline = ServerHelper.GetData("com.steering.mes.zgmil.report.FrmOfflineProcess.JudgeBaseInfo", new object[] { plineCodes }, ob); //_dtPline.AcceptChanges(); string strPlineNames = string.Join(",", _dtPline.Rows.Cast().Select(a => a["plineName"].ToString()).ToArray()); string strPineCodes = string.Join(",", _dtPline.Rows.Cast().Select(a => a["plineCode"].ToString()).ToArray()); ultraTextEditor1.Text = strPlineNames; ultraTextEditor1.Tag = strPineCodes; DataTable dt = TubeRoll.GetComBaseInfo("4113", ob); cmbLx.DataSource = dt; cmbLx.ValueMember = "BASECODE"; cmbLx.DisplayMember = "BASENAME"; TubeRoll.SetComboItemHeight(cmbLx); InitBindColumn(); IsLoadUserView = true; } private void InitBindColumn() { } public override void ToolBar_Click(object sender, string ToolbarKey) { switch (ToolbarKey) { case "Query": QueryOfflineProcess(); break; case "Save": doSave(); break; case "Audit": Audit(); break; case "Close": this.Close(); break; case "Export": GridHelper.ulGridToExcel(ultraGrid1, "离线品管理"); break; } } /// /// 调整设料量 /// //private void updateInputWt() //{ // this.ultraGrid1.UpdateData(); // UltraGridRow uRow = this.ultraGrid1.ActiveRow; // //string departMentid = PipeManageClass.GetDepartIdBySectionId(UserInfo.GetDeptid(), ob); // string departMentid = UserInfo.GetDeptid(); // if (uRow == null) // { // MessageUtil.ShowTips("请选择需要调整的炉信息!"); // return; // } // if (Double.Parse(uRow.Cells["InputCount"].Value.ToString3()) < 0) // { // MessageUtil.ShowTips("请输入正确的数字!"); // return; // } // if (Double.Parse(uRow.Cells["InputWeight"].Value.ToString3()) < 0) // { // MessageUtil.ShowTips("请输入正确的数字 !"); // return; // } // ArrayList list = new ArrayList(); // list.Add(uRow.Cells["JugdeApplyCode"].Value.ToString()); // list.Add(uRow.Cells["JugdeApplySequeno"].Value.ToString()); // list.Add(uRow.Cells["JudgeStoveNo"].Value.ToString()); // list.Add(uRow.Cells["BatchNo"].Value.ToString()); // list.Add(uRow.Cells["BatchGroudNo"].Value.ToString()); // list.Add(uRow.Cells["InputCount"].Text.ToString3()); // list.Add(uRow.Cells["InputWeight"].Text.ToString3()); // list.Add(UserInfo.GetUserName()); // CoreClientParam ccp = new CoreClientParam(); // ccp.ServerName = "com.steering.mes.signature.FrmInOnlineStore"; // ccp.MethodName = "updateInputWt"; // ccp.ServerParams = new object[] { list }; // ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal); // if (ccp.ReturnCode != -1) // { // if (ccp.ReturnInfo.Equals("调整成功!")) // { // QueryZgJugdeApply(); // MessageUtil.ShowTips(ccp.ReturnInfo); // } // else // { // MessageUtil.ShowTips(ccp.ReturnInfo); // } // } //} /// /// 查询离线数据 /// private void QueryOfflineProcess() { string plinCode = ""; string jugeNo = ""; string startTim = ""; string endTim = ""; string isAudit = ""; string orderno = ""; string reason = ""; string lxStartTime = ""; string lxEndTime = ""; string departMentid = UserInfo.GetDeptid(); if (this.chkHeatNo2.Checked && this.txtHeatNo2.Text.Trim() != "") { jugeNo = this.txtHeatNo2.Text.Trim(); } if (chkTim2.Checked) { if (DateTime.Parse(StartTime2.Value.ToString()) > DateTime.Parse(EndTime2.Value.ToString())) { MessageUtil.ShowTips("选择的前面时间不能大于后面的时间!"); return; } else { startTim = this.StartTime2.Value.ToString("yyyy-MM-dd HH:mm:ss"); endTim = this.EndTime2.Value.ToString("yyyy-MM-dd HH:mm:ss"); } } if (lx_check.Checked) { if (DateTime.Parse(StartTime2.Value.ToString()) > DateTime.Parse(EndTime2.Value.ToString())) { MessageUtil.ShowTips("选择的前面时间不能大于后面的时间!"); return; } else { lxStartTime = this.lx_text.Value.ToString("yyyy-MM-dd HH:mm:ss"); lxEndTime = this.dateTimePicker1.Value.ToString("yyyy-MM-dd HH:mm:ss"); } } if(check_reason.Checked) { reason = this.reason.Value.ToString(); } if (check_orderno.Checked) { orderno = this.orderno.Text.Trim(); } if (chkPlineCode.Checked) { plinCode = ultraTextEditor1.Tag.ToString().Replace(",", "', '"); } if (lx_check.Checked) { } if (chekAudit.Checked) { isAudit = proc_chekedAudit(chekAudit.Checked,this.isAudit.Text.Trim()); } List listSource = EntityHelper.GetData( "com.steering.mes.signature.FrmInOnlineStore.QueryOfflineProcess", new object[] { jugeNo, startTim, endTim, plinCode, isAudit, reason, orderno, lxStartTime, lxEndTime }, this.ob); bindingSource2.DataSource = listSource; //GridHelper.RefreshAndAutoSize(ultraGrid1); } ///MESServer/src/com/steering/mes/zgmil/entity/OfflineProcess.java private string proc_chekedAudit(bool cheked, string str) { switch (str) { case "未发起评审": return "0"; case "已发起评审": return "1"; case "评审通过": return "2"; default: return ""; } } private void doSave() { this.ultraGrid1.UpdateData(); IQueryable checkMagRows = this.ultraGrid1.Rows.AsQueryable().Where(" CHK = 'True'"); if (checkMagRows.Count() == 0) { MessageUtil.ShowTips("请选择需要保存的数据!"); return; } ArrayList parm = new ArrayList(); foreach (UltraGridRow uRow in checkMagRows) { OfflineProcessEntity OfflineResult = (OfflineProcessEntity)uRow.ListObject; string OfflineResultTity = JSONFormat.Format(OfflineResult); parm.Add(OfflineResultTity); } CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.mes.zgmil.report.FrmOfflineProcess"; ccp.MethodName = "doSave"; ccp.ServerParams = new object[] { parm}; ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { if (ccp.ReturnInfo.Equals("操作成功")) { // DoQueryInList(); QueryOfflineProcess(); MessageUtil.ShowTips(ccp.ReturnInfo); } else { MessageUtil.ShowTips(ccp.ReturnInfo); } } } private void Audit() { this.ultraGrid1.UpdateData(); IQueryable checkMagRows = this.ultraGrid1.Rows.AsQueryable().Where(" CHK = 'True'"); if (checkMagRows.Count() == 0) { MessageUtil.ShowTips("请选择需要审核的数据!"); return; } ArrayList parm = new ArrayList(); foreach (UltraGridRow uRow in checkMagRows) { OfflineProcessEntity offlineResult = (OfflineProcessEntity)uRow.ListObject; if (offlineResult.Reason1 == "" || offlineResult.Reason2 == "" || offlineResult.Reason3 == "") { MessageUtil.ShowTips("请选择离线原因"); return; } string OfflineResultTity = JSONFormat.Format(offlineResult); parm.Add(OfflineResultTity); } if (MessageUtil.ShowYesNoAndQuestion("确定需要提交审核?") == DialogResult.No) return; string userName = UserInfo.GetUserName(); string department = UserInfo.GetDepartment(); CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.mes.zgmil.report.FrmOfflineProcess"; ccp.MethodName = "doAudit"; ccp.ServerParams = new object[] { parm, userName, department }; ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { if (ccp.ReturnInfo.Equals("操作成功")) { // DoQueryInList(); QueryOfflineProcess(); MessageUtil.ShowTips(ccp.ReturnInfo); } else { MessageUtil.ShowTips(ccp.ReturnInfo); } } } private void chkTim2_CheckedChanged(object sender, EventArgs e) { this.StartTime2.Enabled = this.EndTime2.Enabled = this.chkTim2.Checked; } private void chkHeatNo2_CheckedChanged(object sender, EventArgs e) { this.txtHeatNo2.Enabled = this.chkHeatNo2.Checked; } private void chekAudit_CheckedChanged(object sender, EventArgs e) { this.isAudit.Enabled = this.chekAudit.Checked; } private void check_reason_CheckedChanged(object sender, EventArgs e) { this.reason.Enabled = this.check_reason.Checked; } private void check_orderno_CheckedChanged(object sender, EventArgs e) { this.orderno.Enabled = this.check_orderno.Checked; } private void ultraTextEditor1_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e) { ChoicePlineFrm frm = new ChoicePlineFrm(_dtPline, ultraTextEditor1.Tag.ToString2(), this.ob); if (frm.ShowDialog() == System.Windows.Forms.DialogResult.OK) { ultraTextEditor1.Text = frm.ChoicePlineName; ultraTextEditor1.Tag = frm.ChoicePlineCode; } } private void chkPlineCode_CheckedChanged(object sender, EventArgs e) { this.ultraTextEditor1.Enabled = this.chkPlineCode.Checked; } private void Reason2_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e) { UltraGridRow row = ultraGrid1.ActiveRow; string reason1 = ""; if (!row.Cells["Reason1"].Text.Trim().Equals("")) { reason1 = row.Cells["Reason1"].Value.ToString(); } FrmStopSamll fpdc = new FrmStopSamll(reason1, ob); fpdc.AutoSize = true; fpdc.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height); fpdc.Text = "二级原因"; fpdc.ShowDialog(); if (fpdc.DialogResult == System.Windows.Forms.DialogResult.OK) { //获取弹出窗体的属性值 row.Cells["Reason2"].Value = fpdc.Basename; //cmbStopSmall.Value = fpdc.Basename; basecodeSamll = fpdc.Basecode; } chageReason(); } private void Reason3_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e) { UltraGridRow row = ultraGrid1.ActiveRow; if (row == null) return; string reason2 = basecodeSamll; if (!row.Cells["Reason2"].Text.Equals("")) { reason2 = row.Cells["Reason2"].Value.ToString(); } FrmStopSamll fpdc = new FrmStopSamll(basecodeSamll, ob); fpdc.AutoSize = true; fpdc.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height); fpdc.Text = "三级原因"; fpdc.ShowDialog(); if (fpdc.DialogResult == System.Windows.Forms.DialogResult.OK) { //获取弹出窗体的属性值 row.Cells["Reason3"].Value = fpdc.Basename; //cmbStopReason.Value = fpdc.Basename; basecodeReason = fpdc.Basecode; } chageReason(); } private void ultraGrid1_AfterRowActivate(object sender, EventArgs e) { if (ultraGrid1.ActiveRow == null) return; string id = ultraGrid1.ActiveRow.Cells["ResultNo"].Value.ToString(); DataTable dt = ServerHelper.GetData("com.steering.mes.zgmil.report.FrmOfflineProcess.QueryOfflineAudits", new object[] { id }, ob); GridHelper.CopyDataToDatatable(ref dt, ref dataTable1, true); for (int i = 0; i < ultraGrid2.Rows.Count; i++) { if (ultraGrid2.Rows[i].Cells["ID"].Value.ToString().Equals(id)) { ultraGrid2.ActiveRow = ultraGrid2.Rows[i]; //ulgridSteelPlan.Rows[i].Selected = true; return; } //else //{ // ulgridSteelPlan.ActiveRow = ulgridSteelPlan.Rows[i]; // //ulgridSteelPlan.Rows[i].Selected = true; // return; //} } } private void ultraGrid1_DoubleClick(object sender, EventArgs e) { UltraGridRow row = ultraGrid1.ActiveRow; string srKey = this.ultraGrid1.ActiveCell.Column.ToString(); if (row.Cells["PlineNameA"].Text != null && srKey == "PlineNameA") { row.Cells["PlineNameResponse"].Value = row.Cells["PlineNameA"].Text; } if (row.Cells["PlineNameD"].Text != null && srKey == "PlineNameD") { row.Cells["PlineNameResponse"].Value = row.Cells["PlineNameD"].Text; } if (row.Cells["PlineNameE"].Text != null && srKey == "PlineNameE") { row.Cells["PlineNameResponse"].Value = row.Cells["PlineNameE"].Text; } if (row.Cells["PlineNameF"].Text != null && srKey == "PlineNameF") { row.Cells["PlineNameResponse"].Value = row.Cells["PlineNameF"].Text; } } private void chageReason() { string strkey = ultraGrid1.ActiveCell.Column.ToString(); UltraGridRow row = ultraGrid1.ActiveRow; IQueryable checkMagRows = this.ultraGrid1.Rows.AsQueryable().Where(" CHK = 'True'"); foreach (UltraGridRow uRow in checkMagRows) { if (Convert.ToBoolean(row.Cells["CHK"].Text) == false) return; if ( strkey.Equals("Reason2") || strkey.Equals("Reason3")) { uRow.Cells[strkey].Value = row.Cells[strkey].Text; uRow.Cells["Reason1"].Value = row.Cells["Reason1"].Value; } } } } }