Преглед изворни кода

Improve SellerInvoiceResponse_Changed()

Snoopy пре 3 година
родитељ
комит
923e1cb09b
1 измењених фајлова са 6 додато и 1 уклоњено
  1. 6 1
      TCCInvoice/InvoiceGenerator.cs

+ 6 - 1
TCCInvoice/InvoiceGenerator.cs

@@ -282,7 +282,7 @@ namespace TCCInvoice
         {
             XDocument xDoc = XDocument.Load(e.FullPath);
 
-            int index = 0;
+            int index = -1;
             string status = xDoc.Descendants("Status").ElementAt(0).Value;
             string invoicenumber = xDoc.Descendants("InvoiceNumber").ElementAt(0).Value;
             foreach (InvoiceResponseItem item in invoiceResponseItemList)
@@ -292,6 +292,11 @@ namespace TCCInvoice
                     index = invoiceResponseItemList.IndexOf(item);
                 }
             }
+
+            if (index == -1)
+            {
+                return; // something wrong
+            }
             
             if (status == "1") // 上傳成功
             {