| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150 |
- using System;
- using System.Data;
- using System.Text;
- using System.Windows.Forms;
- using 优软MES.CustomControl.DataGrid_View;
- using 优软MES.DataOperate;
- using 优软MES.PublicMethod;
- namespace 优软MES
- {
- public partial class Batch_In : Form
- {
- string caller = "ProdInOut!Deal";
- string formName = "Batch_In";
- string defaultCondition = "nvl(pd_status,0)='0' and nvl(pd_inqty,0)>0 and pi_class='采购验收单' and nvl(pd_checkstatus,0)>0";
- string[] hiddenField = new string[] {"pi_id" };
- DataHelper dh = new DataHelper();
- public Batch_In()
- {
- InitializeComponent();
- DataTable dt = dh.GetConfigureData(caller, "DataList", defaultCondition);
- BI_DataGrid.DataSource = dt;
- BaseUtil.HideField(BI_DataGrid,hiddenField);
- //添加图片列
- pi_inoutno.Caller = caller;
- pi_inoutno.FormName = formName;
- pr_code.Caller = caller;
- pr_code.FormName = formName;
- wh_code.Caller = caller;
- wh_code.FormName = formName;
- }
- private void Screen_Button_Click(object sender, EventArgs e)
- {
- string beginTime = timePickerWithCombo1.BeginTime;
- string endTime = timePickerWithCombo1.EndTime;
- string pi_inoutno = this.pi_inoutno.Text;
- string pr_code = this.pr_code.Text;
- string pd_location = wh_code.Text;
- string pi_status = this.pi_status.Text;
- StringBuilder condition = new StringBuilder();
- if (!string.IsNullOrWhiteSpace(timePickerWithCombo1.BeginTime) && !string.IsNullOrWhiteSpace(timePickerWithCombo1.EndTime))
- {
- condition.Append(" to_char(pi_date,'yyyy/MM/dd hh:mm:ss') between '" + beginTime + "' and '" + endTime + "'");
- }
- if (!string.IsNullOrEmpty(pi_inoutno))
- {
- if (condition.Length == 0)
- {
- condition.Append(" pi_inoutno like '%" + pi_inoutno + "%' ");
- }
- else
- {
- condition.Append(" and pi_inoutno like '%" + pi_inoutno + "%'");
- }
- }
- if (!string.IsNullOrEmpty(pr_code))
- {
- if (condition.Length == 0)
- {
- condition.Append(" pr_code like '%" + pr_code + "%'");
- }
- else
- {
- condition.Append(" and pr_code like '%" + pr_code + "%'");
- }
- }
- if (!string.IsNullOrEmpty(pd_location))
- {
- if (condition.Length == 0)
- {
- condition.Append(" pd_whcode like '%" + pd_location + "%'");
- }
- else
- {
- condition.Append(" and pd_whcode like '%" + pd_location + "%'");
- }
- }
- if (condition.Length != 0)
- {
- BI_DataGrid.DataSource = dh.GetConfigureData(caller, "DataList", condition.ToString());
- }
- else
- {
- BI_DataGrid.DataSource = dh.GetConfigureData(caller, "DataList", defaultCondition);
- }
- }
- private void Confirm_In_Click(object sender, EventArgs e)
- {
- string[] pd_id = new string[BI_DataGrid.Rows.Count];
- string[] pi_inoutno = new string[BI_DataGrid.Rows.Count];
- StringBuilder pd_id_str = new StringBuilder();
- //string[] pi_id = new string[BI_DataGrid.Rows.Count];
- //string[] pd_pdno = new string[BI_DataGrid.Rows.Count];
- //string[] pd_prodcode = new string[BI_DataGrid.Rows.Count];
- DataTable dt = (DataTable)BI_DataGrid.DataSource;
- int k = 0;
- for (int i = 0; i < BI_DataGrid.Rows.Count; i++)
- {
- if (BI_DataGrid.Rows[i].Cells[0].Value!=null&&(bool)BI_DataGrid.Rows[i].Cells[0].Value) {
- //查找对应caption的列名
- pd_id[k] = dt.Rows[i][BaseUtil.GetColumnNameByCaption(dt, "pd_id")].ToString();
- pd_id_str.Append(pd_id[k] + ",");
- pi_inoutno[k] = dt.Rows[i][BaseUtil.GetColumnNameByCaption(dt, "pi_inoutno")].ToString();
- //pi_id[k] = dt.Rows[i][BaseUtil.GetColumnNameByCaption(dt, "pi_id")].ToString();
- //pd_pdno[k] = dt.Rows[i][BaseUtil.GetColumnNameByCaption(dt, "pd_pdno")].ToString();
- //pd_prodcode[k] = dt.Rows[i][BaseUtil.GetColumnNameByCaption(dt, "pd_prodcode")].ToString();
- k++;
- }
- }
- //dh.CallProcedure("sp_commitprodinout", new string[] { "v_p_piclass", "v_p_piinoutno" , "v_p_pdid", "v_p_commitid" });
- if (k == 0) {
- BaseUtil.ShowError("请勾选需要入库的明细!");
- }
-
- //用于存放查询的结果
- 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");
- StringBuilder Error_Str = new StringBuilder();
- foreach (DataRow dr in dt1.Rows) {
- if (dr["pd_status"].ToString() != "0") {
- Error_Str.Append("单号"+pi_inoutno[dt1.Rows.IndexOf(dr)]+"已经入库!");
- }
- }
- //拼接错误信息
- if (Error_Str.Length != 0) {
- BaseUtil.ShowError(Error_Str.ToString());
- }
- Error_Str.Clear();
- BaseUtil.CleanDataTable(dt1);
- //判断管控类型为批管控的时候必须打印条码
- 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");
-
- foreach (DataRow dr in dt1.Rows) {
- if (dr["bi_printstatus"].ToString() != "1" && dr["bi_printstatus"].ToString()=="2")
- {
- Error_Str.Append("单号" + pi_inoutno[dt1.Rows.IndexOf(dr)] + "未打印条码!");
- }
- }
- if (Error_Str.Length != 0)
- {
- BaseUtil.ShowError(Error_Str.ToString());
- }
- }
- }
- }
|