123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using UAS_MES;
- using UAS_MES.DataOperate;
- using UAS_MES.Entity;
- using UAS_MES.PublicMethod;
- namespace UAS_MES.Make
- {
- public partial class Make_SMTStockStencil : Form
- {
- DataTable Dbfind;
- AutoSizeFormClass asc = new AutoSizeFormClass();
- DataHelper dh = SystemInf.dh;
- StringBuilder sql = new StringBuilder();
- bool ifUsed = false;
- public Make_SMTStockStencil()
- {
- InitializeComponent();
- SU_DEVCODE.Enabled = false;
- SU_DEVCODE1.Enabled = false;
- ST_ENSIONA.Enabled = false;
- ST_ENSIONB.Enabled = false;
- ST_ENSIONC.Enabled = false;
- ST_ENSIOND.Enabled = false;
- ST_ENSIONE.Enabled = false;
- Receive.Enabled = false;
- Return.Enabled = false;
- Scrap.Enabled = false;
- }
- private void Make_SMTStencil_Load(object sender, EventArgs e)
- {
- asc.controllInitializeSize(this);
- //工单号放大镜配置
- ma_code.TableName = "make left join product on ma_prodcode=pr_code";
- ma_code.SelectField = "ma_code # 工单号,ma_prodcode # 产品编号,ma_qty # 工单数量,pr_detail # 产品名称,ma_softversion # 软件版本,ma_salecode # 销售单号,pr_sendchecktype # 产品送检方式";
- ma_code.FormName = Name;
- ma_code.SetValueField = new string[] { "ma_code", "ma_prodcode", "ma_qty", "pr_detail", "ma_softversion", "ma_salecode", "nvl(pr_sendchecktype,'LineCode')pr_sendchecktype" };
- ma_code.Condition = "ma_statuscode in('STARTED','AUDITED')";
- ma_code.DbChange += Ma_code_DbChange;
- SU_DEVCODE.Focus();
- }
- private void Ma_code_DbChange(object sender, EventArgs e)
- {
- Dbfind = ma_code.ReturnData;
- BaseUtil.SetFormValue(this.Controls, Dbfind);
- Confirm.PerformClick();
- }
- private void Make_SMTStencil_SizeChanged(object sender, EventArgs e)
- {
- asc.controlAutoSize(this);
- }
- private void LoadGridData()
- {
- sql.Clear();
- sql.Append("select St_PCBCODE,su_stcode,su_table,su_status,su_linecode,su_usemacode,su_singlepringqty,su_stverison ");
- sql.Append("from StencilUse left join stencil on st_code=su_stcode where su_usemacode='" + ma_code.Text + "' and su_status='在线'");
- DataTable dt = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
- BaseUtil.FillDgvWithDataTable(ToolsBom, dt);
- }
- private void Confirm_Click(object sender, EventArgs e)
- {
- LoadGridData();
- }
- private void Receive_Click(object sender, EventArgs e)
- {
- DataTable dt = (DataTable)dh.ExecuteSql("select ST_USESTATUS,nvl(st_maxusecount,0)st_maxusecount,nvl(st_usecount,0)st_usecount from Stencil where st_code='" + SU_DEVCODE.Text + "' and st_statuscode='AUDITED'", "select");
- int WaringCount = int.Parse(dh.GetConfig("WaringCount", "Stencil").ToString());
- int st_maxusecount = 0;
- int st_usecount = 0;
- if (dt.Rows.Count > 0)
- {
- string status = dt.Rows[0]["ST_USESTATUS"].ToString();
- st_maxusecount = int.Parse(dt.Rows[0]["st_maxusecount"].ToString());
- st_usecount = int.Parse(dt.Rows[0]["st_usecount"].ToString());
- if (status == "借出" || status == "报废" || status == "在线")
- {
- MessageBox.Show("当前钢网" + SU_DEVCODE.Text + "处于" + status + "状态,无法领用");
- return;
- }
- }
- else
- {
- MessageBox.Show("钢网编号" + SU_DEVCODE.Text + "不存在或者未审核");
- return;
- }
- //使用次数预警
- if (st_maxusecount - st_usecount < WaringCount)
- {
- string close = MessageBox.Show(this.ParentForm, "钢网已使用" + st_usecount + ",距离使用上限还有" + (st_maxusecount - st_usecount) + "次", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
- if (close != "Yes")
- {
- return;
- }
- }
- sql.Clear();
- sql.Append("insert into StencilUse(su_id,su_stid,su_stcode,su_stockusedate,su_useman,SU_USEMANCODE,su_stverison,SU_STATUS,SU_CLEANNUMS)");
- sql.Append("select StencilUse_seq.nextval,st_id,'" + SU_DEVCODE.Text + "',sysdate,'" + User.UserName + "','" + User.UserCode + "'");
- sql.Append(",st_version,'借出',ST_CLEANNUMS from ");
- sql.Append("Stencil where st_code='" + SU_DEVCODE.Text + "'");
- dh.ExecuteSql(sql.ToString(), "insert");
- dh.ExecuteSql("update Stencil set ST_USESTATUS='借出' where st_code='" + SU_DEVCODE.Text + "'", "update");
- MessageBox.Show("领用成功");
- SU_DEVCODE.Text = "";
- Receive.Enabled = false;
- LoadGridData();
- }
- private void Return_Click(object sender, EventArgs e)
- {
- if (ST_ENSIONA.Text != "" && ST_ENSIONB.Text != "" && ST_ENSIONC.Text != "" && ST_ENSIOND.Text != "" && ST_ENSIONE.Text != "")
- {
- if (SU_RETURNIFCLEAN.Checked)
- {
- DataTable dt = (DataTable)dh.ExecuteSql("select ST_USESTATUS,nvl(St_USECOUNT,0)St_USECOUNT from Stencil where st_code='" + SU_DEVCODE1.Text + "' and st_statuscode='AUDITED'", "select");
- if (dt.Rows.Count > 0)
- {
- string status = dt.Rows[0]["ST_USESTATUS"].ToString();
- if (status == "在线")
- {
- MessageBox.Show("当前钢网" + SU_DEVCODE1.Text + "处于在线状态,无法退回");
- return;
- }
- if (status == "在仓")
- {
- MessageBox.Show("当前钢网" + SU_DEVCODE1.Text + "未借出,无需归还");
- return;
- }
- if (status == "报废")
- {
- MessageBox.Show("当前钢网" + SU_DEVCODE1.Text + "处于" + status + "状态,无法退回");
- return;
- }
- }
- else
- {
- MessageBox.Show("钢网编号" + SU_DEVCODE1.Text + "不存在或者未审核");
- return;
- }
- sql.Clear();
- sql.Append("update StencilUse set SU_CLEANNUMS = nvl(SU_CLEANNUMS,0)+1,su_returnman='" + User.UserName + "',SU_STOCKBACKDATE=sysdate,SU_ENSIONA='" + ST_ENSIONA.Text + "',SU_ENSIONB='" + ST_ENSIONB.Text + "',SU_ENSIONC='" + ST_ENSIONC.Text + "',SU_ENSIOND='" + ST_ENSIOND.Text + "',");
- sql.Append("SU_ENSIONE='" + ST_ENSIONE.Text + "',SU_STATUS='在仓'");
- sql.Append(",SU_RETURNIFCLEAN='" + (SU_RETURNIFCLEAN.Checked ? "-1" : "0") + "' where su_id=(select max(su_id) from stenciluse where su_stcode='" + SU_DEVCODE1.Text + "' and su_status='借出' and su_stockusedate is not null)");
- dh.ExecuteSql(sql.ToString(), "update");
- sql.Clear();
- sql.Append("update Stencil set st_cleannums=nvl(st_cleannums,0)+1,ST_USESTATUS='在仓',ST_ENSIONA='" + ST_ENSIONA.Text + "',ST_ENSIONB='" + ST_ENSIONB.Text + "',");
- sql.Append("ST_ENSIONC='" + ST_ENSIONC.Text + "',ST_ENSIOND='" + ST_ENSIOND.Text + "',ST_ENSIONE='" + ST_ENSIONE.Text + "' ");
- sql.Append("where st_code='" + SU_DEVCODE1.Text + "'");
- dh.ExecuteSql(sql.ToString(), "update");
- MessageBox.Show("钢网" + SU_DEVCODE1.Text + "退回成功!");
- SU_DEVCODE1.Text = "";
- ST_ENSIONA.Text = "";
- ST_ENSIONB.Text = "";
- ST_ENSIONC.Text = "";
- ST_ENSIOND.Text = "";
- ST_ENSIONE.Text = "";
- SU_RETURNIFCLEAN.Checked = false;
- Return.Enabled = false;
- Confirm.PerformClick();
- }
- else
- {
- MessageBox.Show("请确认是否清洗钢网");
- }
- }
- else
- {
- MessageBox.Show("请维护完成的测试参数");
- }
- }
- Make_StencilScrapReason form;
- private void Scrap_Click(object sender, EventArgs e)
- {
- DataTable dt = (DataTable)dh.ExecuteSql("select st_usestatus,st_status from stencil where st_code='" + SU_DEVCODE1.Text + "' and st_statuscode='AUDITED'", "select");
- if (dt.Rows.Count > 0)
- {
- if (dt.Rows[0]["st_usestatus"].ToString() == "报废")
- {
- MessageBox.Show("钢网" + SU_DEVCODE1.Text + "已处于报废状态");
- return;
- }
- if (dt.Rows[0]["st_usestatus"].ToString() != "借出")
- {
- MessageBox.Show("报废钢网必须" + SU_DEVCODE1.Text + "处于借出状态");
- return;
- }
- string closetab_confirm = MessageBox.Show(this.ParentForm, "报废后不可撤销,是否确认报废", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
- if (closetab_confirm != "Yes")
- {
- return;
- }
- form = new Make_StencilScrapReason();
- BaseUtil.SetFormCenter(form);
- form.Controls["ConfirmScrap"].Click += Make_SMTStencil_Click;
- form.ShowDialog();
- }
- else
- {
- MessageBox.Show("钢网编号" + SU_DEVCODE1.Text + "不存在或者未审核");
- }
- }
- private void Make_SMTStencil_Click(object sender, EventArgs e)
- {
- string Code = "";
- string scrapreason = form.Controls["Reason"].Text;
- if (scrapreason == "")
- {
- MessageBox.Show("报废原因不能为空");
- return;
- }
- sql.Clear();
- sql.Append("update StencilUse set SU_IFSCRAPOLD=-1,SU_STATUS='报废',SU_ENSIONA='" + ST_ENSIONA.Text + "',SU_ENSIONB='" + ST_ENSIONB.Text + "',SU_ENSIONC='" + ST_ENSIONC.Text + "',SU_ENSIOND='" + ST_ENSIOND.Text + "',SU_ENSIONE='" + ST_ENSIONE.Text + "'");
- sql.Append(",SU_RETURNIFCLEAN='" + (SU_RETURNIFCLEAN.Checked ? "-1" : "0") + "' where su_id=(select max(su_id) from stenciluse where su_stcode='" + SU_DEVCODE1.Text + "')");
- dh.ExecuteSql(sql.ToString(), "update");
- sql.Clear();
- sql.Append("update Stencil set ST_SCRAPREASON='" + scrapreason + "',ST_SCRAPMANCODE='" + User.UserCode + "',st_scrapman='" + User.UserName + "',st_scrapdate=sysdate,ST_USESTATUS='报废',ST_ENSIONA='" + ST_ENSIONA.Text + "',ST_ENSIONB='" + ST_ENSIONB.Text + "',");
- sql.Append("ST_ENSIONC='" + ST_ENSIONC.Text + "',ST_ENSIOND='" + ST_ENSIOND.Text + "',ST_ENSIONE='" + ST_ENSIONE.Text + "' ");
- sql.Append("where st_code='" + SU_DEVCODE1.Text + "'");
- dh.ExecuteSql(sql.ToString(), "insert");
- //推送人员信息
- string[] emid = dh.GetConfig("sendEmp", "Stencil").ToString().Replace("\n", "#").Split('#');
- for (int i = 0; i < emid.Length; i++)
- {
- string em_name = dh.getFieldDataByCondition("employee", "em_name", "em_id='" + emid[i] + "'").ToString();
- LogicHandler.SendMessage(emid[i], em_name, "钢网" + SU_DEVCODE1.Text + "已报废" + ",原因" + scrapreason + ",人员" + User.UserName);
- }
- form.Close();
- SU_DEVCODE1.Text = "";
- ST_ENSIONA.Text = "";
- ST_ENSIONB.Text = "";
- ST_ENSIONC.Text = "";
- ST_ENSIOND.Text = "";
- ST_ENSIONE.Text = "";
- SU_RETURNIFCLEAN.Checked = false;
- Scrap.Enabled = false;
- MessageBox.Show("报废成功!");
- }
- private void Radio_CheckedChanged(object sender, EventArgs e)
- {
- switch ((sender as Control).Name)
- {
- case "RadioReceive":
- if ((sender as RadioButton).Checked)
- {
- SU_DEVCODE.Enabled = true;
- Receive.Enabled = true;
- Receive.Enabled = true;
- SU_DEVCODE1.Enabled = false;
- ST_ENSIONA.Enabled = false;
- ST_ENSIONB.Enabled = false;
- ST_ENSIONC.Enabled = false;
- ST_ENSIOND.Enabled = false;
- ST_ENSIONE.Enabled = false;
- Return.Enabled = false;
- Scrap.Enabled = false;
- }
- break;
- case "RadioReturn":
- if ((sender as RadioButton).Checked)
- {
- SU_DEVCODE1.Enabled = true;
- ST_ENSIONA.Enabled = true;
- ST_ENSIONB.Enabled = true;
- ST_ENSIONC.Enabled = true;
- ST_ENSIOND.Enabled = true;
- ST_ENSIONE.Enabled = true;
- SU_DEVCODE.Enabled = false;
- Receive.Enabled = false;
- Receive.Enabled = false;
- }
- break;
- default:
- break;
- }
- }
- //默认范围39-55,如不在范围内则可以报废
- private void ST_ENSION_TextChanged(object sender, EventArgs e)
- {
- double Range = 0;
- List<string> Num = new List<string>();
- Num.Add(ST_ENSIONA.Text);
- Num.Add(ST_ENSIONB.Text);
- Num.Add(ST_ENSIONC.Text);
- Num.Add(ST_ENSIOND.Text);
- Num.Add(ST_ENSIONE.Text);
- int CheckCount = 0;
- int FillCount = 0;
- foreach (string item in Num)
- {
- if (item != "")
- {
- FillCount = FillCount + 1;
- if (double.TryParse(item, out Range))
- {
- //如果使用过张力范围39-55,使用过30-55
- if (ifUsed)
- {
- if (Range > 30 && Range <= 55)
- {
- CheckCount = CheckCount + 1;
- }
- }
- else
- {
- if (Range > 30 && Range <= 55)
- {
- CheckCount = CheckCount + 1;
- }
- }
- }
- }
- }
- if (FillCount == 5)
- {
- if (CheckCount == 5)
- {
- Return.Enabled = true;
- Scrap.Enabled = false;
- }
- else
- {
- Return.Enabled = false;
- Scrap.Enabled = true;
- }
- }
- }
- private void SU_DEVCODE_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.KeyCode == Keys.Enter)
- {
- DataTable dt = (DataTable)dh.ExecuteSql("select st_usestatus,st_table from stencil where st_code='" + SU_DEVCODE.Text + "' and st_statuscode='AUDITED'", "select");
- if (dt.Rows.Count == 0)
- {
- MessageBox.Show("钢网编号" + SU_DEVCODE.Text + "不存在或者未审核");
- }
- if (dt.Rows.Count > 0)
- {
- Receive.Enabled = true;
- if (dt.Rows[0]["st_usestatus"].ToString() == "报废")
- {
- MessageBox.Show("钢网编号" + SU_DEVCODE.Text + "已报废");
- }
- }
- }
- }
- private void SU_DEVCODE1_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.KeyCode == Keys.Enter)
- {
- DataTable dt = (DataTable)dh.ExecuteSql("select nvl(st_usecount,0)st_usecount,case when nvl(ST_COMBINENUMBER,1)=0 then 1 else nvl(ST_COMBINENUMBER,1) end from STENCIL where st_code='" + SU_DEVCODE1.Text + "' and st_statuscode='AUDITED'", "select");
- if (dt.Rows.Count == 0)
- {
- MessageBox.Show("钢网编号" + SU_DEVCODE1.Text + "不存在或者未审核");
- }
- else
- {
- st_usecount.Text = dt.Rows[0]["st_usecount"].ToString();
- if (int.Parse(st_usecount.Text) > 0)
- {
- ifUsed = true;
- }
- else
- {
- ifUsed = false;
- }
- }
- }
- }
- private void ma_code_TextKeyDown(object sender, KeyEventArgs e)
- {
- if (e.KeyCode == Keys.Enter)
- {
- Confirm.PerformClick();
- }
- }
- }
- }
|