Special_CancelProdinout.cs 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data;
  4. using System.Drawing;
  5. using System.Windows.Forms;
  6. using UAS_MES_NEW.DataOperate;
  7. using UAS_MES_NEW.Entity;
  8. using UAS_MES_NEW.PublicMethod;
  9. namespace UAS_MES_NEW.Special
  10. {
  11. public partial class Special_CancelProdinout : Form
  12. {
  13. DataHelper dh = SystemInf.dh;
  14. LogStringBuilder sql = new LogStringBuilder();
  15. public Special_CancelProdinout()
  16. {
  17. InitializeComponent();
  18. }
  19. private void Confirm_Click(object sender, EventArgs e)
  20. {
  21. //OperateResult.AppendText(">>序列号" + sn_code.Text + "不存在\n", Color.Red, sn_code);
  22. if (pi_inoutno.Text != "")
  23. {
  24. if (dh.CheckExist("prodinout", "pi_pdastatus='已出库' and pi_class='出货单' and pi_inoutno = '" + pi_inoutno.Text + "'"))
  25. {
  26. sql.Clear();
  27. 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 = ' ')");
  28. DataTable datatable = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  29. if (datatable.Rows.Count > 0)
  30. {
  31. for (int i = 0; i < datatable.Rows.Count; i++)
  32. {
  33. 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")
  34. {
  35. dh.UpdateByCondition("package", "pa_iostatus=0", "pa_outboxcode = '" + datatable.Rows[i]["pd_outboxcode"].ToString() + "'");
  36. }
  37. }
  38. }
  39. List<String> ExeSQL = new List<string>();
  40. 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 + "'");
  41. 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')");
  42. ExeSQL.Add("update prodinout set pi_pdastatus='备货中' where pi_inoutno='" + pi_inoutno.Text + "'");
  43. 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 + "')");
  44. dh.ExecuteSQLTran(ExeSQL.ToArray());
  45. LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, "", User.UserLineCode, User.UserSourceCode, "出货单" + pi_inoutno.Text + "撤销出货", "出货单" + pi_inoutno.Text + "撤销出货成功", pi_inoutno.Text, "");
  46. OperateResult.AppendText("出货单" + pi_inoutno.Text + "撤销出库成功\n", Color.Black, pi_inoutno);
  47. }
  48. else
  49. OperateResult.AppendText(">>出库单" + pi_inoutno.Text + "不是已出库状态\n", Color.Red);
  50. }
  51. else
  52. OperateResult.AppendText(">>出库单不可为空\n", Color.Red);
  53. }
  54. private void Clean_Click(object sender, EventArgs e)
  55. {
  56. OperateResult.Clear();
  57. }
  58. private void Special_CancelProdinout_Load(object sender, EventArgs e)
  59. {
  60. pi_inoutno.TableName = "prodinout";
  61. pi_inoutno.DBTitle = "出货单查询";
  62. pi_inoutno.SelectField = "pi_id # ID,pi_title # 客户名称,pi_inoutno # 出货单号,pi_type # 出货类型";
  63. pi_inoutno.SetValueField = new string[] { "pi_title", "pi_inoutno", "pi_id", "pi_type" };
  64. pi_inoutno.FormName = Name;
  65. pi_inoutno.Condition = "pi_pdastatus='已出库' and pi_class='出货单'";
  66. }
  67. }
  68. }