章政 6 жил өмнө
parent
commit
145d62567d

+ 0 - 1
UAS-出货标签管理(贸易版)/CustomControl/SearchTextBox.cs

@@ -338,7 +338,6 @@ namespace UAS_LabelMachine.CustomControl
             }
             try
             {
-                Console.WriteLine(sql);
                 dt = (DataTable)dh.ExecuteSql(sql, "select");
                 if (dt.Rows.Count > 0)
                     ReturnDataToForm();

+ 5 - 15
UAS-出货标签管理(贸易版)/PublicMethod/Print.cs

@@ -70,8 +70,6 @@ namespace UAS_LabelMachine.PublicMethod
                 for (int j = 0; j < MidDoc.Variables.FormVariables.Count; j++)
                 {
                     DataRow[] dr1 = MidLabelParam.Select("lp_name='" + MidDoc.Variables.FormVariables.Item(j + 1).Name + "'");
-                    if (dr1.Length == 0)
-                        dr1 = MidLabelParam.Select("lp_name='" + MidDoc.Variables.FormVariables.Item(j + 1).Name.Replace("_1", "") + "'");
                     if (dr1.Length > 0 && dr1[0]["lp_valuetype"].ToString() == "字符串")
                     {
                         MidDoc.Variables.FormVariables.Item(j + 1).Value = dt.Rows[0][dr1[0]["lp_sql"].ToString()].ToString();
@@ -125,9 +123,6 @@ namespace UAS_LabelMachine.PublicMethod
                     for (int j = 0; j < OutBoxDoc.Variables.FormVariables.Count; j++)
                     {
                         DataRow[] dr1 = OutLabelParam.Select("lp_name='" + OutBoxDoc.Variables.FormVariables.Item(j + 1).Name + "'");
-                        //多参数命名
-                        if (dr1.Length == 0)
-                            dr1 = OutLabelParam.Select("lp_name='" + OutBoxDoc.Variables.FormVariables.Item(j + 1).Name.Replace("_1", "") + "'");
                         if (dr1.Length > 0 && dr1[0]["lp_valuetype"].ToString() == "字符串")
                         {
                             OutBoxDoc.Variables.FormVariables.Item(j + 1).Value = dt.Rows[0][dr1[0]["lp_sql"].ToString()].ToString();
@@ -223,12 +218,10 @@ namespace UAS_LabelMachine.PublicMethod
                     }
                 }
                 sql.Append("1,");
-                DataTable dt = (DataTable)SystemInf.sdh.ExecuteSql("select " + sql.ToString().Substring(0, sql.Length - 1) + " from prodiobarcode where pib_inoutno='" + pi_inoutno + "' and pib_outboxcode1=" + (pib_outboxcode1 == "" ? "0" : pib_outboxcode1), "select");
+                DataTable dt = (DataTable)SystemInf.sdh.ExecuteSql("select " + sql.ToString().Substring(0, sql.Length - 1) + " from prodiobarcode where pib_inoutno='" + pi_inoutno + "' and pib_outboxcode1=" + (pib_outboxcode1 == "" ? "0" : pib_outboxcode1) + " limit 0,1", "select");
                 for (int j = 0; j < MidFormat.SubStrings.Count; j++)
                 {
                     DataRow[] dr1 = MidLabelParam.Select("lp_name='" + MidFormat.SubStrings[j].Name + "'");
-                    if (dr1.Length == 0)
-                        dr1 = MidLabelParam.Select("lp_name='" + MidFormat.SubStrings[j].Name.Replace("_1", "") + "'");
                     if (dr1.Length > 0 && dr1[0]["lp_valuetype"].ToString() == "字符串")
                     {
                         MidFormat.SubStrings[j].Value = dt.Rows[0][dr1[0]["lp_sql"].ToString()].ToString();
@@ -276,15 +269,12 @@ namespace UAS_LabelMachine.PublicMethod
                     }
                 }
                 sql.Append("1,");
-                DataTable dt = (DataTable)SystemInf.sdh.ExecuteSql("select " + sql.ToString().Substring(0, sql.Length - 1) + " from prodiobarcode where pib_inoutno='" + pi_inoutno + "' and pib_outboxcode2=" + (pib_outboxcode2 == "" ? "0" : pib_outboxcode2), "select");
+                DataTable dt = (DataTable)SystemInf.sdh.ExecuteSql("select " + sql.ToString().Substring(0, sql.Length - 1) + " from prodiobarcode where pib_inoutno='" + pi_inoutno + "' and pib_outboxcode2=" + (pib_outboxcode2 == "" ? "0" : pib_outboxcode2) + " limit 0,1", "select");
                 if (dt.Rows.Count > 0)
                 {
                     for (int j = 0; j < OutFormat.SubStrings.Count; j++)
                     {
                         DataRow[] dr1 = OutLabelParam.Select("lp_name='" + OutFormat.SubStrings[j].Name + "'");
-                        //多参数命名
-                        if (dr1.Length == 0)
-                            dr1 = OutLabelParam.Select("lp_name='" + OutFormat.SubStrings[j].Name.Replace("_1", "") + "'");
                         if (dr1.Length > 0 && dr1[0]["lp_valuetype"].ToString() == "字符串")
                         {
                             OutFormat.SubStrings[j].Value = dt.Rows[0][dr1[0]["lp_sql"].ToString()].ToString();
@@ -315,9 +305,9 @@ namespace UAS_LabelMachine.PublicMethod
                         }
                         if (OutFormat.SubStrings[j].Value == "")
                         {
-                            dr1 = UAS_出货标签打印.Attach.Select("lp_name='" + OutFormat.SubStrings[j].Name + "'");
-                            if (dr1.Length > 0)
-                                OutFormat.SubStrings[j].Value = dr1[0]["lp_sql"].ToString();
+                            //dr1 = UAS_出货标签打印.Attach.Select("lp_name='" + OutFormat.SubStrings[j].Name + "'");
+                            //if (dr1.Length > 0)
+                            //    OutFormat.SubStrings[j].Value = dr1[0]["lp_sql"].ToString();
                         }
                     }
                     OutFormat.Print();

+ 0 - 1
UAS-出货标签管理(贸易版)/PublicMethod/SqliteDBHelper.cs

@@ -502,7 +502,6 @@ namespace UAS_LabelMachine
         {
             object result = null;
             command = new SQLiteCommand(SQL, this._odcConnection);
-            Console.WriteLine(SQL);
             Reconnect(command);
             switch (Type.ToUpper())
             {

+ 3 - 22
UAS-出货标签管理(贸易版)/UAS_出货标签管理.Designer.cs

@@ -137,8 +137,6 @@
             this.pr_unit = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.pib_lotno = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.pib_datecode = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.pib_cusbarcode = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.pib_cusoutboxcode = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.pib_datecode1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.pib_qty = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.pib_barcode = new System.Windows.Forms.DataGridViewTextBoxColumn();
@@ -751,6 +749,7 @@
             this.AttachInfo.TabIndex = 85;
             this.AttachInfo.Text = "附加信息设置";
             this.AttachInfo.UseVisualStyleBackColor = true;
+            this.AttachInfo.Visible = false;
             this.AttachInfo.Click += new System.EventHandler(this.AttachInfo_Click);
             // 
             // pi_date
@@ -1151,8 +1150,6 @@
             this.pr_unit,
             this.pib_lotno,
             this.pib_datecode,
-            this.pib_cusbarcode,
-            this.pib_cusoutboxcode,
             this.pib_datecode1,
             this.pib_qty,
             this.pib_barcode,
@@ -1277,20 +1274,6 @@
             this.pib_datecode.Name = "pib_datecode";
             this.pib_datecode.Width = 78;
             // 
-            // pib_cusbarcode
-            // 
-            this.pib_cusbarcode.DataPropertyName = "pib_cusbarcode";
-            this.pib_cusbarcode.HeaderText = "ViVo条码号";
-            this.pib_cusbarcode.Name = "pib_cusbarcode";
-            this.pib_cusbarcode.Width = 90;
-            // 
-            // pib_cusoutboxcode
-            // 
-            this.pib_cusoutboxcode.DataPropertyName = "pib_cusoutboxcode";
-            this.pib_cusoutboxcode.HeaderText = "ViVo外箱";
-            this.pib_cusoutboxcode.Name = "pib_cusoutboxcode";
-            this.pib_cusoutboxcode.Width = 78;
-            // 
             // pib_datecode1
             // 
             this.pib_datecode1.DataPropertyName = "pib_datecode1";
@@ -1466,7 +1449,7 @@
             this.MidLabel.Size = new System.Drawing.Size(158, 238);
             this.MidLabel.TabIndex = 78;
             this.MidLabel.TabStop = false;
-            this.MidLabel.Text = "盒标签";
+            this.MidLabel.Text = "盒标签";
             // 
             // MidLabelNum
             // 
@@ -1903,6 +1886,7 @@
         private System.Windows.Forms.DataGridViewTextBoxColumn si_expressionitem;
         private System.Windows.Forms.Button AttachInfo;
         private System.Windows.Forms.Label pi_date;
+        private System.Windows.Forms.Button CleanBarCode;
         private System.Windows.Forms.DataGridViewCheckBoxColumn Choose;
         private System.Windows.Forms.DataGridViewCheckBoxColumn pib_ifpick;
         private System.Windows.Forms.DataGridViewCheckBoxColumn pib_ifprint;
@@ -1916,8 +1900,6 @@
         private System.Windows.Forms.DataGridViewTextBoxColumn pr_unit;
         private System.Windows.Forms.DataGridViewTextBoxColumn pib_lotno;
         private System.Windows.Forms.DataGridViewTextBoxColumn pib_datecode;
-        private System.Windows.Forms.DataGridViewTextBoxColumn pib_cusbarcode;
-        private System.Windows.Forms.DataGridViewTextBoxColumn pib_cusoutboxcode;
         private System.Windows.Forms.DataGridViewTextBoxColumn pib_datecode1;
         private System.Windows.Forms.DataGridViewTextBoxColumn pib_qty;
         private System.Windows.Forms.DataGridViewTextBoxColumn pib_barcode;
@@ -1928,6 +1910,5 @@
         private System.Windows.Forms.DataGridViewTextBoxColumn pr_spec;
         private System.Windows.Forms.DataGridViewTextBoxColumn pib_outboxcode1;
         private System.Windows.Forms.DataGridViewTextBoxColumn pib_outboxcode2;
-        private System.Windows.Forms.Button CleanBarCode;
     }
 }

+ 40 - 11
UAS-出货标签管理(贸易版)/UAS_出货标签管理.cs

@@ -200,6 +200,7 @@ namespace UAS_LabelMachine
             LogManager.DoLog("程序启动,登陆人员【" + User.UserName + "】");
             dh = SystemInf.dh;
             sdh = SystemInf.sdh;
+            sdh.ExecuteZip();
             CheckForIllegalCrossThreadCalls = false;
             CloumnCount = LabelInf.Columns.Count;
             pi_inoutno.Focus();
@@ -963,7 +964,10 @@ namespace UAS_LabelMachine
                     e.Cancel = true;
                 else
                 {
-                    lbl.Quit();
+                    if (lbl != null)
+                        lbl.Quit();
+                    if (engine != null)
+                        engine.Dispose();
                     LogManager.DoLog("关闭程序");
                 }
             }
@@ -1022,6 +1026,8 @@ namespace UAS_LabelMachine
             MidLabelCombox.DataSource = dt;
             if (MidDoc != null)
                 MidDoc.Close();
+            if (MidFormat != null)
+                MidFormat.Close(SaveOptions.DoNotSaveChanges);
             if (!GetGridOnly.Checked)
                 for (int i = 0; i < dt.Rows.Count; i++)
                 {
@@ -1058,6 +1064,8 @@ namespace UAS_LabelMachine
             OutBoxCombox.DataSource = dt;
             if (OutBoxDoc != null)
                 OutBoxDoc.Close();
+            if (OutFormat != null)
+                OutFormat.Close(SaveOptions.DoNotSaveChanges);
             if (!GetGridOnly.Checked)
                 for (int i = 0; i < dt.Rows.Count; i++)
                 {
@@ -1571,11 +1579,7 @@ namespace UAS_LabelMachine
             {
                 //嵌套查询重置RowNum
                 sql.Clear();
-                sql.Append("select t.*,rownum from (select pd_ordercode,pib_year,pib_month,pib_day,pr_barcode,pr_detail,pib_custoutboxcode,pib_custmidboxcode,pr_orispeccode,pd_id,pd_custprodcode,pib_indate,pi_date,pib_inoutno,pd_custprodspec,");
-                sql.Append("nvl(pib_ifrecheck,0)pib_ifrecheck,nvl(pib_ifupload,0)pib_ifupload,nvl(pib_ifmodify,0)pib_ifmodify,pd_pocode,pib_madein,pib_custbarcode,pib_id,pib_pdid,pib_piid,");
-                sql.Append("pib_pdno,pib_prodcode,nvl(nvl(pd_brand,pib_brand),pr_brand)pib_brand, pr_vendprodcode,pib_lotno,pib_datecode,pib_qty,pr_spec,pi_title,pr_zxbzs,pr_unit,pib_barcode,pib_outboxcode1,");
-                sql.Append("pib_outboxcode2,nvl(pib_ifpick,0)pib_ifpick,nvl(pib_ifprint,0)pib_ifprint from prodiobarcode left join prodinout on pib_piid=pi_id left join prodiodetail on pib_piid=pd_piid and  ");
-                sql.Append("pd_pdno=pib_pdno and pd_prodcode=pib_prodcode left join product on pr_code=pib_prodcode left join sale on sa_code=pib_ordercode where pib_piid='" + PI_ID + "' order by to_number(pib_id))t");
+                sql.Append("select t.*,rownum from prodiobarcode_view t where pib_inoutno='" + pi_inoutno.Text + "'");
                 LabelInfDataTable = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
                 //检验查询的字段和本地数据库字段是否匹配
                 sdh.AddColumFromDataTable(LabelInfDataTable, "prodiobarcode");
@@ -1832,6 +1836,7 @@ namespace UAS_LabelMachine
                             BoxCode = BoxCode + 1;
                         }
                     }
+                    sdh.ExecuteSql("update prodiobarcode set pib_outboxcode2=" + BoxCode + " where pib_id=" + LabelInf.Rows[i].Cells["pib_id1"].Value, "update");
                 }
             }
             SaveGrid_Click(sender, e);
@@ -1846,7 +1851,10 @@ namespace UAS_LabelMachine
                 //注销的时候需要将拼接的连接字符串置空
                 DataHelper.DBConnectionString = null;
                 logout = true;
-                lbl.Quit();
+                if (lbl != null)
+                    lbl.Quit();
+                if (engine != null)
+                    engine.Dispose();
                 this.Hide();
                 login.ShowDialog();
                 this.Close();
@@ -1868,11 +1876,17 @@ namespace UAS_LabelMachine
                 {
                     if (SingleDoc != null)
                         SingleDoc.Close();
+                    if (SingleFormat != null)
+                        SingleFormat.Close(SaveOptions.DoNotSaveChanges);
+                    System.DateTime time = Convert.ToDateTime(SingleLabelCombox.SelectedValue.ToString().Split('#')[2]);
                     if (SingleLabelCombox.Text != "" && SingleLabelCombox.SelectedValue != null && !GetGridOnly.Checked)
                     {
-                        System.DateTime time = Convert.ToDateTime(SingleLabelCombox.SelectedValue.ToString().Split('#')[2]);
                         SingleDoc = lbl.Documents.Open(BaseUtil.GetLabelUrl(SingleLabelCombox.SelectedValue.ToString().Split('#')[1], SingleLabelCombox.Text, time));
                     }
+                    else
+                    {
+                        SingleFormat = engine.Documents.Open(BaseUtil.GetLabelUrl(SingleLabelCombox.SelectedValue.ToString().Split('#')[1], SingleLabelCombox.Text, time));
+                    }
                 }
             }
             catch (Exception) { }
@@ -1891,10 +1905,19 @@ namespace UAS_LabelMachine
                 {
                     if (MidDoc != null)
                         MidDoc.Close();
+                    if (MidFormat != null)
+                        MidFormat.Close(SaveOptions.DoNotSaveChanges);
                     if (MidLabelCombox.Text != "" && MidLabelCombox.SelectedValue != null && !GetGridOnly.Checked)
                     {
                         System.DateTime time = Convert.ToDateTime(MidLabelCombox.SelectedValue.ToString().Split('#')[2]);
-                        MidDoc = lbl.Documents.Open(BaseUtil.GetLabelUrl(MidLabelCombox.SelectedValue.ToString().Split('#')[1], MidLabelCombox.Text, time));
+                        if (PrintMethod == "CodeSoft")
+                        {
+                            MidDoc = lbl.Documents.Open(BaseUtil.GetLabelUrl(MidLabelCombox.SelectedValue.ToString().Split('#')[1], MidLabelCombox.Text, time));
+                        }
+                        else
+                        {
+                            MidFormat = engine.Documents.Open(BaseUtil.GetLabelUrl(MidLabelCombox.SelectedValue.ToString().Split('#')[1], MidLabelCombox.Text, time));
+                        }
                     }
                 }
             }
