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 { } } /// /// 加载真空槽号 /// 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); } } /// /// 真空槽信息查询 /// /// /// 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); } } /// /// 真空槽信息新增 /// 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); } } /// /// 真空槽信息修改 /// 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); } } /// /// 真空槽信息删除 /// 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); } } /// /// 菜单栏 /// /// /// 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; } } } }