123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289 |
- using HslCommunication.Profinet.Knx;
- 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.PublicMethod;
- using static System.Runtime.CompilerServices.RuntimeHelpers;
- namespace UAS_MES_NEW.Special
- {
- public partial class Special_Delete : Form
- {
- DataHelper dh;
- LogStringBuilder sql = new LogStringBuilder();
- AutoSizeFormClass asc = new AutoSizeFormClass();
- DataTable Dbfind;
- DataTable dt;
- List<String> sb = new List<string>();
- public Special_Delete()
- {
- InitializeComponent();
- }
- private void Special_BoxSplit_Load(object sender, EventArgs e)
- {
- ma_code.TableName = " make left join product on ma_prodcode=pr_code";
- ma_code.SelectField = "ma_code # 工单编号,pr_code # 产品编号,pr_spec # 型号";
- ma_code.FormName = Name;
- ma_code.SetValueField = new string[] { "ma_code" };
- ma_code.Condition = "ma_statuscode='STARTED'";
- ma_code.DbChange += pr_code_DbChange;
- dh = SystemInf.dh;
- asc.controllInitializeSize(this);
- }
- private void pr_code_DbChange(object sender, EventArgs e)
- {
- Dbfind = ma_code.ReturnData;
- BaseUtil.SetFormValue(this.Controls, Dbfind);
- DataTable dt = (DataTable)dh.ExecuteSql("select ma_qty,ma_prodcode,pr_detail,ma_printnum from make left join product on ma_prodcode=pr_code left join (select count(1)ma_printnum,mil_makecode from makeimeilist where mil_printstatus=-1 group by mil_makecode) on mil_makecode=ma_code where ma_code='" + ma_code.Text + "'", "select");
- }
- private void Cd_stepcode_DbChange(object sender, EventArgs e)
- {
- BaseUtil.SetFormValue(this.Controls, Dbfind);
- }
- private bool ReSN(string sncode)
- {
- DataTable dt = (DataTable)dh.ExecuteSql("select ms_makecode,ms_sncode,ms_code from makeserial where ms_sncode ='" + sncode + "' order by ms_id desc", "select");
- if (dt.Rows.Count > 0)
- {
- string ms_makecode = dt.Rows[0]["ms_makecode"].ToString();
- string ms_sncode = dt.Rows[0]["ms_sncode"].ToString();
- string ms_code = dt.Rows[0]["ms_code"].ToString();
- dh.ExecuteSql("delete makeserial where ms_sncode='" + sncode + "' and ms_makecode='" + ms_makecode + "'", "update");
- dh.ExecuteSql("delete makebad where mb_sncode = '" + sncode + "' and mb_status = 0", "delete");
- dh.ExecuteSql("delete labelprintlog where lpl_value = '" + sncode + "' and lpl_makecode='" + ms_makecode + "'", "delete");
- sql.Clear();
- sql.Append("delete craftmaterial where cm_sncode = '" + sncode + "' and cm_makecode='" + ms_makecode + "' ");
- dh.ExecuteSql(sql.GetString(), "update");
- List<string> sqls = new List<string>();
- sqls.Add("delete from sninfo where si_sn='" + ms_sncode + "'");
- //sqls.Add("update makeaddresslist set mal_sncode='',mal_status=0 where mal_sncode='" + sn_code.Text + "'");
- //删除打印日志
- sqls.Add("delete from labelprintlog where lpl_value='" + ms_sncode + "' and lpl_makecode='" + ms_makecode + "'");
- //删除老化记录
- sqls.Add("delete from AGINGRECORD where ar_sncode='" + ms_sncode + "' and ar_macode='" + ms_makecode + "'");
- //删除IMIE分配记录
- sqls.Add("update makeimeilist set mil_status=0 where mil_sncode='" + ms_sncode + "' and mil_makecode='" + ms_makecode + "'");
- //更新MAC使用记录
- sqls.Add("update makeserial set ms_nextmacode='' where ms_sncode='"+ms_sncode+"' or ms_code='"+ ms_code + "' and ms_nextmacode='" + ms_makecode + "'");
- sqls.Add("update makeaddresslist set mal_status=0 where mal_sncode='" + ms_sncode + "' and mal_makecode='" + ms_makecode + "'");
- //初始化导入数据状态
- sqls.Add("update makesnlist set msl_status=0 where msl_sncode='" + ms_sncode + "' and msl_makecode='" + ms_makecode + "' and msl_type='before'");
- ////初始化号段状态
- sqls.Add("update MAKESNRULEDETAIL set msd_status=0 where msd_sncode='" + ms_sncode + "' and msd_makecode='" + ms_makecode + "' and msd_type='before'");
- sqls.Add("delete from makesnrelation where SN='" + ms_sncode + "' and makecode='" + ms_makecode + "' ");
- dh.ExecuteSQLTran(sqls.ToArray());
- LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ms_makecode, User.UserLineCode, User.UserSourceCode, "工单解绑", "工单解绑成功", sncode, "");
- }
- return true;
- }
- private void Split_Click(object sender, EventArgs e)
- {
- if (sb.Count == 0)
- {
- OperatResult.AppendText(">>采集数工位不能为空\n", Color.Red);
- return;
- }
- string Delete = MessageBox.Show(this.ParentForm, "是否确认解绑工单?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
- if (Delete == "Yes")
- {
- if (serBtn.Checked)
- {
- for (int i = 0; i < sb.Count; i++)
- {
- if (ReSN(sb[i].ToString()))
- OperatResult.AppendText("SN:" + sb[i].ToString() + "解绑完成\n", Color.Green);
- }
- WeighRecord.Clear();
- sb.Clear();
- }
- else if (bigboxBtn.Checked)
- {
- for (int i = 0; i < sb.Count; i++)
- {
- DataTable dt2 = (DataTable)dh.ExecuteSql("select ms_sncode from makeserial where ms_outboxcode = '" + sb[i].ToString() + "'", "select");
- for (int k = 0; k < dt2.Rows.Count; k++)
- {
- ReSN(dt2.Rows[k]["ms_sncode"].ToString());
- }
- dh.ExecuteSql("delete from labelprintlog where lpl_value='" + sb[i].ToString() + "'", "delete");
- dh.ExecuteSql("insert into PACKAGEBACKUP select * from package where pa_outboxcode='" + sb[i].ToString() + "'", "insert");
- dh.ExecuteSql("insert into PACKAGEBACKUPDETAIL select * from packagedetail where pd_outboxcode='" + sb[i].ToString() + "'", "insert");
- dh.ExecuteSql("delete from package where pa_outboxcode = '" + sb[i].ToString() + "'", "delete");
- //删除箱的明细
- dh.ExecuteSql("delete from packagedetail where pd_outboxcode='" + sb[i].ToString() + "'", "delete");
- LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ms_makecode.Text, User.UserLineCode, User.UserSourceCode, "解绑工单", "解绑工单成功", sb[i].ToString(), "");
- OperatResult.AppendText("卡通箱:" + sb[i].ToString() + "解绑完成\n", Color.Green);
- }
- WeighRecord.Clear();
- sb.Clear();
- }
- sql.Clear();
- sql.Append("MERGE INTO makecraftdetail USING (select mcd_macode,mcd_detno,mcd_stepcode,mcd_stepname,nvl(count(distinct A.ms_sncode),0) n,nvl(count(distinct B.ms_sncode),0) bn,(select nvl(count(distinct sp_sncode),0) from STEPPASSED where SP_MAKECODE = mcd_macode AND SP_STEPCODE = mcd_stepcode) inqty from MAKECRAFTdetail");
- sql.Append(" left join makeserial A on mcd_macode = A.ms_makecode and mcd_stepcode = A.ms_nextstepcode AND A.MS_STATUS = 1 LEFT JOIN MAKESERIAL B ON mcd_macode = B.ms_makecode AND MCD_STEPCODE = B.MS_STEPCODE AND B.MS_STATUS = 3 where mcd_macode = '" + ms_makecode.Text + "' group by mcd_macode,mcd_detno, mcd_stepcode, mcd_stepname order by mcd_detno asc) A");
- sql.Append(" ON (makecraftdetail.MCD_MACODE = A.MCD_MACODE and makecraftdetail.mcd_stepcode = A.mcd_stepcode) ");
- sql.Append(" WHEN MATCHED THEN UPDATE SET makecraftdetail.mcd_inqty = A.inqty,makecraftdetail.mcd_outqty = A.inqty,makecraftdetail.mcd_okqty = A.inqty ");
- dh.ExecuteSql(sql.GetString(), "update");
- }
- }
- private void bigboxBtn_Click(object sender, EventArgs e)
- {
- if (((RadioButton)sender).Checked == true)
- {
- if (WeighRecord.Items.Count > 0)
- {
- string logout_confirm = MessageBox.Show(this.ParentForm, "是否更换采集项(已录入信息会清空)?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
- if (logout_confirm == "Yes")
- {
- WeighRecord.Items.Clear();
- sb.Clear();
- ms_makecode.Text = "";
- ms_prodcode.Text = "";
- }
- else
- {
- serBtn.Checked = bigboxBtn.Checked;
- bigboxBtn.Checked = !serBtn.Checked;
- }
- }
- if (((RadioButton)sender).Name == "serBtn")
- {
- input.Focus();
- OperatResult.AppendText("请输入序列号进行采集\n", Color.Black, input);
- }
- else if (((RadioButton)sender).Name == "bigboxBtn")
- {
- input.Focus();
- OperatResult.AppendText("请输入箱号进行采集\n", Color.Black, input);
- }
- }
- }
- private void input_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.KeyCode == Keys.Enter)
- {
- if (serBtn.Checked)
- {
- dt = (DataTable)dh.ExecuteSql("select ms_makecode,ms_prodcode,ms_sncode,ms_craftcode cr_code,ms_status,ms_outboxcode from makeserial where ms_sncode = '" + input.Text + "' or ms_imei1='" + input.Text + "' or ms_imei2='" + input.Text + "' order by ms_id desc", "select");
- if (dt.Rows.Count > 0)
- {
- input.Text = dt.Rows[0]["ms_sncode"].ToString();
- if (ms_makecode.Text != "" && dt.Rows[0]["ms_makecode"].ToString() != ms_makecode.Text)
- {
- OperatResult.AppendText("SN:" + input.Text + "所属工单" + dt.Rows[0]["ms_makecode"].ToString() + "与当前工单" + ms_makecode.Text + "不一致\n", Color.Red, input);
- return;
- }
- if (dt.Rows[0]["ms_status"].ToString() == "3")
- {
- OperatResult.AppendText("SN:" + input.Text + "为不良品,不允许采集\n", Color.Red, input);
- return;
- }
- if (dt.Rows[0]["ms_outboxcode"].ToString() != "")
- {
- OperatResult.AppendText("SN:" + input.Text + "已装箱" + dt.Rows[0]["ms_outboxcode"].ToString() + ",不允许采集\n", Color.Red, input);
- return;
- }
- BaseUtil.SetFormValue(this.Controls, dt);
- if (sb.Contains(dt.Rows[0]["ms_sncode"].ToString()))
- {
- OperatResult.AppendText("SN:" + input.Text + "已采集\n", Color.Red, input);
- return;
- }
- WeighRecord.Items.Add(dt.Rows[0]["ms_sncode"].ToString());
- sb.Add(dt.Rows[0]["ms_sncode"].ToString());
- OperatResult.AppendText("SN:" + input.Text + "采集\n", Color.Green, input);
- }
- else
- {
- OperatResult.AppendText("SN:" + input.Text + "不存在\n", Color.Red, input);
- return;
- }
- }
- else if (bigboxBtn.Checked)
- {
- dt = (DataTable)dh.ExecuteSql("select pa_makecode ms_makecode,pa_prodcode ms_prodcode,pa_outboxcode,pa_mothercode,ma_craftcode,nvl(pa_iostatus,0)pa_iostatus,ma_craftcode cr_code from package left join make on pa_makecode = ma_code where pa_outboxcode = '" + input.Text + "' and pa_type = '1'", "select");
- if (dt.Rows.Count > 0)
- {
- if (ms_makecode.Text != "" && dt.Rows[0]["ms_makecode"].ToString() != ms_makecode.Text)
- {
- OperatResult.AppendText("SN:" + input.Text + "所属工单" + dt.Rows[0]["ms_makecode"].ToString() + "与当前工单" + ms_makecode.Text + "不一致\n", Color.Red, input);
- return;
- }
- if (dt.Rows[0]["pa_iostatus"].ToString() != "0")
- {
- OperatResult.AppendText("卡通箱:" + input.Text + "处于状态入库状态,不允许采集\n", Color.Red, input);
- return;
- }
- if (dt.Rows[0]["pa_mothercode"].ToString() != "")
- {
- OperatResult.AppendText("卡通箱:" + input.Text + "已装栈板" + dt.Rows[0]["pa_mothercode"].ToString() + ",不允许采集\n", Color.Red, input);
- return;
- }
- BaseUtil.SetFormValue(this.Controls, dt);
- if (sb.Contains(dt.Rows[0]["pa_outboxcode"].ToString()))
- {
- OperatResult.AppendText("卡通箱:" + input.Text + "已采集\n", Color.Red, input);
- return;
- }
- WeighRecord.Items.Add(dt.Rows[0]["pa_outboxcode"].ToString());
- sb.Add(dt.Rows[0]["pa_outboxcode"].ToString());
- OperatResult.AppendText("卡通箱:" + input.Text + "采集\n", Color.Green, input);
- }
- else
- {
- OperatResult.AppendText("卡通箱:" + input.Text + "不存在\n", Color.Red, input);
- return;
- }
- }
- }
- }
- private void 数据清空_Click(object sender, EventArgs e)
- {
- BaseUtil.CleanControls(this.Controls);
- WeighRecord.Items.Clear();
- sb.Clear();
- }
- private void Special_Reset_SizeChanged(object sender, EventArgs e)
- {
- asc.controlAutoSize(this);
- }
- private void DeleteALLSN_Click(object sender, EventArgs e)
- {
- if (PassWord.Text == dh.getFieldDataByCondition("configs", "data", "code='Password' and caller='MESSetting'").ToString())
- {
- DataTable dt = (DataTable)dh.ExecuteSql("select ms_sncode,ms_makecode from makeserial where ms_makecode ='" + ma_code.Text + "'", "select");
- TotalSN.Text = "总计" + dt.Rows.Count;
- for (int i = 0; i < dt.Rows.Count; i++)
- {
- ReSN(dt.Rows[i]["ms_sncode"].ToString());
- RemainSN.Text = "已解绑" + (i + 1);
- }
- dh.ExecuteSql("update make set ma_inqty=0,ma_endqty=0 where ma_code='" + ma_code.Text + "'", "update");
- dh.ExecuteSql("update makecraftdetail set MCD_INQTY=0, MCD_OUTQTY=0, MCD_OKQTY=0 where mcd_macode='"+ma_code.Text+"'","update");
- }
- else
- {
- MessageBox.Show("密码不正确");
- }
- }
- }
- }
|