| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517 |
- 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 System.Threading;
- using Infragistics.Win;
- using Infragistics.Win.UltraWinGrid;
- using CoreFS.CA06;
- using Core.Mes.Client.Common;
- namespace Core.LgMes.Client.LgDeviceManager
- {
- public partial class FrmIronLadleManage : frmStyleBase
- {
- public FrmIronLadleManage()
- {
- InitializeComponent();
- CheckForIllegalCrossThreadCalls = false;
- }
- private string strCurrID = "";
- private bool bSelected = false;
- private bool bRefreshNow = false;
- private Thread _refreshThread;
- private bool _bStop = false;
- public bool _bAutoRefresh = false;
- private delegate void RefreshDataHandler();
- private RefreshDataHandler refreshDataHandler;
- private void FrmIronLadleManage_Load(object sender, EventArgs e)
- {
- GetID();
- chkAutoRefresh.Checked = true;
- refreshDataHandler = new RefreshDataHandler(GetAndSetData);
- StartupThread();
- GetAndSetData();
- }
- private void StartupThread()
- {
- try
- {
- _refreshThread = new Thread(new ThreadStart(refreshData));
- _refreshThread.IsBackground = true;
- _refreshThread.Start();
- }
- catch { }
- }
- private void refreshData()
- {
- There:
- while (!_bStop)
- {
- if (!this.On_Off_Thread || !_bAutoRefresh)
- {
- Thread.Sleep(500);
- continue;
- }
- try
- {
- if (refreshDataHandler != null)
- {
- this.Invoke(refreshDataHandler);
- }
- Thread.Sleep(1000 * 5);
- }
- catch { }
- }
- goto There;
- }
- /// <summary>
- /// 铁包信息查询
- /// </summary>
- public void GetAndSetData()
- {
- bRefreshNow = true;
- try
- {
- string strErr = "", strWhere = "";
- if (!chkShowBF.Checked)
- {
- strWhere = " and t.STATUS <> '报废'";
- }
- if (chkID.Checked && ucmeID.SelectedIndex > -1)
- {
- strWhere += " and t.LADLEID = '" + ucmeID.Text.Trim() + "'";
- }
- if (chkStatus.Checked && cmbStatus.SelectedIndex > -1)
- {
- strWhere += " and t.STATUS = '" + cmbStatus.Text.Trim() + "'";
- }
- ArrayList arry = new ArrayList();
- ArrayList sqlList = new ArrayList();
- arry.Add("FrmIronLadleManage_Query1");
- 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);
- strErr = CCP_LgEts.ReturnInfo;
- if (strErr == "" && ds != null && ds.Tables.Count > 0)
- {
- ugrdTBinfo.BeginUpdate();
- dataTable1.Rows.Clear();
- DataRow row;
- for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
- {
- row = dataTable1.NewRow();
- for (int j = 0; j < ds.Tables[0].Columns.Count; j++)
- {
- if (dataTable1.Columns.Contains(ds.Tables[0].Columns[j].ColumnName))
- row[ds.Tables[0].Columns[j].ColumnName] = ds.Tables[0].Rows[i][j];
- }
- dataTable1.Rows.Add(row);
- }
- ugrdTBinfo.EndUpdate();
- }
- if (ugrdTBinfo.Rows.Count > 0)
- {
- SetGridBackColor();
- if (strCurrID.Length > 0)
- LocateRecord(strCurrID, bSelected);
- }
- else
- strCurrID = "";
- }
- catch
- { }
- finally
- {
- bRefreshNow = false;
- }
- }
- /// <summary>
- /// 颜色显示
- /// </summary>
- private void SetGridBackColor()
- {
- try
- {
- Hashtable htOperate = new Hashtable();
- htOperate.Add("备用", Color.GhostWhite);
- htOperate.Add("使用", Color.LightGreen);
- htOperate.Add("维修", Color.LightBlue);
- htOperate.Add("烘烤", Color.Yellow);
- htOperate.Add("报废", Color.Red);
- LadleCommonClass.SetGridBackColor(ugrdTBinfo, htOperate, "当前状态", true);
- }
- catch { }
- }
- private void LocateRecord(string strID, bool bSelect)
- {
- try
- {
- for (int i = 0; i < ugrdTBinfo.Rows.Count; i++)
- {
- if (Convert.ToString(ugrdTBinfo.Rows[i].Cells["铁包编号"].Value) == strID)
- {
- ugrdTBinfo.ActiveRow = ugrdTBinfo.Rows[i];
- ugrdTBinfo.Rows[i].Selected = bSelect;
- return;
- }
- }
- }
- catch { }
- }
- /// <summary>
- /// 加载铁包号
- /// </summary>
- public void GetID()
- {
- try
- {
- string strID = "";
- if (ucmeID.SelectedIndex >= 0)
- strID = ucmeID.Text;
- string strErr = "";
- ArrayList arry = new ArrayList();
- arry.Add("FrmIronLadleManage_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 (ucmeID.Items.Count > 0 )
- {
- if (strID.Length > 0)
- ucmeID.Text = strID;
- else
- ucmeID.SelectedIndex = -1;
- }
- }
- catch { }
- }
- private void cbxID_CheckedChanged(object sender, EventArgs e)
- {
- ucmeID.Enabled = chkID.Checked;
- }
- private void cbxStatus_CheckedChanged(object sender, EventArgs e)
- {
- cmbStatus.Enabled = chkStatus.Checked;
- }
- private void ulgrid_AfterRowActivate(object sender, EventArgs e)
- {
- try
- {
- if (bRefreshNow) return;
- UltraGridRow row = ugrdTBinfo.ActiveRow;
- if (row != null)
- {
- strCurrID = Convert.ToString(row.Cells["铁包编号"].Value);
- bSelected = ugrdTBinfo.ActiveRow.Selected;
- }
- }
- catch
- {
- strCurrID = "";
- }
- }
- private void cbxAutoRefresh_CheckedChanged(object sender, EventArgs e)
- {
- _bAutoRefresh = chkAutoRefresh.Checked;
- }
- /// <summary>
- /// 铁包报废
- /// </summary>
- /// <param name="strID"></param>
- private void proc_RejectTB(string strID)
- {
- try
- {
- string strErr = "";
- ArrayList arry = new ArrayList();
- arry.Add("FrmIronLadleManage_Query3");
- 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))
- {
- MessageBox.Show("铁包[" + strID + "]报废操作失败,请重试!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
- return;
- }
- if (ds.Tables[0].Rows.Count == 0)
- {
- MessageBox.Show("铁包编号[" + strID + "]不存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
- return;
- }
- string strCurrStatus = Convert.ToString(ds.Tables[0].Rows[0]["当前状态"]);
- if (strCurrStatus == "报废")
- {
- MessageBox.Show("铁包[" + strID + "]已经报废!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
- return;
- }
- if (strCurrStatus != "备用")
- {
- MessageBox.Show("铁包[" + strID + "]当前状态为[" + strCurrStatus + "],不能执行报废操作!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
- return;
- }
- for (int i = 0; i < 3; i++)
- {
- string strTimes = (i == 0 ? "一" : (i == 1 ? "二" : (i == 2 ? "三" : "")));
- if (MessageBox.Show("第[" + strTimes + "]次确认\r\n\r\n"
- + "铁包号:[" + strID + "]\r\n"
- + "报废操作不能撤销\r\n"
- + "确认要报废吗?",
- "报废",
- MessageBoxButtons.YesNo,
- MessageBoxIcon.Question,
- MessageBoxDefaultButton.Button2) == DialogResult.No)
- return;
- }
- string strReturn = "";
- strErr = "";
- arry.Clear();
- arry.Add("FrmIronLadleManage_Edit");
- arry.Add(strID);
- strReturn = ccs.NoQueryFunctions("Core.LgMes.Server.Common.ComDBSave", "doSimpleSave", arry, out strErr);
- if (strErr != "")
- {
- MessageBox.Show("铁包[" + strID + "]报废操作失败!\n" + strErr, "错误!", MessageBoxButtons.OK, MessageBoxIcon.Error);
- return;
- }
- if (!chkAutoRefresh.Checked)
- {
- GetID();
- GetAndSetData();
- }
- GetAndSetData();
- MessageBox.Show("铁包[" + strID + "]报废操作成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
- }
- catch (Exception ex)
- {
- MessageBox.Show("铁包报废操作失败!\r\n" + ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
- return;
- }
- }
- public override void ToolBar_Click(object sender, string ToolbarKey)
- {
- switch (ToolbarKey)
- {
- case "Query":
- {
- GetAndSetData();
- break;
- }
- case "BaseInfo": //基础信息
- {
- string strInitID = "";
- UltraGridRow row = ugrdTBinfo.ActiveRow;
- if (row != null)
- strInitID = Convert.ToString(row.Cells["铁包编号"].Value);
- FrmILBaseInfo frm = new FrmILBaseInfo(ob);
- frm.Tag = this;
- frm.strInitiD = strInitID;
- frm.ShowDialog();
- break;
- }
- case "Repair": //维修
- {
- string strInitID = "";
- UltraGridRow row = ugrdTBinfo.ActiveRow;
- if (row != null)
- strInitID = Convert.ToString(row.Cells["铁包编号"].Value);
- FrmILRepair frm = new FrmILRepair(strInitID,ob);
- frm.Tag = this;
- //frm.strInitiD = strInitID;
- frm.ShowDialog();
- break;
- }
- case "TBBake"://铁包烘烤
- {
- string strInitID = "";
- UltraGridRow row = ugrdTBinfo.ActiveRow;
- if (row != null)
- strInitID = Convert.ToString(row.Cells["铁包编号"].Value);
- FrmILFire frm = new FrmILFire(strInitID,ob);
- frm.Tag = this;
- frm.ShowDialog();
- break;
- }
- case "Reject": //报废
- {
- UltraGridRow row = ugrdTBinfo.ActiveRow;
- if (row != null)
- {
- proc_RejectTB(Convert.ToString(row.Cells["铁包编号"].Value));
- }
- break;
- }
- case "UseDetail": //使用信息
- {
- string strInitID = "";
- UltraGridRow row = ugrdTBinfo.ActiveRow;
- if (row != null)
- strInitID = Convert.ToString(row.Cells["铁包编号"].Value);
- FrmILHistory frm = new FrmILHistory(ToolsName.铁包, strInitID, RecordsName.使用记录,ob);
-
- frm.Tag = this;
- frm.ShowDialog();
- break;
- }
- case "RepairDetail": //维修记录
- {
- string strInitID = "";
- UltraGridRow row = ugrdTBinfo.ActiveRow;
- if (row != null)
- strInitID = Convert.ToString(row.Cells["铁包编号"].Value);
- FrmILHistory frm = new FrmILHistory(ToolsName.铁包, strInitID, RecordsName.维修记录,ob);
- frm.Tag = this;
- frm.ShowDialog();
- break;
- }
- case "烘烤记录":
- {
- string strInitID = "";
- UltraGridRow row = ugrdTBinfo.ActiveRow;
- if (row != null)
- strInitID = Convert.ToString(row.Cells["铁包编号"].Value);
- FrmILHistory frm = new FrmILHistory(ToolsName.铁包, strInitID, RecordsName.烘烤记录, ob);
- frm.Tag = this;
- frm.ShowDialog();
- break;
- }
- case "ILSend":
- frmILSend frmIL = new frmILSend(ob);
- frmIL._ds = dStTBinfo.Copy();
- frmIL.ShowDialog();
- break;
- case "Cance":
- CancelIronUserInfo();
- break;
- case "Exit":
- {
- this.Close();
- break;
- }
- }
- }
-
- /// <summary>
- /// 是否显示废钢信息
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void cbxShowBF_CheckedChanged(object sender, EventArgs e)
- {
- //GetAndSetData();
- }
- /// <summary>
- /// 取消铁水使用信息
- /// </summary>
- private void CancelIronUserInfo()
- {
- string strSqlID = ""; //sqlId
- string strErr = ""; //错误信息
- if (ugrdTBinfo.ActiveRow == null)
- {
- MessageBox.Show("没有选择要取消使用信息的铁包,请选择!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
- return;
- }
- if (MessageBox.Show("是否确认取消【铁包号:" + ugrdTBinfo.ActiveRow.Cells["铁包编号"].Value.ToString() +
- "】铁水使用信息!", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk) == DialogResult.Yes)
- {
- strSqlID = "CancelIronUserInfo.Cancel"; //SQLID
- Hashtable ht = new Hashtable();
- ht.Add("I1", ugrdTBinfo.ActiveRow.Cells["铁包编号"].Value.ToString()); //铁水罐号
- ht.Add("O1", "");
- ht.Add("O2", "");
- CommonClientToServer ccTs = new CommonClientToServer();
- ccTs.ob = ob;
- string strRCode = ccTs.ExecuteProcedureFunctions("Core.LgMes.Server.LgDeviceManager.LadleManager",
- "CancelIronUserInfo", strSqlID, ht, out strErr);
- if (strErr == "")
- {
- MessageBox.Show("铁水使用信息取消成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- GetAndSetData();
- }
- else
- MessageBox.Show("铁水使用信息取消失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- }
- }
- /// <summary>
- /// 工器具名称
- /// </summary>
- public enum ToolsName
- {
- 钢包, 铁包, 中包, 氧枪, 结晶器, 出钢口
- }
- /// <summary>
- /// 工器具记录类别
- /// </summary>
- public enum RecordsName
- {
- 使用记录, 维修记录, 烘烤记录
- }
- }
|