Special_CancelProdinout.cs 4.3 KB

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