Explorar el Código

Improve SellerInvoiceResponse_Changed()

Snoopy hace 3 años
padre
commit
923e1cb09b
Se han modificado 1 ficheros con 6 adiciones y 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") // 上傳成功
             {