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.Diagnostics; using CoreFS.CA06; using Core.Mes.Client.Common; namespace Core.LgMes.Client.LgDeviceManager { public partial class FrmOLUseDetailOperation : FrmLgDevFunctions { private string strStatus = ""; private string strOxygenlanceID = ""; private string strOAge = ""; //要更换的氧枪枪龄 private string strRecrodid ="";//氧枪使用唯一标示 public FrmOLUseDetailOperation(OpeBase oba) { InitializeComponent(); this.cmbLanceID.SelectionChangeCommitted += new System.EventHandler(this.comboBox1_SelectionChangeCommitted); this.chkQStartTime.CheckedChanged += new System.EventHandler(this.chkQStartTime_CheckedChanged); this.chkQEndTime.CheckedChanged += new System.EventHandler(this.chkQEndTime_CheckedChanged); this.chkQOxygenLanceID.CheckedChanged += new System.EventHandler(this.chkQOxygenLanceID_CheckedChanged); this.chkPos.CheckedChanged += new System.EventHandler(this.cbPos_CheckedChanged); ob = oba; } private void FrmOLUseDetailOperation_Load(object sender, EventArgs e) { ucmeOxygenLanceID.Enabled = false; udteStartTime.Enabled = false; udteEndTime.Enabled = false; ucmePos.Enabled = false; udteStartTime.Text = System.DateTime.Now.ToString("yyyy-MM-dd") + " 00:00:00"; udteEndTime.Text = System.DateTime.Now.ToString("yyyy-MM-dd") + " 23:59:59"; FrmOxygenLanceManage FrmOLM = (FrmOxygenLanceManage)this.Tag; for (int i = 0; i < FrmOLM.ulgridBaseInfo.Rows.Count; i++) { cmbLanceID.Items.Add(FrmOLM.ulgridBaseInfo.Rows[i].Cells["OXYGENLANCEID"].Value.ToString()); ucmeOxygenLanceID.Items.Add(FrmOLM.ulgridBaseInfo.Rows[i].Cells["OXYGENLANCEID"].Value.ToString()); } cmbLanceID.Items.Add(""); cmbLanceID.Text = cmbLanceID.Items[0].ToString(); GetSpoutFactory();//初始化喷头厂家信息 refreshgrid(""); } ///// <喷头厂家> ///// 喷头厂家 ///// //private void GetSpoutFactory() //{ // try // { // ArrayList ar = new ArrayList(); // ar.Add(LadleCommonClass.strSpoutHeadFactoryCode); // ar.Add(""); // ar.Add("order by BASENAME"); // DataSet ds = QueryArrayFunions("Core.LgMes.Server.LgDeviceManager.LadleManager", "GetFactory", new object[] { ar }, ob); // if (ds != null) // { // for (int i = 0; i < ds.Tables[0].Rows.Count; i++) // { // this.ucmePtcj.Items.Add(ds.Tables[0].Rows[i]["BASENAME"]); // } // } // } // catch { } //} /// <喷头厂家> /// 喷头厂家 /// private void GetSpoutFactory() { try { string strErr = ""; ArrayList arry = new ArrayList(); arry.Add("LoadGetYQ.Query"); 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) GetSpoutFactory(); return; } this.ucmePtcj.DataSource = ds.Tables[0].DefaultView; this.ucmePtcj.DisplayMember = "BASENAME"; this.ucmePtcj.ValueMember = "BASECODE"; } catch (Exception ex) { MessageBox.Show(ex.Message); } } private void ucmePtcj_ValueChanged(object sender, EventArgs e) { try { string strErr = ""; string strByid = this.ucmePtcj.Value.ToString(); ArrayList arry = new ArrayList(); arry.Add("LoadGetYQBy_ID.Query"); arry.Add(strByid); CommonClientToServer ccs = new CommonClientToServer(); ccs.ob = this.ob; DataSet ds = ccs.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBQuery", "doSimpleQuery", arry, out strErr); if( ds.Tables[0].Rows.Count>0) { this.txt_Memo.Text = ds.Tables[0].Rows[0]["MEMO"].ToString(); } } catch { } } private void proc_UpdateBaseInfoAge(string strRecordID, string strAge) { try { string strErr = ""; string strSql = "select case when ENDTIME is null then '0' else '1' end Finished from DEV_yq_use_detail where RECRODID='" + strRecordID + "'"; //CallingMessage par = new CallingMessage(); //par.ServerName = "LgDeviceManager"; //par.AssemblyName = "Core.LgMes.Server.LgDeviceManager"; //par.ClassName = "Core.LgMes.Server.LgDeviceManager.OxygenLanceManager"; //par.MethodName = "OxygenLance_Return"; //par.args = new object[] { strSql }; DataSet ds = null;// (DataSet)ClientCommon._RemotingHelp.ExecuteMethod(par, out strErr); if (!((strErr == null || strErr == "") && ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)) return; string strFinished = Convert.ToString(ds.Tables[0].Rows[0]["Finished"]); if (strFinished == "1") return; strErr = ""; strSql = "update DEV_YQ_BASE_INFO set USEMAXTIME = '" + strAge + "' where OXYGENLANCEID = (select OXYGENLANCEID from DEV_YQ_USE_DETAIL where RECRODID = '" + strRecordID + "')"; //par.MethodName = "OxygenLance_NonReturn"; //par.args = new object[] { strSql }; //ClientCommon._RemotingHelp.ExecuteMethod(par, out strErr); } catch (Exception ex) { MessageBox.Show(ex.Message, "出错"); } } /// <新增> /// 新增 /// private void AddUseDetail() { try { //if (comboBox1.SelectedIndex < 0) //{ // MessageBox.Show("氧枪编号不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); // comboBox1.Focus(); // return; //} //if (comboBox6.SelectedIndex < 0) //{ // MessageBox.Show("炉座号不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); // comboBox6.Focus(); // return; //} //if (comboBox3.SelectedIndex < 0) //{ // MessageBox.Show("使用类型不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); // comboBox3.Focus(); // return; //} if (!CheckIsNumberByASCII(txtQL.Text.Trim())) { MessageBox.Show("枪龄输入不正确!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); txtQL.Text = "0"; txtQL.SelectAll(); txtQL.Focus(); return; } if (!CheckIsNumberByASCII(txtSLL.Text.Trim())) { MessageBox.Show("高压水流量输入不正确!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); txtSLL.SelectAll(); txtSLL.Focus(); return; } if (dtpQEndTime.Value != null && Convert.ToDateTime(dtpQStartTime.Value) > Convert.ToDateTime(dtpQEndTime.Value)) { MessageBox.Show("上线时间不能大于下线时间!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); dtpQStartTime.Focus(); return; } string strOLID = cmbLanceID.Text.Trim(); //string strCurrStatus = ""; //if (this.GetYQCurrStatus(strOLID, out strCurrStatus)) //{ // MessageBox.Show("氧枪[" + strOLID + "]当前状态为[" + strCurrStatus + "],不能再使用,请选择其它氧枪!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); // return; //} if (this.GetYQUserInfo(comboBox6.Text.Trim(), cmbType.Text.Trim())) { if (MessageBox.Show("炉座号[" + comboBox6.Text.Trim() + "]有[" + this.strOxygenlanceID + "]号氧枪正在工作!是否更换为新的氧枪号[" + cmbLanceID.Text.Trim() + "]?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) return; else { string strErr = ""; if (strErr == null || strErr == "") { dtpQEndTime.Value = DateTime.Now; BaseInfoStateUpdate("下线", strOxygenlanceID, strOAge, ""); //更新基础表状态 } else { MessageBox.Show("氧枪更换下线失败,重试!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } } string classstr = ClassTransCode(); if (txtQL.Text.Trim() == "") { txtQL.Text = "0"; } if (txtSLL.Text.Trim() == "") { txtSLL.Text = "0"; } dtpQEndTime.Value = null; string strSql = "insert into DEV_YQ_USE_DETAIL " + "(RECRODID, OXYGENLANCEID, CLASS, NOWPOSITION, OVENID," + " NOWSTATUS, USETIMES, BEGINTIME, ENDTIME, REASON," + " MEMO, HEATNO, SPOUTFACTORY, FLUX) values " + "((select to_char(nvl(max(to_number(recrodid)),0)+1) from DEV_yq_use_detail)," + "'" + cmbLanceID.Text.Trim() + "'," + "'" + classstr + "'," + "'" + cmbType.Text.Trim() + "'," + "'" + comboBox6.Text.Trim() + "'," + "'" + comboBox4.Text.Trim() + "'," + "'" + txtQL.Text.Trim() + "'," + "to_date('" + dtpQStartTime.Value + "','yyyy-mm-dd hh24:mi:ss')," + "null," + "'" + txtReason.Text.Trim() + "'," + "'" + txtmemo.Text.Trim() + "'," + "''," + "'" + ucmePtcj.Text.Trim() + "', " + txtSLL.Text.Trim() + " )"; CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "Core.LgMes.Server.DEV.Methods.DEVPublicMethods"; ccp.MethodName = "UpdateMethods"; ccp.ServerParams = new Object[] { strSql }; ob.ExecuteQueryToDataTable(ccp,CoreInvokeType.Internal); //CallingMessage par = new CallingMessage(); //par.ServerName = "LgDeviceManager"; //par.AssemblyName = "Core.LgMes.Server.LgDeviceManager"; //par.ClassName = "Core.LgMes.Server.LgDeviceManager.OxygenLanceManager"; //par.MethodName = "OxygenLance_NonReturn"; //par.args = new object[] { strSql }; string strErr1 = ""; //ClientCommon._RemotingHelp.ExecuteMethod(par, out strErr1); if (strErr1 == null || strErr1 == "") { BaseInfoStateUpdate("使用", cmbLanceID.Text.Trim(), txtQL.Text.Trim(), cmbType.Text.Trim()); refreshgrid(""); QueryDataselect(); MessageBox.Show("炉座号[" + comboBox6.Text.Trim() + "]氧枪[" + cmbLanceID.Text.Trim() + "]设置成功 !", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("炉座号[" + comboBox6.Text.Trim() + "]氧枪[" + cmbLanceID.Text.Trim() + "]设置失败 !", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception ex) { MessageBox.Show(ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); } } /// <修改氧枪使用信息> /// 修改氧枪使用信息 /// private void ModifyUseDetail() { try { if (ulgridBaseInfo.ActiveRow == null) return; //if (this.comboBox1.SelectedIndex == 0 || this.comboBox1.SelectedItem.ToString().Trim().Length == 0 || this.textBox1.Text.Trim().Length == 0) //{ // MessageBox.Show("请选择需要修改的记录!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); // comboBox1.Focus(); // return; //} if (dtpQEndTime.Value != null && Convert.ToDateTime(dtpQStartTime.Value) > Convert.ToDateTime(dtpQEndTime.Value)) { MessageBox.Show("上线时间不能大于下线时间!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); dtpQStartTime.Focus(); return; } if (!CheckIsNumberByASCII(txtQL.Text.Trim()) || txtQL.Text.Trim().Length == 0) { MessageBox.Show("请输入正确的枪龄!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); txtQL.Text = "0"; txtQL.SelectAll(); txtQL.Focus(); return; } if (txtSLL.Text == "") { txtSLL.Text = "0"; } string classstr = ClassTransCode(); string strSql = "update DEV_yq_use_detail set " + "USETIMES=" + Convert.ToInt32(txtQL.Text.Trim()) + "," + "REASON='" + txtReason.Text.Trim() + "'," + "MEMO='" + txtmemo.Text.Trim() + "'," + "SPOUTFACTORY='" + ucmePtcj.Text.Trim() + "'," + "FLUX=" + Convert.ToInt32(txtSLL.Text.Trim()) + "," + "BEGINTIME=to_date('" + dtpQStartTime.Value.ToString() + "','yyyy-mm-dd hh24:mi:ss')," + "OVENID='"+comboBox6.Text.ToString().Trim()+"'," + "CLASS='" + classstr + "' " + "where RECRODID='" + txtJLBH.Text.Trim() + "'"; string strErr = ""; CoreClientParam ccp = new CoreClientParam(); ccp.ServerParams = new Object[] { strSql }; ccp.ServerName = "Core.LgMes.Server.DEV.Methods.DEVPublicMethods"; ccp.MethodName = "UpdateMethods"; ob.ExecuteQueryToDataTable(ccp,CoreInvokeType.Internal); if (strErr == null || strErr == "") { string tt = txtQL.Text.Trim(); int qq = Convert.ToInt32(txtQL.Text.Trim()); string ww = cmbType.Text.Trim(); string rr = cmbLanceID.Text.Trim(); string Sqlstr = "update dev_yq_base_info t set t.usemaxtime='" + Convert.ToInt32(txtQL.Text.Trim()) + "'" + ", t.usetype='" + cmbType.Text.Trim()+ "' where t.oxygenlanceid='" + cmbLanceID.Text.Trim() + "'"; strErr = ""; CoreClientParam ccp_str = new CoreClientParam(); ccp_str.ServerParams = new Object[] { Sqlstr }; ccp_str.ServerName = "Core.LgMes.Server.DEV.Methods.DEVPublicMethods"; ccp_str.MethodName = "UpdateMethods"; ob.ExecuteQueryToDataTable(ccp_str, CoreInvokeType.Internal); proc_UpdateBaseInfoAge(txtJLBH.Text.Trim(), txtQL.Text.Trim()); refreshgrid(""); FrmOxygenLanceManage FrmOLM = (FrmOxygenLanceManage)this.Tag; MessageBox.Show("记录修改成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); FrmOLM.OLInfoToShow(); QueryDataselect(); } else { MessageBox.Show("记录修改失败!\r\n" + strErr, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception ex) { MessageBox.Show(ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); } } /// <删除氧枪使用信息> /// 删除氧枪使用信息 /// private void DelUseDetail() { try { if (ulgridBaseInfo.ActiveRow == null) return; //if (this.comboBox1.SelectedIndex == 0 || this.comboBox1.SelectedItem.ToString().Trim().Length == 0 || this.textBox1.Text.Trim().Length == 0) //{ // MessageBox.Show("请选择需要删除的记录!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); // comboBox1.Focus(); // return; //} if (MessageBox.Show("确定要删除当前记录吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) return; string strErr = ""; string strSql = "select case when ENDTIME is null then '0' else '1' end Finished from DEV_yq_use_detail where RECRODID='" + txtJLBH.Text.Trim() + "'"; 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; this.ob.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal);// DataSet ds = new DataSet(); ds.Tables.Add(dt); if ((strErr == null || strErr == "") && ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { string strFinished = Convert.ToString(ds.Tables[0].Rows[0]["Finished"]); if (strFinished == "1") { MessageBox.Show("该记录氧枪使用已经结束,不能删除!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } } else { MessageBox.Show("记录删除失败!\r\n" + strErr, "错误", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } strErr = ""; strSql = "update DEV_YQ_BASE_INFO set STATUS = '备用',USETYPE = '' where OXYGENLANCEID = (select OXYGENLANCEID from DEV_YQ_USE_DETAIL where RECRODID = '" + txtJLBH.Text.Trim() + "')"; CoreClientParam ccpqu = new CoreClientParam(); ccpqu.ServerName = "Core.LgMes.Server.DEV.Methods.DEVPublicMethods"; ccpqu.MethodName = "UpdateMethods"; ccpqu.ServerParams = new Object[] { strSql }; ob.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal); string Sqlstr = "delete from DEV_YQ_USE_DETAIL where RECRODID='" + txtJLBH.Text.Trim() + "'"; CoreClientParam ccpdel = new CoreClientParam(); ccpdel.ServerName ="Core.LgMes.Server.DEV.Methods.DEVPublicMethods"; ccpdel.MethodName ="UpdateMethods"; ccpdel.ServerParams = new Object[] { Sqlstr }; ob.ExecuteQueryToDataTable(ccpdel,CoreInvokeType.Internal); if (strErr == null || strErr == "") { refreshgrid(""); FrmOxygenLanceManage FrmOLM = (FrmOxygenLanceManage)this.Tag; FrmOLM.OLInfoToShow(); MessageBox.Show("记录删除成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); QueryDataselect(); } else { MessageBox.Show("记录删除失败!\r\n" + strErr, "错误", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } } catch (Exception ex) { MessageBox.Show(ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); } } //新增和修改氧枪使用状态时,同时更新氧枪基本信息中氧枪的使用状态 private void BaseInfoStateUpdate(string strNowStatus, string strYQID, string strYQAge, string strAB) { string sql = "update DEV_yq_base_info set STATUS='" + strNowStatus + "',USEMAXTIME='" + strYQAge + "',USETYPE = '" + strAB + "' where OXYGENLANCEID = '" + strYQID + "'"; CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "Core.LgMes.Server.DEV.Methods.DEVPublicMethods"; ccp.MethodName = "UpdateMethods"; ccp.ServerParams = new Object[] { sql}; ob.ExecuteQueryToDataTable(ccp,CoreInvokeType.Internal); UserInfoEidt(); FrmOxygenLanceManage FrmOLM = (FrmOxygenLanceManage)this.Tag; FrmOLM.OLInfoToShow(); } //修改氧枪使用信息 private void UserInfoEidt() { string sql = "update DEV_yq_use_detail t set t.endtime=sysdate where t.recrodid = "+strRecrodid+""; CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "Core.LgMes.Server.DEV.Methods.DEVPublicMethods"; ccp.MethodName = "UpdateMethods"; ccp.ServerParams = new Object[] { sql }; ob.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal); } /// /// 获取班别 /// /// private string ClassTransCode() { DateTime TimeNow = new DateTime(); TimeNow = System.DateTime.Now; string str1 = ""; string str2 = ""; //string str; if (TimeNow >= Convert.ToDateTime("8:00:00") && TimeNow <= Convert.ToDateTime("15:59:59")) { str1 = "1"; } else if (TimeNow >= Convert.ToDateTime("16:00:00") && TimeNow <= Convert.ToDateTime("23:59:59")) { str1 = "2"; } else { str1 = "3"; } switch (ucmeClass.Text) { case "甲": { str2 = "1"; break; } case "乙": { str2 = "2"; break; } case "丙": { str2 = "3"; break; } case "丁": { str2 = "4"; break; } } return (str1 + str2); } private string ClassTransChar(string code) { string str = ""; switch (code) { case "1": { str = "甲"; break; } case "2": { str = "乙"; break; } case "3": { str = "丙"; break; } case "4": { str = "丁"; break; } } return str; } private bool CheckIsNumberByASCII(string sSrc) { bool bRet = true; ASCIIEncoding AE = new ASCIIEncoding(); byte[] bArray = AE.GetBytes(sSrc); for (int i = 0; i < bArray.Length; i++) { if (bArray[i] < 47 || bArray[i] > 57) { bRet = false; break; } } return bRet; } /// <获取氧枪使用信息> /// 获取氧枪使用信息 /// /// private void refreshgrid(string sqlwhere) { string sql = "select RECRODID,OXYGENLANCEID,CLASS," +"NOWPOSITION,OVENID,NOWSTATUS,USETIMES,BEGINTIME,ENDTIME,REASON,MEMO," +"SPOUTFACTORY,FLUX from DEV_yq_use_detail where 1=1 and (RECRODID,OXYGENLANCEID) " +"in (select recrodid, OXYGENLANCEID from (select t.*,row_number() over(partition by " +"t.OXYGENLANCEID order by to_number(t.recrodid) desc) xh from DEV_yq_use_detail t) where xh <= 2) " + sqlwhere + " " +"order by case when endtime is null then '0' else '1' end,oxygenlanceid,to_char(endtime,'yyyy-MM-dd') desc,ovenid,nowposition"; //string err = ""; DataSet ds = null;// (DataSet)ClientCommon._RemotingHelp.ExecuteMethod(par, out err); if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { ultdsUseDetail.Rows.Clear(); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { object[] RowValue = new object[ds.Tables[0].Columns.Count]; for (int j = 0; j < ds.Tables[0].Columns.Count; j++) { RowValue[j] = ds.Tables[0].Rows[i][j].ToString(); } RowValue[2] = ClassTransChar(RowValue[2].ToString().Substring(1)); ultdsUseDetail.Rows.Add(RowValue); } Hashtable htOperate = new Hashtable(); htOperate.Add("", Color.LightGreen); Core.LgMes.Client.LgDeviceManager.LadleCommonClass.SetGridBackColor(ulgridBaseInfo, htOperate, "ENDTIME", true); } else { ultdsUseDetail.Rows.Clear(); dtpQStartTime.Text = System.DateTime.Now.ToString(); dtpQEndTime.Text = null; comboBox4.SelectedIndex = -1; ucmeClass.SelectedIndex = -1; cmbType.SelectedIndex = -1; ucmePtcj.SelectedIndex = -1; txtQL.Clear(); txtSLL.Clear(); comboBox6.SelectedIndex = -1; txtReason.Clear(); txtmemo.Clear(); txtJLBH.Clear(); } } /// <按条件查询> /// //按条件查询 /// private void QueryDataselect() { string sqlSelect = "select RECRODID,OXYGENLANCEID," +"case substr(CLASS,1,1) when '1' then '白' when '2' then '中' when '3' then '夜' end" +"||case substr(CLASS,2,1) when '1' then '甲' when '2' then '乙' when '3' then '丙' when '4' then '丁' end CLASS," + "NOWPOSITION,OVENID,NOWSTATUS,USETIMES,to_char(BEGINTIME,'yyyy-mm-dd HH:mm:ss')BEGINTIME,to_char(ENDTIME,'yyyy-mm-dd HH:mm:ss')ENDTIME," +"REASON,MEMO,SPOUTFACTORY,FLUX from DEV_yq_use_detail where 1=1 "; string sqlWhere = ""; //string err = ""; string YQbianhao = ucmeOxygenLanceID.Text; string startTime = udteStartTime.Value.ToString(); string endTime = udteEndTime.Value.ToString(); if (chkQStartTime.Checked && chkQEndTime.Checked) { if (Convert.ToDateTime(startTime) > Convert.ToDateTime(endTime)) { MessageBox.Show("上线时间不能大于下线时间!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } } bool bDone = false; if (chkQOxygenLanceID.Checked) { sqlWhere += " and OxygenLanceID= '" + YQbianhao + "'"; } if (chkPos.Checked && ucmePos.Text.Trim().Length > 0) { sqlWhere += " and OVENID= '" + ucmePos.Text.Trim() + "'"; } if (chkQStartTime.Checked) { sqlWhere += " and BeginTime >= to_date('" + startTime + "','yyyy-mm-dd hh24:mi:ss')"; bDone = true; } if (chkQEndTime.Checked) { sqlWhere += " and EndTime <= to_date( '" + endTime + "','yyyy-mm-dd hh24:mi:ss')"; bDone = true; } if (!bDone) sqlWhere += " and (RECRODID,OXYGENLANCEID) in (select recrodid, OXYGENLANCEID from (select t.*,row_number() over(partition by t.OXYGENLANCEID order by to_number(t.recrodid) desc) xh from DEV_yq_use_detail t) where xh <= 1)"; string strsql = sqlSelect + sqlWhere + " order by BEGINTIME desc";//case when endtime is null then '0' else '1' end,oxygenlanceid,to_char(endtime,'yyyy-MM-dd') desc,ovenid,nowposition 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; try { ob.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal);// } catch (Exception ad) { string dd = ad.Message.ToString().Trim(); } DataSet ds = new DataSet(); ds.Tables.Add(dt); try { ((DataSet)ulgridBaseInfo.DataSource).Tables[0].Rows.Clear(); } catch (Exception) { } if (ds.Tables[0].Rows.Count > 0) { ulgridBaseInfo.DataSource = ds; } if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { ultdsUseDetail.Rows.Clear();//清空原有行 for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { object[] RowValue = new object[ds.Tables[0].Columns.Count]; for (int j = 0; j < ds.Tables[0].Columns.Count; j++) { RowValue[j] = ds.Tables[0].Rows[i][j]; } //RowValue[2] = ClassTransChar(RowValue[2].ToString().Substring(1)); ultdsUseDetail.Rows.Add(RowValue); } Hashtable htOperate = new Hashtable(); htOperate.Add("", Color.LightGreen); //Core.LgMes.Client.LgDeviceManager.LadleCommonClass.SetGridBackColor(ulgridBaseInfo, htOperate, "ENDTIME", true); } else { ultdsUseDetail.Rows.Clear(); cmbLanceID.SelectedIndex = -1; dtpQStartTime.Text = System.DateTime.Now.ToString(); dtpQEndTime.Text = null; comboBox4.SelectedIndex = 1; ucmeClass.SelectedIndex = 1; cmbType.SelectedIndex = 1; ucmePtcj.SelectedIndex = 1; txtQL.Clear(); txtSLL.Clear(); comboBox6.SelectedIndex = 1; txtReason.Clear(); txtmemo.Clear(); txtJLBH.Clear(); } } /// <氧枪下线> /// 氧枪下线 /// private void proc_OffLine() { try { if (ulgridBaseInfo.ActiveRow == null) return; //if (this.comboBox1.SelectedIndex == 0 || this.comboBox1.SelectedItem.SelectedItem.ToString().Trim().Length == 0||this.textBox1.Text.Trim().Length == 0) //{ // MessageBox.Show("请选择需要下线的枪号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); // comboBox1.Focus(); // return; //} string strOLID = cmbLanceID.Text.Trim(); string strRDID = txtJLBH.Text.Trim(); string strErr = ""; string strSql = "select case when ENDTIME is null then '0' else '1' end Finished from DEV_yq_use_detail where RECRODID='" + strRDID + "'"; DataSet ds = QueryFixedFunions(strSql,ob); #region //CallingMessage par = new CallingMessage(); //par.ServerName = "LgDeviceManager"; //par.AssemblyName = "Core.LgMes.Server.LgDeviceManager"; //par.ClassName = "Core.LgMes.Server.LgDeviceManager.OxygenLanceManager"; //par.MethodName = "OxygenLance_Return"; //par.args = new object[] { strSql }; //DataSet ds = null;// (DataSet)ClientCommon._RemotingHelp.ExecuteMethod(par, out strErr); #endregion if (!((strErr == null || strErr == "") && ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)) { MessageBox.Show("[" + strOLID + "]号氧枪下线失败!\r\n" + strErr, "错误", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } string strFinished = Convert.ToString(ds.Tables[0].Rows[0]["Finished"]); //if (strFinished == "1") // return; if (MessageBox.Show("确定[" + strOLID + "]号氧枪下线吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) return; strErr = ""; string Sqlstr = "update DEV_YQ_USE_DETAIL set ENDTIME = sysdate where OXYGENLANCEID = '" + strOLID + "' and ENDTIME is null"; strErr = NoQueryExecutive(Sqlstr,ob); //par.MethodName = "OxygenLance_NonReturn"; //par.args = new object[] { strSql }; //ClientCommon._RemotingHelp.ExecuteMethod(par, out strErr); if (strErr != "") { MessageBox.Show("[" + strOLID + "]号氧枪下线失败!\r\n" + strErr, "错误", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } strErr = ""; string strSql1 = "update DEV_YQ_BASE_INFO set STATUS = '下线' where OXYGENLANCEID = '" + strOLID + "'"; //par.args = new object[] { strSql }; //ClientCommon._RemotingHelp.ExecuteMethod(par, out strErr); strErr = NoQueryExecutive(strSql1, ob); if (strErr != "") { MessageBox.Show("[" + strOLID + "]号氧枪下线失败!\r\n" + strErr, "错误", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } refreshgrid(""); FrmOxygenLanceManage FrmOLM = (FrmOxygenLanceManage)this.Tag; FrmOLM.OLInfoToShow(); MessageBox.Show("[" + strOLID + "]号氧枪下线成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); QueryDataselect(); } catch (Exception ex) { MessageBox.Show(ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); } } /// <导出> /// 导出 /// private void proc_Export() { try { if (ulgridBaseInfo.Rows.Count == 0) return; Core.Mes.Client.Common.Globals.ulGridToExcel(ulgridBaseInfo, Text); //string strFileName = string.Format(Application.StartupPath + "\\Report\\氧枪使用记录.xls"); //ultraGridExcelExporter1.Export(ulgridBaseInfo, strFileName); //ProcessStartInfo p = new ProcessStartInfo(strFileName); //p.WorkingDirectory = System.IO.Path.GetDirectoryName(strFileName); //Process.Start(p); } catch (Exception ex) { MessageBox.Show(ex.Message); } } private void chkQOxygenLanceID_CheckedChanged(object sender, EventArgs e) { ucmeOxygenLanceID.Enabled = chkQOxygenLanceID.Checked; } private void cbPos_CheckedChanged(object sender, EventArgs e) { ucmePos.Enabled = chkPos.Checked; } private void chkQStartTime_CheckedChanged(object sender, EventArgs e) { udteStartTime.Enabled = chkQStartTime.Checked; } private void chkQEndTime_CheckedChanged(object sender, EventArgs e) { udteEndTime.Enabled = chkQEndTime.Checked; } //public override void ToolBar_Click(object sender, string ToolbarKey) //{ // switch (ToolbarKey) // { // case "query": // this.QueryDataselect(); // break; // //