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; namespace UAS_MES_NEW.Special { public partial class Special_ReSNBD : Form { AutoSizeFormClass asc = new AutoSizeFormClass(); DataHelper dh; string bsncode = "";//序列号录入框值 LogStringBuilder sql = new LogStringBuilder(); public Special_ReSNBD() { InitializeComponent(); } private void Special_BoxSplit_Load(object sender, EventArgs e) { asc.controllInitializeSize(this); dh = SystemInf.dh; sncode.Focus(); OperateResult.AppendText(">>请输入返修SN号\n", Color.Black); } private void ClearSn_code_Click(object sender, EventArgs e) { bsncode = ""; if (ChangeResult.Checked) { //勾选的时候提示输入TSN OperateResult.AppendText(">>请输入待转换新SN号\n", Color.Black,show_sncode); } else { OperateResult.AppendText(">>请输入返修SN号\n", Color.Black, show_sncode); } ChangeResult.Enabled = true; } string makecode; string prodcode; string orispeccode; private void sncode_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { if (sncode.Text != "") { if (bsncode == "") { if (!ChangeResult.Checked) { if (!dh.CheckExist("makeserial", "ms_sncode = '" + sncode.Text + "'")) { if (!dh.CheckExist("AFSALES", "as_sn = '" + sncode.Text + "'")) { OperateResult.AppendText(">>SN" + sncode.Text + "未查询到生产记录以及售后判定记录,无法采集\n", Color.Red, sncode); return; } else { makecode = ""; prodcode = ""; orispeccode = ""; } } else { DataTable dt = (DataTable)dh.ExecuteSql("select * from makeserial left join product on ms_prodcode = pr_code where ms_sncode = '"+sncode.Text+"' order by ms_id desc", "select"); makecode = dt.Rows[0]["ms_makecode"].ToString(); prodcode = dt.Rows[0]["ms_prodcode"].ToString(); orispeccode = dt.Rows[0]["pr_orispeccode"].ToString(); } if (dh.CheckExist("returnsnbd", "rsb_oldsn = '" + sncode.Text + "'")) { string newsn = dh.getFieldDataByCondition("returnsnbd", "rsb_newsn", "rsb_oldsn = '" + sncode.Text + "'").ToString(); OperateResult.AppendText(">>返修SN" + sncode.Text + "已关联SN"+newsn+",无法直接采集,需转换\n", Color.Red, sncode); return; } bsncode = sncode.Text; show_sncode.Text = bsncode; sncode.Text = ""; ChangeResult.Enabled = false; OperateResult.AppendText(">>返修SN" + bsncode + "采集\n", Color.Green, sncode); return; } else { if (!dh.CheckExist("returnsnbd", "rsb_newsn = '" + sncode.Text + "'")) { OperateResult.AppendText(">>待转换新SN" + sncode.Text + "无采集记录,不可转换\n", Color.Red, sncode); return; } bsncode = sncode.Text; show_sncode.Text = bsncode; sncode.Text = ""; ChangeResult.Enabled = false; OperateResult.AppendText(">>待转换新SN" + bsncode + "采集\n", Color.Green, sncode); return; } } else { if (sncode.Text == bsncode) { OperateResult.AppendText(">>不允许自己转自己\n", Color.Red, sncode); return; } if (!ChangeResult.Checked) { if (dh.CheckExist("returnsnbd", "rsb_newsn = '" + sncode.Text + "'")) { string oldsn = dh.getFieldDataByCondition("returnsnbd", "rsb_oldsn", "rsb_newsn = '" + sncode.Text + "'").ToString(); OperateResult.AppendText(">>采集新SN:" + sncode.Text + "已关联返修SN:" + oldsn + ",无法采集\n", Color.Red, sncode); return; } dh.ExecuteSql("insert into returnsnbd (rsb_id,rsb_newsn,rsb_oldsn,RSB_MAKECODE,RSB_PRODCODE,RSB_ORISPECCODE) values (returnsnbd_seq.nextval,'" + sncode.Text + "','"+ show_sncode.Text + "','"+makecode+"','"+prodcode+"','"+orispeccode+"') ", "insert"); bsncode = ""; ChangeResult.Enabled = true; OperateResult.AppendText(">>返修SN:" + show_sncode.Text + "与新SN:"+ sncode.Text + "关联成功\n", Color.LawnGreen, sncode, show_sncode); return; } else { if (dh.CheckExist("returnsnbd", "rsb_newsn = '" + sncode.Text + "'")) { string oldsn = dh.getFieldDataByCondition("returnsnbd", "rsb_oldsn", "rsb_newsn = '" + sncode.Text + "'").ToString(); OperateResult.AppendText(">>采集新SN:" + sncode.Text + "已关联返修SN:" + oldsn + ",无法采集\n", Color.Red, sncode); return; } dh.ExecuteSql(" update returnsnbd set rsb_newsn = '"+ sncode.Text + "' where rsb_newsn = '"+show_sncode.Text+"' ", "update"); bsncode = ""; ChangeResult.Enabled = true; OperateResult.AppendText(">>待转换新SN:" + show_sncode.Text + "更换至新SN:" + sncode.Text + "成功\n", Color.LawnGreen, sncode, show_sncode); return; } } } else { OperateResult.AppendText("<<序列号不能为空\n", Color.Red); } } } private void ChangeResult_CheckedChanged(object sender, EventArgs e) { if (ChangeResult.Checked) { //勾选的时候提示输入TSN OperateResult.AppendText(">>请输入待转换新SN号\n", Color.Black); } else { OperateResult.AppendText(">>请输入返修SN号\n", Color.Black); } } private void Special_ReSNBD_SizeChanged(object sender, EventArgs e) { asc.controlAutoSize(this); } } }