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 FrmTDBaseInfo : FrmLgDevFunctions { bool bOK = false; //是否响应中间包号选择改变事件 public string strBH = "", strCCM = "",strPID=""; public FrmTDBaseInfo(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 FrmTDBaseInfo_Load(object sender, EventArgs e) { if (strCCM.Length > 0) { ucmeCCM.Text = strCCM; this.cbbCCM_SelectedIndexChanged(this, null);//铸机号查询 if (strBH.Length > 0) { ucmeID.Text = strBH; 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("Proc_GetIDByOneTWOCCM"); } else { arry.Add("proc_GetID.Query"); 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; } ucmeID.Items.Clear(); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { ucmeID.Items.Add(ds.Tables[0].Rows[i][0]); } if (ds.Tables[0].Rows.Count == 0) proc_ResetControl(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } private void proc_ResetControl() { try { ucmeID.Text = ""; txtStatus.Clear(); txtAge.Clear(); udtePTime.DateTime = DateTime.Now; udteBuyTime.DateTime = DateTime.Now; txtMemo.Clear(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } private void proc_Add() { try { string strErr = ""; string msg = ""; string strCcm = ucmeCCM.Text.Trim(); string strID = ucmeID.Text.Trim(); string tbAge = this.txtAge.Text.Trim(); string tionDateTime = Convert.ToDateTime(udtePTime.Value.ToString()).ToString("yyyy-MM-dd"); string BuyDateTime = Convert.ToDateTime(udteBuyTime.Value.ToString()).ToString("yyyy-MM-dd"); string tbMemo = this.txtMemo.Text.Trim(); CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "Core.LgMes.Server.LgDeviceManager.LadleManager"; ccp.MethodName = "proc_Add"; string[] a = new string[] { strCcm, strID, tbAge, tionDateTime, BuyDateTime, tbMemo }; ccp.ServerParams = new Object[] { "LG_DEV_ZJB_BaseInfo_add", a }; ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal); System.Collections.ArrayList al = (System.Collections.ArrayList)ccp.ReturnObject; strErr = al[0].ToString(); msg = al[1].ToString(); if (strErr == "1") { FrmTundishManage frm = (FrmTundishManage)this.Tag; frm.QueryZJBData(strCcm, strID); proc_GetID(strCcm); MessageBox.Show(msg, "提示", MessageBoxButtons.OK); return; } else { MessageBox.Show(msg, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } catch (Exception ex) { MessageBox.Show(ex.Message); } } private void proc_Edit() { try { if (ucmeID.Items.Count == 0) return; string strCcm = ucmeCCM.Text.Trim(); string strID = ucmeID.Text.Trim(); if (strID.Length == 0) { MessageBox.Show("请选择需要修改的中间包编号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); ucmeID.Focus(); return; } if (MessageBox.Show("确定要修改[" + strCcm + "]的中间包[" + strID + "]信息吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) return; string strErr = ""; string strSql = "select count(1) from DEV_ZJB_BASE_INFO where CCM_ID = '" + strCcm + "' and TUNDISHID = '" + strID + "'"; CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "Core.LgMes.Server.DEV.Methods.DEVPublicMethods"; ccp.MethodName = "QueryMethods"; ccp.ServerParams = new Object[] { strSql }; DataTable dt = new DataTable(); ccp.SourceDataTable = dt; ob.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal); DataSet ds = new DataSet(); ds.Tables.Add(dt); 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; } strErr = ""; strSql = "update DEV_ZJB_BASE_INFO set " + "CCM_ID = '" + strCcm + "'," + "AGE = '" + (txtAge.Text.Trim() == "" ? "0" : txtAge.Text.Trim()) + "'," + "CREATIVEDATE = to_date('" + udtePTime.DateTime.ToString("yyyy-MM-dd") + "','yyyy-MM-dd')," + "BUYDATE = to_date('" + udteBuyTime.DateTime.ToString("yyyy-MM-dd") + "','yyyy-MM-dd')," + "MEMO = '" + txtMemo.Text.Trim() + "' " + "where TUNDISHID = '" + strID + "' and ID='" + strPID + "'"; CoreClientParam ccp_up = new CoreClientParam(); ccp_up.ServerName = "Core.LgMes.Server.DEV.Methods.DEVPublicMethods"; ccp_up.MethodName = "UpdateMethods"; ccp_up.ServerParams = new Object[] { strSql }; ob.ExecuteNonQuery(ccp_up, CoreInvokeType.Internal); FrmTundishManage frm = (FrmTundishManage)this.Tag; frm.QueryZJBData(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 { if (ucmeID.Items.Count == 0) return; string strCcm = ucmeCCM.Text.Trim(); string strID = ucmeID.Text.Trim(); if (strID.Length == 0) { MessageBox.Show("请选择需要删除的中间包编号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); ucmeID.Focus(); return; } if (MessageBox.Show("确定要删除[" + strCcm + "]中间包[" + strID + "]的信息吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) return; string strErr = ""; string strSql = "select count(1) from DEV_ZJB_BASE_INFO where CCM_ID = '" + strCcm + "' and TUNDISHID = '" + strID + "'"; CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "Core.LgMes.Server.DEV.Methods.DEVPublicMethods"; ccp.MethodName = "QueryMethods"; ccp.ServerParams = new Object[] { strSql }; DataTable dt = new DataTable(); ccp.SourceDataTable = dt; ob.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal); DataSet ds = new DataSet(); ds.Tables.Add(dt); 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); ucmeID.Focus(); return; } iCnt = 0; ds = null; strErr = ""; strSql = "select count(1) from DEV_ZJB_USE_DETAIL where TUNDISHID = (select ID from DEV_ZJB_BASE_INFO where CCM_ID = '" + strCcm + "' and TUNDISHID = '" + strID + "')"; CoreClientParam ccp_up = new CoreClientParam(); ccp_up.ServerName = "Core.LgMes.Server.DEV.Methods.DEVPublicMethods"; ccp_up.MethodName = "QueryMethods"; ccp_up.ServerParams = new Object[] { strSql }; DataTable dtt = new DataTable(); ccp_up.SourceDataTable = dtt; ob.ExecuteQueryToDataTable(ccp_up, CoreInvokeType.Internal); DataSet dss = new DataSet(); dss.Tables.Add(dtt); if (strErr != "" || !(dss != null && dss.Tables.Count > 0 && dss.Tables[0].Rows.Count > 0)) { MessageBox.Show("[" + strCcm + "]中间包[" + strID + "]信息删除失败!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } iCnt = Convert.ToInt32(dss.Tables[0].Rows[0][0]); if (iCnt > 0) { MessageBox.Show("[" + strCcm + "]中间包[" + strID + "]存在使用记录,不能删除!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); ucmeID.Focus(); return; } strErr = ""; strSql = "delete from DEV_ZJB_BASE_INFO where CCM_ID = '" + strCcm + "' and TUNDISHID = '" + strID + "'"; CoreClientParam ccp_del = new CoreClientParam(); ccp_del.ServerName = "Core.LgMes.Server.DEV.Methods.DEVPublicMethods"; ccp_del.MethodName = "UpdateMethods"; ccp_del.ServerParams = new Object[] { strSql }; ob.ExecuteNonQuery(ccp_del, CoreInvokeType.Internal); if (!(strErr == null || strErr == "")) { MessageBox.Show("[" + strCcm + "]中间包[" + strID + "]信息删除失败!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } FrmTundishManage frm = (FrmTundishManage)this.Tag; frm.QueryZJBData(strCcm, ""); proc_GetID(strCcm); MessageBox.Show("[" + strCcm + "]中间包[" + strID + "]信息删除成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); 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 (ucmeCCM.Text.Length > 0) proc_GetID(ucmeCCM.Text); } /// /// 中间包查询 /// /// /// private void cbbID_SelectedIndexChanged(object sender, EventArgs e) { try { if (!bOK) return; string strCCM = ucmeCCM.Text.Trim(); string strID = ucmeID.Text.Trim(); if (strID.Length == 0) return; string strErr = ""; string strSql = "where TUNDISHID = '" + strID + "' and CCM_ID = '" + strCCM + "'"; CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "Core.LgMes.Server.LgDeviceManager.LadleManager"; ccp.MethodName = "cbbID_SelectedIndexChanged"; ccp.ServerParams = new Object[] { strSql }; DataTable dt = new DataTable(); ccp.SourceDataTable = dt; ob.ExecuteQueryToDataTable(ccp,CoreInvokeType.Internal); DataSet ds = new DataSet(); ds.Tables.Add(dt); if (strErr != "" || !(ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)) { MessageBox.Show("中间包[" + strID + "]信息查询失败!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } txtStatus.Text = Convert.ToString(ds.Tables[0].Rows[0]["STATUS"]); txtAge.Text = Convert.ToString(ds.Tables[0].Rows[0]["AGE"]); udtePTime.DateTime = Convert.ToDateTime(ds.Tables[0].Rows[0]["CREATIVEDATE"]); 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, "提示"); } } } }