Fixed a bug with the invoice table failing to save an invoice number longer then 9 characters.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.OleDb;
|
||||
using System.Runtime.InteropServices;
|
||||
@@ -451,7 +452,7 @@ namespace AdvertsingProfitControl
|
||||
oleDbCommand.CommandText =
|
||||
"INSERT INTO Invoice (InvoiceDate, InvoiceNumber, InvoiceNetAmountAtCost, InvoiceNetAmount, InvoiceNote, FK_Supplier, FK_DateID) VALUES(?,?,?,?,?,?,?)";
|
||||
oleDbCommand.Parameters.AddWithValue("InvoiceDate", table.Rows[i].Cells[(int)InvoiceTableColumns.InvoiceDate].EditedFormattedValue.ToString());
|
||||
oleDbCommand.Parameters.AddWithValue("InvoiceNumber", long.Parse(table.Rows[i].Cells[(int)InvoiceTableColumns.InvoiceNumber].EditedFormattedValue.ToString()));
|
||||
oleDbCommand.Parameters.AddWithValue("InvoiceNumber", table.Rows[i].Cells[(int)InvoiceTableColumns.InvoiceNumber].EditedFormattedValue.ToString());
|
||||
oleDbCommand.Parameters.AddWithValue("InvoiceNetAmountAtCost", table.Rows[i].Cells[(int)InvoiceTableColumns.InvoiceNetAmountAtCost].EditedFormattedValue.ToString() == "" ? 0 : double.Parse(table.Rows[i].Cells[(int)InvoiceTableColumns.InvoiceNetAmountAtCost].EditedFormattedValue.ToString()));
|
||||
oleDbCommand.Parameters.AddWithValue("InvoiceNetAmount", table.Rows[i].Cells[(int)InvoiceTableColumns.InvoiceNetAmount].EditedFormattedValue.ToString() == "" ? 0 : double.Parse(table.Rows[i].Cells[(int)InvoiceTableColumns.InvoiceNetAmount].EditedFormattedValue.ToString()));
|
||||
oleDbCommand.Parameters.AddWithValue("InvoiceNote", table.Rows[i].Cells[(int)InvoiceTableColumns.InvoiceNote].EditedFormattedValue.ToString());
|
||||
@@ -467,7 +468,7 @@ namespace AdvertsingProfitControl
|
||||
oleDbCommand.CommandText =
|
||||
"UPDATE Invoice SET InvoiceDate = ?, InvoiceNumber = ?, InvoiceNetAmountAtCost = ?, InvoiceNetAmount = ?, InvoiceNote = ?, FK_Supplier = ?, FK_DateID = ? WHERE ID = ?";
|
||||
oleDbCommand.Parameters.AddWithValue("InvoiceDate", table.Rows[i].Cells[(int)InvoiceTableColumns.InvoiceDate].EditedFormattedValue.ToString());
|
||||
oleDbCommand.Parameters.AddWithValue("InvoiceNumber", long.Parse(table.Rows[i].Cells[(int)InvoiceTableColumns.InvoiceNumber].EditedFormattedValue.ToString()));
|
||||
oleDbCommand.Parameters.AddWithValue("InvoiceNumber", table.Rows[i].Cells[(int)InvoiceTableColumns.InvoiceNumber].EditedFormattedValue.ToString());
|
||||
oleDbCommand.Parameters.AddWithValue("InvoiceNetAmountAtCost", table.Rows[i].Cells[(int)InvoiceTableColumns.InvoiceNetAmountAtCost].EditedFormattedValue.ToString() == "" ? 0 : double.Parse(table.Rows[i].Cells[(int)InvoiceTableColumns.InvoiceNetAmountAtCost].EditedFormattedValue.ToString()));
|
||||
oleDbCommand.Parameters.AddWithValue("InvoiceNetAmount", table.Rows[i].Cells[(int)InvoiceTableColumns.InvoiceNetAmount].EditedFormattedValue.ToString() == "" ? 0 : double.Parse(table.Rows[i].Cells[(int)InvoiceTableColumns.InvoiceNetAmount].EditedFormattedValue.ToString()));
|
||||
oleDbCommand.Parameters.AddWithValue("InvoiceNote", table.Rows[i].Cells[(int)InvoiceTableColumns.InvoiceNote].EditedFormattedValue.ToString());
|
||||
@@ -523,7 +524,7 @@ namespace AdvertsingProfitControl
|
||||
else
|
||||
{
|
||||
_logConsole.WriteToLog(FrmLogConsole.Level.Error, "Failed on row " + (lastRowProcessed + 1) + " due to the above error. Dumping contents of row " + (lastRowProcessed + 1) + " from Invoices.");
|
||||
status.SetErrorMessage("Failed to write to the database on row " + (lastRowProcessed + 1) + ".");
|
||||
status.SetErrorMessage("Failed to save invoice on row " + (lastRowProcessed + 1) + " to the database.");
|
||||
}
|
||||
oleDbTransaction?.Rollback();
|
||||
_logConsole.WriteToLog(FrmLogConsole.Level.Critical, "Rollback completed successfully, Invoice table failed on update.");
|
||||
|
||||
Reference in New Issue
Block a user