| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459 |
- 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 { }
- }
- /// <summary>
- /// 氧枪编号查询
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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();
- }
- }
- /// <summary>
- /// 判断枪龄输入
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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;
- }
- /// <summary>
- /// 新增
- /// </summary>
- 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);
- }
- }
- /// <summary>
- /// 修改
- /// </summary>
- 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);
- }
- }
- /// <summary>
- /// 删除
- /// </summary>
- 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);
- }
- }
- /// <summary>
- /// 工具栏
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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;
- }
- }
- }
- }
|