using System; using System.Collections.Generic; using System.Data; using System.Drawing; 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_ChangeMakeCode : Form { DataHelper dh = SystemInf.dh; LogStringBuilder sql = new LogStringBuilder(); public Special_ChangeMakeCode() { InitializeComponent(); } private void Clean_Click(object sender, EventArgs e) { OperateResult.Clear(); } private void Special_CancelCollection_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; ma_code1.TableName = " make left join product on ma_prodcode=pr_code"; ma_code1.SelectField = "ma_code # 工单编号,pr_code # 产品编号,pr_spec # 型号"; ma_code1.FormName = Name; ma_code1.SetValueField = new string[] { "ma_code1" }; ma_code1.Condition = "ma_statuscode='STARTED'"; ma_code1.DbChange += pr_code_DbChange1; } DataTable Dbfind; 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"); if (dt.Rows.Count > 0) { pr_code.Text = dt.Rows[0]["ma_prodcode"].ToString(); pr_detail.Text = dt.Rows[0]["pr_detail"].ToString(); } } private void pr_code_DbChange1(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"); if (dt.Rows.Count > 0) { pr_code1.Text = dt.Rows[0]["ma_prodcode"].ToString(); pr_detail1.Text = dt.Rows[0]["pr_detail"].ToString(); } } private void Confirm_Click(object sender, EventArgs e) { if (ma_code.Text == "" || ma_code1.Text == "") { OperateResult.AppendText("工单号不允许为空\n"); return; } if (!dh.CheckExist("make", "ma_code='" + ma_code.Text + "'")) { OperateResult.AppendText("工单号" + ma_code.Text + "不存在\n"); return; } if (!dh.CheckExist("make", "ma_code='" + ma_code1.Text + "'")) { OperateResult.AppendText("工单号" + ma_code1.Text + "不存在\n"); return; } //if (dh.getFieldDataByCondition("make", "ma_prodcode", "ma_code='" + ma_code.Text + "'").ToString() != dh.getFieldDataByCondition("make", "ma_prodcode", "ma_code='" + ma_code1.Text + "'").ToString()) //{ // OperateResult.AppendText("工单号产品编号不对应,不允许切换\n"); // return; //} List sqls = new List(); sqls.Add("update CRAFTMATERIAL set cm_makecode='" + ma_code1.Text + "' where cm_makecode= '" + ma_code.Text + "'"); sqls.Add("update steppassed set sp_makecode='" + ma_code1.Text + "' where sp_makecode= '" + ma_code.Text + "'"); sqls.Add("update makeserial set ms_makecode='" + ma_code1.Text + "' where ms_makecode= '" + ma_code.Text + "'"); sqls.Add("update makeprocess set mp_makecode='" + ma_code1.Text + "' where mp_makecode= '" + ma_code.Text + "'"); sqls.Add("update commandlog set cl_makecode='" + ma_code1.Text + "' where cl_makecode= '" + ma_code.Text + "'"); sqls.Add("update makebad set mb_makecode='" + ma_code1.Text + "' where mb_makecode= '" + ma_code.Text + "'"); sqls.Add("update labelprintlog set lpl_makecode='" + ma_code1.Text + "' where lpl_makecode= '" + ma_code.Text + "'"); sqls.Add("update package set pa_makecode='" + ma_code1.Text + "' where pa_makecode= '" + ma_code.Text + "'"); sqls.Add("update packagedetail set pd_makecode='" + ma_code1.Text + "' where pd_makecode= '" + ma_code.Text + "'"); sqls.Add("update make set ma_inqty=(select count(1) from makeserial where ms_makecode='"+ma_code1.Text+"') and ma_code='"+ma_code1.Text+"'"); sqls.Add("update make set ma_endqty=(select count(1) from makeserial where ms_makecode='" + ma_code1.Text+"' and ms_status=2) and ma_code='"+ma_code1.Text+"'"); dh.ExecuteSQLTran(sqls.ToArray()); OperateResult.AppendText("工单号切换成功\n"); LogicHandler.DoCommandLog("", User.UserName, ma_code.Text, User.UserLineCode, User.UserSourceCode, "工单变更", "工单变更" + ma_code.Text + "切换到" + ma_code1.Text, "", ""); } } }