| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573 |
- 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 FrmVTPluginInfo : FrmLgDevFunctions
- {
- public FrmVTPluginInfo(OpeBase opb)
- {
- InitializeComponent();
- ob = opb;
- }
- private void FrmVTPluginInfo_Load(object sender, EventArgs e)
- {
- udteBuyTime.DateTime = DateTime.Today;
- proc_LoadPluginID();
- proc_Query("", "");
- }
- private void cbCCM_CheckedChanged(object sender, EventArgs e)
- {
- cmbCCM.Enabled = chkCCM.Checked;
- }
- private void cbID_CheckedChanged(object sender, EventArgs e)
- {
- cmbID.Enabled = chkID.Checked;
- }
- private void cbbCCM_SelectedIndexChanged(object sender, EventArgs e)
- {
- proc_LoadPluginID();
- }
- private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
- {
- try
- {
- if (ultraGrid1.Rows.Count == 0) return;
- if (ultraGrid1.ActiveRow == null) return;
- cmbZJH.Text = Convert.ToString(ultraGrid1.ActiveRow.Cells["RH炉号"].Value);
- txtNO.Text = Convert.ToString(ultraGrid1.ActiveRow.Cells["槽号"].Value);
- txtCS.Text = Convert.ToString(ultraGrid1.ActiveRow.Cells["槽龄"].Value);
- udteBuyTime.DateTime = Convert.ToDateTime(ultraGrid1.ActiveRow.Cells["购买日期"].Value);
- txtMemo.Text = Convert.ToString(ultraGrid1.ActiveRow.Cells["备注"].Value);
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message);
- }
- }
- private void proc_ExecuteCommand_Return(object[] obj, out DataSet ds, out string strErr)
- {
- //CallingMessage par = new CallingMessage();
- //par.ServerName = "炼钢工器具";
- //par.AssemblyName = "Core.LgMes.Server.LgDeviceManager";
- //par.ClassName = "Core.LgMes.Server.LgDeviceManager.jjqmanager";
- //par.MethodName = "ExecuteCommand_Return";
- //par.args = obj;
- strErr = "";
- ds = null;//ClientCommon._RemotingHelp.ExecuteMethod(par, out strErr) as DataSet;
- }
- private void proc_ExecuteCommand_NonReturn(object[] obj, out string strErr)
- {
- //CallingMessage par = new CallingMessage();
- //par.ServerName = "炼钢工器具";
- //par.AssemblyName = "Core.LgMes.Server.LgDeviceManager";
- //par.ClassName = "Core.LgMes.Server.LgDeviceManager.jjqmanager";
- //par.MethodName = "ExecuteCommand_NonReturn";
- //par.args = obj;
- strErr = "";
- //ClientCommon._RemotingHelp.ExecuteMethod(par, out strErr);
- }
- private void proc_ResetControl()
- {
- try
- {
- cmbZJH.SelectedIndex = -1;
- txtNO.Clear();
- txtCS.Clear();
- udteBuyTime.DateTime = DateTime.Today;
- txtMemo.Clear();
- }
- catch { }
- }
- /// <summary>
- /// 加载真空槽号
- /// </summary>
- private void proc_LoadPluginID()
- {
- try
- {
- string strWhere = "";
- if (cmbCCM.SelectedIndex > -1)
- {
- strWhere = "and RHS_ID = '" + cmbCCM.Text.Trim() + "' ";
- }
- string strErr = "";
- ArrayList arry = new ArrayList();
- ArrayList sqlList = new ArrayList();
- arry.Add("FrmVTPluginInfo_Query2");
- if (cmbCCM.SelectedIndex > -1)
- {
- sqlList.Add(strWhere);
- }
- else
- {
- sqlList.Add(strWhere);
- }
- CoreClientParam CCP_LgEts = new CoreClientParam();
- DataTable dt = new DataTable();
- CCP_LgEts.ServerName = "Core.LgMes.Server.Common.ComDBQuery";
- CCP_LgEts.MethodName = "doQuery";
- CCP_LgEts.ServerParams = new object[] { arry, sqlList };
- CCP_LgEts.SourceDataTable = dt;
- this.ExecuteQueryToDataTable(CCP_LgEts, 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_LoadPluginID();
- return;
- }
- cmbID.ResetText();
- cmbID.DataSource = ds.Tables[0];
- cmbID.DisplayMember = "PLUGINNO";
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message);
- }
- }
- /// <summary>
- /// 真空槽信息查询
- /// </summary>
- /// <param RH炉号="strRHS"></param>
- /// <param 槽号="strID"></param>
- private void proc_Query(string strRHS, string strID)
- {
- try
- {
- string strwhere = "";
- string PLUG = "";
- if (chkCCM.Checked && cmbCCM.SelectedIndex > -1)
- {
- strwhere= "and t.RHS_ID = '"+cmbCCM.SelectedItem.ToString()+"'";
- }
- if (chkID.Checked && cmbID.SelectedIndex > -1)
- {
- PLUG= "and t.PLUGINNO='"+cmbID.Text.Trim()+"'";
- }
- string strErr = "";
- ArrayList arry = new ArrayList();
- ArrayList sqlList = new ArrayList();
-
- arry.Add("FrmVTPluginInfo_Query1");
- if (chkCCM.Checked)
- {
- sqlList.Add(strwhere);
- }
- else { sqlList.Add(strwhere); }
- if (chkID.Checked)
- {
- sqlList.Add(PLUG);
- }
- else { sqlList.Add(PLUG); }
- CoreClientParam CCP_LgEts = new CoreClientParam();
- DataTable dt = new DataTable();
- CCP_LgEts.ServerName = "Core.LgMes.Server.Common.ComDBQuery";
- CCP_LgEts.MethodName = "doQuery";
- CCP_LgEts.ServerParams = new object[] { arry, sqlList };
- CCP_LgEts.SourceDataTable = dt;
- this.ExecuteQueryToDataTable(CCP_LgEts, CoreInvokeType.Internal);
- DataSet ds = new DataSet();
- ds.Tables.Add(dt);
- try
- {
- ((DataSet)ultraGrid1.DataSource).Tables[0].Rows.Clear();
- }
- catch (Exception)
- {
- }
- if (ds != null && ds.Tables[0].Rows.Count > 0)
- {
- ultraGrid1.DataSource = ds.Tables[0];
- }
-
- if (strErr != "" || !(ds != null && ds.Tables.Count > 0))
- {
- MessageBox.Show("真空槽信息查询失败!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
- return;
- }
- if (ds.Tables[0].Rows.Count == 0)
- {
- proc_ResetControl();
- return;
- }
- if (strRHS.Length > 0) //定位记录
- {
- for (int i = 0; i < ultraGrid1.Rows.Count; i++)
- {
- if (Convert.ToString(ultraGrid1.Rows[i].Cells["RH炉号"].Value) == strRHS)
- {
- if (strID.Length > 0)
- {
- if (Convert.ToString(ultraGrid1.Rows[i].Cells["槽号"].Value) == strID)
- {
- ultraGrid1.ActiveRow = ultraGrid1.Rows[i];
- ultraGrid1.Rows[i].Selected = true;
- return;
- }
- }
- else
- {
- ultraGrid1.ActiveRow = ultraGrid1.Rows[i];
- ultraGrid1.Rows[i].Selected = true;
- return;
- }
- }
- }
- }
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message);
- }
- }
- /// <summary>
- /// 真空槽信息新增
- /// </summary>
- private void proc_Add()
- {
- try
- {
- if (cmbZJH.SelectedIndex < 0)
- {
- MessageBox.Show("请选择RH炉号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- cmbZJH.Focus();
- return;
- }
- if (txtNO.Text.Trim().Length == 0)
- {
- MessageBox.Show("请录入槽号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- txtNO.Focus();
- return;
- }
- string strRHS = cmbZJH.Text.Trim();
- string strNO = txtNO.Text.Trim();
- string strUseTimes = (txtCS.Text.Trim().Length == 0 ? "0" : txtCS.Text.Trim());
- string strDate = udteBuyTime.DateTime.ToString("yyyy-MM-dd");
- string strMemo = txtMemo.Text.Trim();
- string strErr = "";
- ArrayList arry = new ArrayList();
- arry.Add("FrmVTPluginInfo_Query3");
- arry.Add(strRHS);
- arry.Add(strNO);
- CommonClientToServer ccs = new CommonClientToServer();
- ccs.ob = this.ob;
- DataSet ds = ccs.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBQuery", "doSimpleQuery", arry, out strErr);
- if (strErr != "" || !(ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0))
- {
- MessageBox.Show("新增[" + strRHS + "]槽号[" + strNO + "]失败!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
- return;
- }
- int iCnt = Convert.ToInt32(ds.Tables[0].Rows[0][0]);
- if (iCnt > 0)
- {
- MessageBox.Show("[" + strRHS + "]已存在槽号[" + strNO + "],不能重复录入!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
- txtNO.Focus();
- return;
- }
- strErr = "";
- arry.Clear();
- ccs.ob = this.ob;
-
- arry.Add("FrmVTPluginInfo_Add.1");
- arry.Add(strNO);
- arry.Add(strRHS);
- arry.Add(strUseTimes);
- arry.Add(strDate);
- arry.Add(strMemo);
- string strReturn = ccs.NoQueryFunctions("Core.LgMes.Server.Common.ComDBSave", "doSimpleSave", arry, out strErr);
- if (!(strErr == null || strErr == ""))
- {
- MessageBox.Show("新增[" + strRHS + "]槽号[" + strNO + "]失败!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
- return;
- }
- proc_Query(strRHS, strNO);
- MessageBox.Show("新增[" + strRHS + "]槽号[" + strNO + "]成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message);
- }
- }
- /// <summary>
- /// 真空槽信息修改
- /// </summary>
- private void proc_Edit()
- {
- try
- {
- if (ultraGrid1.Rows.Count == 0)
- return;
- if (ultraGrid1.ActiveRow == null)
- {
- MessageBox.Show("请选择您要修改的记录!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- return;
- }
- if (cmbZJH.SelectedIndex < 0)
- {
- MessageBox.Show("请选择RH炉号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- cmbZJH.Focus();
- return;
- }
- if (txtNO.Text.Trim().Length == 0)
- {
- MessageBox.Show("请录入槽号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- txtNO.Focus();
- return;
- }
- string strRHS = cmbZJH.Text.Trim();
- string strNO = txtNO.Text.Trim();
- string strUseTimes = (txtCS.Text.Trim().Length == 0 ? "0" : txtCS.Text.Trim());
- string strDate = udteBuyTime.DateTime.ToString("yyyy-MM-dd");
- string strMemo = txtMemo.Text.Trim();
- if (MessageBox.Show("确定要修改[" + strRHS + "]槽号[" + strNO + "]相关信息吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
- return;
- string strErr = "";
- ArrayList arry = new ArrayList();
- arry.Add("FrmVTPluginInfo_Query4");
- arry.Add(strRHS);
- arry.Add(strNO);
- CommonClientToServer ccs = new CommonClientToServer();
- ccs.ob = this.ob;
- DataSet ds = ccs.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBQuery", "doSimpleQuery", arry, out strErr);
- if (strErr != "" || !(ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0))
- {
- MessageBox.Show("[" + strRHS + "]槽号[" + strNO + "]信息修改失败!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
- return;
- }
- int iCnt = Convert.ToInt32(ds.Tables[0].Rows[0][0]);
- if (iCnt == 0)
- {
- MessageBox.Show("[" + strRHS + "]不存在槽号[" + strNO + "],无法修改!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
- txtNO.Focus();
- return;
- }
- strErr = "";
- arry.Clear();
- ccs.ob = this.ob;
- arry.Add("FrmVTPluginInfo_Edit.1");
- arry.Add(strUseTimes);
- arry.Add(strDate);
- arry.Add(strMemo);
- arry.Add(strRHS);
- arry.Add(strNO);
- string strReturn = ccs.NoQueryFunctions("Core.LgMes.Server.Common.ComDBSave", "doSimpleSave", arry, out strErr);
- if (!(strErr == null || strErr == ""))
- {
- MessageBox.Show("[" + strRHS + "]槽号[" + strNO + "]信息修改失败!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
- return;
- }
- proc_Query(strRHS, strNO);
- MessageBox.Show("[" + strRHS + "]槽号[" + strNO + "]信息修改成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message);
- }
- }
- /// <summary>
- /// 真空槽信息删除
- /// </summary>
- private void proc_Del()
- {
- try
- {
- if (ultraGrid1.Rows.Count == 0)
- return;
- if (ultraGrid1.ActiveRow == null)
- {
- MessageBox.Show("请选择您要删除的记录!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- return;
- }
- string strID = Convert.ToString(ultraGrid1.ActiveRow.Cells["ID"].Value);
- string strNO = Convert.ToString(ultraGrid1.ActiveRow.Cells["槽号"].Value);
- string strRHS = Convert.ToString(ultraGrid1.ActiveRow.Cells["RH炉号"].Value);
- if (MessageBox.Show("确定要删除[" + strRHS + "]槽号[" + strNO + "]信息吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
- return;
- string strErr = "";
- ArrayList arry = new ArrayList();
- arry.Add("FrmVTPluginInfo_Query5");
- arry.Add(strID);
- CommonClientToServer ccs = new CommonClientToServer();
- ccs.ob = this.ob;
- DataSet ds = ccs.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBQuery", "doSimpleQuery", arry, out strErr);
- if (strErr != "" || !(ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0))
- {
- MessageBox.Show("[" + strRHS + "]槽号[" + strNO + "]信息删除失败!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
- return;
- }
- int iCnt = Convert.ToInt32(ds.Tables[0].Rows[0][0]);
- if (iCnt == 0)
- {
- MessageBox.Show("[" + strRHS + "]不存在槽号[" + strNO + "],无法删除!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
- txtNO.Focus();
- return;
- }
- iCnt = 0;
- strErr = "";
- arry.Clear();
- ds = null;
- ccs.ob = this.ob;
- arry.Add("FrmVTPluginInfo_Query6");
- arry.Add(strID);
- arry.Add(strID);
- arry.Add(strID);
- ds = ccs.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBQuery", "doSimpleQuery", arry, out strErr);
- if (strErr != "" || !(ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0))
- {
- MessageBox.Show("[" + strRHS + "]槽号[" + strNO + "]信息删除失败!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
- return;
- }
- iCnt = Convert.ToInt32(ds.Tables[0].Rows[0][0]);
- if (iCnt > 0)
- {
- MessageBox.Show("[" + strRHS + "]槽号[" + strNO + "]存在使用记录,不能删除!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
- txtNO.Focus();
- return;
- }
- strErr = "";
- arry.Clear();
- ds = null;
- ccs.ob = this.ob;
- arry.Add("FrmVTPluginInfo_Query7");
- arry.Add(strID);
- arry.Add(strID);
- arry.Add(strID);
- ds = ccs.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBQuery", "doSimpleQuery", arry, out strErr);
- if (strErr != "" || !(ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0))
- {
- MessageBox.Show("[" + strRHS + "]槽号[" + strNO + "]信息删除失败!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
- return;
- }
- iCnt = Convert.ToInt32(ds.Tables[0].Rows[0][0]);
- if (iCnt > 0)
- {
- MessageBox.Show("[" + strRHS + "]槽号[" + strNO + "]存在使用记录,不能删除!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
- txtNO.Focus();
- return;
- }
- strErr = "";
- arry.Clear();
- ccs.ob = this.ob;
- arry.Add("FrmVTPluginInfo_Del.1");
- arry.Add(strID);
- string strReturn = ccs.NoQueryFunctions("Core.LgMes.Server.Common.ComDBSave", "doSimpleSave", arry, out strErr);
- if (!(strErr == null || strErr == ""))
- {
- MessageBox.Show("[" + strRHS + "]槽号[" + strNO + "]信息删除失败!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
- return;
- }
- proc_Query(strRHS, strNO);
- MessageBox.Show("[" + strRHS + "]槽号[" + strNO + "]信息删除成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message);
- }
- }
- /// <summary>
- /// 菜单栏
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void toolStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
- {
- if (e.ClickedItem == null) return;
- switch (e.ClickedItem.Name)
- {
- case "QUERY":
- {
- proc_Query("", "");
- break;
- }
- case "ADD":
- {
- proc_Add();
- break;
- }
- case "EDIT":
- {
- proc_Edit();
- break;
- }
- case "DEL":
- {
- proc_Del();
- break;
- }
- case "CLOSE":
- {
- this.Close();
- break;
- }
- }
- }
- private void tbCS_KeyPress(object sender, KeyPressEventArgs e)
- {
- if (!(Char.IsNumber(e.KeyChar) || e.KeyChar == '\b' || e.KeyChar == '.') ||
- (((TextBox)(sender)).Text.Trim().Contains(".") && e.KeyChar == '.') ||
- (((TextBox)(sender)).Text.Trim().Length == 0 && e.KeyChar == '.'))
- {
- e.Handled = true;
- }
- }
- }
- }
|