Special_AfterSaleOut.cs 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. using System;
  2. using System.Data;
  3. using System.Drawing;
  4. using System.Windows.Forms;
  5. using UAS_MES_NEW.DataOperate;
  6. using UAS_MES_NEW.Entity;
  7. using UAS_MES_NEW.PublicMethod;
  8. namespace UAS_MES_NEW.Special
  9. {
  10. public partial class Special_AfterSaleOut : Form
  11. {
  12. DataHelper dh = SystemInf.dh;
  13. LogStringBuilder sql = new LogStringBuilder();
  14. AutoSizeFormClass asc = new AutoSizeFormClass();
  15. public Special_AfterSaleOut()
  16. {
  17. InitializeComponent();
  18. }
  19. private void Special_CancelProdinout_Load(object sender, EventArgs e)
  20. {
  21. cu_code.TableName = "customer";
  22. cu_code.DBTitle = "出货单查询";
  23. cu_code.SelectField = "cu_id # ID,cu_code # 客户编号,cu_name # 客户名城";
  24. cu_code.SetValueField = new string[] { "cu_code", "cu_name" };
  25. cu_code.FormName = Name;
  26. InDate.Value = DateTime.Now;
  27. asc.controllInitializeSize(this);
  28. }
  29. private void Confirm_Click(object sender, EventArgs e)
  30. {
  31. int out_qty = 0;
  32. if (!int.TryParse(outqty.Text, out out_qty))
  33. {
  34. OperateResult.AppendText(">>出库数错误\n", Color.Red, barcode);
  35. return;
  36. }
  37. //正常录入资料的时候
  38. if (!Cancel.Checked)
  39. {
  40. if (cu_code.Text == "")
  41. {
  42. OperateResult.AppendText(">>客户编号不能为空\n", Color.Red, barcode);
  43. return;
  44. }
  45. if (!dh.CheckExist("aftersalerecord", "afr_barcode='" + barcode.Text + "' and nvl(afr_outqty,0)+" + outqty.Text + "<=afr_inqty"))
  46. {
  47. OperateResult.AppendText(">>条码" + barcode.Text + "不存在或出库数量不足\n", Color.Red, barcode);
  48. return;
  49. }
  50. if (dh.CheckExist("aftersalerecord", "afr_barcode='" + barcode.Text + "' and afr_outqty>=afr_inqty"))
  51. {
  52. OperateResult.AppendText(">>条码" + barcode.Text + "已出库\n", Color.Red, barcode);
  53. return;
  54. }
  55. if (dh.getFieldDataByCondition("aftersalerecord", "afr_cucode", "afr_barcode='" + barcode.Text + "'").ToString() != cu_code.Text)
  56. {
  57. OperateResult.AppendText(">>条码" + barcode.Text + "不允许出库给客户" + cu_name.Text + "\n", Color.Red, barcode);
  58. return;
  59. }
  60. sql.Clear();
  61. sql.Append("update aftersalerecord set afr_outdate=sysdate,afr_outcucode='" + cu_code.Text + "',afr_outqty=nvl(afr_outqty,0)+" + outqty.Text + " where afr_barcode='" + barcode.Text + "'");
  62. dh.ExecuteSql(sql.GetString(), "update");
  63. dh.ExecuteSql("insert into aftersalerecordlog(afl_id,afl_barcode,afl_prodcode,afl_qty,afl_type) select aftersalerecordlog_seq.nextval,afr_barcode,afr_prodcode," + outqty.Text + ",'出库' from aftersalerecord where afr_barcode='" + barcode.Text + "'", "insert");
  64. OperateResult.AppendText(">>条码" + barcode.Text + "出库成功\n", Color.Green, barcode);
  65. LoadGridData();
  66. }
  67. else
  68. {
  69. if (!dh.CheckExist("aftersalerecord", "afr_barcode='" + barcode.Text + "'"))
  70. {
  71. OperateResult.AppendText(">>条码" + barcode.Text + "不存在\n", Color.Red, barcode);
  72. return;
  73. }
  74. if (dh.CheckExist("aftersalerecord", "afr_barcode='" + barcode.Text + "' and nvl(afr_outqty,0)-" + outqty.Text + "<0"))
  75. {
  76. OperateResult.AppendText(">>条码" + barcode.Text + "取消出库数量不足\n", Color.Red, barcode);
  77. return;
  78. }
  79. sql.Clear();
  80. sql.Append("update aftersalerecord set afr_outdate=null,afr_outcucode=null,afr_outqty=nvl(afr_outqty,0)-" + outqty.Text + " where afr_barcode='" + barcode.Text + "'");
  81. dh.ExecuteSql("insert into aftersalerecordlog(afl_id,afl_barcode,afl_prodcode,afl_qty,afl_type) select aftersalerecordlog_seq.nextval,afr_barcode,afr_prodcode," + outqty.Text + ",'取消出库' from aftersalerecord where afr_barcode='" + barcode.Text + "'", "insert");
  82. dh.ExecuteSql(sql.GetString(), "update");
  83. OperateResult.AppendText(">>条码" + barcode.Text + "取消出库成功\n", Color.Green, barcode);
  84. LoadGridData();
  85. }
  86. }
  87. private void Clean_Click(object sender, EventArgs e)
  88. {
  89. OperateResult.Clear();
  90. }
  91. private void LoadGridData()
  92. {
  93. sql.Clear();
  94. sql.Append("select * from aftersalerecord left join product on afr_prodcode=pr_code where trunc(afr_outdate)=trunc(to_date('" + InDate.Value.ToString("yyyy-MM-dd hh:mm:ss") + "','yyyy-mm-dd hh24:mi:ss')) and afr_outdate is not null ");
  95. if (cu_code.Text != "")
  96. {
  97. sql.Append(" and afr_outcucode='" + cu_code.Text + "'");
  98. }
  99. DataTable dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  100. BaseUtil.FillDgvWithDataTable(Info, dt);
  101. }
  102. private void Special_AfterSaleIn_SizeChanged(object sender, EventArgs e)
  103. {
  104. asc.controlAutoSize(this);
  105. }
  106. private void barcode_KeyDown(object sender, KeyEventArgs e)
  107. {
  108. if (e.KeyCode == Keys.Enter)
  109. {
  110. Confirm.PerformClick();
  111. }
  112. }
  113. private void dateTimePicker1_ValueChanged(object sender, EventArgs e)
  114. {
  115. LoadGridData();
  116. }
  117. private void cu_code_UserControlTextChanged(object sender, EventArgs e)
  118. {
  119. LoadGridData();
  120. }
  121. }
  122. }