Added the methods to insert and update invoice records in the database, as well as fixing a bug where the Invoice Notes would disappear on row validation.
This commit is contained in:
@@ -112,8 +112,9 @@ namespace AdvertsingProfitControl
|
||||
{
|
||||
var dataGridView = (DataGridView) sender;
|
||||
if (dataGridView.Rows[e.RowIndex].IsNewRow) return;
|
||||
DateTime dateTime;
|
||||
//Check to make sure the Invoice Date, Invoice Number and the Supplier values are set.
|
||||
if (dataGridView.Rows[e.RowIndex].Cells[(int) InvoiceTableColumns.InvoiceDate].EditedFormattedValue.ToString() == "")
|
||||
if (dataGridView.Rows[e.RowIndex].Cells[(int) InvoiceTableColumns.InvoiceDate].EditedFormattedValue.ToString() == "" || !DateTime.TryParse(dataGridView.Rows[e.RowIndex].Cells[(int)InvoiceTableColumns.InvoiceDate].EditedFormattedValue.ToString(), out dateTime))
|
||||
{
|
||||
MessageBox.Show(@"An invoice date must be specified.", @"Invalid Invoice Date", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
e.Cancel = true;
|
||||
@@ -228,6 +229,9 @@ namespace AdvertsingProfitControl
|
||||
dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].ErrorText = "A Supplier is Required";
|
||||
}
|
||||
break;
|
||||
case (int)InvoiceTableColumns.InvoiceNote:
|
||||
dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = userInput;
|
||||
break;
|
||||
default:
|
||||
//Should only process the InvoiceNetAmountAtCost and InvoiceNetAmount columns.
|
||||
if (e.ColumnIndex != (int) InvoiceTableColumns.Id &&
|
||||
@@ -243,6 +247,7 @@ namespace AdvertsingProfitControl
|
||||
{
|
||||
//Since the input is a number format it to show the cents and display it.
|
||||
dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = Math.Round(parsedNumber, 2).ToString("N", new CultureInfo("en-US"));
|
||||
//dataGridView.RefreshEdit();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1719,6 +1724,12 @@ namespace AdvertsingProfitControl
|
||||
return;
|
||||
}
|
||||
if (!ProcessTrimmingStatusResult(actualSalesDataGridView, "ActualSales", operationStatus, trimmedTable, updateTable)) return;
|
||||
//Commit the Invoice table to the database.
|
||||
var writerStatus = dbW.ProccessInvoiceTable(invoicesDataGridView, dateId, dbT.DatabaseConnectionString);
|
||||
if (writerStatus.GetWritingOperationStatus() != WritingOperationStatus.Failed)
|
||||
{
|
||||
errorLabel.Text = writerStatus.GetErrorMessage();
|
||||
}
|
||||
informationLabel.Text = @"All operations completed successfully.";
|
||||
//Create the transaction scope.
|
||||
//By default the TransactionScopeOption is "Required", so if an ambient transaction does not
|
||||
@@ -2251,7 +2262,6 @@ namespace AdvertsingProfitControl
|
||||
dataGridView.Rows[rowIndex.Key - 1].Cells[(int)SalesTableColumns.IsDirty].Value = false;
|
||||
}
|
||||
informationLabel.Text += Environment.NewLine + tableName + @" table successfully added to the database.";
|
||||
successful = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2274,7 +2284,6 @@ namespace AdvertsingProfitControl
|
||||
else
|
||||
{
|
||||
errorLabel.Text = @"Failed to update the " + trimmedTable + @" table.";
|
||||
successful = false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user