Special_AfterSaleOut.cs 4.9 KB

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