Special_CancelProdinout.cs 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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_NEW.DataOperate;
  10. using UAS_MES_NEW.Entity;
  11. using UAS_MES_NEW.PublicMethod;
  12. namespace UAS_MES_NEW.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. try { UAS_MES_NEW.I18n.LanguageManager.Localize(this); } catch { }
  22. }
  23. private void Confirm_Click(object sender, EventArgs e)
  24. {
  25. //OperateResult.AppendText(">>序列号" + sn_code.Text + "不存在\n", Color.Red, sn_code);
  26. if (pi_inoutno.Text != "")
  27. {
  28. if (dh.CheckExist("prodinout", "pi_pdastatus='已出库' and pi_class='出货单' and pi_inoutno = '" + pi_inoutno.Text + "'"))
  29. {
  30. sql.Clear();
  31. 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 = ' ')");
  32. DataTable datatable = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  33. if (datatable.Rows.Count > 0)
  34. {
  35. for (int i = 0; i < datatable.Rows.Count; i++)
  36. {
  37. 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")
  38. {
  39. dh.UpdateByCondition("package", "pa_iostatus=0", "pa_outboxcode = '" + datatable.Rows[i]["pd_outboxcode"].ToString() + "'");
  40. }
  41. }
  42. }
  43. List<String> ExeSQL = new List<string>();
  44. 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 + "'");
  45. 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')");
  46. ExeSQL.Add("update prodinout set pi_pdastatus='备货中' where pi_inoutno='" + pi_inoutno.Text + "'");
  47. 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 + "')");
  48. dh.ExecuteSQLTran(ExeSQL.ToArray());
  49. LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, "", User.UserLineCode, User.UserSourceCode, "出货单" + pi_inoutno.Text + "撤销出货", "出货单" + pi_inoutno.Text + "撤销出货成功", pi_inoutno.Text, "");
  50. OperateResult.AppendText("出货单" + pi_inoutno.Text + "撤销出库成功\n", Color.Black, pi_inoutno);
  51. }
  52. else
  53. OperateResult.AppendText(">>出库单"+ pi_inoutno.Text + "不是已出库状态\n", Color.Red);
  54. }
  55. else
  56. OperateResult.AppendText(">>出库单不可为空\n", Color.Red);
  57. }
  58. private void Clean_Click(object sender, EventArgs e)
  59. {
  60. OperateResult.Clear();
  61. }
  62. private void Special_CancelProdinout_Load(object sender, EventArgs e)
  63. {
  64. pi_inoutno.TableName = "prodinout";
  65. pi_inoutno.DBTitle = "出货单查询";
  66. pi_inoutno.SelectField = "pi_id # ID,pi_title # 客户名称,pi_inoutno # 出货单号,pi_type # 出货类型";
  67. pi_inoutno.SetValueField = new string[] { "pi_title", "pi_inoutno", "pi_id", "pi_type" };
  68. pi_inoutno.FormName = Name;
  69. pi_inoutno.Condition = "pi_pdastatus='已出库' and pi_class='出货单'";
  70. }
  71. }
  72. }