Special_AfterSaleOut.cs 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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. //正常录入资料的时候
  32. if (!Cancel.Checked)
  33. {
  34. if (cu_code.Text == "")
  35. {
  36. OperateResult.AppendText(">>客户编号不能为空\n", Color.Red, barcode);
  37. return;
  38. }
  39. if (!dh.CheckExist("aftersalerecord", "afr_barcode='" + barcode.Text + "'"))
  40. {
  41. OperateResult.AppendText(">>条码" + barcode.Text + "不存在\n", Color.Red, barcode);
  42. return;
  43. }
  44. if (!dh.CheckExist("aftersalerecord", "afr_barcode='" + barcode.Text + "' and afr_outdate is null"))
  45. {
  46. OperateResult.AppendText(">>条码" + barcode.Text + "已出库\n", Color.Red, barcode);
  47. return;
  48. }
  49. if (dh.getFieldDataByCondition("aftersalerecord", "afr_cucode", "afr_barcode='" + barcode.Text + "'").ToString() != cu_code.Text)
  50. {
  51. OperateResult.AppendText(">>条码" + barcode.Text + "不允许出库给客户" + cu_name.Text + "\n", Color.Red, barcode);
  52. return;
  53. }
  54. sql.Clear();
  55. sql.Append("update aftersalerecord set afr_outdate=sysdate,afr_outcucode='" + cu_code.Text + "' where afr_barcode='" + barcode.Text + "'");
  56. dh.ExecuteSql(sql.GetString(), "update");
  57. OperateResult.AppendText(">>条码" + barcode.Text + "出库成功\n", Color.Green, barcode);
  58. LoadGridData();
  59. }
  60. else
  61. {
  62. if (!dh.CheckExist("aftersalerecord", "afr_barcode='" + barcode.Text + "'"))
  63. {
  64. OperateResult.AppendText(">>条码" + barcode.Text + "不存在\n", Color.Red, barcode);
  65. return;
  66. }
  67. if (dh.CheckExist("aftersalerecord", "afr_barcode='" + barcode.Text + "' and afr_outdate is null"))
  68. {
  69. OperateResult.AppendText(">>条码" + barcode.Text + "未出库\n", Color.Red, barcode);
  70. return;
  71. }
  72. sql.Clear();
  73. sql.Append("update aftersalerecord set afr_outdate=null,afr_outcucode=null where afr_barcode='" + barcode.Text + "'");
  74. dh.ExecuteSql(sql.GetString(), "update");
  75. OperateResult.AppendText(">>条码" + barcode.Text + "取消出库成功\n", Color.Green, barcode);
  76. LoadGridData();
  77. }
  78. }
  79. private void Clean_Click(object sender, EventArgs e)
  80. {
  81. OperateResult.Clear();
  82. }
  83. private void LoadGridData()
  84. {
  85. sql.Clear();
  86. 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 ");
  87. if (cu_code.Text != "")
  88. {
  89. sql.Append(" and afr_outcucode='" + cu_code.Text + "'");
  90. }
  91. DataTable dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  92. BaseUtil.FillDgvWithDataTable(Info, dt);
  93. }
  94. private void Special_AfterSaleIn_SizeChanged(object sender, EventArgs e)
  95. {
  96. asc.controlAutoSize(this);
  97. }
  98. private void barcode_KeyDown(object sender, KeyEventArgs e)
  99. {
  100. if (e.KeyCode == Keys.Enter)
  101. {
  102. Confirm.PerformClick();
  103. }
  104. }
  105. private void dateTimePicker1_ValueChanged(object sender, EventArgs e)
  106. {
  107. LoadGridData();
  108. }
  109. private void cu_code_UserControlTextChanged(object sender, EventArgs e)
  110. {
  111. LoadGridData();
  112. }
  113. }
  114. }