using System; using System.Data; using System.Text; using System.Windows.Forms; using UAS_MES_NEW.DataOperate; using UAS_MES_NEW.Entity; using UAS_MES_NEW.PublicMethod; namespace UAS_MES_NEW.Special { public partial class Special_CancelOQC : Form { DataHelper dh; LogStringBuilder sql = new LogStringBuilder(); DataTable Dbfind; public Special_CancelOQC() { InitializeComponent(); } private void Special_BoxSplit_Load(object sender, EventArgs e) { dh = SystemInf.dh; cd_stepcode.FormName = Name; cd_stepcode.TableName = "craftdetail left join step on st_code=cd_stepcode left join craft on cd_crid=cr_id"; cd_stepcode.SetValueField = new string[] { "cd_stepcode", "cd_stepno" }; cd_stepcode.SelectField = "cd_stepname # 工序名称 ,cd_stepcode # 工序编号,cd_stepno # 执行顺序"; cd_stepcode.DBTitle = "回流工序"; cd_stepcode.DbChange += Cd_stepcode_DbChange; } private void Cd_stepcode_DbChange(object sender, EventArgs e) { Dbfind = cd_stepcode.ReturnData; BaseUtil.SetFormValue(this.Controls, Dbfind); } string ms_id = ""; private void SaveRepairInf_Click(object sender, EventArgs e) { if (ms_id == "") { OperateResult.AppendText(">>请先获取SN\n"); return; } if (cd_stepcode.Text == "") { OperateResult.AppendText(">>请选择回流工序\n"); return; } DataTable dt = (DataTable)dh.ExecuteSql("select ms_makecode,ms_firstsn,ms_sncode,ms_prodcode,ms_checkno,ms_craftcode,ms_outboxcode from makeserial where ms_id='" + ms_id + "' and instr(ms_paststep,'" + cd_stepcode.Text + "')>0 ", "select"); if (dt.Rows.Count == 0) { OperateResult.AppendText(">>" + SN.Text + "不存在或未执行过" + cd_stepcode.Text + "工序\n"); return; } string ms_makecode = dt.Rows[0]["ms_makecode"].ToString(); string ms_firstsn = dt.Rows[0]["ms_firstsn"].ToString(); string ms_prodcode = dt.Rows[0]["ms_prodcode"].ToString(); string ms_sncode = dt.Rows[0]["ms_sncode"].ToString(); string ms_checkno = dt.Rows[0]["ms_checkno"].ToString(); string ms_craftcode = dt.Rows[0]["ms_craftcode"].ToString(); string ms_outboxcode = dt.Rows[0]["ms_outboxcode"].ToString(); if (ms_outboxcode != "") { OperateResult.AppendText(">>序列号已经装箱" + ms_outboxcode + "\n"); return; } if (cr_code.Text != "" && cr_code.Text != ms_craftcode) { OperateResult.AppendText(">>序列号途程和所选途程不一致\n"); return; } dt = (DataTable)dh.ExecuteSql("select cd_id from craft left join craftdetail on cr_id=cd_crid where cr_prodcode='" + ms_prodcode + "' and cr_code='" + ms_craftcode + "' and cd_stepcode='" + cd_stepcode.Text + "'", "select"); if (dt.Rows.Count == 0) { OperateResult.AppendText(">>工序不在所选途程中\n"); return; } StringBuilder sql = new StringBuilder(); sql.Append("update craftmaterial set cm_status=-1,CM_DROPMAN='"+User.UserName+"' where cm_stepcode in (select cd_stepcode from craft left join "); sql.Append("craftdetail on cd_crid = cr_id where cr_prodcode = '" + ms_prodcode + "' and cd_detno >= " + cd_stepno.Text + ") "); sql.Append("and cm_firstsn='" + ms_firstsn + "' and cm_makecode='" + ms_makecode + "'"); dh.ExecuteSql(sql.ToString(), "update"); //dh.ExecuteSql("delete from oqcbatchdetail where obd_sncode='" + ms_sncode + "'", "update"); //dh.ExecuteSql("update oqcbatch set ob_nowcheckqty=(select count(1) from oqcbatchdetail where obd_checkno='" + ms_checkno + "') where ob_checkno='" + ms_checkno + "'", "update"); dh.ExecuteSql("update makeserial set ms_nextstepcode='" + cd_stepcode.Text + "' where ms_id='" + ms_id + "'", "update"); LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ms_makecode, User.UserLineCode, User.UserSourceCode, "OQC回流", "回流成功" + cd_stepcode.Text, ms_sncode, ms_checkno); OperateResult.AppendText(">>" + SN.Text + "回流成功\n"); //cr_code.Text = ""; //cd_stepcode.Text = ""; SN.Text = ""; ms_id = ""; } private void SN_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { DataTable dt = (DataTable)dh.ExecuteSql("select ms_id,ms_craftcode,ms_prodcode,ms_checkno from makeserial where ms_sncode='" + SN.Text + "' order by ms_id desc", "select"); if (dt.Rows.Count == 0) { OperateResult.AppendText(">>" + SN.Text + "不存在\n", System.Drawing.Color.Red, SN); return; } ms_id = dt.Rows[0]["ms_id"].ToString(); string ms_checkno = dt.Rows[0]["ms_checkno"].ToString(); if (ms_checkno == "") { OperateResult.AppendText(">>" + SN.Text + "不存在抽检批次中\n", System.Drawing.Color.Red, SN); return; } cr_code.Text = dt.Rows[0]["ms_craftcode"].ToString(); string ms_prodcode = dt.Rows[0]["ms_prodcode"].ToString(); cd_stepcode.Condition = "ST_STATUSCODE='AUDITED' and cr_code='" + cr_code.Text + "' and cr_prodcode='" + ms_prodcode + "' order by cd_stepno"; SaveRepairInf_Click(sender, e); } } } }