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 CoreFS.CA06; using Core.Mes.Client.Common; namespace Core.LgMes.Client.LgDeviceManager { public partial class FrmVacuumTankManage : Core.Mes.Client.Common.frmStyleBase { public FrmVacuumTankManage() { InitializeComponent(); } private void FrmVacuumTankManage_Load(object sender, EventArgs e) { udteFrom.DateTime = DateTime.Today; udteTo.DateTime = DateTime.Today; proc_LoadCLID(); proc_GetBaseInfo("", ""); } private string ConvertShift(string strFlag, string strShift) { if (strFlag == "1") { switch (strShift.Substring(0, 1)) { case "1": return "白"; case "2": return "中"; case "3": return "夜"; default: return ""; } } else if (strFlag == "2") { switch (strShift.Substring(1, 1)) { case "1": return "甲"; case "2": return "乙"; case "3": return "丙"; case "4": return "丁"; default: return ""; } } else if (strFlag == "3") { switch (strShift.Trim()) { case "白": return "1"; case "中": return "2"; case "夜": return "3"; default: return ""; } } else if (strFlag == "4") { switch (strShift.Trim()) { case "甲": return "1"; case "乙": return "2"; case "丙": return "3"; case "丁": return "4"; default: return ""; } } return ""; } private void SetLeftTableRowColor() { for (int i = 0; i < this.ugrdBaseInfo.Rows.Count; i++) { switch (this.ugrdBaseInfo.Rows[i].Cells["状态"].Text.Trim()) { case "上线"://上线 this.ugrdBaseInfo.Rows[i].Appearance.BackColor = Color.LightGreen; break; case "烘烤"://烘烤 this.ugrdBaseInfo.Rows[i].Appearance.BackColor = Color.LightBlue; break; default: this.ugrdBaseInfo.Rows[i].Appearance.BackColor = Color.LightYellow; break; } } } private void SetRightTableRowColor() { for (int i = 0; i < this.ugrdUseInfo.Rows.Count; i++) { switch (this.ugrdUseInfo.Rows[i].Cells["状态"].Text.Trim()) { case "上线"://上线 this.ugrdUseInfo.Rows[i].Appearance.BackColor = Color.LightGreen; break; case "烘烤"://烘烤 this.ugrdUseInfo.Rows[i].Appearance.BackColor = Color.LightBlue; break; default: this.ugrdUseInfo.Rows[i].Appearance.BackColor = Color.LightYellow; break; } } } private void proc_ResetEditArea() { try { txtID.Clear(); ucmeCCM.Text = ""; ucmeStatus.Text = ""; txtLJCS.Clear(); txtDQCS.Clear(); txtOBCS.Clear(); txtNO1.Clear(); txtCS1.Clear(); txtNO2.Clear(); txtCS2.Clear(); txtNO3.Clear(); txtCS3.Clear(); udteOnTime.Text = ""; udteNextTime.Text = ""; txtMemo.Clear(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } private void proc_ResetRepairArea() { try { txtID1.Clear(); txtBegin1.Clear(); txtEnd1.Clear(); txtPeriod1.Clear(); txtMemo1.Clear(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } private void proc_Edit() { try { if (ugrdUseInfo.Rows.Count == 0) return; if (ugrdUseInfo.ActiveRow == null) { MessageBox.Show("请选择要修改的使用记录!", "提示"); return; } string strID = Convert.ToString(ugrdUseInfo.ActiveRow.Cells["ID"].Value); string strNO = Convert.ToString(ugrdUseInfo.ActiveRow.Cells["槽车编号"].Value); string strRHS = Convert.ToString(ugrdUseInfo.ActiveRow.Cells["RH炉号"].Value); string strCYCID = Convert.ToString(ugrdUseInfo.ActiveRow.Cells["周期编号"].Value); if (MessageBox.Show("确定要修改[" + strRHS + "]槽车[" + strNO + "]的当前使用记录吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) return; string strErr = ""; ArrayList arry = new ArrayList(); arry.Add("FrmVacuumTankManage_Query5"); arry.Add(strID); arry.Add(strCYCID); 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("[" + strRHS + "]槽车[" + strNO + "]的当前使用记录修改失败!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } int iCnt = Convert.ToInt32(ds.Tables[0].Rows[0][0]); if (iCnt == 0) { MessageBox.Show("[" + strRHS + "]槽车[" + strNO + "]的当前使用记录不存在,无法修改!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); proc_GetBaseInfo(strRHS, strNO); return; } string strReturn = ""; strErr = ""; arry.Clear(); ccs.ob = ob; arry.Add("FrmVacuumTankManage_Update.1"); arry.Add(txtLJCS.Text.Trim()); arry.Add(txtDQCS.Text.Trim()); arry.Add(txtOBCS.Text.Trim()); arry.Add(txtCS1.Text.Trim()); arry.Add(txtCS2.Text.Trim()); arry.Add(txtCS3.Text.Trim()); arry.Add(udteOnTime.Text); arry.Add(udteNextTime.Text); arry.Add(txtMemo.Text.Trim()); arry.Add(strID); arry.Add(strCYCID); strReturn = ccs.NoQueryFunctions("Core.LgMes.Server.Common.ComDBSave", "doSimpleSave", arry, out strErr); if (!(strErr == null || strErr == "")) { MessageBox.Show("[" + strRHS + "]槽车[" + strNO + "]的当前使用记录修改失败!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } proc_GetBaseInfo(strRHS, strNO); MessageBox.Show("[" + strRHS + "]槽车[" + strNO + "]的当前使用记录修改成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } catch (Exception ex) { MessageBox.Show(ex.Message, "提示"); } } private void proc_Del() { try { if (ugrdUseInfo.Rows.Count == 0) return; if (ugrdUseInfo.ActiveRow == null) { MessageBox.Show("请选择要删除的使用记录!", "提示"); return; } string strID = Convert.ToString(ugrdUseInfo.ActiveRow.Cells["ID"].Value); string strNO = Convert.ToString(ugrdUseInfo.ActiveRow.Cells["槽车编号"].Value); string strRHS = Convert.ToString(ugrdUseInfo.ActiveRow.Cells["RH炉号"].Value); string strCYCID = Convert.ToString(ugrdUseInfo.ActiveRow.Cells["周期编号"].Value); if (MessageBox.Show("确定要删除[" + strRHS + "]槽车[" + strNO + "]的当前使用记录吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) return; string strErr = ""; ArrayList arry = new ArrayList(); arry.Add("FrmVacuumTankManage_Query6"); arry.Add(strID); arry.Add(strCYCID); 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("[" + strRHS + "]槽车[" + strNO + "]的当前使用记录删除失败!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } int iCnt = Convert.ToInt32(ds.Tables[0].Rows[0][0]); if (iCnt == 0) { MessageBox.Show("[" + strRHS + "]槽车[" + strNO + "]的当前使用记录不存在,无法删除!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); proc_GetBaseInfo(strRHS, strNO); return; } ds = null; strErr = ""; arry.Clear(); ccs.ob = ob; arry.Add("FrmVacuumTankManage_Query7"); arry.Add(strID); arry.Add(strCYCID); 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("[" + strRHS + "]槽车[" + strNO + "]的当前使用记录删除失败!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (Convert.ToString(ds.Tables[0].Rows[0]["NOWSTATUS"]) != "1") //1代表上线 { MessageBox.Show("[" + strRHS + "]槽车[" + strNO + "]的当前使用记录已经结束,不能删除!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } string strReturn = ""; strErr = ""; arry.Clear(); ccs.ob = ob; arry.Add("FrmVacuumTankManage_Del"); arry.Add(strID); arry.Add(strCYCID); strReturn = ccs.NoQueryFunctions("Core.LgMes.Server.Common.ComDBSave", "doSimpleSave", arry, out strErr); if (!(strErr == null || strErr == "")) { MessageBox.Show("[" + strRHS + "]槽车[" + strNO + "]的当前使用记录删除失败!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } strReturn = ""; strErr = ""; arry.Clear(); arry.Add("FrmVacuumTankManage_Update.2"); arry.Add(strID); ccs.ob = ob; strReturn = ccs.NoQueryFunctions("Core.LgMes.Server.Common.ComDBSave", "doSimpleSave", arry, out strErr); if (!(strErr == null || strErr == "")) { MessageBox.Show("[" + strRHS + "]槽车[" + strNO + "]的当前使用记录删除失败!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } proc_GetBaseInfo(strRHS, strNO); MessageBox.Show("[" + strRHS + "]槽车[" + strNO + "]的当前使用记录删除成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } catch (Exception ex) { MessageBox.Show(ex.Message, "提示"); } } /// /// 真空槽信息加载 /// private void proc_LoadCLID() { try { string strErr = ""; string strSql = ""; if (chkRHS.Checked && ucmeRHS.SelectedIndex > -1) strSql="where RHS_ID = '" + ucmeRHS.Text.Trim() + "'"; else strSql=""; ArrayList arry = new ArrayList(); ArrayList sqlList = new ArrayList(); arry.Add("FrmVacuumTankManage_Query1"); sqlList.Add(strSql); 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)) { MessageBox.Show("真空槽信息加载失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); if (MessageBox.Show("是否重新加载真空槽信息?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) proc_LoadCLID(); return; } ucmeID.DataSource = ds.Tables[0]; ucmeID.DisplayMember = "TANKCARID"; } catch (Exception ex) { MessageBox.Show(ex.Message, "提示"); } } /// /// 基础信息查询 /// /// /// public void proc_GetBaseInfo(string strRHSID, string strVTKNO) { try { string strErr = ""; string strWhere = ""; if (chkRHS.Checked && ucmeRHS.Text.Trim().Length > 0) strWhere = "and t.RHS_ID = '" + ucmeRHS.Text.Trim() + "' "; if (chkID.Checked && ucmeID.Text.Length > 0) strWhere += "and t.TANKCARID = '" + ucmeID.Text.Trim() + "'"; ArrayList arry = new ArrayList(); ArrayList sqlList = new ArrayList(); arry.Add("FrmVacuumTankManage_Query2"); 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; //try //{ // ((DataTable)ugrdBaseInfo.DataSource).Rows.Clear(); //} //catch (Exception) //{ //} if (ds != null && ds.Tables[0].Rows.Count > 0) { ugrdBaseInfo.DataSource = ds.Tables[0]; } if (strErr != "" || !(ds != null && ds.Tables.Count > 0)) { MessageBox.Show("槽车信息查询失败!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } SetLeftTableRowColor(); if (ds.Tables[0].Rows.Count == 0) { proc_ResetRepairArea(); return; } if (strRHSID.Length > 0) //定位记录 { for (int i = 0; i < ugrdBaseInfo.Rows.Count; i++) { if (Convert.ToString(ugrdBaseInfo.Rows[i].Cells["RH炉号"].Value) == strRHSID) { if (strVTKNO.Length > 0) { if (Convert.ToString(ugrdBaseInfo.Rows[i].Cells["槽车编号"].Value) == strVTKNO) { ugrdBaseInfo.ActiveRow = ugrdBaseInfo.Rows[i]; ugrdBaseInfo.Rows[i].Selected = true; return; } } else { ugrdBaseInfo.ActiveRow = ugrdBaseInfo.Rows[i]; ugrdBaseInfo.Rows[i].Selected = true; return; } } } } } catch (Exception ex) { MessageBox.Show(ex.Message, "提示"); } } /// /// 使用信息 /// /// private void proc_GetUseInfo(string strID) { try { string strErr = ""; string strWhere = ""; if (strID.Length > 0) strWhere = "and T.TANKCARID = '" + strID + "' "; if (chkDate.Checked) { strWhere += "and to_char(T.BEGINTIME,'yyyy-MM-dd') between '" + udteFrom.DateTime.ToString("yyyy-MM-dd") + "' and '" + udteTo.DateTime.ToString("yyyy-MM-dd") + "'"; } else { strWhere += "and (T.TANKCARID, T.CYCID) in (select TANKCARID, CYCID from " + "(select row_number() over (partition by x.TANKCARID order by x.CYCID desc) xh, x.* " + "from DEV_ZKC_USE_DETAIL x) where xh < 3)"; } ArrayList arry = new ArrayList(); ArrayList sqlList = new ArrayList(); arry.Add("FrmVacuumTankManage_Query3"); 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; try { ((DataSet)ugrdUseInfo.DataSource).Tables[0].Rows.Clear(); } catch (Exception) { } if (ds != null && ds.Tables[0].Rows.Count > 0) { ugrdUseInfo.DataSource = ds; } if (strErr != "" || !(ds != null && ds.Tables.Count > 0)) { MessageBox.Show("槽车[" + strID + "]使用信息查询失败!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } SetRightTableRowColor(); if (ds.Tables[0].Rows.Count == 0) proc_ResetEditArea(); } catch (Exception ex) { MessageBox.Show(ex.Message, "提示"); } } /// /// 烘烤信息查询 /// /// private void proc_GetHotInfo(string strID) { try { if (strID.Length == 0) return; string strErr = ""; ArrayList arry = new ArrayList(); arry.Add("FrmVacuumTankManage_Query4"); arry.Add(strID); 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) { txtID1.Text = Convert.ToString(ds.Tables[0].Rows[0]["槽车编号"]); txtBegin1.Text = Convert.ToString(ds.Tables[0].Rows[0]["烘烤开始时刻"]); txtEnd1.Text = Convert.ToString(ds.Tables[0].Rows[0]["烘烤结束时刻"]); txtPeriod1.Text = Convert.ToString(ds.Tables[0].Rows[0]["烘烤时间"]); txtMemo1.Text = Convert.ToString(ds.Tables[0].Rows[0]["备注"]); } else proc_ResetRepairArea(); } catch (Exception ex) { MessageBox.Show(ex.Message, "提示"); } } /// /// 菜单 /// /// /// public override void ToolBar_Click(object sender, string ToolbarKey) { switch (ToolbarKey) { case "HotDetail": { FrmVTHotDetail frm = new FrmVTHotDetail(ob);//真空槽烘烤记录 frm.ShowDialog(); break; } case "PLUGIN": { FrmVTPluginInfo frm = new FrmVTPluginInfo(ob);//真空槽信息 frm.ShowDialog(); break; } case "BaseInfo": { FrmVTBaseInfo frm = new FrmVTBaseInfo(ob);//基础信息 frm.Tag = this; if (ugrdBaseInfo.ActiveRow != null) { frm.strRHS = Convert.ToString(ugrdBaseInfo.ActiveRow.Cells["RH炉号"].Value); frm.strNo = Convert.ToString(ugrdBaseInfo.ActiveRow.Cells["槽车编号"].Value); } frm.ShowDialog(); break; } case "VanHot": { FrmVTHot frm = new FrmVTHot(ob);//真空槽烘烤 frm.Tag = this; if (ugrdBaseInfo.ActiveRow != null) { frm.strRHS = Convert.ToString(ugrdBaseInfo.ActiveRow.Cells["RH炉号"].Value); frm.strNo = Convert.ToString(ugrdBaseInfo.ActiveRow.Cells["槽车编号"].Value); } frm.ShowDialog(); } break; case "Query": { proc_GetBaseInfo("", ""); break; } case "Exit": { this.Close(); break; } case "Update": { proc_Edit(); break; } case "Delete": { proc_Del(); break; } } } private void ulgridBaseInfo_DoubleClickRow(object sender, Infragistics.Win.UltraWinGrid.DoubleClickRowEventArgs e) { try { if (ugrdBaseInfo.ActiveRow == null) return; FrmVT frm = new FrmVT(ob); frm.Tag = this; frm.strID = Convert.ToString(ugrdBaseInfo.ActiveRow.Cells["ID"].Value); frm.strNO = Convert.ToString(ugrdBaseInfo.ActiveRow.Cells["槽车编号"].Value); frm.strRHS = Convert.ToString(ugrdBaseInfo.ActiveRow.Cells["RH炉号"].Value); frm.strSTATUS = Convert.ToString(ugrdBaseInfo.ActiveRow.Cells["状态"].Value); frm.ShowDialog(); } catch (Exception ex) { MessageBox.Show(ex.Message, "提示"); } } private void ulgridBaseInfo_AfterRowActivate(object sender, EventArgs e) { try { if (ugrdBaseInfo.ActiveRow == null) return; string strID = Convert.ToString(ugrdBaseInfo.ActiveRow.Cells["ID"].Value); proc_GetUseInfo(strID); proc_GetHotInfo(strID); } catch (Exception ex) { MessageBox.Show(ex.Message, "提示"); } } private void ulgridUseInfo_AfterRowActivate(object sender, EventArgs e) { try { if (ugrdUseInfo.ActiveRow == null) return; Infragistics.Win.UltraWinGrid.UltraGridRow ulRow = ugrdUseInfo.ActiveRow; txtID.Text = Convert.ToString(ulRow.Cells["槽车编号"].Value); ucmeCCM.Text = Convert.ToString(ulRow.Cells["RH炉号"].Value); ucmeStatus.Text = Convert.ToString(ulRow.Cells["状态"].Value); txtLJCS.Text = Convert.ToString(ulRow.Cells["累计使用炉数"].Value); txtDQCS.Text = Convert.ToString(ulRow.Cells["本次使用炉数"].Value); txtOBCS.Text = Convert.ToString(ulRow.Cells["累计真空处理时间"].Value); txtNO1.Text = Convert.ToString(ulRow.Cells["ID1"].Value); txtCS1.Text = Convert.ToString(ulRow.Cells["CS1"].Value); txtNO2.Text = Convert.ToString(ulRow.Cells["ID2"].Value); txtCS2.Text = Convert.ToString(ulRow.Cells["CS2"].Value); txtNO3.Text = Convert.ToString(ulRow.Cells["ID3"].Value); txtCS3.Text = Convert.ToString(ulRow.Cells["CS3"].Value); udteOnTime.Text = Convert.ToString(ulRow.Cells["上线时间"].Value); udteNextTime.Text = Convert.ToString(ulRow.Cells["下线时间"].Value); txtMemo.Text = Convert.ToString(ulRow.Cells["备注"].Value); } catch (Exception ex) { MessageBox.Show(ex.Message, "提示"); } } private void chkID_CheckedChanged(object sender, EventArgs e) { ucmeID.Enabled = chkID.Checked; } private void cbCCM_CheckedChanged(object sender, EventArgs e) { ucmeRHS.Enabled = chkRHS.Checked; proc_LoadCLID(); } private void cbbZJH_SelectedIndexChanged(object sender, EventArgs e) { proc_LoadCLID(); } private void cbDate_CheckedChanged(object sender, EventArgs e) { udteFrom.Enabled = chkDate.Checked; udteTo.Enabled = chkDate.Checked; } private void NumberEditor_KeyPress(object sender, KeyPressEventArgs e) { if (!(Char.IsNumber(e.KeyChar) || e.KeyChar == '\b' || e.KeyChar == '.') || (((TextBox)(sender)).Text.Trim().Contains(".") && e.KeyChar == '.') || (((TextBox)(sender)).Text.Trim().Length == 0 && e.KeyChar == '.')) { e.Handled = true; } } } }