Fixed a bug with the invoice table failing to save an invoice number longer then 9 characters.
This commit is contained in:
Binary file not shown.
@@ -1,4 +1,5 @@
|
|||||||
using System.Collections.Generic;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
using System.Data.OleDb;
|
using System.Data.OleDb;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
@@ -451,7 +452,7 @@ namespace AdvertsingProfitControl
|
|||||||
oleDbCommand.CommandText =
|
oleDbCommand.CommandText =
|
||||||
"INSERT INTO Invoice (InvoiceDate, InvoiceNumber, InvoiceNetAmountAtCost, InvoiceNetAmount, InvoiceNote, FK_Supplier, FK_DateID) VALUES(?,?,?,?,?,?,?)";
|
"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("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("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("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());
|
oleDbCommand.Parameters.AddWithValue("InvoiceNote", table.Rows[i].Cells[(int)InvoiceTableColumns.InvoiceNote].EditedFormattedValue.ToString());
|
||||||
@@ -467,7 +468,7 @@ namespace AdvertsingProfitControl
|
|||||||
oleDbCommand.CommandText =
|
oleDbCommand.CommandText =
|
||||||
"UPDATE Invoice SET InvoiceDate = ?, InvoiceNumber = ?, InvoiceNetAmountAtCost = ?, InvoiceNetAmount = ?, InvoiceNote = ?, FK_Supplier = ?, FK_DateID = ? WHERE ID = ?";
|
"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("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("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("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());
|
oleDbCommand.Parameters.AddWithValue("InvoiceNote", table.Rows[i].Cells[(int)InvoiceTableColumns.InvoiceNote].EditedFormattedValue.ToString());
|
||||||
@@ -523,7 +524,7 @@ namespace AdvertsingProfitControl
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
_logConsole.WriteToLog(FrmLogConsole.Level.Error, "Failed on row " + (lastRowProcessed + 1) + " due to the above error. Dumping contents of row " + (lastRowProcessed + 1) + " from Invoices.");
|
_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();
|
oleDbTransaction?.Rollback();
|
||||||
_logConsole.WriteToLog(FrmLogConsole.Level.Critical, "Rollback completed successfully, Invoice table failed on update.");
|
_logConsole.WriteToLog(FrmLogConsole.Level.Critical, "Rollback completed successfully, Invoice table failed on update.");
|
||||||
|
|||||||
@@ -3295,7 +3295,11 @@ namespace AdvertsingProfitControl
|
|||||||
{
|
{
|
||||||
errorLabel.Text += @"Failed to process actual sales." + Environment.NewLine;
|
errorLabel.Text += @"Failed to process actual sales." + Environment.NewLine;
|
||||||
}
|
}
|
||||||
return success;
|
if (!SaveInvoices(dateId)) return false;
|
||||||
|
if (!SaveComments(dateId)) return false;
|
||||||
|
if (!SaveWeeklySales(dateId)) return false;
|
||||||
|
if (!SaveTaxable(dateId)) return false;
|
||||||
|
return SaveCostAnalysis(dateId) && success;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -3325,6 +3329,222 @@ namespace AdvertsingProfitControl
|
|||||||
return dateId;
|
return dateId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool SaveInvoices(int dateId)
|
||||||
|
{
|
||||||
|
var dbT = new DatabaseTracker();
|
||||||
|
var dbW = new DatabaseWriter(dbT.DatabaseConnectionString);
|
||||||
|
//Commit the Invoice table to the database.
|
||||||
|
var writerStatus = dbW.ProccessInvoiceTable(invoicesDataGridView, dateId, dbT.DatabaseConnectionString);
|
||||||
|
if (writerStatus.GetWritingOperationStatus() == WritingOperationStatus.Failed)
|
||||||
|
{
|
||||||
|
errorLabel.Text = writerStatus.GetErrorMessage();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
informationLabel.Text += writerStatus.GetErrorMessage() + Environment.NewLine;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool SaveComments(int dateId)
|
||||||
|
{
|
||||||
|
var dbT = new DatabaseTracker();
|
||||||
|
var dbW = new DatabaseWriter(dbT.DatabaseConnectionString);
|
||||||
|
//TODO: If the comments are null but there is a comment ID, delete the comments from the database.
|
||||||
|
if (isCommentDirtyCheckBox.Checked)
|
||||||
|
{
|
||||||
|
if (isCommentDirtyCheckBox.Tag == null)
|
||||||
|
{
|
||||||
|
var status = dbW.ProcessComments(commentsTextBox.Text, dateId, dbT.DatabaseConnectionString);
|
||||||
|
if (status.Status == WritingOperationStatus.Failed)
|
||||||
|
{
|
||||||
|
informationLabel.Text += @"Failed to add Comments to the database." + Environment.NewLine;
|
||||||
|
errorLabel.Text = status.ErrorMessage;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
informationLabel.Text += @"Comment(s) processed successfully." + Environment.NewLine;
|
||||||
|
var id = status.Id;
|
||||||
|
isCommentDirtyCheckBox.Tag = id;
|
||||||
|
isCommentDirtyCheckBox.Text = @"IsCommentDirty (" + id + @")";
|
||||||
|
isCommentDirtyCheckBox.Checked = false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//Check for a null comment box and delete the comment ID from the database.
|
||||||
|
//Then if all is successful clear the Tag in the isCommentsDirty check box.
|
||||||
|
var status = dbW.ProcessComments(commentsTextBox.Text, dateId, dbT.DatabaseConnectionString,
|
||||||
|
int.Parse(isCommentDirtyCheckBox.Tag.ToString()));
|
||||||
|
if (status.Status == WritingOperationStatus.Failed)
|
||||||
|
{
|
||||||
|
informationLabel.Text += @"Failed to add Comments to the database." + Environment.NewLine;
|
||||||
|
errorLabel.Text = status.ErrorMessage;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
isCommentDirtyCheckBox.Checked = false;
|
||||||
|
informationLabel.Text += @"Comment(s) processed successfully." + Environment.NewLine;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
informationLabel.Text += @"No changes detected for the comment(s)" + Environment.NewLine;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool SaveWeeklySales(int dateId)
|
||||||
|
{
|
||||||
|
var dbT = new DatabaseTracker();
|
||||||
|
var dbW = new DatabaseWriter(dbT.DatabaseConnectionString);
|
||||||
|
//Begin checking the Weekly Sales.
|
||||||
|
if (isWeeklySalesDirtyCheckBox.Checked)
|
||||||
|
{
|
||||||
|
//Parse out all the text boxes' values in the weekly sales group.
|
||||||
|
var weeklySales = new double[8];
|
||||||
|
weeklySales[0] = sundayWeeklySalesTextBox.Text == "" ? 0 : double.Parse(sundayWeeklySalesTextBox.Text);
|
||||||
|
weeklySales[1] = mondayWeeklySalesTextBox.Text == "" ? 0 : double.Parse(mondayWeeklySalesTextBox.Text);
|
||||||
|
weeklySales[2] = tuesdayWeeklySalesTextBox.Text == "" ? 0 : double.Parse(tuesdayWeeklySalesTextBox.Text);
|
||||||
|
weeklySales[3] = wednesdayWeeklySalesTextBox.Text == "" ? 0 : double.Parse(wednesdayWeeklySalesTextBox.Text);
|
||||||
|
weeklySales[4] = thursdayWeeklySalesTextBox.Text == ""
|
||||||
|
? 0
|
||||||
|
: double.Parse(thursdayWeeklySalesTextBox.Text);
|
||||||
|
weeklySales[5] = fridayWeeklySalesTextBox.Text == "" ? 0 : double.Parse(fridayWeeklySalesTextBox.Text);
|
||||||
|
weeklySales[6] = saturdayWeeklySalesTextBox.Text == ""
|
||||||
|
? 0
|
||||||
|
: double.Parse(saturdayWeeklySalesTextBox.Text);
|
||||||
|
weeklySales[7] = totalWeeklySalesTextBox.Text == "" ? 0 : double.Parse(totalWeeklySalesTextBox.Text);
|
||||||
|
|
||||||
|
if (isWeeklySalesDirtyCheckBox.Tag == null)
|
||||||
|
{
|
||||||
|
//Weekly sales is not in the database.
|
||||||
|
var status = dbW.ProcessWeeklySales(weeklySales, dateId, dbT.DatabaseConnectionString);
|
||||||
|
if (status.Status == WritingOperationStatus.Failed)
|
||||||
|
{
|
||||||
|
informationLabel.Text += @"Failed to add Weekly Sales to the database." + Environment.NewLine;
|
||||||
|
errorLabel.Text = status.ErrorMessage;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
informationLabel.Text += @"Weekly Sales processed successfully." + Environment.NewLine;
|
||||||
|
isWeeklySalesDirtyCheckBox.Tag = status.Id;
|
||||||
|
isWeeklySalesDirtyCheckBox.Text = @"IsWeeklySalesDirty (" + status.Id + @")";
|
||||||
|
isWeeklySalesDirtyCheckBox.Checked = false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var status = dbW.ProcessWeeklySales(weeklySales, dateId, dbT.DatabaseConnectionString,
|
||||||
|
int.Parse(isWeeklySalesDirtyCheckBox.Tag.ToString()));
|
||||||
|
if (status.Status == WritingOperationStatus.Failed)
|
||||||
|
{
|
||||||
|
informationLabel.Text += @"Failed to add Weekly Sales to the database." + Environment.NewLine;
|
||||||
|
errorLabel.Text = status.ErrorMessage;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
isWeeklySalesDirtyCheckBox.Checked = false;
|
||||||
|
informationLabel.Text += @"Weekly Sales updated successfully." + Environment.NewLine;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
informationLabel.Text += @"No changes detected for Weekly Sales." + Environment.NewLine;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool SaveTaxable(int dateId)
|
||||||
|
{
|
||||||
|
var dbT = new DatabaseTracker();
|
||||||
|
var dbW = new DatabaseWriter(dbT.DatabaseConnectionString);
|
||||||
|
//Begin checking the Taxable.
|
||||||
|
if (isTaxableDirtyCheckBox.Checked)
|
||||||
|
{
|
||||||
|
//Parse out all the text boxes' values in the taxable group.
|
||||||
|
var taxable = new double[8];
|
||||||
|
taxable[0] = sundayTaxableTextBox.Text == "" ? 0 : double.Parse(sundayTaxableTextBox.Text);
|
||||||
|
taxable[1] = mondayTaxableTextBox.Text == "" ? 0 : double.Parse(mondayTaxableTextBox.Text);
|
||||||
|
taxable[2] = tuesdayTaxableTextBox.Text == "" ? 0 : double.Parse(tuesdayTaxableTextBox.Text);
|
||||||
|
taxable[3] = wednesdayTaxableTextBox.Text == "" ? 0 : double.Parse(wednesdayTaxableTextBox.Text);
|
||||||
|
taxable[4] = thursdayTaxableTextBox.Text == "" ? 0 : double.Parse(thursdayTaxableTextBox.Text);
|
||||||
|
taxable[5] = fridayTaxableTextBox.Text == "" ? 0 : double.Parse(fridayTaxableTextBox.Text);
|
||||||
|
taxable[6] = saturdayTaxableTextBox.Text == "" ? 0 : double.Parse(saturdayTaxableTextBox.Text);
|
||||||
|
taxable[7] = totalTaxableTextBox.Text == "" ? 0 : double.Parse(totalTaxableTextBox.Text);
|
||||||
|
|
||||||
|
if (isTaxableDirtyCheckBox.Tag == null)
|
||||||
|
{
|
||||||
|
//Taxable is not in the database.
|
||||||
|
var status = dbW.ProcessTaxable(taxable, dateId, dbT.DatabaseConnectionString);
|
||||||
|
if (status.Status == WritingOperationStatus.Failed)
|
||||||
|
{
|
||||||
|
informationLabel.Text += @"Failed to add Taxable to the database." + Environment.NewLine;
|
||||||
|
errorLabel.Text = status.ErrorMessage;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
informationLabel.Text += @"Taxable processed successfully." + Environment.NewLine;
|
||||||
|
isTaxableDirtyCheckBox.Tag = status.Id;
|
||||||
|
isTaxableDirtyCheckBox.Text = @"IsTaxableDirty (" + status.Id + @")";
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var status = dbW.ProcessTaxable(taxable, dateId, dbT.DatabaseConnectionString,
|
||||||
|
int.Parse(isTaxableDirtyCheckBox.Tag.ToString()));
|
||||||
|
if (status.Status == WritingOperationStatus.Failed)
|
||||||
|
{
|
||||||
|
informationLabel.Text += @"Failed to add Taxable to the database." + Environment.NewLine;
|
||||||
|
errorLabel.Text = status.ErrorMessage;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
isTaxableDirtyCheckBox.Checked = false;
|
||||||
|
informationLabel.Text += @"Taxable updated successfully." + Environment.NewLine;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
informationLabel.Text += @"No changes detected for Taxable." + Environment.NewLine;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool SaveCostAnalysis(int dateId)
|
||||||
|
{
|
||||||
|
var dbT = new DatabaseTracker();
|
||||||
|
var dbW = new DatabaseWriter(dbT.DatabaseConnectionString);
|
||||||
|
//Begin checking cost analysis.
|
||||||
|
if (isCostAnalysisDirtyCheckBox.Checked)
|
||||||
|
{
|
||||||
|
//Parse out the cost analysis group values.
|
||||||
|
var costAnalysis = new double[4];
|
||||||
|
costAnalysis[0] = salesPerManHourTextBox.Text == "" ? 0 : double.Parse(salesPerManHourTextBox.Text);
|
||||||
|
costAnalysis[1] = salaryPercentageTextBox.Text == "" ? 0 : double.Parse(salaryPercentageTextBox.Text);
|
||||||
|
costAnalysis[2] = salaryDollarsTextBox.Text == "" ? 0 : double.Parse(salaryDollarsTextBox.Text);
|
||||||
|
costAnalysis[3] = suppliesTextBox.Text == "" ? 0 : double.Parse(suppliesTextBox.Text);
|
||||||
|
|
||||||
|
if (isCostAnalysisDirtyCheckBox.Tag == null)
|
||||||
|
{
|
||||||
|
//Weekly sales is not in the database.
|
||||||
|
var status = dbW.ProcessCostAnalysis(costAnalysis, dateId, dbT.DatabaseConnectionString);
|
||||||
|
if (status.Status == WritingOperationStatus.Failed)
|
||||||
|
{
|
||||||
|
informationLabel.Text += @"Failed to add Cost Analysis to the database." + Environment.NewLine;
|
||||||
|
errorLabel.Text = status.ErrorMessage;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
informationLabel.Text += @"Costs Analysis processed successfully." + Environment.NewLine;
|
||||||
|
isCostAnalysisDirtyCheckBox.Tag = status.Id;
|
||||||
|
isCostAnalysisDirtyCheckBox.Text = @"IsCostAnalysisDirty (" + status.Id + @")";
|
||||||
|
isCostAnalysisDirtyCheckBox.Checked = false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var status = dbW.ProcessCostAnalysis(costAnalysis, dateId, dbT.DatabaseConnectionString,
|
||||||
|
int.Parse(isCostAnalysisDirtyCheckBox.Tag.ToString()));
|
||||||
|
if (status.Status == WritingOperationStatus.Failed)
|
||||||
|
{
|
||||||
|
informationLabel.Text += @"Failed to add Cost Analysis to the database." + Environment.NewLine;
|
||||||
|
errorLabel.Text = status.ErrorMessage;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
isCostAnalysisDirtyCheckBox.Checked = false;
|
||||||
|
informationLabel.Text += @"Cost Analysis updated successfully." + Environment.NewLine;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
informationLabel.Text += @"No changes made to Cost Analysis." + Environment.NewLine;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Table Trimming Operations
|
#region Table Trimming Operations
|
||||||
@@ -3641,200 +3861,13 @@ namespace AdvertsingProfitControl
|
|||||||
return TrimmingOperationResult.CreatedNewInsertionAndUpdateTables;
|
return TrimmingOperationResult.CreatedNewInsertionAndUpdateTables;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool ProcessTrimmingStatusResult(DataGridView dataGridView, string tableName, TrimmingOperationResult operationStatus, DataTable trimmedTable, DataTable updateTable)
|
#endregion
|
||||||
{
|
|
||||||
//Create the database interaction objects.
|
|
||||||
var dbT = new DatabaseTracker();
|
|
||||||
var dbW = new DatabaseWriter(dbT.DatabaseConnectionString);
|
|
||||||
DbTableWriterStatus dbWriterStatus;
|
|
||||||
var successful = false;
|
|
||||||
switch (operationStatus)
|
|
||||||
{
|
|
||||||
case TrimmingOperationResult.NoChangesRequired:
|
|
||||||
informationLabel.Text += @"No changes to the " + TextFormat.AddSpacesToSentence(tableName, false) + @" table detected." + Environment.NewLine;
|
|
||||||
successful = true;
|
|
||||||
break;
|
|
||||||
case TrimmingOperationResult.CreatedNewInsertionTable:
|
|
||||||
dbWriterStatus = dbW.InsertIntoSalesTable(trimmedTable, dbT.DatabaseConnectionString);
|
|
||||||
if (dbWriterStatus.GetErrorMessage() == string.Empty)
|
|
||||||
{
|
|
||||||
//Spin through the collection and update the affected rows.
|
|
||||||
foreach (var rowIndex in dbWriterStatus.GetRowCollection())
|
|
||||||
{
|
|
||||||
dataGridView.Rows[rowIndex.Key - 1].Cells[(int)SalesTableColumns.Id].Value = rowIndex.Value;
|
|
||||||
dataGridView.Rows[rowIndex.Key - 1].Cells[(int)SalesTableColumns.IsDirty].Value = false;
|
|
||||||
dataGridView.Rows[rowIndex.Key - 1].HeaderCell.Style.BackColor = ApplicationColors.EditingSaved;
|
|
||||||
}
|
|
||||||
informationLabel.Text += TextFormat.AddSpacesToSentence(tableName, false) + @" table successfully added to the database." + Environment.NewLine;
|
|
||||||
successful = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
errorLabel.Text = @"Failed to insert " + trimmedTable + @" into the database." + Environment.NewLine;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case TrimmingOperationResult.CreatedUpdateTable:
|
|
||||||
dbWriterStatus = dbW.UpdateSalesTable(updateTable, dbT.DatabaseConnectionString);
|
|
||||||
if (dbWriterStatus.GetErrorMessage() == string.Empty)
|
|
||||||
{
|
|
||||||
//Spin through the collection and update the affected rows.
|
|
||||||
foreach (var rowIndex in dbWriterStatus.GetRowCollection())
|
|
||||||
{
|
|
||||||
//Only reset the IsDirty value to false since the updates when through.
|
|
||||||
dataGridView.Rows[rowIndex.Key - 1].Cells[(int)SalesTableColumns.IsDirty].Value = false;
|
|
||||||
dataGridView.Rows[rowIndex.Key - 1].HeaderCell.Style.BackColor = ApplicationColors.EditingSaved;
|
|
||||||
}
|
|
||||||
informationLabel.Text += TextFormat.AddSpacesToSentence(tableName, false) + @" table successfully updated." + Environment.NewLine;
|
|
||||||
successful = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
errorLabel.Text = @"Failed to update the " + trimmedTable + @" table." + Environment.NewLine;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case TrimmingOperationResult.CreatedNewInsertionAndUpdateTables:
|
|
||||||
//Insert the new values...
|
|
||||||
dbWriterStatus = dbW.InsertIntoSalesTable(trimmedTable, dbT.DatabaseConnectionString);
|
|
||||||
if (dbWriterStatus.GetErrorMessage() == string.Empty)
|
|
||||||
{
|
|
||||||
//Spin through the collection and update the affected rows.
|
|
||||||
foreach (var rowIndex in dbWriterStatus.GetRowCollection())
|
|
||||||
{
|
|
||||||
//Add the ID numbers to the first column since these are new additions to the database.
|
|
||||||
dataGridView.Rows[rowIndex.Key - 1].Cells[(int)SalesTableColumns.Id].Value = rowIndex.Value;
|
|
||||||
dataGridView.Rows[rowIndex.Key - 1].Cells[(int)SalesTableColumns.IsDirty].Value = false;
|
|
||||||
dataGridView.Rows[rowIndex.Key - 1].HeaderCell.Style.BackColor = ApplicationColors.EditingSaved;
|
|
||||||
}
|
|
||||||
informationLabel.Text += TextFormat.AddSpacesToSentence(tableName, false) + @" table successfully added to the database." + Environment.NewLine;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
errorLabel.Text = @"Failed to insert " + trimmedTable + @" into the database." + Environment.NewLine;
|
|
||||||
}
|
|
||||||
//... and update the existing values.
|
|
||||||
dbWriterStatus = dbW.UpdateSalesTable(updateTable, dbT.DatabaseConnectionString);
|
|
||||||
if (dbWriterStatus.GetErrorMessage() == string.Empty)
|
|
||||||
{
|
|
||||||
//Spin through the collection and update the affected rows.
|
|
||||||
foreach (var rowIndex in dbWriterStatus.GetRowCollection())
|
|
||||||
{
|
|
||||||
//Only reset the IsDirty value to false since the updates when through.
|
|
||||||
dataGridView.Rows[rowIndex.Key - 1].Cells[(int)SalesTableColumns.IsDirty].Value = false;
|
|
||||||
dataGridView.Rows[rowIndex.Key - 1].HeaderCell.Style.BackColor = ApplicationColors.EditingSaved;
|
|
||||||
}
|
|
||||||
informationLabel.Text += TextFormat.AddSpacesToSentence(tableName, false) + @" table successfully updated." + Environment.NewLine;
|
|
||||||
successful = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
errorLabel.Text = @"Failed to update the " + trimmedTable + @" table." + Environment.NewLine;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return successful;
|
|
||||||
}
|
|
||||||
|
|
||||||
private bool ProcessTrimmingStatusForInventory(TrimmingOperationResult operationStatus, DataTable trimmedTable, DataTable updateTable)
|
|
||||||
{
|
|
||||||
//Create the database interaction objects.
|
|
||||||
var dbT = new DatabaseTracker();
|
|
||||||
var dbW = new DatabaseWriter(dbT.DatabaseConnectionString);
|
|
||||||
DbTableWriterStatus dbWriterStatus;
|
|
||||||
var successful = false;
|
|
||||||
switch (operationStatus)
|
|
||||||
{
|
|
||||||
case TrimmingOperationResult.NoChangesRequired:
|
|
||||||
informationLabel.Text += @"No changes to the Inventory table detected." + Environment.NewLine;
|
|
||||||
successful = true;
|
|
||||||
break;
|
|
||||||
case TrimmingOperationResult.CreatedNewInsertionTable:
|
|
||||||
dbWriterStatus = dbW.InsertIntoInventoryTable(trimmedTable, dbT.DatabaseConnectionString);
|
|
||||||
if (dbWriterStatus.GetErrorMessage() == string.Empty)
|
|
||||||
{
|
|
||||||
//Spin through the collection and update the affected rows.
|
|
||||||
foreach (var rowIndex in dbWriterStatus.GetRowCollection())
|
|
||||||
{
|
|
||||||
inventoryDataGridView.Rows[rowIndex.Key - 1].Cells[(int)InventoryTableColumns.Id].Value = rowIndex.Value;
|
|
||||||
inventoryDataGridView.Rows[rowIndex.Key - 1].Cells[(int)InventoryTableColumns.IsDirty].Value = false;
|
|
||||||
inventoryDataGridView.Rows[rowIndex.Key - 1].HeaderCell.Style.BackColor = ApplicationColors.EditingSaved;
|
|
||||||
}
|
|
||||||
informationLabel.Text += @"Inventory table successfully added to the database." + Environment.NewLine;
|
|
||||||
successful = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
errorLabel.Text = @"Failed to insert Inventory table into the database." + Environment.NewLine;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case TrimmingOperationResult.CreatedUpdateTable:
|
|
||||||
dbWriterStatus = dbW.UpdateInventoryTable(updateTable, dbT.DatabaseConnectionString);
|
|
||||||
if (dbWriterStatus.GetErrorMessage() == string.Empty)
|
|
||||||
{
|
|
||||||
//Spin through the collection and update the affected rows.
|
|
||||||
foreach (var rowIndex in dbWriterStatus.GetRowCollection())
|
|
||||||
{
|
|
||||||
//Only reset the IsDirty value to false since the updates when through.
|
|
||||||
inventoryDataGridView.Rows[rowIndex.Key - 1].Cells[(int)InventoryTableColumns.IsDirty].Value = false;
|
|
||||||
inventoryDataGridView.Rows[rowIndex.Key - 1].HeaderCell.Style.BackColor = ApplicationColors.EditingSaved;
|
|
||||||
}
|
|
||||||
informationLabel.Text += @"Inventory table successfully updated." + Environment.NewLine;
|
|
||||||
successful = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
errorLabel.Text = @"Failed to update the changes in the Inventory table." + Environment.NewLine;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case TrimmingOperationResult.CreatedNewInsertionAndUpdateTables:
|
|
||||||
//Insert the new values...
|
|
||||||
dbWriterStatus = dbW.InsertIntoInventoryTable(trimmedTable, dbT.DatabaseConnectionString);
|
|
||||||
if (dbWriterStatus.GetErrorMessage() == string.Empty)
|
|
||||||
{
|
|
||||||
//Spin through the collection and update the affected rows.
|
|
||||||
foreach (var rowIndex in dbWriterStatus.GetRowCollection())
|
|
||||||
{
|
|
||||||
//Add the ID numbers to the first column since these are new additions to the database.
|
|
||||||
inventoryDataGridView.Rows[rowIndex.Key - 1].Cells[(int)InventoryTableColumns.Id].Value = rowIndex.Value;
|
|
||||||
inventoryDataGridView.Rows[rowIndex.Key - 1].Cells[(int)InventoryTableColumns.IsDirty].Value = false;
|
|
||||||
inventoryDataGridView.Rows[rowIndex.Key - 1].HeaderCell.Style.BackColor = ApplicationColors.EditingSaved;
|
|
||||||
}
|
|
||||||
informationLabel.Text += @"Inventory table successfully added to the database." + Environment.NewLine;
|
|
||||||
successful = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
errorLabel.Text = @"Failed to insert Inventory table into the database." + Environment.NewLine;
|
|
||||||
}
|
|
||||||
dbWriterStatus = dbW.UpdateInventoryTable(updateTable, dbT.DatabaseConnectionString);
|
|
||||||
if (dbWriterStatus.GetErrorMessage() == string.Empty)
|
|
||||||
{
|
|
||||||
//Spin through the collection and update the affected rows.
|
|
||||||
foreach (var rowIndex in dbWriterStatus.GetRowCollection())
|
|
||||||
{
|
|
||||||
//Only reset the IsDirty value to false since the updates when through.
|
|
||||||
inventoryDataGridView.Rows[rowIndex.Key - 1].Cells[(int)InventoryTableColumns.IsDirty].Value = false;
|
|
||||||
inventoryDataGridView.Rows[rowIndex.Key - 1].HeaderCell.Style.BackColor = ApplicationColors.EditingSaved;
|
|
||||||
}
|
|
||||||
informationLabel.Text += @"Inventory table successfully updated." + Environment.NewLine;
|
|
||||||
successful = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
errorLabel.Text = @"Failed to update the changes in the Inventory table." + Environment.NewLine;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
inventoryDataGridView.RefreshEdit();
|
|
||||||
return successful;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addRecordButton_Click(object sender, EventArgs e)
|
private void addRecordButton_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
SaveRecords();
|
SaveRecords();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
//private void NormalizeApcTables(DataTable projections, DataTable inventory, DataTable actualSales, string dateId)
|
//private void NormalizeApcTables(DataTable projections, DataTable inventory, DataTable actualSales, string dateId)
|
||||||
//{
|
//{
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
|
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
|
||||||
</dsig:Transforms>
|
</dsig:Transforms>
|
||||||
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
|
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
|
||||||
<dsig:DigestValue>Btzwp78H3RT2AmoucaHpeRFbGzPf83asDL/GO1dGVPA=</dsig:DigestValue>
|
<dsig:DigestValue>1Hy88d0pyLqSm+LXJWOGDCgRmXG4f4D5il87bOZtle0=</dsig:DigestValue>
|
||||||
</hash>
|
</hash>
|
||||||
</dependentAssembly>
|
</dependentAssembly>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|||||||
@@ -43,14 +43,14 @@
|
|||||||
</dependentAssembly>
|
</dependentAssembly>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<dependentAssembly dependencyType="install" allowDelayedBinding="true" codebase="AdvertsingProfitControl.exe" size="3617280">
|
<dependentAssembly dependencyType="install" allowDelayedBinding="true" codebase="AdvertsingProfitControl.exe" size="3617792">
|
||||||
<assemblyIdentity name="AdvertsingProfitControl" version="0.9.5.2" language="neutral" processorArchitecture="amd64" />
|
<assemblyIdentity name="AdvertsingProfitControl" version="0.9.5.2" language="neutral" processorArchitecture="amd64" />
|
||||||
<hash>
|
<hash>
|
||||||
<dsig:Transforms>
|
<dsig:Transforms>
|
||||||
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
|
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
|
||||||
</dsig:Transforms>
|
</dsig:Transforms>
|
||||||
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
|
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
|
||||||
<dsig:DigestValue>xkEtzq+MLDnIJnChEMusRcJt0LD8/sPMW87LQ9g7ulE=</dsig:DigestValue>
|
<dsig:DigestValue>9J9ugoTiC4+wY6MW3l8lpcH7ZE4DSPiDNUUMrWgEDvE=</dsig:DigestValue>
|
||||||
</hash>
|
</hash>
|
||||||
</dependentAssembly>
|
</dependentAssembly>
|
||||||
</dependency>
|
</dependency>
|
||||||
@@ -93,7 +93,7 @@
|
|||||||
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
|
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
|
||||||
</dsig:Transforms>
|
</dsig:Transforms>
|
||||||
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
|
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
|
||||||
<dsig:DigestValue>yZCLj+jy8vUBAeTKpwbwGxsDAc4IOfwKM+XGhtNBq5M=</dsig:DigestValue>
|
<dsig:DigestValue>h0U0mLzUnhEKHaiuXsTC+7xvKixcE9+lG0nu0vBTYdI=</dsig:DigestValue>
|
||||||
</hash>
|
</hash>
|
||||||
</file>
|
</file>
|
||||||
<file name="Stretched Logo Collection.ico" size="370070">
|
<file name="Stretched Logo Collection.ico" size="370070">
|
||||||
|
|||||||
Reference in New Issue
Block a user