浏览代码

数据为空的异常处理

callm 3 年之前
父节点
当前提交
d1ff8893c1
共有 1 个文件被更改,包括 22 次插入0 次删除
  1. 22 0
      UAS-出货标签管理(泽天)/UAS_出货标签管理.cs

+ 22 - 0
UAS-出货标签管理(泽天)/UAS_出货标签管理.cs

@@ -621,6 +621,14 @@ namespace UAS_LabelMachine
                 SumQty = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
             }
             //采集后重新计数,自动跳到下一行
+
+            if (SumQty == null)
+            {
+                sql.Clear();
+                sql.Append("select pib_pdno,pib_prodcode,sum(pib_qty) pib_qty from  prodiodetail left join prodiobarcode on pd_id=pib_pdid and pd_pdno=pib_pdno ");
+                sql.Append("where pib_inoutno='" + pi_inoutno.Text + "' group by pib_prodcode,pib_pdno order by pib_pdno ");
+                SumQty = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
+            }
             collectqty = (SumQty.Compute("sum(pib_qty)", "pib_prodcode='" + CurrentPrCode + "' and pib_pdno='" + CurrentPDNO + "'").ToString());
             CollectQty = (collectqty == "" ? 0 : double.Parse(collectqty));
 
@@ -1713,6 +1721,13 @@ namespace UAS_LabelMachine
                         string CurrentPrCode = GridPrcode.Rows[i].Cells["pd_prodcode"].Value.ToString();
                         string CurrentPDNO = GridPrcode.Rows[i].Cells["pd_pdno"].Value.ToString();
                         string CurrentOutQTY = GridPrcode.Rows[i].Cells["pd_outqty"].Value.ToString();
+                        if (SumQty == null)
+                        {
+                            sql.Clear();
+                            sql.Append("select pib_pdno,pib_prodcode,sum(pib_qty) pib_qty from  prodiodetail left join prodiobarcode on pd_id=pib_pdid and pd_pdno=pib_pdno ");
+                            sql.Append("where pib_inoutno='" + pi_inoutno.Text + "' group by pib_prodcode,pib_pdno order by pib_pdno ");
+                            SumQty = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
+                        }
                         string collectqty = (SumQty.Compute("sum(pib_qty)", "pib_prodcode='" + CurrentPrCode + "' and pib_pdno='" + CurrentPDNO + "'").ToString());
                         CollectNum += double.Parse(collectqty == "" ? "0" : collectqty);
                         OutNum += double.Parse(CurrentOutQTY);
@@ -1763,6 +1778,13 @@ namespace UAS_LabelMachine
                         string CurrentPrCode = GridPrcode.Rows[i].Cells["pd_prodcode"].Value.ToString();
                         string CurrentPDNO = GridPrcode.Rows[i].Cells["pd_pdno"].Value.ToString();
                         string CurrentOutQTY = GridPrcode.Rows[i].Cells["pd_outqty"].Value.ToString();
+                        if (SumQty == null)
+                        {
+                            sql.Clear();
+                            sql.Append("select pib_pdno,pib_prodcode,sum(pib_qty) pib_qty from  prodiodetail left join prodiobarcode on pd_id=pib_pdid and pd_pdno=pib_pdno ");
+                            sql.Append("where pib_inoutno='" + pi_inoutno.Text + "' group by pib_prodcode,pib_pdno order by pib_pdno ");
+                            SumQty = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
+                        }
                         string collectqty = (SumQty.Compute("sum(pib_qty)", "pib_prodcode='" + CurrentPrCode + "' and pib_pdno='" + CurrentPDNO + "'").ToString());
                         CollectNum += double.Parse(collectqty == "" ? "0" : collectqty);
                         OutNum += double.Parse(CurrentOutQTY);