| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458 |
- 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 { }
- }
- /// <summary>
- /// 加载铁包信息
- /// </summary>
- /// <param 铁包编号="strID"></param>
- 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);
- }
- }
- /// <summary>
- /// 加载铁包编号
- /// </summary>
- /// <param 铁包编号="strID"></param>
- 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 { }
- }
- /// <summary>
- /// 铁包基础信息新增
- /// </summary>
- 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);
- }
- }
- /// <summary>
- /// 铁包基础信息修改
- /// </summary>
- 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);
- }
- }
- /// <summary>
- /// 基础信息删除
- /// </summary>
- 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;
- }
- }
- }
- }
|