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; using System.Collections; namespace Core.LgMes.Client.LgDeviceManager { public partial class FrmSGBaseInfo : Core.Mes.Client.Common.frmStyleBase//frmModelFormStyle { bool bOK = false; //是否响应扇形段号选择改变事件 public string strNo = "", strCCM = ""; public FrmSGBaseInfo(OpeBase oba) { InitializeComponent(); ob = oba; } private void txtAge_KeyPress(object sender, KeyPressEventArgs e) { if (!(Char.IsNumber(e.KeyChar) || e.KeyChar == '\b')) { e.Handled = true; } } private void FrmSGBaseInfo_Load(object sender, EventArgs e) { if (strCCM.Length > 0) { cmbCCM.Text = strCCM; this.cbbCCM_SelectedIndexChanged(this, null); if (strNo.Length > 0) { cmbID.Text = strNo; bOK = true; this.cbbID_SelectedIndexChanged(this, null); } } else bOK = true; } /// /// 扇形段号加载 /// /// private void proc_GetID(string strCCM) { try { if (strCCM.Length == 0) return; string strErr = ""; ArrayList arry = new ArrayList(); if (strCCM == "1#连铸机" || strCCM == "2#连铸机") { arry.Add("OneandTwoCCM_SG.select"); } else { arry.Add("FrmSGBaseInfo_Query1"); arry.Add(strCCM); } 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)) { MessageBox.Show("扇形段号加载失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); if (MessageBox.Show("是否重新加载扇形段号?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) proc_GetID(strCCM); return; } cmbID.DataSource = ds.Tables[0]; cmbID.DisplayMember = "SEGMENTID"; if (ds.Tables[0].Rows.Count == 0) proc_ResetControl(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } private void proc_ResetControl() { try { cmbID.Text = ""; txtType.Clear(); txtSYCS.Clear(); txtStatus.Clear(); txtPos.Clear(); udteBuyTime.DateTime = DateTime.Today; txtMemo.Clear(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } /// /// 新增 /// private void proc_Add() { try { string strCcm = cmbCCM.Text.Trim(); string strID = cmbID.Text.Trim(); if (strCcm.Length == 0) { MessageBox.Show("请选择铸机号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); cmbCCM.Focus(); return; } if (strID.Length == 0) { MessageBox.Show("请输入扇形段编号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); cmbID.Focus(); return; } string strType = "1"; //板坯扇形段 string strErr = ""; ArrayList arry = new ArrayList(); arry.Add("FrmSGBaseInfo_Query3"); arry.Add(strCcm); 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("新增[" + 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); cmbID.Focus(); return; } string strReturn = ""; strErr = ""; arry.Clear(); ccs.ob = ob; arry.Add("FrmSGBaseInfo_Add1"); arry.Add(strID); arry.Add(strCcm); arry.Add(strType); arry.Add(txtSYCS.Text.Trim() == "" ? "0" : txtSYCS.Text.Trim()); arry.Add(udteBuyTime.DateTime.ToString("yyyy-MM-dd")); arry.Add(txtMemo.Text.Trim()); strReturn = ccs.NoQueryFunctions("Core.LgMes.Server.Common.ComDBSave", "doSimpleSave", arry, out strErr); if (!(strErr == null || strErr == "")) { MessageBox.Show("新增[" + strCcm + "]扇形段[" + strID + "]失败!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } FrmSegMentManage frm = (FrmSegMentManage)this.Tag; frm.proc_GetBaseInfo(strCcm, strID); proc_GetID(strCcm); MessageBox.Show("新增[" + strCcm + "]扇形段[" + strID + "]成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); this.Close(); return; } catch (Exception ex) { MessageBox.Show(ex.Message); } } /// /// 修改 /// private void proc_Edit() { try { string strCcm = cmbCCM.Text.Trim(); string strID = cmbID.Text.Trim(); if (strID.Length == 0) { MessageBox.Show("请选择需要修改的扇形段编号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); cmbID.Focus(); return; } if (MessageBox.Show("确定要修改[" + strCcm + "]的扇形段[" + strID + "]信息吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) return; string strErr = ""; ArrayList arry = new ArrayList(); arry.Add("FrmSGBaseInfo_Query4"); arry.Add(strCcm); 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("[" + strCcm + "]扇形段[" + strID + "]信息修改失败!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } string strReturn = ""; strErr = ""; arry.Clear(); arry.Add("FrmSGBaseInfo_Update1"); arry.Add(strCcm); arry.Add(txtSYCS.Text.Trim() == "" ? "0" : txtSYCS.Text.Trim()); arry.Add(udteBuyTime.DateTime.ToString("yyyy-MM-dd")); arry.Add(txtMemo.Text.Trim()); arry.Add(strID); strReturn = ccs.NoQueryFunctions("Core.LgMes.Server.Common.ComDBSave", "doSimpleSave", arry, out strErr); if (!(strErr == null || strErr == "")) { MessageBox.Show("[" + strCcm + "]扇形段[" + strID + "]信息修改失败!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } FrmSegMentManage frm = (FrmSegMentManage)this.Tag; frm.proc_GetBaseInfo(strCcm, strID); proc_GetID(strCcm); MessageBox.Show("[" + strCcm + "]扇形段[" + strID + "]信息修改成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); this.Close(); return; } catch (Exception ex) { MessageBox.Show(ex.Message); } } /// /// 删除 /// private void proc_Del() { try { string strCcm = cmbCCM.Text.Trim(); string strID = cmbID.Text.Trim(); if (strID.Length == 0) { MessageBox.Show("请选择需要删除的扇形段编号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); cmbID.Focus(); return; } if (MessageBox.Show("确定要删除[" + strCcm + "]扇形段[" + strID + "]的信息吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) return; string strErr = ""; ArrayList arry = new ArrayList(); arry.Add("FrmSGBaseInfo_Query5"); arry.Add(strCcm); 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("[" + strCcm + "]扇形段[" + strID + "]信息删除失败!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } ds = null; strErr = ""; arry.Clear(); ccs.ob = ob; arry.Add("FrmSGBaseInfo_Query6"); arry.Add(strCcm); 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("[" + strCcm + "]扇形段[" + strID + "]信息删除失败!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } ds = null; strErr = ""; arry.Clear(); ccs.ob = ob; arry.Add("FrmSGBaseInfo_Query7"); arry.Add(strCcm); 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("[" + strCcm + "]扇形段[" + strID + "]信息删除失败!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } string strReturn = ""; strErr = ""; arry.Clear(); arry.Add("FrmSGBaseInfo_Del1"); arry.Add(strCcm); arry.Add(strID); strReturn = ccs.NoQueryFunctions("Core.LgMes.Server.Common.ComDBSave", "doSimpleSave", arry, out strErr); if (!(strErr == null || strErr == "")) { MessageBox.Show("[" + strCcm + "]扇形段[" + strID + "]信息删除失败!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } FrmSegMentManage frm = (FrmSegMentManage)this.Tag; frm.proc_GetBaseInfo(strCcm, ""); proc_GetID(strCcm); MessageBox.Show("[" + strCcm + "]扇形段[" + strID + "]信息删除成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); this.Close(); return; } catch (Exception ex) { MessageBox.Show(ex.Message); } } /// /// 菜单栏 /// /// /// private void toolStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e) { switch (e.ClickedItem.Name) { case "ADD": { this.proc_Add(); break; } case "EDIT": { this.proc_Edit(); break; } case "DEL": { this.proc_Del(); break; } case "CLOSE": { this.Close(); break; } default: break; } } private void cbbCCM_SelectedIndexChanged(object sender, EventArgs e) { if (cmbCCM.Text.Length > 0) proc_GetID(cmbCCM.Text); } /// /// 扇形段信息查询 /// /// /// private void cbbID_SelectedIndexChanged(object sender, EventArgs e) { try { if (!bOK) return; string strCCM = cmbCCM.Text.Trim(); string strID = cmbID.Text.Trim(); if (strID.Length == 0) return; string strErr = ""; ArrayList arry = new ArrayList(); arry.Add("FrmSGBaseInfo_Query2"); arry.Add(strID); arry.Add(strCCM); 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)) { MessageBox.Show("扇形段[" + strID + "]信息查询失败!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (ds.Tables[0].Rows.Count == 0) return; txtType.Text = Convert.ToString(ds.Tables[0].Rows[0]["TYPE"]); txtSYCS.Text = Convert.ToString(ds.Tables[0].Rows[0]["USETIMES"]); txtStatus.Text = Convert.ToString(ds.Tables[0].Rows[0]["NOWSTATUS"]); txtPos.Text = Convert.ToString(ds.Tables[0].Rows[0]["POSITION"]); udteBuyTime.DateTime = Convert.ToDateTime(ds.Tables[0].Rows[0]["BUYDATE"]); txtMemo.Text = Convert.ToString(ds.Tables[0].Rows[0]["MEMO"]); } catch (Exception ex) { MessageBox.Show(ex.Message, "提示"); } } } }