| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297 |
- 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 System.Collections;
- using Core.Mes.Client.Common;
- namespace Core.LgMes.Client.LgDeviceManager
- {
- public partial class FrmTD : FrmLgDevFunctions
- {
- public string strID = ""; //ID
- public string strNO = ""; //中间包编号
- public string strCCM = ""; //铸机号
- public string strPOS = ""; //工位
- public string strSTATUS = ""; //当前状态
- public FrmTD(OpeBase oba)
- {
- InitializeComponent();
- ob = oba;
- }
- private void FrmTD_Load(object sender, EventArgs e)
- {
- this.ultraGroupBox1.Text = "[" + this.strCCM + "]-中间包[" + this.strNO + "]";
- txtCurrPos.Text = ucmePos.Text = this.strPOS;
- txtCurrStatus.Text = ucmeStatus.Text = this.strSTATUS;
- cmbCCM.Text = strCCM;
- }
- 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 string proc_CodeNameExchangePosition(bool bCodetoName, string str)
- {
- if (bCodetoName) //代码->名称
- {
- switch (str)
- {
- case "1":
- return "南";
- case "2":
- return "北";
- default:
- return "";
- }
- }
- else
- {
- switch (str)
- {
- case "南":
- return "1";
- case "北":
- return "2";
- default:
- return "";
- }
- }
- }
- private void proc_OK()
- {
- try
- {
- if ((strCCM == "1#连铸机" || strCCM == "2#连铸机") && cmbCCM.Text.Trim() == "3#连铸机")
- {
- MessageBox.Show("1#机、2#机不能与3#机共用同一个中间包!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
- return;
- }
- if (strCCM == "3#连铸机" && (cmbCCM.Text.Trim() == "1#连铸机" || cmbCCM.Text.Trim() == "2#连铸机"))
- {
- MessageBox.Show("3#机不能与1#、2#机共用同一个中间包!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
- return;
- }
- string strErr = "";
- string strSql = "select count(1) from DEV_ZJB_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 + "]中间包[" + 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 + "]不存在中间包[" + this.strNO + "],请录入基础信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
- return;
- }
- string strPos = proc_CodeNameExchangePosition(false, ucmePos.Text.Trim());
- string strStatus = proc_CodeNameExchangeStatus(false, ucmeStatus.Text.Trim());
- if (strStatus == "")
- {
- MessageBox.Show("请选择状态!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
- ucmeStatus.Focus();
- return;
- }
- if (strStatus == "1" && strPos == "")
- {
- MessageBox.Show("请选择工位!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
- ucmePos.Focus();
- return;
- }
- ds = null;
- strErr = "";
- strSql = "select STATUS, POSITIONID from DEV_ZJB_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 + "]中间包[" + this.strNO + "]设置失败!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
- return;
- }
- this.strPOS = Convert.ToString(ds.Tables[0].Rows[0]["POSITIONID"]); //原始状态
- this.strSTATUS = Convert.ToString(ds.Tables[0].Rows[0]["STATUS"]);
- txtCurrPos.Text = proc_CodeNameExchangePosition(true, this.strPOS);
- txtCurrStatus.Text = proc_CodeNameExchangeStatus(true, this.strSTATUS);
- if (this.strSTATUS == "")
- {
- MessageBox.Show("[" + this.strCCM + "]中间包[" + 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);
- ucmeStatus.Focus();
- return;
- }
- if (this.strSTATUS == "0" && (strStatus == "1" || strStatus == "2"))
- {
- MessageBox.Show("不能将[" + this.strCCM + "]中间包[" + this.strNO + "]从[下线]状态发至[等待位]或[浇铸位]!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
- ucmeStatus.Focus();
- return;
- }
- if ((this.strSTATUS == "1" || this.strSTATUS == "2") && strStatus == "3")
- {
- MessageBox.Show("不能将[" + this.strCCM + "]中间包[" + this.strNO + "]从[等待位]或[浇铸位]改为[备用]状态!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
- ucmeStatus.Focus();
- return;
- }
- if ((this.strSTATUS == "1" || this.strSTATUS == "2") && strStatus == "0")
- {
- if (MessageBox.Show("确定[" + this.strCCM + "]中间包[" + this.strNO + "]从" + (this.strSTATUS == "1" ? "[" + ucmePos.Text.Trim() + "]工位[等待位]" : "[浇铸位]") + "[下线]吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
- {
- ucmeStatus.Focus();
- return;
- }
- }
- if (strStatus == "1" || strStatus == "2")
- {
- ds = null;
- strErr = "";
- if (strStatus == "2")
- strSql = "select * from DEV_ZJB_BASE_INFO where CCM_ID = '" + this.strCCM + "' and ID <> '" + this.strID + "' and STATUS = '" + strStatus + "'";
- else
- strSql = "select * from DEV_ZJB_BASE_INFO where CCM_ID = '" + this.strCCM + "' and ID <> '" + this.strID + "' and STATUS = '" + strStatus + "' and POSITIONID = '" + strPos + "'";
- ds = QueryFixedFunions(strSql, ob);
- if (strErr != "")
- {
- MessageBox.Show("[" + this.strCCM + "]中间包[" + this.strNO + "]设置失败!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
- return;
- }
- if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
- {
- string str = Convert.ToString(ds.Tables[0].Rows[0]["TUNDISHID"]);
- string strMsg = "";
- if (strStatus == "1")
- strMsg = "当前[" + this.strCCM + "]中间包[" + str + "]处于[" + ucmePos.Text.Trim() + "][" + ucmeStatus.Text.Trim() + "],你要替换为中间包[" + this.strNO + "]吗?";
- else if (strStatus == "2")
- strMsg = "当前[" + this.strCCM + "]中间包[" + str + "]处于[" + ucmeStatus.Text.Trim() + "],你要替换为中间包[" + this.strNO + "]吗?";
- if (MessageBox.Show(strMsg, "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
- return;
- }
- }
- string[] strParams = new string[3] { this.strID, strPos, strStatus };
- strErr = "";
- string msg = "";
- ProcedureZ("Core.LgMes.Server.DEV.Methods.DEVPublicMethods", "procedure", new object[] { "RES_LG_TOOLMANAGE.ZJBSTATUS_CHANGE", strParams },ob, out strErr, out msg);
- if (Convert.ToInt32(strErr) > 0)
- {
- FrmTundishManage frm = (FrmTundishManage)this.Tag;
- frm.QueryZJBData(this.strCCM, this.strNO);
- MessageBox.Show(msg, "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
-
- //修改中间包铸机号
- ZJBCcmNo_Edit();
- this.Close();
- }
- else
- MessageBox.Show(msg, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message);
- }
- }
- /// <summary>
- /// 修改中间包对应的铸机号
- /// </summary>
- public void ZJBCcmNo_Edit()
- {
- string strErr = "";
- ArrayList arry = new ArrayList();
- arry.Add("FrmZJB_CCMNO.Edit");
- 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);
- }
- FrmTundishManage frm = (FrmTundishManage)this.Tag;
- frm.QueryZJBData(this.strCCM, this.strNO);
- }
- private void btnOK_Click(object sender, EventArgs e)
- {
- this.proc_OK();
- }
- }
- }
|