Explorar o código

Improve SellerInvoiceResponse_Changed()

Snoopy %!s(int64=3) %!d(string=hai) anos
pai
achega
923e1cb09b
Modificáronse 1 ficheiros con 6 adicións e 1 borrados
  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") // 上傳成功
             {