@@ -1914,11 +1937,17 @@ namespace UAS_LabelMachine
                 {
                     if (OutBoxDoc != null)
                         OutBoxDoc.Close();
+                    if (OutFormat != null)
+                        OutFormat.Close(SaveOptions.DoNotSaveChanges);
+                    System.DateTime time = Convert.ToDateTime(OutBoxCombox.SelectedValue.ToString().Split('#')[2]);
                     if (OutBoxCombox.Text != "" && OutBoxCombox.SelectedValue != null && !GetGridOnly.Checked)
                     {
-                        System.DateTime time = Convert.ToDateTime(OutBoxCombox.SelectedValue.ToString().Split('#')[2]);
                         OutBoxDoc = lbl.Documents.Open(BaseUtil.GetLabelUrl(OutBoxCombox.SelectedValue.ToString().Split('#')[1], OutBoxCombox.Text, time));
                     }
+                    else
+                    {
+                        OutFormat = engine.Documents.Open(BaseUtil.GetLabelUrl(OutBoxCombox.SelectedValue.ToString().Split('#')[1], OutBoxCombox.Text, time));
+                    }
                 }
             }
             catch (Exception) { }
@@ -2090,7 +2119,7 @@ namespace UAS_LabelMachine
                     else
                     {
                         if (OutFormat != null)
-                            OutFormat.PrintSetup.PrinterName = OutBoxLabelPrint.Text;
+                            OutFormat.PrintSetup.PrinterName = OutBoxPrinter.Text;
                     }
                     break;
                 default:

