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; namespace Core.LgMes.Client.LgDeviceManager { public partial class FrmOLBaseInfo : FrmLgDevFunctions { public FrmOLBaseInfo(OpeBase oba) { InitializeComponent(); ucmeLanceType.SelectedIndex = 0; ob = oba; } private void FrmOLBaseInfo_Load(object sender, EventArgs e) { try { FrmOxygenLanceManage FrmOLM = (FrmOxygenLanceManage)this.Tag; ucmeLanceN.Items.Clear(); for (int i = 0; i < FrmOLM.ulgridBaseInfo.Rows.Count; i++) { ucmeLanceN.Items.Add(FrmOLM.ulgridBaseInfo.Rows[i].Cells["OxygenLanceID"].Value.ToString()); } if (FrmOLM.ulgridBaseInfo.Selected != null) { ucmeLanceN.Text = FrmOLM.ulgridBaseInfo.ActiveRow.Cells["OxygenLanceID"].Value.ToString(); ucmeNowStatus.Text = FrmOLM.ulgridBaseInfo.ActiveRow.Cells["Status"].Value.ToString(); //if (FrmOLM.ulgridBaseInfo.ActiveRow.Cells["CreativeDate"].Value.ToString() == "") //{ udtePTime.DateTime = DateTime.Now; //} //else //{ //udtePTime.DateTime = Convert.ToDateTime(FrmOLM.ulgridBaseInfo.ActiveRow.Cells["CreativeDate"].Value); //} if (FrmOLM.ulgridBaseInfo.ActiveRow.Cells["BuyDate"].Value.ToString() == "") { udtePTime.DateTime = DateTime.Now; } else { udtePTime.DateTime = Convert.ToDateTime(FrmOLM.ulgridBaseInfo.ActiveRow.Cells["BuyDate"].Value); } txtBaseInfoMemo.Text = FrmOLM.ulgridBaseInfo.ActiveRow.Cells["Memo"].Value.ToString(); string strsql = "select UseType,YQType,UseMaxTime,CUTSULFUR from DEV_yq_base_info where OxygenLanceID = '" + ucmeLanceN.Text + "'"; DataSet ds = QueryFixedFunions(strsql, ob); if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { ucmeType.Text = ds.Tables[0].Rows[0]["UseType"].ToString(); ucmeLanceType.Text = ds.Tables[0].Rows[0]["YQType"].ToString(); txtAge.Text = ds.Tables[0].Rows[0]["UseMaxTime"].ToString(); textBox1.Text = ds.Tables[0].Rows[0]["CUTSULFUR"].ToString(); } else { this.Show(); } } else { ucmeLanceN.Text = ""; ucmeNowStatus.Text = ""; txtBaseInfoMemo.Text = ""; } } catch { } } /// /// 氧枪编号查询 /// /// /// public void comboBox4_SelectedValueChanged(object sender, EventArgs e) { string YQid = ucmeLanceN.Text; string strsql = "select * from DEV_yq_base_info where OxygenLanceID = '" + ucmeLanceN.Text + "'"; DataSet ds = QueryFixedFunions(strsql, ob); if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { ucmeType.Text = ds.Tables[0].Rows[0]["USETYPE"].ToString(); ucmeLanceType.Text = ds.Tables[0].Rows[0]["YQTYPE"].ToString(); ucmeNowStatus.Text = ds.Tables[0].Rows[0]["STATUS"].ToString(); udtePTime.DateTime = Convert.ToDateTime(ds.Tables[0].Rows[0]["CREATIVEDATE"]); udteBuyTime.DateTime = Convert.ToDateTime(ds.Tables[0].Rows[0]["BUYDATE"]); txtAge.Text = ds.Tables[0].Rows[0]["USEMAXTIME"].ToString(); txtBaseInfoMemo.Text = ds.Tables[0].Rows[0]["MEMO"].ToString(); } } /// /// 判断枪龄输入 /// /// /// private void txtAge_TextChanged(object sender, EventArgs e) { if (!CheckIsNumberByASCII(txtAge.Text)) { MessageBox.Show("错误的数据输入!", "", MessageBoxButtons.OK, MessageBoxIcon.Information); txtAge.Clear(); } } 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 proc_Add() { try { bool bUsed = false; string strSql = "select count(1) from DEV_YQ_USE_DETAIL where OXYGENLANCEID = '" + ucmeLanceN.Text.Trim() + "'"; DataSet ds = QueryFixedFunions(strSql, ob); if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { if (Convert.ToInt32(ds.Tables[0].Rows[0][0]) > 0) bUsed = true; } ds = null; bool bExist = false; strSql = "select count(1) from DEV_YQ_BASE_INFO where OXYGENLANCEID = '" + ucmeLanceN.Text.Trim() + "'"; ds = QueryFixedFunions(strSql, ob); if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { if (Convert.ToInt32(ds.Tables[0].Rows[0][0]) > 0) bExist = true; } string err = ""; if (!(err == null || err == "")) { MessageBox.Show("氧枪[" + ucmeLanceN.Text.Trim() + "]新增失败!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (!bExist) { if (ucmeLanceN.Text.Trim() == "") { MessageBox.Show("氧枪编号不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); ucmeLanceN.Focus(); return; } if (udtePTime.DateTime > udteBuyTime.DateTime) { MessageBox.Show("生产日期不能大于购买日期!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); udtePTime.Focus(); return; } else { string strOxygenLanceID = ucmeLanceN.Text.Trim();//氧枪编号 string strUserType = ucmeType.Text.Trim();//使用状态 string strCreativeDate = udtePTime.DateTime.ToString("yyyy-MM-dd");//生产日期 string strBuyDate = udteBuyTime.DateTime.ToString("yyyy-MM-dd");//购买日期 string strOxygenLanceType = ucmeLanceType.Text.Trim(); //氧枪类型 string strStatus = ucmeNowStatus.Text.Trim();//当前状态 string strAge = txtAge.Text.Trim();//枪龄 string strMemo = txtBaseInfoMemo.Text.Trim();//备注 string SqlCommand = "insert into DEV_yq_base_info (OXYGENLANCEID,PARAID,USETYPE,STATUS,CREATIVEDATE,BUYDATE,MEMO,YQTYPE,USEMAXTIME) values( '" + strOxygenLanceID + "' , '" + "','" + strUserType + "', '备用',to_date('" + strCreativeDate + "','yyyy-mm-dd') ," + "to_date('" + strBuyDate + "','yyyy-mm-dd') ,'" + strMemo + "','" + strOxygenLanceType + "','" + strAge + "')"; string err1 = NoQueryExecutive(SqlCommand, ob); if (err1 == null || err1 == "") { txtAge.Clear(); txtBaseInfoMemo.Clear(); ucmeType.Text = ""; ucmeLanceN.Text = ""; ucmeNowStatus.Text = ""; ucmeLanceN.Items.Add(strOxygenLanceID); udtePTime.DateTime = System.DateTime.Now; udteBuyTime.DateTime = System.DateTime.Now; //重新刷新主界面数据 FrmOxygenLanceManage FrmOLM = (FrmOxygenLanceManage)this.Tag; FrmOLM.OLInfoToShow(); MessageBox.Show("氧枪[" + strOxygenLanceID + "]新增成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("氧枪[" + strOxygenLanceID + "]新增失败!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } else { MessageBox.Show("氧枪[" + ucmeLanceN.Text.Trim() + "]已存在,不能重复插入!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { MessageBox.Show(ex.Message); } } /// /// 修改 /// private void proc_Edit() { try { if (ucmeLanceN.Text.Trim().Length == 0) return; FrmOxygenLanceManage FrmOLM = (FrmOxygenLanceManage)this.Tag; string strOxygenLanceID = ucmeLanceN.Text.Trim(); string strErr = ""; bool bUsed = false; string strSql = "select count(1) from DEV_YQ_USE_DETAIL where OXYGENLANCEID = '" + ucmeLanceN.Text.Trim() + "'"; DataSet ds = QueryFixedFunions(strSql, ob); if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { if (Convert.ToInt32(ds.Tables[0].Rows[0][0]) > 0) bUsed = true; } strErr = ""; ds = null; bool bExist = false; strSql = "select count(1) from DEV_YQ_BASE_INFO where OXYGENLANCEID = '" + ucmeLanceN.Text.Trim() + "'"; ds = QueryFixedFunions(strSql, ob); if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { if (Convert.ToInt32(ds.Tables[0].Rows[0][0]) > 0) bExist = true; } if (!(strErr == null || strErr == "")) { MessageBox.Show("氧枪[" + strOxygenLanceID + "]修改失败!\r\n" + strErr, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (!bExist) { MessageBox.Show("[" + strOxygenLanceID + "]号氧枪不存在!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (MessageBox.Show("确定要修改[" + strOxygenLanceID + "]号氧枪吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) return; strErr = ""; strSql = "select STATUS, USETYPE from DEV_YQ_BASE_INFO where OXYGENLANCEID = '" + strOxygenLanceID + "'"; ds = QueryFixedFunions(strSql, ob); string strOldStatus = "", strOldType = ""; if ((strErr == null || strErr == "") && ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { strOldStatus = Convert.ToString(ds.Tables[0].Rows[0]["STATUS"]); strOldType = Convert.ToString(ds.Tables[0].Rows[0]["USETYPE"]); } else { MessageBox.Show("氧枪[" + strOxygenLanceID + "]修改失败!\r\n" + strErr, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } string strCreativeDate = udtePTime.DateTime.ToString("yyyy-MM-dd"); string strBuyDate = udteBuyTime.DateTime.ToString("yyyy-MM-dd"); string strStatus = ucmeNowStatus.Text.Trim(); string strAge = txtAge.Text.Trim(); string strUserType = ucmeType.Text.Trim(); string strMemo = txtBaseInfoMemo.Text.Trim(); string strOxygenLanceType = ucmeLanceType.Text.Trim(); if (strOldStatus == "使用" && (strStatus != strOldStatus || strUserType != strOldType)) { MessageBox.Show("氧枪[" + strOxygenLanceID + "]当前状态为[" + strOldStatus + "]当前使用类型为[" + strOldType + "],不能更改其使用类型及状态!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } else if (strOldStatus == "备用" && (strStatus != "备用" && strStatus != "下线")) { MessageBox.Show("氧枪[" + strOxygenLanceID + "]当前状态为[" + strOldStatus + "],不能将其状态改为[" + strStatus + "]!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } else if (strOldStatus == "下线" && (strStatus != "备用" && strStatus != "下线")) { MessageBox.Show("氧枪[" + strOxygenLanceID + "]当前状态为[" + strOldStatus + "],不能将其状态改为[" + strStatus + "]!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } strErr = ""; strSql = "update DEV_yq_base_info set " + "UseType = '" + strUserType + "'," + "Status = '" + strStatus + "'," + //"CreativeDate = to_date('" + strCreativeDate + "','yyyy-mm-dd')," + //"BuyDate = to_date('" + strBuyDate + "','yyyy-mm-dd') ," + "Memo = '" + strMemo + "'," + "YQType ='" + strOxygenLanceType + "', " + "UseMaxTime = '" + strAge + "', " + "CUTSULFUR = " + textBox1.Text + ", " + "MODIFY_DATE = SYSDATE " + "where OxygenLanceID = '" + strOxygenLanceID + "'"; strErr = NoQueryExecutive(strSql, ob); if (!(strErr == null || strErr == "")) { MessageBox.Show("氧枪[" + strOxygenLanceID + "]修改失败!\r\n" + strErr, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } FrmOLM.OLInfoToShow(); MessageBox.Show("氧枪[" + strOxygenLanceID + "]修改成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show(ex.Message); } } /// /// 删除 /// private void proc_Del() { try { if (ucmeLanceN.Text.Trim().Length == 0) return; FrmOxygenLanceManage FrmOLM = (FrmOxygenLanceManage)this.Tag; string OLID = ucmeLanceN.Text; bool bUsed = false; string strSql = "select count(1) from DEV_YQ_USE_DETAIL where OXYGENLANCEID = '" + ucmeLanceN.Text.Trim() + "'"; DataSet ds = QueryFixedFunions(strSql, ob); if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { if (Convert.ToInt32(ds.Tables[0].Rows[0][0]) > 0) bUsed = true; } ds = null; bool bExist = false; strSql = "select count(1) from DEV_YQ_BASE_INFO where OXYGENLANCEID = '" + ucmeLanceN.Text.Trim() + "'"; ds = QueryFixedFunions(strSql, ob); if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { if (Convert.ToInt32(ds.Tables[0].Rows[0][0]) > 0) bExist = true; } if (!bExist) { MessageBox.Show("[" + OLID + "]号氧枪不存在!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else { if (MessageBox.Show("确定要删除[" + OLID + "]号氧枪吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) return; } if (bUsed) { MessageBox.Show("该氧枪已使用过,不能删除!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } string strErr = ""; strSql = "delete from DEV_YQ_BASE_INFO where OXYGENLANCEID = '" + OLID + "'"; strErr = NoQueryExecutive(strSql, ob); if (strErr == null || strErr == "") { FrmOLM.OLInfoToShow(); ucmeLanceN.Clear(); txtAge.Clear(); txtBaseInfoMemo.Clear(); ucmeType.Text = ""; ucmeLanceN.Text = ""; ucmeNowStatus.Text = ""; udtePTime.DateTime = System.DateTime.Now; udteBuyTime.DateTime = System.DateTime.Now; ucmeLanceN.Items.Clear(); for (int i = 0; i < FrmOLM.ulgridBaseInfo.Rows.Count; i++) { ucmeLanceN.Items.Add(FrmOLM.ulgridBaseInfo.Rows[i].Cells["OxygenLanceID"].Value.ToString()); } MessageBox.Show("[" + OLID + "]号氧枪删除成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("[" + OLID + "]号氧枪删除失败!\r\n" + strErr, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception ex) { MessageBox.Show(ex.Message); } } /// /// 工具栏 /// /// /// private void toolStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e) { switch (e.ClickedItem.Name) { case "ADD": { this.proc_Add(); break; } case "EDIT": { this.proc_Edit(); break; } case "DEL": { this.proc_Del(); break; } case "CLOSE": { this.Close(); break; } default: break; } } } }