Special_AfterSaleIn.cs 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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. int in_qty = 0;
  37. if (!int.TryParse(inqty.Text, out in_qty))
  38. {
  39. OperateResult.AppendText(">>入库数错误\n", Color.Red, barcode);
  40. return;
  41. }
  42. //正常录入资料的时候
  43. if (!Cancel.Checked)
  44. {
  45. if (cu_code.Text == "" || pr_code.Text == "")
  46. {
  47. OperateResult.AppendText(">>客户编号和物料编号不能为空\n", Color.Red, barcode);
  48. return;
  49. }
  50. if (barcode.Text == "")
  51. {
  52. OperateResult.AppendText(">>输入信息不允许为空\n", Color.Red, barcode);
  53. return;
  54. }
  55. if (dh.CheckExist("aftersalerecord", "afr_barcode='" + barcode.Text + "'"))
  56. {
  57. OperateResult.AppendText(">>条码" + barcode.Text + "已录入\n", Color.Red, barcode);
  58. return;
  59. }
  60. sql.Clear();
  61. sql.Append("insert into aftersalerecord(afr_id,afr_barcode,afr_prodcode,afr_cucode,afr_indate,afr_inqty)");
  62. sql.Append("values(aftersalerecord_seq.nextval,'" + barcode.Text + "','" + pr_code.Text + "','" + cu_code.Text + "',sysdate," + inqty.Text + ")");
  63. dh.ExecuteSql(sql.GetString(), "insert");
  64. dh.ExecuteSql("insert into aftersalerecordlog(afl_id,afl_barcode,afl_prodcode,afl_qty,afl_type) select aftersalerecordlog_seq.nextval,afr_barcode,afr_prodcode," + inqty.Text + ",'入库' from aftersalerecord where afr_barcode='" + barcode.Text + "'", "insert");
  65. OperateResult.AppendText(">>条码" + barcode.Text + "录入成功\n", Color.Green, barcode);
  66. LoadGridData();
  67. }
  68. else
  69. {
  70. if (!dh.CheckExist("aftersalerecord", "afr_barcode='" + barcode.Text + "'"))
  71. {
  72. OperateResult.AppendText(">>条码" + barcode.Text + "不存在\n", Color.Red, barcode);
  73. return;
  74. }
  75. if (dh.CheckExist("aftersalerecord", "afr_barcode='" + barcode.Text + "' and nvl(afr_outqty,0) =0"))
  76. {
  77. OperateResult.AppendText(">>条码" + barcode.Text + "已出库\n", Color.Red, barcode);
  78. return;
  79. }
  80. sql.Clear();
  81. sql.Append("delete from aftersalerecord where afr_barcode='" + barcode.Text + "'");
  82. dh.ExecuteSql(sql.GetString(), "delete");
  83. dh.ExecuteSql("insert into aftersalerecordlog(afl_id,afl_barcode,afl_prodcode,afl_qty,afl_type) select aftersalerecordlog_seq.nextval,afr_barcode,afr_prodcode," + inqty.Text + ",'取消入库' from aftersalerecord where afr_barcode='" + barcode.Text + "'", "insert");
  84. OperateResult.AppendText(">>条码" + barcode.Text + "取消成功\n", Color.Green, barcode);
  85. LoadGridData();
  86. }
  87. }
  88. private void Clean_Click(object sender, EventArgs e)
  89. {
  90. OperateResult.Clear();
  91. }
  92. private void LoadGridData()
  93. {
  94. sql.Clear();
  95. 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')) ");
  96. if (cu_code.Text != "")
  97. {
  98. sql.Append(" and afr_cucode='" + cu_code.Text + "'");
  99. }
  100. if (pr_code.Text != "")
  101. {
  102. sql.Append(" and afr_prodcode='" + pr_code.Text + "'");
  103. }
  104. DataTable dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  105. BaseUtil.FillDgvWithDataTable(Info, dt);
  106. }
  107. private void Special_AfterSaleIn_SizeChanged(object sender, EventArgs e)
  108. {
  109. asc.controlAutoSize(this);
  110. }
  111. private void barcode_KeyDown(object sender, KeyEventArgs e)
  112. {
  113. if (e.KeyCode == Keys.Enter)
  114. {
  115. Confirm.PerformClick();
  116. }
  117. }
  118. private void dateTimePicker1_ValueChanged(object sender, EventArgs e)
  119. {
  120. LoadGridData();
  121. }
  122. private void cu_code_UserControlTextChanged(object sender, EventArgs e)
  123. {
  124. LoadGridData();
  125. }
  126. private void pr_code_UserControlTextChanged(object sender, EventArgs e)
  127. {
  128. LoadGridData();
  129. }
  130. }
  131. }