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 FrmILBaseInfo :Core.Mes.Client.Common.frmStyleBase { private bool bOK = false; private string strInitID = ""; #region "================================Add on 2009-07-28==============================" #endregion public string strInitiD = ""; public FrmILBaseInfo(OpeBase oba) { InitializeComponent(); this.strInitID = strInitiD; ob=oba; } private void FrmILBaseInfo_Load(object sender, EventArgs e) { proc_GetID(strInitID); bOK = true; cbbID_SelectedIndexChanged(null, null); } private void cbbID_SelectedIndexChanged(object sender, EventArgs e) { if (!bOK) return; if (ucmeID.Items.Count == 0) return; string strID = ucmeID.Text.Trim(); proc_GetInfo(strID); } private void proc_ResetEditArea(bool bFlag) { try { if (bFlag) ucmeID.Text = ""; txtCurrStatus.Text = "系统默认"; txtAgeTS.Clear(); tbAgeBG.Clear(); txtMemo.Clear(); } catch { } } /// /// 加载铁包信息 /// /// private void proc_GetInfo(string strID) { try { string strErr = ""; ArrayList arry = new ArrayList(); arry.Add("FrmILBaseInfo_Query1"); arry.Add(ucmeID.Text.Trim()); 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) { proc_ResetEditArea(false); if (ds.Tables[0].Rows.Count > 0) { txtCurrStatus.Text = ds.Tables[0].Rows[0]["当前状态"].ToString(); //当前状态 txtAgeTS.Text = ds.Tables[0].Rows[0]["铁水包龄"].ToString(); //铁水包龄 tbAgeBG.Text = ds.Tables[0].Rows[0]["半钢包龄"].ToString(); //半钢包龄 txtMemo.Text = ds.Tables[0].Rows[0]["备注"].ToString();//备注 txtProduct.Text = ds.Tables[0].Rows[0]["MANUFACTURERS"].ToString();//生产厂家 txtTraeWeight.Text = ds.Tables[0].Rows[0]["TAREWEIGHT"].ToString();//生产厂家 } } else { MessageBox.Show("铁包信息查询出错!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception ex) { MessageBox.Show("铁包信息查询出错!\r\n" + ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } } /// /// 加载铁包编号 /// /// private void proc_GetID(string strID) { try { string strErr = ""; ArrayList arry = new ArrayList(); arry.Add("FrmILBaseInfo_Query2"); 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) { this.ucmeID.Items.Clear(); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { ucmeID.Items.Add(ds.Tables[0].Rows[i]["铁包编号"]); } if (ds.Tables[0].Rows.Count == 0) { proc_ResetEditArea(true); return; } if (strID.Length > 0) ucmeID.Text = strID; cbbID_SelectedIndexChanged(null, null); } else { MessageBox.Show("铁包包号信息查询出错!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception ex) { MessageBox.Show("铁包包号信息查询出错!\r\n" + ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } } private void TextBoxNumberEditor_KeyPress(object sender, KeyPressEventArgs e) { try { if (!(Char.IsNumber(e.KeyChar) || e.KeyChar == '\b' || e.KeyChar == '.')) e.Handled = true; } catch { } } /// /// 铁包基础信息新增 /// private void IronLadle_Add() { try { if (ucmeID.Text.Trim().Length == 0) { MessageBox.Show("请输入铁包编号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); ucmeID.Focus(); return; } string strErr = ""; ArrayList arry = new ArrayList(); arry.Add("FrmILBaseInfo_Query3"); arry.Add(ucmeID.Text.Trim()); 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("铁包[" + ucmeID.Text.Trim() + "]新增失败,请重试!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (ds.Tables[0].Rows.Count > 0) { MessageBox.Show("铁包编号[" + ucmeID.Text.Trim() + "]已经存在,请重新指定!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); ucmeID.Focus(); return; } string strmaxid = ""; strErr = ""; arry.Clear(); ds = null; arry.Add("QueryIronMaxID"); ccs.ob = this.ob; ds = ccs.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBQuery", "doSimpleQuery", arry, out strErr); if (strErr == "" && ds != null && ds.Tables.Count > 0) { strmaxid=ds.Tables[0].Rows[0]["maxid"].ToString(); } string strReturn = ""; strErr = ""; arry.Clear(); arry.Add("FrmILBaseInfo_Add"); arry.Add(Convert.ToInt32(strmaxid)); arry.Add(ucmeID.Text.Trim()); arry.Add(txtAgeTS.Text.Trim() == "" ? "0" : txtAgeTS.Text.Trim()); arry.Add(tbAgeBG.Text.Trim() == "" ? "0" : tbAgeBG.Text.Trim()); arry.Add(txtMemo.Text.Trim()); arry.Add(txtProduct.Text.Trim()); arry.Add(txtTraeWeight.Text.Trim()); ccs.ob = this.ob; strReturn = ccs.NoQueryFunctions("Core.LgMes.Server.Common.ComDBSave", "doSimpleSave", arry, out strErr); if (strErr == "") { proc_GetID(ucmeID.Text.Trim()); FrmIronLadleManage frm = (FrmIronLadleManage)this.Tag; if (!frm._bAutoRefresh) { frm.GetID(); frm.GetAndSetData(); } MessageBox.Show("铁包[" + ucmeID.Text.Trim() + "]新增成功!", "提示"); } else { MessageBox.Show("铁包[" + ucmeID.Text.Trim() + "]新增失败!\n" + strErr, "错误!", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception ex) { MessageBox.Show("铁包[" + ucmeID.Text.Trim() + "]新增失败!\n" + ex.Message, "错误!", MessageBoxButtons.OK, MessageBoxIcon.Error); } } /// /// 铁包基础信息修改 /// private void IronLadle_Edit() { try { if (ucmeID.Items.Count == 0) return; if (ucmeID.Text.Trim().Length == 0) { MessageBox.Show("请选择需要修改的铁包编号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); ucmeID.Focus(); return; } string strErr = ""; ArrayList arry = new ArrayList(); arry.Add("FrmILBaseInfo_Query4"); arry.Add(ucmeID.Text.Trim()); 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("铁包[" + ucmeID.Text.Trim() + "]信息修改失败,请重试!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (ds.Tables[0].Rows.Count == 0) { MessageBox.Show("铁包编号[" + ucmeID.Text.Trim() + "]不存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); proc_GetID(""); ucmeID.Focus(); return; } string strOldAgeTS = Convert.ToString(ds.Tables[0].Rows[0]["铁水包龄"]); string strOldAgeBG = Convert.ToString(ds.Tables[0].Rows[0]["半钢包龄"]); string strOldStatus = Convert.ToString(ds.Tables[0].Rows[0]["当前状态"]); string strCurAgeTS = (txtAgeTS.Text.Trim() == "" ? "0" : txtAgeTS.Text.Trim()); string strCurAgeBG = (tbAgeBG.Text.Trim() == "" ? "0" : tbAgeBG.Text.Trim()); string strMemo = txtMemo.Text.Trim(); string strMturers = txtProduct.Text.Trim(); string strTWeight = txtTraeWeight.Text.Trim(); if (strOldStatus == "使用" && (strOldAgeTS != strCurAgeTS || strOldAgeBG != strCurAgeBG)) { MessageBox.Show("铁包[" + ucmeID.Text.Trim() + "]正在使用,不能修改铁水包龄!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); if (strOldAgeTS != strCurAgeTS) txtAgeTS.Focus(); else tbAgeBG.Focus(); return; } string strReturn = ""; strErr = ""; arry.Clear(); arry.Add("FrmILBaseInfo_Edit"); arry.Add(strCurAgeTS); arry.Add(strCurAgeBG); arry.Add(strMemo); arry.Add(strMturers); arry.Add(strTWeight); arry.Add(ucmeID.Text.Trim()); strReturn = ccs.NoQueryFunctions("Core.LgMes.Server.Common.ComDBSave", "doSimpleSave", arry, out strErr); if (strErr == "") { proc_GetID(ucmeID.Text.Trim()); FrmIronLadleManage frm = (FrmIronLadleManage)this.Tag; if (!frm._bAutoRefresh) { frm.GetID(); frm.GetAndSetData(); } MessageBox.Show("铁包[" + ucmeID.Text.Trim() + "]信息修改成功!", "提示"); } else { MessageBox.Show("铁包[" + ucmeID.Text.Trim() + "]信息修改失败!\n" + strErr, "错误!", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception ex) { MessageBox.Show("铁包[" + ucmeID.Text.Trim() + "]信息修改失败!\n" + ex.Message, "错误!", MessageBoxButtons.OK, MessageBoxIcon.Error); } } /// /// 基础信息删除 /// private void IronLadle_Del() { try { if (ucmeID.Items.Count == 0) return; if (ucmeID.Text.Trim().Length == 0) { MessageBox.Show("请选择需要删除的铁包编号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); ucmeID.Focus(); return; } string strErr = ""; ArrayList arry = new ArrayList(); arry.Add("FrmILBaseInfo_Query5"); arry.Add(ucmeID.Text.Trim()); 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("铁包[" + ucmeID.Text.Trim() + "]信息删除失败,请重试!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (ds.Tables[0].Rows.Count == 0) { MessageBox.Show("铁包编号[" + ucmeID.Text.Trim() + "]不存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); proc_GetID(""); ucmeID.Focus(); return; } if (MessageBox.Show("确定要删除铁包[" + ucmeID.Text.Trim() + "]信息吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) return; strErr = ""; ds = null; arry.Clear(); ccs.ob = ob; arry.Add("FrmILBaseInfo_Query6"); arry.Add(ucmeID.Text.Trim()); arry.Add(ucmeID.Text.Trim()); arry.Add(ucmeID.Text.Trim()); 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("铁包[" + ucmeID.Text.Trim() + "]信息删除失败,请重试!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } int iCount = Convert.ToInt16(ds.Tables[0].Rows[0][0]); if (iCount > 0) { MessageBox.Show("铁包[" + ucmeID.Text.Trim() + "]存在使用记录、维修记录或烘烤记录,不能删除!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } string strReturn = ""; strErr = ""; arry.Clear(); arry.Add("FrmILBaseInfo_Delect"); arry.Add(ucmeID.Text.Trim()); strReturn = ccs.NoQueryFunctions("Core.LgMes.Server.Common.ComDBSave", "doSimpleSave", arry, out strErr); if (strErr == "") { proc_GetID(""); FrmIronLadleManage frm = (FrmIronLadleManage)this.Tag; if (!frm._bAutoRefresh) { frm.GetID(); frm.GetAndSetData(); } MessageBox.Show("铁包[" + ucmeID.Text.Trim() + "]信息删除成功!", "提示"); } else { MessageBox.Show("铁包[" + ucmeID.Text.Trim() + "]信息删除失败!\n" + strErr, "错误!", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception ex) { MessageBox.Show("铁包[" + ucmeID.Text.Trim() + "]信息删除失败!\n" + ex.Message, "错误!", MessageBoxButtons.OK, MessageBoxIcon.Error); } } private void btnClose_Click(object sender, EventArgs e) { this.Close(); } private void toolStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e) { switch (e.ClickedItem.Name) { case "ADD": { IronLadle_Add(); break; } case "EDIT": { IronLadle_Edit(); break; } case "DEL": { IronLadle_Del(); break; } case "CLOSE": { this.Close(); break; } default: break; } } } }