Special_AfterSaleIn.cs 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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_AfterSaleIn : Form
  11. {
  12. DataHelper dh = SystemInf.dh;
  13. LogStringBuilder sql = new LogStringBuilder();
  14. AutoSizeFormClass asc = new AutoSizeFormClass();
  15. public Special_AfterSaleIn()
  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. pr_code.TableName = "product";
  27. pr_code.DBTitle = "出货单查询";
  28. pr_code.SelectField = "pr_code # 物料编号,pr_detail # 物料名称,pr_spec # 物料规格";
  29. pr_code.SetValueField = new string[] { "pr_code", "pr_detail", "pr_spec" };
  30. pr_code.FormName = Name;
  31. InDate.Value = DateTime.Now;
  32. asc.controllInitializeSize(this);
  33. }
  34. private void Confirm_Click(object sender, EventArgs e)
  35. {
  36. //正常录入资料的时候
  37. if (!Cancel.Checked)
  38. {
  39. if (cu_code.Text == "" || pr_code.Text == "")
  40. {
  41. OperateResult.AppendText(">>客户编号和物料编号不能为空\n", Color.Red, barcode);
  42. return;
  43. }
  44. if (barcode.Text == "")
  45. {
  46. OperateResult.AppendText(">>输入信息不允许为空\n", Color.Red, barcode);
  47. return;
  48. }
  49. if (dh.CheckExist("aftersalerecord", "afr_barcode='" + barcode.Text + "'"))
  50. {
  51. OperateResult.AppendText(">>条码" + barcode.Text + "已录入\n", Color.Red, barcode);
  52. return;
  53. }
  54. sql.Clear();
  55. sql.Append("insert into aftersalerecord(afr_id,afr_barcode,afr_prodcode,afr_cucode,afr_indate)");
  56. sql.Append("values(aftersalerecord_seq.nextval,'" + barcode.Text + "','" + pr_code.Text + "','" + cu_code.Text + "',sysdate)");
  57. dh.ExecuteSql(sql.GetString(), "insert");
  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 not null"))
  69. {
  70. OperateResult.AppendText(">>条码" + barcode.Text + "已出库\n", Color.Red, barcode);
  71. return;
  72. }
  73. sql.Clear();
  74. sql.Append("delete from aftersalerecord where afr_barcode='" + barcode.Text + "'");
  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 where trunc(afr_indate)=trunc(to_date('" + InDate.Value.ToString("yyyy-MM-dd hh:mm:ss") + "','yyyy-mm-dd hh24:mi:ss')) ");
  87. if (cu_code.Text != "")
  88. {
  89. sql.Append(" and afr_cucode='" + cu_code.Text + "'");
  90. }
  91. if (pr_code.Text != "")
  92. {
  93. sql.Append(" and afr_prodcode='" + pr_code.Text + "'");
  94. }
  95. DataTable dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  96. BaseUtil.FillDgvWithDataTable(Info, dt);
  97. }
  98. private void Special_AfterSaleIn_SizeChanged(object sender, EventArgs e)
  99. {
  100. asc.controlAutoSize(this);
  101. }
  102. private void barcode_KeyDown(object sender, KeyEventArgs e)
  103. {
  104. if (e.KeyCode == Keys.Enter)
  105. {
  106. Confirm.PerformClick();
  107. }
  108. }
  109. private void dateTimePicker1_ValueChanged(object sender, EventArgs e)
  110. {
  111. LoadGridData();
  112. }
  113. private void cu_code_UserControlTextChanged(object sender, EventArgs e)
  114. {
  115. LoadGridData();
  116. }
  117. private void pr_code_UserControlTextChanged(object sender, EventArgs e)
  118. {
  119. LoadGridData();
  120. }
  121. }
  122. }