internal void SaveInvoice() { DataSet ds = new DataSet(); clsData = new clsDataAccess(); string sSQL; if (CurrentInvoice.Items != null && CurrentInvoice.Items.Count > 0) { if (CurrentInvoice.InvoiceNumber == null) { sSQL = String.Format(clsMainSQL.SaveNewInvoice, CurrentInvoice.InvoiceDate, CurrentInvoice.Cost); int incId = clsData.InsertNonQuery(sSQL); CurrentInvoice.InvoiceNumber = incId.ToString(); } else { sSQL = String.Format(clsMainSQL.SaveInvoice, CurrentInvoice.InvoiceDate.ToShortDateString(), CurrentInvoice.Cost.ToString(), CurrentInvoice.InvoiceNumber); clsData.ExecuteNonQuery(sSQL); } sSQL = String.Format(clsMainSQL.DeleteLineItems, CurrentInvoice.InvoiceNumber); clsData.ExecuteNonQuery(sSQL); int i = 1; foreach (Item row in CurrentInvoice.Items) { sSQL = String.Format(clsMainSQL.SaveLineItems, CurrentInvoice.InvoiceNumber, i, row.Code); clsData.ExecuteNonQuery(sSQL); i++; } } }