Batch_In.cs 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. using System;
  2. using System.Data;
  3. using System.Text;
  4. using System.Windows.Forms;
  5. using 优软MES.CustomControl.DataGrid_View;
  6. using 优软MES.DataOperate;
  7. using 优软MES.PublicMethod;
  8. namespace 优软MES
  9. {
  10. public partial class Batch_In : Form
  11. {
  12. string caller = "ProdInOut!Deal";
  13. string formName = "Batch_In";
  14. string defaultCondition = "nvl(pd_status,0)='0' and nvl(pd_inqty,0)>0 and pi_class='采购验收单' and nvl(pd_checkstatus,0)>0";
  15. string[] hiddenField = new string[] {"pi_id" };
  16. DataHelper dh = new DataHelper();
  17. public Batch_In()
  18. {
  19. InitializeComponent();
  20. DataTable dt = dh.GetConfigureData(caller, "DataList", defaultCondition);
  21. BI_DataGrid.DataSource = dt;
  22. BaseUtil.HideField(BI_DataGrid,hiddenField);
  23. //添加图片列
  24. pi_inoutno.Caller = caller;
  25. pi_inoutno.FormName = formName;
  26. pr_code.Caller = caller;
  27. pr_code.FormName = formName;
  28. wh_code.Caller = caller;
  29. wh_code.FormName = formName;
  30. }
  31. private void Screen_Button_Click(object sender, EventArgs e)
  32. {
  33. string beginTime = timePickerWithCombo1.BeginTime;
  34. string endTime = timePickerWithCombo1.EndTime;
  35. string pi_inoutno = this.pi_inoutno.Text;
  36. string pr_code = this.pr_code.Text;
  37. string pd_location = wh_code.Text;
  38. string pi_status = this.pi_status.Text;
  39. StringBuilder condition = new StringBuilder();
  40. if (!string.IsNullOrWhiteSpace(timePickerWithCombo1.BeginTime) && !string.IsNullOrWhiteSpace(timePickerWithCombo1.EndTime))
  41. {
  42. condition.Append(" to_char(pi_date,'yyyy/MM/dd hh:mm:ss') between '" + beginTime + "' and '" + endTime + "'");
  43. }
  44. if (!string.IsNullOrEmpty(pi_inoutno))
  45. {
  46. if (condition.Length == 0)
  47. {
  48. condition.Append(" pi_inoutno like '%" + pi_inoutno + "%' ");
  49. }
  50. else
  51. {
  52. condition.Append(" and pi_inoutno like '%" + pi_inoutno + "%'");
  53. }
  54. }
  55. if (!string.IsNullOrEmpty(pr_code))
  56. {
  57. if (condition.Length == 0)
  58. {
  59. condition.Append(" pr_code like '%" + pr_code + "%'");
  60. }
  61. else
  62. {
  63. condition.Append(" and pr_code like '%" + pr_code + "%'");
  64. }
  65. }
  66. if (!string.IsNullOrEmpty(pd_location))
  67. {
  68. if (condition.Length == 0)
  69. {
  70. condition.Append(" pd_whcode like '%" + pd_location + "%'");
  71. }
  72. else
  73. {
  74. condition.Append(" and pd_whcode like '%" + pd_location + "%'");
  75. }
  76. }
  77. if (condition.Length != 0)
  78. {
  79. BI_DataGrid.DataSource = dh.GetConfigureData(caller, "DataList", condition.ToString());
  80. }
  81. else
  82. {
  83. BI_DataGrid.DataSource = dh.GetConfigureData(caller, "DataList", defaultCondition);
  84. }
  85. }
  86. private void Confirm_In_Click(object sender, EventArgs e)
  87. {
  88. string[] pd_id = new string[BI_DataGrid.Rows.Count];
  89. string[] pi_inoutno = new string[BI_DataGrid.Rows.Count];
  90. StringBuilder pd_id_str = new StringBuilder();
  91. //string[] pi_id = new string[BI_DataGrid.Rows.Count];
  92. //string[] pd_pdno = new string[BI_DataGrid.Rows.Count];
  93. //string[] pd_prodcode = new string[BI_DataGrid.Rows.Count];
  94. DataTable dt = (DataTable)BI_DataGrid.DataSource;
  95. int k = 0;
  96. for (int i = 0; i < BI_DataGrid.Rows.Count; i++)
  97. {
  98. if (BI_DataGrid.Rows[i].Cells[0].Value!=null&&(bool)BI_DataGrid.Rows[i].Cells[0].Value) {
  99. //查找对应caption的列名
  100. pd_id[k] = dt.Rows[i][BaseUtil.GetColumnNameByCaption(dt, "pd_id")].ToString();
  101. pd_id_str.Append(pd_id[k] + ",");
  102. pi_inoutno[k] = dt.Rows[i][BaseUtil.GetColumnNameByCaption(dt, "pi_inoutno")].ToString();
  103. //pi_id[k] = dt.Rows[i][BaseUtil.GetColumnNameByCaption(dt, "pi_id")].ToString();
  104. //pd_pdno[k] = dt.Rows[i][BaseUtil.GetColumnNameByCaption(dt, "pd_pdno")].ToString();
  105. //pd_prodcode[k] = dt.Rows[i][BaseUtil.GetColumnNameByCaption(dt, "pd_prodcode")].ToString();
  106. k++;
  107. }
  108. }
  109. //dh.CallProcedure("sp_commitprodinout", new string[] { "v_p_piclass", "v_p_piinoutno" , "v_p_pdid", "v_p_commitid" });
  110. if (k == 0) {
  111. BaseUtil.ShowError("请勾选需要入库的明细!");
  112. }
  113. //用于存放查询的结果
  114. DataTable dt1 = (DataTable)dh.ExecuteSql("select pd_status from prodiodetail where pd_id in ("+pd_id_str.Remove(pd_id_str.Length-1,1)+")","select");
  115. StringBuilder Error_Str = new StringBuilder();
  116. foreach (DataRow dr in dt1.Rows) {
  117. if (dr["pd_status"].ToString() != "0") {
  118. Error_Str.Append("单号"+pi_inoutno[dt1.Rows.IndexOf(dr)]+"已经入库!");
  119. }
  120. }
  121. //拼接错误信息
  122. if (Error_Str.Length != 0) {
  123. BaseUtil.ShowError(Error_Str.ToString());
  124. }
  125. Error_Str.Clear();
  126. BaseUtil.CleanDataTable(dt1);
  127. //判断管控类型为批管控的时候必须打印条码
  128. dt1 =(DataTable)dh.ExecuteSql("select bi_printstatus,pr_tracekind from barcodeio left join product on pr_id=bi_prodid where bi_pdid in("+ pd_id_str.Remove(pd_id_str.Length - 1, 1) + ")", "select");
  129. foreach (DataRow dr in dt1.Rows) {
  130. if (dr["bi_printstatus"].ToString() != "1" && dr["bi_printstatus"].ToString()=="2")
  131. {
  132. Error_Str.Append("单号" + pi_inoutno[dt1.Rows.IndexOf(dr)] + "未打印条码!");
  133. }
  134. }
  135. if (Error_Str.Length != 0)
  136. {
  137. BaseUtil.ShowError(Error_Str.ToString());
  138. }
  139. }
  140. }
  141. }