using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using CoreFS.CA06; using Core.Mes.Client.Common; namespace Core.LgMes.Client.LgDeviceManager { public partial class FrmCLRepair : frmModelFormStyle { bool bOK = false; //是否响应结晶器号选择改变事件 public string strNo = "", strCCM = ""; OpeBase ob = null; public FrmCLRepair(OpeBase oba) { InitializeComponent(); ob = oba; } private void FrmCLRepair_Load(object sender, EventArgs e) { if (strCCM.Length > 0) { ucmbCCM.Text = strCCM; this.cbbCCM_SelectedIndexChanged(this, null); if (strNo.Length > 0) { ucmbID.Text = strNo; bOK = true; this.cbbID_SelectedIndexChanged(this, null); } } else { bOK = true; proc_ResetControl(); btnBegin.Enabled = btnEnd.Enabled = false; } } private void NumberEditor_KeyPress(object sender, KeyPressEventArgs e) { if (!(Char.IsNumber(e.KeyChar) || e.KeyChar == '\b')) { e.Handled = true; } } /// /// 结晶器编号查询 /// /// private void proc_GetID(string strCCM) { try { if (strCCM.Length == 0) return; string strErr = ""; string strSql = "select CRYSTALLIZERID from DEV_JJQ_BASE_INFO where CCM_ID = '" + strCCM + "' order by length(CRYSTALLIZERID), CRYSTALLIZERID"; CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "Core.LgMes.Server.DEV.Methods.DEVPublicMethods"; ccp.MethodName = "QueryMethods"; ccp.ServerParams = new Object[] { strSql }; DataTable dt = new DataTable(); ccp.SourceDataTable = dt; ob.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal); DataSet ds = new DataSet(); ds.Tables.Add(dt); if (strErr != "" || !(ds != null && ds.Tables.Count > 0)) { MessageBox.Show("结晶器号加载失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); if (MessageBox.Show("是否重新加载结晶器号?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) proc_GetID(strCCM); return; } ucmbID.Items.Clear(); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { ucmbID.Items.Add(ds.Tables[0].Rows[i][0]); } if (ds.Tables[0].Rows.Count == 0) { proc_ResetControl(); btnBegin.Enabled = btnEnd.Enabled = false; } } catch (Exception ex) { MessageBox.Show(ex.Message); } } private void proc_ResetControl() { try { ucmbID.Text = ""; ucmbType.SelectedIndex = -1; udteRepair.Text = ""; udteRepairTime.Text = ""; ucmbReason.Text = ""; txtTGBHCurr.Clear(); txtTGBHDest.Clear(); txtTBCScurr.Clear(); txtTBCSDest.Clear(); txtMemo.Clear(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } /// /// 维修开始 /// private void proc_Begin() { try { if (ucmbID.Items.Count == 0) return; string strCcm = ucmbCCM.Text.Trim(); string strID = ucmbID.Text.Trim(); if (strID.Length == 0) { MessageBox.Show("请选择需要维修的结晶器编号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); ucmbID.Focus(); return; } string strType = ucmbType.Text.Trim(); if (strType.Length == 0) { MessageBox.Show("请选择维修类别!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); ucmbType.Focus(); return; } if (udteRepair.Text.Trim().Length == 0) udteRepair.DateTime = DateTime.Now; if (MessageBox.Show("确定要维修[" + strCcm + "]的结晶器[" + strID + "]吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { proc_GetID(strCcm); return; } string strErr = ""; string strSql = "select count(1) from DEV_JJQ_BASE_INFO where CCM_ID = '" + strCcm + "' and CRYSTALLIZERID = '" + strID + "'"; CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "Core.LgMes.Server.DEV.Methods.DEVPublicMethods"; ccp.MethodName = "QueryMethods"; ccp.ServerParams = new Object[] { strSql }; DataTable dt = new DataTable(); ccp.SourceDataTable = dt; ob.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal); DataSet ds = new DataSet(); ds.Tables.Add(dt); if (strErr != "" || !(ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)) { MessageBox.Show("[" + strCcm + "]结晶器[" + strID + "]维修信息保存失败!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } int iCnt = Convert.ToInt32(ds.Tables[0].Rows[0][0]); if (iCnt == 0) { MessageBox.Show("[" + strCcm + "]不存在结晶器[" + strID + "]信息,无法维修!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); proc_GetID(strCcm); ucmbID.Focus(); return; } iCnt = 0; ds = null; dt = null; strErr = ""; strSql = "select case NOWSTATUS when '0' then '下线' when '1' then '上线' when '2' then '维修' when '3' then '备用' end NOWSTATUS from DEV_JJQ_BASE_INFO where CCM_ID = '" + strCcm + "' and CRYSTALLIZERID = '" + strID + "'"; CoreClientParam ccp1 = new CoreClientParam(); ccp1.ServerName = "Core.LgMes.Server.DEV.Methods.DEVPublicMethods"; ccp1.MethodName = "QueryMethods"; ccp1.ServerParams = new Object[] { strSql }; DataTable dtt = new DataTable(); ccp1.SourceDataTable = dtt; ob.ExecuteQueryToDataTable(ccp1, CoreInvokeType.Internal); DataSet dss = new DataSet(); dss.Tables.Add(dtt); if (strErr != "" || !(dss != null && dss.Tables.Count > 0 && dss.Tables[0].Rows.Count > 0)) { MessageBox.Show("[" + strCcm + "]结晶器[" + strID + "]维修信息保存失败!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (Convert.ToString(dss.Tables[0].Rows[0]["NOWSTATUS"]).ToString().Trim() != "下线") { MessageBox.Show("[" + strCcm + "]结晶器[" + strID + "]当前状态[" + Convert.ToString(dss.Tables[0].Rows[0]["NOWSTATUS"]) + "],只有在[下线]状态才能维修!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); ucmbID.Focus(); return; } strErr = ""; strSql = "insert into DEV_TOOL_REPAIR (REPAIRID, TOOLTYPEID, REPAIRTOOLID, REPAIRTYPE, REPAIRTIME, REASON, MEMO, RECORDER) " + "values " + "(" + "(select nvl(max(REPAIRID),100000001) + 1 from DEV_TOOL_REPAIR)," + "'2'," + "(select ID from DEV_JJQ_BASE_INFO where CRYSTALLIZERID = '" + strID + "' and CCM_ID = '" + strCcm + "')," + "'" + strType + "'," + "to_date('" + udteRepair.DateTime.ToString("yyyy-MM-dd HH:mm:ss") + "','yyyy-MM-dd HH24:mi:ss')," + "'" + ucmbReason.Text.Trim() + "'," + "'" + txtMemo.Text.Trim() + "'," + "'" + CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName() + "' " + ")"; CoreClientParam ccp_K = new CoreClientParam(); ccp_K.ServerName = "Core.LgMes.Server.DEV.Methods.DEVPublicMethods"; ccp_K.MethodName = "UpdateMethods"; ccp_K.ServerParams = new Object[] { strSql }; ob.ExecuteNonQuery(ccp_K, CoreInvokeType.Internal); if (!(strErr == null || strErr == "")) { MessageBox.Show("[" + strCcm + "]结晶器[" + strID + "]维修信息保存失败!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } strErr = ""; strSql = "update DEV_JJQ_BASE_INFO set NOWSTATUS = '2', CCM_S_ID = null, " + "OUTERCOPPER = '" + txtTGBHDest.Text.Trim() + "', " + "CUPRUMCANALTIME = '" + txtTBCSDest.Text.Trim() + "' " + "where CCM_ID = '" + strCcm + "' and CRYSTALLIZERID = '" + strID + "'"; CoreClientParam ccp_up = new CoreClientParam(); ccp_up.ServerName = "Core.LgMes.Server.DEV.Methods.DEVPublicMethods"; ccp_up.MethodName = "UpdateMethods"; ccp_up.ServerParams = new Object[] { strSql }; ob.ExecuteNonQuery(ccp_up, CoreInvokeType.Internal); FrmCrystallizerManage frm = (FrmCrystallizerManage)this.Tag; frm.proc_GetBaseInfo(strCcm, strID); proc_GetID(strCcm); MessageBox.Show("[" + strCcm + "]结晶器[" + strID + "]维修信息保存成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); btnBegin.Enabled = false; btnEnd.Enabled = true; return; } catch (Exception ex) { MessageBox.Show(ex.Message); } } /// /// 维修结束 /// private void proc_End() { try { if (ucmbID.Items.Count == 0) return; string strCcm = ucmbCCM.Text.Trim(); string strID = ucmbID.Text.Trim(); if (strID.Length == 0) { MessageBox.Show("请选择维修中的结晶器编号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); ucmbID.Focus(); return; } string strType = ucmbType.Text.Trim(); if (strType.Length == 0) { MessageBox.Show("请选择维修类别!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); ucmbType.Focus(); return; } if (udteRepairTime.Text.Trim().Length == 0) udteRepairTime.DateTime = DateTime.Now; if (udteRepair.DateTime > udteRepairTime.DateTime) { MessageBox.Show("送修时间不能大于修复时间!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); udteRepairTime.Focus(); return; } if (MessageBox.Show("确定[" + strCcm + "]结晶器[" + strID + "]维修结束吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { proc_GetID(strCcm); return; } string strErr = ""; string strSql = "select count(1) from DEV_JJQ_BASE_INFO where CCM_ID = '" + strCcm + "' and CRYSTALLIZERID = '" + strID + "'"; CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "Core.LgMes.Server.DEV.Methods.DEVPublicMethods"; ccp.MethodName = "QueryMethods"; ccp.ServerParams = new Object[] { strSql }; DataTable dt = new DataTable(); ccp.SourceDataTable = dt; ob.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal); DataSet ds = new DataSet(); ds.Tables.Add(dt); if (strErr != "" || !(ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)) { MessageBox.Show("[" + strCcm + "]结晶器[" + strID + "]维修信息保存失败!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } int iCnt = Convert.ToInt32(ds.Tables[0].Rows[0][0]); if (iCnt == 0) { MessageBox.Show("[" + strCcm + "]结晶器[" + strID + "]信息不存在,无法保存维修信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); proc_GetID(strCcm); ucmbID.Focus(); return; } iCnt = 0; ds = null; strErr = ""; strSql = "select case NOWSTATUS when '0' then '下线' when '1' then '上线' when '2' then '维修' when '3' then '备用' end NOWSTATUS from DEV_JJQ_BASE_INFO where CCM_ID = '" + strCcm + "' and CRYSTALLIZERID = '" + strID + "'"; CoreClientParam ccp1 = new CoreClientParam(); ccp1.ServerName = "Core.LgMes.Server.DEV.Methods.DEVPublicMethods"; ccp1.MethodName = "QueryMethods"; ccp1.ServerParams = new Object[] { strSql }; DataTable dtt = new DataTable(); ccp1.SourceDataTable = dtt; ob.ExecuteQueryToDataTable(ccp1, CoreInvokeType.Internal); DataSet dss = new DataSet(); dss.Tables.Add(dtt); if (strErr != "" || !(dss != null && dss.Tables.Count > 0 && dss.Tables[0].Rows.Count > 0)) { MessageBox.Show("[" + strCcm + "]结晶器[" + strID + "]维修信息保存失败!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (Convert.ToString(dss.Tables[0].Rows[0]["NOWSTATUS"]).Trim() != "维修") { MessageBox.Show("[" + strCcm + "]结晶器[" + strID + "]当前状态[" + Convert.ToString(dss.Tables[0].Rows[0]["NOWSTATUS"]) + "],只有在[维修]状态才能结束维修!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); ucmbID.Focus(); return; } strErr = ""; strSql = "update DEV_TOOL_REPAIR set " + "REPAIRTYPE = '" + strType + "'," + "REPAIRTIME = to_date('" + udteRepair.DateTime.ToString("yyyy-MM-dd HH:mm:ss") + "','yyyy-MM-dd HH24:mi:ss')," + "REPAIREDTIME = to_date('" + udteRepairTime.DateTime.ToString("yyyy-MM-dd HH:mm:ss") + "','yyyy-MM-dd HH24:mi:ss')," + "REASON = '" + ucmbReason.Text.Trim() + "'," + "MEMO = '" + txtMemo.Text.Trim() + "'," + "RECORDER = '" + CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName() + "' " + "where TOOLTYPEID = '2' and REPAIREDTIME is null and REPAIRTOOLID = " + "(select ID from DEV_JJQ_BASE_INFO where CRYSTALLIZERID = '" + strID + "' and CCM_ID = '" + strCcm + "')"; CoreClientParam ccp_up = new CoreClientParam(); ccp_up.ServerName = "Core.LgMes.Server.DEV.Methods.DEVPublicMethods"; ccp_up.MethodName = "UpdateMethods"; ccp_up.ServerParams = new Object[] { strSql }; ob.ExecuteNonQuery(ccp_up, CoreInvokeType.Internal); if (!(strErr == null || strErr == "")) { MessageBox.Show("[" + strCcm + "]结晶器[" + strID + "]维修信息保存失败!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } strErr = ""; strSql = "update DEV_JJQ_BASE_INFO set NOWSTATUS = '3', CCM_S_ID = null, " + "OUTERCOPPER = '" + txtTGBHDest.Text.Trim() + "', " + "CUPRUMCANALTIME = '" + txtTBCSDest.Text.Trim() + "' " + "where CCM_ID = '" + strCcm + "' and CRYSTALLIZERID = '" + strID + "'"; CoreClientParam ccp_u = new CoreClientParam(); ccp_u.ServerName = "Core.LgMes.Server.DEV.Methods.DEVPublicMethods"; ccp_u.MethodName = "UpdateMethods"; ccp_u.ServerParams = new Object[] { strSql }; ob.ExecuteNonQuery(ccp_u, CoreInvokeType.Internal); //if (!(strErr == null || strErr == "")) //{ // MessageBox.Show("[" + strCcm + "]结晶器[" + strID + "]维修信息保存失败!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); // return; //} FrmCrystallizerManage frm = (FrmCrystallizerManage)this.Tag; frm.proc_GetBaseInfo(strCcm, strID); proc_GetID(strCcm); MessageBox.Show("[" + strCcm + "]结晶器[" + strID + "]维修信息保存成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); btnBegin.Enabled = true; btnEnd.Enabled =false ; return; } catch (Exception ex) { MessageBox.Show(ex.Message); } } private void btnBegin_Click(object sender, EventArgs e) { proc_Begin(); } private void btnEnd_Click(object sender, EventArgs e) { proc_End(); } private void cbbCCM_SelectedIndexChanged(object sender, EventArgs e) { if (ucmbCCM.Text.Length > 0) { ucmbID.SelectedIndex = -1; proc_GetID(ucmbCCM.Text); } } private void cbbID_SelectedIndexChanged(object sender, EventArgs e) { try { if (!bOK) return; string strCcm = ucmbCCM.Text.Trim(); string strID = ucmbID.Text.Trim(); if (strID.Length == 0) { ucmbType.SelectedIndex = -1; udteRepair.Text = ""; udteRepairTime.Text = ""; ucmbReason.Text = ""; txtTGBHCurr.Clear(); txtTGBHDest.Clear(); txtTBCScurr.Clear(); txtTBCSDest.Clear(); txtMemo.Clear(); btnBegin.Enabled = btnEnd.Enabled = false; return; } string strErr = ""; string strSql = "select REPAIRTYPE, REPAIRTIME, REASON, MEMO from DEV_TOOL_REPAIR " + "where TOOLTYPEID = '2' and REPAIREDTIME is null and REPAIRTOOLID = " + "(select ID from DEV_JJQ_BASE_INFO where CRYSTALLIZERID = '" + strID + "' and CCM_ID = '" + strCcm + "')"; CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "Core.LgMes.Server.DEV.Methods.DEVPublicMethods"; ccp.MethodName = "QueryMethods"; ccp.ServerParams = new Object[] { strSql }; DataTable dt = new DataTable(); ccp.SourceDataTable = dt; ob.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal); DataSet ds = new DataSet(); ds.Tables.Add(dt); if (strErr != "" || !(ds != null && ds.Tables.Count > 0)) { MessageBox.Show("[" + strCcm + "]结晶器[" + strID + "]维修信息查询失败!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (ds.Tables[0].Rows.Count > 0) { ucmbType.Text = Convert.ToString(ds.Tables[0].Rows[0]["REPAIRTYPE"]); udteRepair.DateTime = Convert.ToDateTime(ds.Tables[0].Rows[0]["REPAIRTIME"]); udteRepairTime.Text = ""; ucmbReason.Text = Convert.ToString(ds.Tables[0].Rows[0]["REASON"]); txtMemo.Text = Convert.ToString(ds.Tables[0].Rows[0]["MEMO"]); btnBegin.Enabled = false; } else { ucmbType.SelectedIndex = -1; udteRepair.Text = ""; udteRepairTime.Text = ""; ucmbReason.Text = ""; txtMemo.Clear(); btnBegin.Enabled = true; } btnEnd.Enabled = !btnBegin.Enabled; strSql = "select OUTERCOPPER, CUPRUMCANALTIME from DEV_JJQ_BASE_INFO where CRYSTALLIZERID = '" + strID + "' and CCM_ID = '" + strCcm + "'"; CoreClientParam ccp1 = new CoreClientParam(); ccp1.ServerName = "Core.LgMes.Server.DEV.Methods.DEVPublicMethods"; ccp1.MethodName = "QueryMethods"; ccp1.ServerParams = new Object[] { strSql }; DataTable dtt = new DataTable(); ccp1.SourceDataTable = dtt; ob.ExecuteQueryToDataTable(ccp1, CoreInvokeType.Internal); DataSet dss = new DataSet(); dss.Tables.Add(dtt); if (strErr != "" || !(dss != null && dss.Tables.Count > 0)) { MessageBox.Show("[" + strCcm + "]结晶器[" + strID + "]基本信息查询失败!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (dss.Tables[0].Rows.Count > 0) { txtTGBHCurr.Text = txtTGBHDest.Text = Convert.ToString(dss.Tables[0].Rows[0]["OUTERCOPPER"]); txtTBCScurr.Text = txtTBCSDest.Text = Convert.ToString(dss.Tables[0].Rows[0]["CUPRUMCANALTIME"]); } } catch (Exception ex) { MessageBox.Show(ex.Message, "提示"); } } } }