/// <summary> /// This function deletes a particular invoice from the database /// </summary> /// <param name="Invoice">Invoice</param> public void DeleteInvoice(clsMainLogic Invoice) { try { DataSet ds = new DataSet(); int iRet = 0; ds = db.ExecuteSQLStatement(SQLQueries.SelectLineItems(Invoice.InvoiceNum), ref iRet); // Delete all the line items that is associated with this invoice for (int i = 0; i < iRet; i++) { int lineItemNum = Convert.ToInt32(ds.Tables[0].Rows[i][0].ToString()); db.ExecuteNonQuery(SQLQueries.deleteLineItem(Invoice.InvoiceNum, lineItemNum)); } // Delete the invoice db.ExecuteNonQuery(SQLQueries.deleteInvoice(Invoice.InvoiceNum)); } catch (Exception ex) { //Just throw the exception throw new Exception(MethodInfo.GetCurrentMethod().DeclaringType.Name + "." + MethodInfo.GetCurrentMethod().Name + " -> " + ex.Message); } }