+ 0 - 6
UAS-出货标签管理(贸易版)/UAS_出货标签管理.resx

@@ -156,12 +156,6 @@
   <metadata name="pr_unit.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
     <value>True</value>
   </metadata>
-  <metadata name="pib_cusbarcode.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
-    <value>True</value>
-  </metadata>
-  <metadata name="pib_cusoutboxcode.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
-    <value>True</value>
-  </metadata>
   <metadata name="pib_datecode1.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
     <value>True</value>
   </metadata>

+ 3 - 22
UAS-出货标签管理(贸易版)/客户标签维护.cs

@@ -1,11 +1,8 @@
-using LabelManager2;
-using System;
+using System;
 using System.Data;
-using System.Drawing;
 using System.Text;
 using System.IO;
 using System.Windows.Forms;
-using UAS_LabelMachine.CustomControl;
 using UAS_LabelMachine.Properties;
 using UAS_LabelMachine.PublicMethod;
 using UAS_LabelMachine.Entity;
@@ -25,8 +22,6 @@ namespace UAS_LabelMachine
         StringBuilder condition = new StringBuilder();
         StringBuilder sql = new StringBuilder();
         /*CodeSoft新建打印机引擎*/
-        ApplicationClass lbl;
-        Document doc;
         /*BarTender新建打印机引擎*/
         //private Engine engine = null;
         //private LabelFormatDocument format ;
