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_CancelProdinout : Form { DataHelper dh = SystemInf.dh; LogStringBuilder sql = new LogStringBuilder(); public Special_CancelProdinout() { InitializeComponent(); } private void Confirm_Click(object sender, EventArgs e) { //OperateResult.AppendText(">>序列号" + sn_code.Text + "不存在\n", Color.Red, sn_code); if (pi_inoutno.Text != "") { if (dh.CheckExist("prodinout", "pi_pdastatus='已出库' and pi_class='出货单' and pi_inoutno = '" + pi_inoutno.Text + "'")) { sql.Clear(); sql.Append("select DISTINCT pd_outboxcode from PACKAGEDETAIL where pd_barcode in (select pim_mac from prodiomac where pim_inoutno='" + pi_inoutno.Text + "' and pim_inorout='OUT' and PIM_TYPE = ' ')"); DataTable datatable = (DataTable)dh.ExecuteSql(sql.GetString(), "select"); if (datatable.Rows.Count > 0) { for (int i = 0; i < datatable.Rows.Count; i++) { if (dh.getFieldDataByCondition("makeserial left join PACKAGEDETAIL on pd_barcode = ms_sncode and pd_makecode = ms_makecode", "count(1)", "pd_outboxcode = '" + datatable.Rows[i]["pd_outboxcode"].ToString() + "' and ms_outno is null").ToString() != "0") { dh.UpdateByCondition("package", "pa_iostatus=0", "pa_outboxcode = '" + datatable.Rows[i]["pd_outboxcode"].ToString() + "'"); } } } List ExeSQL = new List(); ExeSQL.Add("update package set pa_iostatus=1 where exists (select 1 from prodiomac where pim_inoutno='" + pi_inoutno.Text + "' and pim_outboxcode=pa_outboxcode and ((pim_type='PALLET' AND PA_TYPE=3) OR (PIM_TYPE='BOX' AND PA_TYPE IN(1,2)))) AND PA_OUTNO='" + pi_inoutno.Text + "'"); ExeSQL.Add("update makeserial set ms_iostatus=1,ms_enddate = sysdate where ms_outno='" + pi_inoutno.Text + "' and exists(select 1 from prodiomac where pim_inoutno='" + pi_inoutno.Text + "' and pim_mac=ms_sncode and pim_inorout='OUT')"); ExeSQL.Add("update prodinout set pi_pdastatus='备货中' where pi_inoutno='" + pi_inoutno.Text + "'"); ExeSQL.Add("insert into messagelog(ml_id,ml_date,ml_man,ml_content,ml_result,ml_search)values(messagelog_seq.nextval,sysdate,'" + User.UserName + "','撤销出货','撤销出货成功','ProdInOut!Sale|pi_inoutno=" + pi_inoutno.Text + "')"); dh.ExecuteSQLTran(ExeSQL.ToArray()); LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, "", User.UserLineCode, User.UserSourceCode, "出货单" + pi_inoutno.Text + "撤销出货", "出货单" + pi_inoutno.Text + "撤销出货成功", pi_inoutno.Text, ""); OperateResult.AppendText("出货单" + pi_inoutno.Text + "撤销出库成功\n", Color.Black, pi_inoutno); } else OperateResult.AppendText(">>出库单"+ pi_inoutno.Text + "不是已出库状态\n", Color.Red); } else OperateResult.AppendText(">>出库单不可为空\n", Color.Red); } private void Clean_Click(object sender, EventArgs e) { OperateResult.Clear(); } private void Special_CancelProdinout_Load(object sender, EventArgs e) { pi_inoutno.TableName = "prodinout"; pi_inoutno.DBTitle = "出货单查询"; pi_inoutno.SelectField = "pi_id # ID,pi_title # 客户名称,pi_inoutno # 出货单号,pi_type # 出货类型"; pi_inoutno.SetValueField = new string[] { "pi_title", "pi_inoutno", "pi_id", "pi_type" }; pi_inoutno.FormName = Name; pi_inoutno.Condition = "pi_pdastatus='已出库' and pi_class='出货单'"; } } }