123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- 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_NEW.DataOperate;
- using UAS_MES_NEW.Entity;
- using UAS_MES_NEW.Make;
- using UAS_MES_NEW.PublicMethod;
- namespace UAS_MES_NEW.Special
- {
- public partial class Special_GetBad : Form
- {
- DataHelper dh;
- LogStringBuilder sql = new LogStringBuilder();
- DataTable dt;
- public Special_GetBad()
- {
- InitializeComponent();
- }
- private void Special_BoxSplit_Load(object sender, EventArgs e)
- {
- dh = SystemInf.dh;
- }
- private void Split_Click(object sender, EventArgs e)
- {
- if (SN.Text == "" || makecode.Text == null || makecode.Text == ""|| bc_remark.Text==null|| bc_remark.Text=="")
- {
- OperatResult.AppendText(">>序列号,工单号,原因分析不允许为空\n", Color.Red);
- }
- else
- {
- //如果存在送检批号则进行删除
- if (dh.CheckExist("oqcbatchdetail", "obd_sncode='" + SN.Text + "'"))
- {
- string checkno = dh.getFieldDataByCondition("oqcbatchdetail", "obd_checkno", "obd_sncode='" + SN.Text + "'").ToString();
- string ifng = dh.getFieldDataByCondition("oqcbatchdetail", "obd_ifng", "obd_sncode='" + SN.Text + "'").ToString();
- if (ifng == "-1")
- {
- dh.ExecuteSql("delete OQCITEMSAMPLES where ois_sncode = '" + SN.Text + "'", "select");
- dh.ExecuteSql("update oqcbatch set ob_nowcheckqty=ob_nowcheckqty-1,ob_ngqty = ob_ngqty -1 where ob_checkno='" + checkno + "'", "update");
- }
- dh.ExecuteSql("delete from oqcbatchdetail where obd_sncode='" + SN.Text + "'", "delete");
- }
- //之前保存的不良就不再调用
- DataTable dt = dh.getFieldsDataByCondition("makeserial", new string[] { "ms_stepcode", "nvl(ms_ifrework,0)ms_ifrework", "ms_status" }, "ms_sncode='" + SN.Text + "' and ms_makecode='" + makecode.Text + "'");
- if (dt.Rows.Count > 0)
- {
- string ifrework = dt.Rows[0]["ms_ifrework"].ToString();
- string ms_stepcode = dt.Rows[0]["ms_stepcode"].ToString();
- string ms_status = dt.Rows[0]["ms_status"].ToString();
- if (ms_status == "2")
- {
- dh.UpdateByCondition("make", "ma_madeqty=nvl(ma_madeqty,0)-1", "ma_code='" + makecode.Text + "'");
- }
- dh.UpdateByCondition("makeserial", "ms_nextstepcode='',ms_status=3", "ms_sncode='" + SN.Text + "' and ms_makecode='" + makecode.Text + "' ");
- }
- if (dh.CheckExist("makeserial", "ms_sncode='" + SN.Text + "' and ms_makecode='" + makecode.Text + "' and ms_outboxcode is not null"))
- {
- string outboxcode = dh.getFieldDataByCondition("makeserial", "nvl(ms_outboxcode,' ')", "ms_sncode='" + SN.Text + "' and ms_makecode='" + makecode.Text + "' order by ms_id desc").ToString();
- string delete1 = "delete from packagedetail where pd_outboxcode = '"+ outboxcode + "' and pd_barcode = '" + SN.Text + "'";
- string delete2 = "update makeserial set ms_outboxcode = '', ms_currentstepcode = null where ms_sncode='" + SN.Text + "' and ms_makecode='" + makecode.Text + "'";
- string delete3 = "update package set pa_currentqty = pa_currentqty - 1,pa_totalqty = pa_totalqty - 1,pa_packageqty = pa_packageqty - 1,pa_status = 0 where pa_outboxcode = '" + outboxcode + "' ";
- string delete4 = "update package set pa_packtype = null, pa_sccode = null, pa_checkno = null, pa_salecode = null, pa_makecode = null, pa_prodcode = null where pa_outboxcode = '" + outboxcode + "' and pa_currentqty = 0";
- //string delete = "delete from makebad where mb_id = '" + mb_id + "'";
- dh.ExecuteSQLTran(delete1, delete2, delete3, delete4);
- }
- dh.ExecuteSql("insert into FIRSTALY(fa_id,fa_sncode,fa_makecode,fa_content,fa_date) values (FIRSTALY_seq.nextval,'"+SN.Text+"','"+makecode.Text+"','"+ bc_remark.Text+ "',SYSDATE)", "insert");
- LogicHandler.InsertMakeProcess(SN.Text, makecode.Text, User.UserSourceCode, "采集成不良", "首件测试不良", User.UserCode);
- LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, makecode.Text, User.UserLineCode, User.UserSourceCode, "采集成不良", "首件采集不良", SN.Text,"");
- OperatResult.AppendText(">>序列号:" + SN.Text + "不良采集成功\n", Color.Green);
- BaseUtil.CleanControls(this.Controls);
- }
- }
- private void SN_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.KeyCode == Keys.Enter)
- {
- sql.Clear();
- sql.Append("select ms_makecode makecode from makeserial left join make ");
- sql.Append("on ms_makecode=ma_code where ms_sncode = '" + SN.Text + "' order by ms_id desc");
- dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
- BaseUtil.SetFormValue(this.Controls, dt);
- string ms_paststep = "";
- if (!(dt.Rows.Count > 0))
- {
- OperatResult.AppendText(">>序列号:" + SN.Text + "不存在\n", Color.Red);
- BaseUtil.CleanForm(this);
- return;
- }
- if (!dh.CheckExist("FIRSTRECORD", "fr_content='" + SN.Text + "' and FR_STATUS = 0"))
- {
- string outboxcode = dh.getFieldDataByCondition("makeserial", "nvl(ms_outboxcode,' ')", "ms_sncode='" + SN.Text + "' and ms_makecode='" + makecode.Text + "' order by ms_id desc").ToString();
- if (!dh.CheckExist("FIRSTRECORD", "fr_content='" + outboxcode + "' and FR_STATUS = 0"))
- {
- OperatResult.AppendText(">>序列号:" + SN.Text + "非在测首件SN\n", Color.Red);
- BaseUtil.CleanForm(this);
- return;
- }
- }
- }
- }
- private void NewBadCode_Click(object sender, EventArgs e)
- {
- if (SN.Text == "" || makecode.Text == null || makecode.Text == "")
- {
- OperatResult.AppendText(">>序列号和工单号不允许为空\n", Color.Red);
- }
- else
- {
- Make_NewBadCode badcode = new Make_NewBadCode(SN.Text, makecode.Text);
- // badcode.FormClosed += LoadBadInfTree;
- BaseUtil.SetFormCenter(badcode);
- badcode.ShowDialog();
- }
- }
- }
- }
|