@@ -106,7 +101,6 @@ namespace UAS_LabelMachine
             LoadData();
             Width = Width + 1;
             asc.controllInitializeSize(this);
-            lbl = new ApplicationClass();
             Width = Width + 1;
         }
 
@@ -114,10 +108,6 @@ namespace UAS_LabelMachine
         {
             if (LabelDataGridView.Columns[e.ColumnIndex].HeaderText == "预览")
             {
-                if (lbl.Documents.Count > 0)
-                {
-                    lbl.ActiveDocument.Close();
-                }
                 //获取路径和标签名称
                 LabelPath = LabelDataGridView.Rows[e.RowIndex].Cells["cl_labelurl"].Value.ToString();
                 LabelCode = LabelDataGridView.Rows[e.RowIndex].Cells["cl_labelcode"].Value.ToString();
@@ -135,14 +125,7 @@ namespace UAS_LabelMachine
                 if (CodeSoft.Checked)
                 {
                     string LabelName = LabelDataGridView.Rows[e.RowIndex].Cells["cl_labelname"].Value.ToString();
-                    doc = lbl.Documents.Open(BaseUtil.GetLabelUrl(LabelPath, LabelName,time));
-                    Bitmap bit = new Bitmap(doc.CopyImageToFile());
-                    pictureBox1.Image = bit;
                     //如果文件已不存在则进行提示
-                    if (doc == null)
-                    {
-                        return;
-                    }
                 }
             }
             if (LabelDataGridView.Columns[e.ColumnIndex].HeaderText == "编辑")
@@ -313,8 +296,7 @@ namespace UAS_LabelMachine
         {
             if (LabelCode != "")
             {
-                doc.Printer.SwitchTo(PrinterList.Text);
-                doc.PrintDocument();
+          
             }
         }
 
@@ -322,8 +304,7 @@ namespace UAS_LabelMachine
         {
             try
             {
-                lbl.Documents.CloseAll();
-                lbl.Application.Quit();
+             
             }
             catch (Exception)
             {

+ 29 - 14
UAS-出货标签管理(贸易版)/生成条码.cs

@@ -221,7 +221,7 @@ namespace UAS_LabelMachine
                     ArrayList<string> barcode = new ArrayList<string>();
                     ArrayList<string> custbarcode = new ArrayList<string>();
                     int restqty1 = 0;
-                    if (ProdIoInfDGV.Rows[i].Cells["pib_restqty1"].Value.ToString() != "")
+                    if (ProdIoInfDGV.Rows[i].Cells["pib_restqty1"].Value != null && ProdIoInfDGV.Rows[i].Cells["pib_restqty1"].Value.ToString() != "")
                     {
                         string[] restqty = ProdIoInfDGV.Rows[i].Cells["pib_restqty1"].Value.ToString().Split(',');
                         for (int k = 0; k < restqty.Length; k++)
@@ -276,10 +276,10 @@ namespace UAS_LabelMachine
                         //插入条码
                         sql.Clear();
                         sql.Append("insert into prodiobarcode (PIB_ID,PIB_PRODCODE,PIB_INDATE,PIB_INOUTNO,PIB_PIID,pib_brand,PIB_BARCODE,PIB_CUSTBARCODE,PIB_PDNO,");
-                        sql.Append("PIB_PDID,PIB_PICLASS,PIB_QTY,PIB_PRODID,PIB_IFPRINT,PIB_IFPICK,PIB_ORDERCODE,PIB_CUSTPO,pib_orderdetno)");
+                        sql.Append("PIB_PDID,PIB_PICLASS,PIB_QTY,PIB_PRODID,PIB_OUTBOXCODE1,PIB_IFPRINT,PIB_IFPICK,PIB_ORDERCODE,PIB_CUSTPO,pib_orderdetno)");
                         sql.Append(" values (prodiobarcode_seq.nextval,'" + pd_prodcode + "',sysdate,'" + pi_inoutno.Text + "'," + pi_id + ",'" + pr_brand + "',:barcode,:custbarcode,'" + pd_pdno + "','" + pd_id + "',");
-                        sql.Append("'" + pi_class.Text + "',:pib_inqty,'" + pr_id + "',0,0,'" + pd_ordercode + "','','" + pd_orderdetno + "')");
-                        dh.BatchInsert(sql.ToString(), new string[] { "barcode", "custbarcode", "pib_inqty" }, barcode.ToArray(), custbarcode.ToArray(), pib_inqty.ToArray());
+                        sql.Append("'" + pi_class.Text + "',:pib_inqty,'" + pr_id + "',:midcode,0,0,'" + pd_ordercode + "','','" + pd_orderdetno + "')");
+                        dh.BatchInsert(sql.ToString(), new string[] { "barcode", "custbarcode", "pib_inqty" , "midcode" }, barcode.ToArray(), custbarcode.ToArray(), pib_inqty.ToArray(), midcode.ToArray());
                         //更新最大流水号
                         dh.UpdateByCondition("RuleMaxNum", "rmn_maxnumber='" + custserialnum + "'", "rmn_nrcode='" + NrCode + "' and rmn_prefix='" + Prefix + "'");
                     }
@@ -400,7 +400,7 @@ namespace UAS_LabelMachine
             object mid_qty = ProdIoInfDGV.Rows[e.RowIndex].Cells["mid_qty"].Value;
             object pd_totalqty = ProdIoInfDGV.Rows[e.RowIndex].Cells["pd_totalqty"].Value;
             int restqty1 = 0;
-            if (ProdIoInfDGV.Rows[e.RowIndex].Cells["pib_restqty1"].Value.ToString() != "")
+            if (ProdIoInfDGV.Rows[e.RowIndex].Cells["pib_restqty1"].Value != null && ProdIoInfDGV.Rows[e.RowIndex].Cells["pib_restqty1"].Value.ToString() != "")
             {
                 string[] restqty = ProdIoInfDGV.Rows[e.RowIndex].Cells["pib_restqty1"].Value.ToString().Split(',');
                 for (int k = 0; k < restqty.Length; k++)
@@ -439,7 +439,7 @@ namespace UAS_LabelMachine
             {
                 ProdIoInfDGV.Rows[i].Cells["mid_qty"].Value = MidCapacity.Text;
                 int restqty1 = 0;
-                if (ProdIoInfDGV.Rows[i].Cells["pib_restqty1"].Value.ToString() != "")
+                if (ProdIoInfDGV.Rows[i].Cells["pib_restqty1"].Value != null && ProdIoInfDGV.Rows[i].Cells["pib_restqty1"].Value.ToString() != "")
                 {
                     string[] restqty = ProdIoInfDGV.Rows[i].Cells["pib_restqty1"].Value.ToString().Split(',');
                     for (int k = 0; k < restqty.Length; k++)
@@ -486,14 +486,29 @@ namespace UAS_LabelMachine
             {
                 pi_id = dt.Rows[0]["pi_id"].ToString();
                 BaseUtil.SetFormValue(this.Controls, dt);
-                //查询出入库的类型
-                dt = (DataTable)dh.ExecuteSql("select ds_inorout from documentsetup where ds_name='" + pi_class.Text + "'", "select");
-                sql.Clear();
-                sql.Append("select '' pib_restqty1,pd_piid,pd_id,pr_id,pr_brand,pr_unit,pr_detail,pr_spec,pr_zxbzs,outqty pd_totalqty,pd_ordercode,pd_orderdetno,pd_pdno, ");
-                sql.Append("pd_prodcode,pd_piclass,pd_qty from (select pd_piid,pd_id,pr_id,pr_brand,pr_unit,pr_detail,pr_spec,pr_zxbzs,outqty,pd_ordercode,pd_orderdetno,pd_pdno,pd_prodcode,pd_piclass,");
-                sql.Append("outqty-nvl((select sum(nvl(pib_qty,0)) from PRODIOBARCODE where PIB_PIID=pd_piid and pib_pdno=pd_pdno),0)pd_qty from (select pd_piid,min(pd_id) pd_id,sum(pd_outqty)outqty, ");
-                sql.Append("pd_ordercode,pd_orderdetno,pd_pdno,max(pd_prodcode)pd_prodcode,max(pd_piclass)pd_piclass from prodiodetail where pd_piclass='出货单' group by pd_piid,pd_ordercode,pd_orderdetno,pd_pdno)T ");
-                sql.Append("left join product on pr_code=pd_prodcode where nvl(pr_zxbzs,0)>0)  where  pd_piid='" + pi_id + "'");
+                switch (pi_class.Text)
+                {
+                    case "出货单":
+                        sql.Clear();
+                        sql.Append("select pd_piid,pd_id,pr_id,pr_brand,pr_madein,pr_unit,pr_detail,pr_spec,pr_zxbzs,outqty pd_totalqty,pd_ordercode,pd_orderdetno,pd_pdno,pd_prodcode,");
+                        sql.Append("pd_piclass,pd_qty from (select pd_piid,pd_id,pr_id,pr_brand,pr_madein,pr_unit,pr_detail,pr_spec,pr_zxbzs,outqty,pd_ordercode,pd_orderdetno,pd_pdno,");
+                        sql.Append("pd_prodcode,pd_piclass,outqty-nvl((select sum(nvl(pib_qty,0)) from PRODIOBARCODE where PIB_PIID=pd_piid and pib_pdno=pd_pdno ),0)pd_qty ");
+                        sql.Append("from (select pd_piid,min(pd_id) pd_id,sum(pd_outqty)outqty,pd_ordercode,pd_orderdetno,pd_pdno,max(pd_prodcode)pd_prodcode,max(pd_piclass)pd_piclass ");
+                        sql.Append("from prodiodetail  group by pd_piid,pd_ordercode, pd_orderdetno,pd_pdno)T left join product ");
+                        sql.Append("on pr_code=pd_prodcode where nvl(pr_zxbzs,0)>0)  where  pd_piid='" + pi_id + "'");
+                        break;
+                    case "完工入库单":
+                        sql.Clear();
+                        sql.Append("select pd_piid,pd_id,pr_id,pr_brand,pr_madein,pr_unit,pr_detail,pr_spec,pr_zxbzs,inqty pd_totalqty,pd_ordercode,pd_orderdetno,pd_pdno,pd_prodcode,");
+                        sql.Append("pd_piclass,pd_qty from (select pd_piid,pd_id,pr_id,pr_brand,pr_madein,pr_unit,pr_detail,pr_spec,pr_zxbzs,inqty,pd_ordercode,pd_orderdetno,pd_pdno,");
+                        sql.Append("pd_prodcode,pd_piclass,inqty-nvl((select sum(nvl(pib_qty,0)) from PRODIOBARCODE where PIB_PIID=pd_piid and pib_pdno=pd_pdno ),0)pd_qty ");
+                        sql.Append("from (select pd_piid,min(pd_id) pd_id,sum(pd_inqty)inqty,pd_ordercode,pd_orderdetno,pd_pdno,max(pd_prodcode)pd_prodcode,max(pd_piclass)pd_piclass ");
+                        sql.Append("from prodiodetail  group by pd_piid,pd_ordercode, pd_orderdetno,pd_pdno)T left join product ");
+                        sql.Append("on pr_code=pd_prodcode )  where  pd_piid='" + pi_id + "'");
+                        break;
+                    default:
+                        break;
+                }
                 dt = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
                 BaseUtil.FillDgvWithDataTable(ProdIoInfDGV, dt);
             }