using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Collections; using CoreFS.CA06; using Core.Mes.Client.Common; namespace Core.LgMes.Client.LgDeviceManager { public partial class FrmZEROCL : FrmLgDevFunctions { public string strFlag = ""; //标识调用窗口 public string strID = ""; //ID public string strNO = ""; //编号 public string strCCM = ""; //铸机号 public string strPOS = ""; //流号 public string strSTATUS = ""; //当前状态 public string strVBType = ""; //段位类型 public FrmZEROCL(OpeBase oba) { InitializeComponent(); ob = oba; } private void FrmCL_Load(object sender, EventArgs e) { cmbCCM.Text = strCCM; this.ultraGroupBox1.Text = "[" + this.strCCM + "]-" + strVBType + "[" + this.strNO + "]"; tbCurrPos.Text = ucmbPos.Text = this.strPOS; tbCurrStatus.Text = ucmbStatus.Text = this.strSTATUS; } private void btnclose_Click(object sender, EventArgs e) { this.Close(); } private string proc_CodeNameExchangeStatus(bool bCodetoName, string str) { if (bCodetoName) //代码->名称 { switch (str) { case "0": return "下线"; case "1": return "上线"; case "2": return "维修"; case "3": return "备用"; default: return ""; } } else { switch (str) { case "下线": return "0"; case "上线": return "1"; case "维修": return "2"; case "备用": return "3"; default: return ""; } } } private void proc_OK() { string strPosText = ""; //显示流名 try { string strErr = ""; string strSql = "select count(1) from DEV_VB_BASE_INFO where ID = '" + this.strID + "'"; DataSet ds = QueryFixedFunions(strSql, ob); if (strErr != "" || !(ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)) { MessageBox.Show("[" + this.strCCM + "]" + strVBType + "[" + this.strNO + "]设置失败!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } int iCnt = Convert.ToInt32(ds.Tables[0].Rows[0][0]); if (iCnt == 0) { MessageBox.Show("[" + this.strCCM + "]不存在" + strVBType + "[" + this.strNO + "],请录入基础信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } string strPos = ucmbPos.Text.Trim(); string strStatus = proc_CodeNameExchangeStatus(false, ucmbStatus.Text.Trim()); if (strStatus == "") { MessageBox.Show("请选择状态!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); ucmbStatus.Focus(); return; } if (strStatus == "1" && strPos == "") { MessageBox.Show("请选择流号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); ucmbPos.Focus(); return; } if (ucmbStatus.Text.Trim() == "上线") { if (this.tbDM.Text == "" && this.txtWidth.Text == "") { MessageBox.Show("请输入断面信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); ucmbStatus.Focus(); return; } if (this.tbDM.Text == "") { MessageBox.Show("请输入断面厚度!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); ucmbStatus.Focus(); return; } if (this.txtWidth.Text == "") { MessageBox.Show("请输入断面宽度!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); ucmbStatus.Focus(); return; } } ds = null; strErr = ""; strSql = "select NOWSTATUS, CCM_S_ID from DEV_VB_BASE_INFO where ID = '" + this.strID + "'"; ds = QueryFixedFunions(strSql, ob); if (strErr != "" || !(ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)) { MessageBox.Show("[" + this.strCCM + "]" + strVBType + "[" + this.strNO + "]设置失败!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } this.strPOS = Convert.ToString(ds.Tables[0].Rows[0]["CCM_S_ID"]); //原始状态 this.strSTATUS = Convert.ToString(ds.Tables[0].Rows[0]["NOWSTATUS"]); this.strSTATUS = Convert.ToString(ds.Tables[0].Rows[0]["NOWSTATUS"]); tbCurrPos.Text = this.strPOS; tbCurrStatus.Text = proc_CodeNameExchangeStatus(true, this.strSTATUS); if (this.strSTATUS == "") { MessageBox.Show("[" + this.strCCM + "]" + strVBType + "[" + this.strNO + "]当前状态不明确,无法设置!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if ((this.strSTATUS == "0" && strStatus == "0") || (this.strSTATUS == "2" && strStatus == "2") || (this.strSTATUS == "3" && strStatus == "3") || ((this.strSTATUS == "1" && strStatus == "1") && (this.strPOS == strPos))) { MessageBox.Show("操作无意义!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); ucmbStatus.Focus(); return; } if (this.strSTATUS == "0" && strStatus == "1") { MessageBox.Show("不能将[" + this.strCCM + "]" + strVBType + "[" + this.strNO + "]从[下线]改为[上线]状态!\r\n如有必要,请先设置为[备用]状态!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); ucmbStatus.Focus(); return; } if (this.strSTATUS == "1" && (strStatus == "2" || strStatus == "3")) { MessageBox.Show("不能将[" + this.strCCM + "]" + strVBType + "[" + this.strNO + "]从[上线]改为[维修]或[备用]状态!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); ucmbStatus.Focus(); return; } if (this.strSTATUS == "2" && (strStatus == "0" || strStatus == "1")) { MessageBox.Show("不能将[" + this.strCCM + "]" + strVBType + "[" + this.strNO + "]从[维修]改为[下线]或[上线]状态!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); ucmbStatus.Focus(); return; } if (this.strSTATUS == "3" && strStatus == "2") { MessageBox.Show("不能将[" + this.strCCM + "]" + strVBType + "[" + this.strNO + "]从[备用]改为[维修]状态!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); ucmbStatus.Focus(); return; } if (this.strSTATUS == "0" && strStatus == "2") { if (MessageBox.Show("确定[" + this.strCCM + "]" + strVBType + "[" + this.strNO + "]开始维修吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { ucmbStatus.Focus(); return; } } if (this.strSTATUS == "1" && strStatus == "0") { if (MessageBox.Show("确定[" + this.strCCM + "]" + strVBType + "[" + this.strNO + "][下线]吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { ucmbStatus.Focus(); return; } } if (this.strSTATUS == "2" && strStatus == "3") { if (MessageBox.Show("确定[" + this.strCCM + "]" + strVBType + "[" + this.strNO + "]结束维修吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { ucmbStatus.Focus(); return; } } if (strStatus == "1") { ds = null; strErr = ""; strPosText = strPos; string temptype = strVBType == "垂直段" ? "1" : "2"; //strSql = "select CRYSTALLIZERID from DEV_VB_BASE_INFO where NOWSTATUS = '1' and CCM_S_ID = '" + strPos + "' and CCM_ID = '" + cmbCCM.Text.Trim() + "'"; strSql = "select CRYSTALLIZERID from DEV_VB_BASE_INFO where NOWSTATUS = '1' and TYPE = '"+temptype+"' and CCM_ID = '" + cmbCCM.Text.Trim() + "'"; ds = QueryFixedFunions(strSql, ob); if (strErr != "" || !(ds != null && ds.Tables.Count > 0)) { MessageBox.Show("[" + this.strCCM + "]" + strVBType + "[" + this.strNO + "]设置失败!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (ds.Tables[0].Rows.Count > 0) { string str = Convert.ToString(ds.Tables[0].Rows[0]["CRYSTALLIZERID"]); if (MessageBox.Show("当前" + strVBType + "[" + str + "]处于[" + cmbCCM.Text.Trim() + "][" + strPosText + "],确定要替换为" + strVBType + "[" + this.strNO + "]吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { ucmbStatus.Focus(); return; } } } string[] strParams = new string[6] { this.strID, strPos, strStatus, CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName(), tbDM.Text.Trim() + "X" + txtWidth.Text.Trim(),cmbCCM.Text.Trim() }; string msg = ""; strErr = ""; ProcedureZ("Core.LgMes.Server.DEV.Methods.DEVPublicMethods", "procedure", new object[] { "RES_LG_TOOLMANAGE.VBSTATUS_CHANGE", strParams }, ob, out strErr, out msg); if (Convert.ToInt32(strErr) > 0) { if (strFlag == "0") { FrmCrystallizerManage frm = (FrmCrystallizerManage)this.Tag; frm.proc_GetBaseInfo(this.strCCM, this.strNO); } else if (strFlag == "1") { FrmZEROManage frm = (FrmZEROManage)this.Tag; frm.proc_GetBaseInfo(this.strCCM, this.strNO); } MessageBox.Show(msg, "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); FrmZEROManage frmCL = (FrmZEROManage)this.Tag; frmCL.proc_GetBaseInfo(this.strCCM, this.strNO); this.Close(); } else MessageBox.Show(msg, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (Exception ex) { MessageBox.Show(ex.Message); } } /// /// 修改段位对应的铸机号 /// public void JJQCcmNo_Edit() { string strErr = ""; ArrayList arry = new ArrayList(); arry.Add(""); arry.Add(this.cmbCCM.Text); arry.Add(strNO); arry.Add(strID); CommonClientToServer cctos = new CommonClientToServer(); cctos.ob = this.ob; DataSet ds = cctos.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBSave", "doSimpleSave", arry, out strErr); if (strErr != "" && ds != null) { MessageBox.Show(strErr); } } private void btnOK_Click(object sender, EventArgs e) { this.proc_OK(); } private void tbDM_KeyPress(object sender, KeyPressEventArgs e) { try { if (!(Char.IsNumber(e.KeyChar) || e.KeyChar == '\b' || e.KeyChar == '.')) e.Handled = true; } catch { } } private void txtWidth_KeyPress(object sender, KeyPressEventArgs e) { try { if (!(Char.IsNumber(e.KeyChar) || e.KeyChar == '\b' || e.KeyChar == '.')) e.Handled = true; } catch { } } } }