Updated the UI of the add record form. Added support to clear the APC tables if even one fails to be added to the database. Fixed a crash bug with the trimming operations where Header and Member Booleans would be null.

This commit is contained in:
2016-12-08 01:02:01 -06:00
parent 0bf2290ab0
commit 91c2326db2
6 changed files with 280 additions and 296 deletions
+59 -13
View File
@@ -359,7 +359,7 @@ namespace AdvertsingProfitControl
oleDbTransaction.Commit(); oleDbTransaction.Commit();
foreach (DataRow row in table.Rows) foreach (DataRow row in table.Rows)
{ {
var rowId = RetrieveRowId(table.TableName, int.Parse(row[4].ToString()), int.Parse(row[8].ToString()), int.Parse(table.Rows[7].ToString())); var rowId = RetrieveRowId(table.TableName, int.Parse(row[4].ToString()), int.Parse(row[8].ToString()), int.Parse(row[7].ToString()));
if (int.Parse(row[7].ToString()) != 0) if (int.Parse(row[7].ToString()) != 0)
{ {
//Account for the ad special row. //Account for the ad special row.
@@ -421,6 +421,7 @@ namespace AdvertsingProfitControl
OleDbTransaction oleDbTransaction = null; OleDbTransaction oleDbTransaction = null;
try try
{ {
var dirtyRowsProcessed = 0;
oleDbConnection.Open(); oleDbConnection.Open();
oleDbTransaction = oleDbConnection.BeginTransaction(); oleDbTransaction = oleDbConnection.BeginTransaction();
oleDbCommand.Transaction = oleDbTransaction; oleDbCommand.Transaction = oleDbTransaction;
@@ -432,6 +433,7 @@ namespace AdvertsingProfitControl
lastRowProcessed = i + 1; lastRowProcessed = i + 1;
continue; continue;
} }
dirtyRowsProcessed++;
//Grab the supplier ID number before moving forward. //Grab the supplier ID number before moving forward.
var supplierId = RetrieveSupplierId( var supplierId = RetrieveSupplierId(
table.Rows[i].Cells[(int) InvoiceTableColumns.Supplier].EditedFormattedValue.ToString()); table.Rows[i].Cells[(int) InvoiceTableColumns.Supplier].EditedFormattedValue.ToString());
@@ -439,6 +441,7 @@ namespace AdvertsingProfitControl
{ {
status.SetErrorMessage("Failed to obtain supplier ID number for " + table.Rows[i].Cells[(int)InvoiceTableColumns.Supplier].EditedFormattedValue + "."); status.SetErrorMessage("Failed to obtain supplier ID number for " + table.Rows[i].Cells[(int)InvoiceTableColumns.Supplier].EditedFormattedValue + ".");
status.SetStatus(WritingOperationStatus.Failed); status.SetStatus(WritingOperationStatus.Failed);
oleDbTransaction.Rollback();
return status; return status;
} }
//Check whether or not the row is already in the database by seeing if anything is in the ID number cell. //Check whether or not the row is already in the database by seeing if anything is in the ID number cell.
@@ -480,23 +483,32 @@ namespace AdvertsingProfitControl
oleDbTransaction.Commit(); oleDbTransaction.Commit();
foreach (DataGridViewRow row in table.Rows) foreach (DataGridViewRow row in table.Rows)
{ {
if (rowsAdded.Contains(row.Index)) if(row.IsNewRow) continue;
{ if (!rowsAdded.Contains(row.Index)) continue;
var supplierId = RetrieveSupplierId(row.Cells[(int)InvoiceTableColumns.Supplier].EditedFormattedValue.ToString()); var supplierId = RetrieveSupplierId(row.Cells[(int)InvoiceTableColumns.Supplier].EditedFormattedValue.ToString());
var invoiceIdNumber = var invoiceIdNumber =
RetrieveInvoiceId( RetrieveInvoiceId(
row.Cells[(int)InvoiceTableColumns.InvoiceDate].EditedFormattedValue row.Cells[(int)InvoiceTableColumns.InvoiceDate].EditedFormattedValue
.ToString(), .ToString(),
long.Parse( long.Parse(
row.Cells[(int)InvoiceTableColumns.InvoiceNumber].EditedFormattedValue row.Cells[(int)InvoiceTableColumns.InvoiceNumber].EditedFormattedValue
.ToString()), supplierId, dateId); .ToString()), supplierId, dateId);
row.Cells[(int)InvoiceTableColumns.Id].Value = invoiceIdNumber; row.Cells[(int)InvoiceTableColumns.Id].Value = invoiceIdNumber;
}
row.Cells[(int)InvoiceTableColumns.IsDirty].Value = false; row.Cells[(int)InvoiceTableColumns.IsDirty].Value = false;
row.HeaderCell.Style.BackColor = ApplicationColors.EditingSaved;
} }
table.RefreshEdit(); table.RefreshEdit();
//Set the status. //Set the status.
status.SetStatus(WritingOperationStatus.InsertionSuccessful); status.SetStatus(WritingOperationStatus.InsertionSuccessful);
//Set the message to be used on the calling form since we don't have access to the form's information label.
if (dirtyRowsProcessed == 0)
{
status.SetErrorMessage("No changes to the Invoices table detected.");
}
else
{
status.SetErrorMessage("Invoices processed successfully.");
}
} }
catch (OleDbException e) catch (OleDbException e)
{ {
@@ -765,6 +777,40 @@ namespace AdvertsingProfitControl
return status; return status;
} }
/// <summary>
/// Deletes the contents for the specified table where the date IDs
/// match the one sent to this method.
/// </summary>
/// <param name="tableName">The name of the table in the database to be trimmed.</param>
/// <param name="dateId">The ID number for the date that is to be dropped.</param>
/// <param name="connectionString">The connection info for the database.</param>
public void DeleteApcDataEntriesByDate(string tableName, int dateId, string connectionString)
{
var oleDbConnection = new OleDbConnection(connectionString);
var oleDbCommand = new OleDbCommand
{
Connection = oleDbConnection,
CommandText = "DELETE * FROM " + tableName + " WHERE FK_DateID = ?"
};
oleDbCommand.Parameters.AddWithValue("DateID", dateId);
try
{
oleDbConnection.Open();
oleDbCommand.ExecuteNonQuery();
}
catch (OleDbException e)
{
_logConsole.WriteToLog(FrmLogConsole.Level.Error,
"Failed to delete the entries in " + tableName + " with the date ID of " + dateId + ".");
_logConsole.WriteToLog(FrmLogConsole.Level.Error, e.Message);
}
finally
{
oleDbConnection.Close();
}
}
/// <summary> /// <summary>
/// Inserts a new ad item into the database and returns the new item's ID number. /// Inserts a new ad item into the database and returns the new item's ID number.
/// Supports rolling back as to not corrupt the database. /// Supports rolling back as to not corrupt the database.
+53 -94
View File
@@ -51,6 +51,7 @@
this.isTaxableDirtyCheckBox = new System.Windows.Forms.CheckBox(); this.isTaxableDirtyCheckBox = new System.Windows.Forms.CheckBox();
this.isWeeklySalesDirtyCheckBox = new System.Windows.Forms.CheckBox(); this.isWeeklySalesDirtyCheckBox = new System.Windows.Forms.CheckBox();
this.isCommentDirtyCheckBox = new System.Windows.Forms.CheckBox(); this.isCommentDirtyCheckBox = new System.Windows.Forms.CheckBox();
this.informationLabel = new System.Windows.Forms.Label();
this.mainMenuStrip = new System.Windows.Forms.MenuStrip(); this.mainMenuStrip = new System.Windows.Forms.MenuStrip();
this.FileMainMenu = new System.Windows.Forms.ToolStripMenuItem(); this.FileMainMenu = new System.Windows.Forms.ToolStripMenuItem();
this.clearFormFileMainMenu = new System.Windows.Forms.ToolStripMenuItem(); this.clearFormFileMainMenu = new System.Windows.Forms.ToolStripMenuItem();
@@ -101,14 +102,10 @@
this.tuesdayTaxableLabel = new System.Windows.Forms.Label(); this.tuesdayTaxableLabel = new System.Windows.Forms.Label();
this.saturdayTaxableTextBox = new System.Windows.Forms.TextBox(); this.saturdayTaxableTextBox = new System.Windows.Forms.TextBox();
this.dateGroupBox = new System.Windows.Forms.GroupBox(); this.dateGroupBox = new System.Windows.Forms.GroupBox();
this.monthCalendarInstructionsLabel = new System.Windows.Forms.Label(); this.weekEndingCalendar = new System.Windows.Forms.MonthCalendar();
this.weekEndingMonthCalendar = new System.Windows.Forms.MonthCalendar();
this.dateTimeMaskedTextBoxPanel = new System.Windows.Forms.Panel(); this.dateTimeMaskedTextBoxPanel = new System.Windows.Forms.Panel();
this.errorLabel = new System.Windows.Forms.Label();
this.weekEndingMaskedTextBox = new System.Windows.Forms.MaskedTextBox();
this.weekEndingMaskedTextBoxInstructionLabel = new System.Windows.Forms.Label();
this.informationPanel = new System.Windows.Forms.Panel(); this.informationPanel = new System.Windows.Forms.Panel();
this.informationLabel = new System.Windows.Forms.Label(); this.errorLabel = new System.Windows.Forms.Label();
this.addRecordButton = new System.Windows.Forms.Button(); this.addRecordButton = new System.Windows.Forms.Button();
this.commentsGroupBox.SuspendLayout(); this.commentsGroupBox.SuspendLayout();
this.mainTabControl.SuspendLayout(); this.mainTabControl.SuspendLayout();
@@ -142,7 +139,7 @@
this.commentsGroupBox.Margin = new System.Windows.Forms.Padding(4); this.commentsGroupBox.Margin = new System.Windows.Forms.Padding(4);
this.commentsGroupBox.Name = "commentsGroupBox"; this.commentsGroupBox.Name = "commentsGroupBox";
this.commentsGroupBox.Padding = new System.Windows.Forms.Padding(4); this.commentsGroupBox.Padding = new System.Windows.Forms.Padding(4);
this.commentsGroupBox.Size = new System.Drawing.Size(461, 223); this.commentsGroupBox.Size = new System.Drawing.Size(461, 177);
this.commentsGroupBox.TabIndex = 2; this.commentsGroupBox.TabIndex = 2;
this.commentsGroupBox.TabStop = false; this.commentsGroupBox.TabStop = false;
this.commentsGroupBox.Text = "Comments"; this.commentsGroupBox.Text = "Comments";
@@ -154,7 +151,8 @@
this.commentsTextBox.MaxLength = 256; this.commentsTextBox.MaxLength = 256;
this.commentsTextBox.Multiline = true; this.commentsTextBox.Multiline = true;
this.commentsTextBox.Name = "commentsTextBox"; this.commentsTextBox.Name = "commentsTextBox";
this.commentsTextBox.Size = new System.Drawing.Size(453, 193); this.commentsTextBox.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
this.commentsTextBox.Size = new System.Drawing.Size(453, 147);
this.commentsTextBox.TabIndex = 4; this.commentsTextBox.TabIndex = 4;
// //
// mainTabControl // mainTabControl
@@ -303,7 +301,6 @@
// //
// debugPanel // debugPanel
// //
this.debugPanel.Controls.Add(this.informationLabel);
this.debugPanel.Controls.Add(this.generateCostAnalysisIdButton); this.debugPanel.Controls.Add(this.generateCostAnalysisIdButton);
this.debugPanel.Controls.Add(this.generateTaxableIdButton); this.debugPanel.Controls.Add(this.generateTaxableIdButton);
this.debugPanel.Controls.Add(this.generateWeeklySalesIdButton); this.debugPanel.Controls.Add(this.generateWeeklySalesIdButton);
@@ -408,6 +405,14 @@
this.isCommentDirtyCheckBox.Text = "IsCommentDirty"; this.isCommentDirtyCheckBox.Text = "IsCommentDirty";
this.isCommentDirtyCheckBox.UseVisualStyleBackColor = true; this.isCommentDirtyCheckBox.UseVisualStyleBackColor = true;
// //
// informationLabel
//
this.informationLabel.AutoSize = true;
this.informationLabel.Location = new System.Drawing.Point(0, 7);
this.informationLabel.Name = "informationLabel";
this.informationLabel.Size = new System.Drawing.Size(0, 25);
this.informationLabel.TabIndex = 27;
//
// mainMenuStrip // mainMenuStrip
// //
this.mainLayoutPanel.SetColumnSpan(this.mainMenuStrip, 4); this.mainLayoutPanel.SetColumnSpan(this.mainMenuStrip, 4);
@@ -464,8 +469,8 @@
this.mainLayoutPanel.RowCount = 4; this.mainLayoutPanel.RowCount = 4;
this.mainLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 35F)); this.mainLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 35F));
this.mainLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 60F)); this.mainLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 60F));
this.mainLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 25F)); this.mainLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 20F));
this.mainLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 15F)); this.mainLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 20F));
this.mainLayoutPanel.Size = new System.Drawing.Size(1876, 961); this.mainLayoutPanel.Size = new System.Drawing.Size(1876, 961);
this.mainLayoutPanel.TabIndex = 0; this.mainLayoutPanel.TabIndex = 0;
// //
@@ -482,28 +487,28 @@
this.costAnalysisGroupBox.Dock = System.Windows.Forms.DockStyle.Fill; this.costAnalysisGroupBox.Dock = System.Windows.Forms.DockStyle.Fill;
this.costAnalysisGroupBox.Location = new System.Drawing.Point(1410, 593); this.costAnalysisGroupBox.Location = new System.Drawing.Point(1410, 593);
this.costAnalysisGroupBox.Name = "costAnalysisGroupBox"; this.costAnalysisGroupBox.Name = "costAnalysisGroupBox";
this.costAnalysisGroupBox.Size = new System.Drawing.Size(463, 225); this.costAnalysisGroupBox.Size = new System.Drawing.Size(463, 179);
this.costAnalysisGroupBox.TabIndex = 6; this.costAnalysisGroupBox.TabIndex = 6;
this.costAnalysisGroupBox.TabStop = false; this.costAnalysisGroupBox.TabStop = false;
this.costAnalysisGroupBox.Text = "Cost Analysis"; this.costAnalysisGroupBox.Text = "Cost Analysis";
// //
// suppliesTextBox // suppliesTextBox
// //
this.suppliesTextBox.Location = new System.Drawing.Point(205, 185); this.suppliesTextBox.Location = new System.Drawing.Point(203, 139);
this.suppliesTextBox.Name = "suppliesTextBox"; this.suppliesTextBox.Name = "suppliesTextBox";
this.suppliesTextBox.Size = new System.Drawing.Size(199, 29); this.suppliesTextBox.Size = new System.Drawing.Size(199, 29);
this.suppliesTextBox.TabIndex = 25; this.suppliesTextBox.TabIndex = 25;
// //
// salaryPercentageTextBox // salaryPercentageTextBox
// //
this.salaryPercentageTextBox.Location = new System.Drawing.Point(205, 87); this.salaryPercentageTextBox.Location = new System.Drawing.Point(203, 69);
this.salaryPercentageTextBox.Name = "salaryPercentageTextBox"; this.salaryPercentageTextBox.Name = "salaryPercentageTextBox";
this.salaryPercentageTextBox.Size = new System.Drawing.Size(199, 29); this.salaryPercentageTextBox.Size = new System.Drawing.Size(199, 29);
this.salaryPercentageTextBox.TabIndex = 23; this.salaryPercentageTextBox.TabIndex = 23;
// //
// salaryDollarsTextBox // salaryDollarsTextBox
// //
this.salaryDollarsTextBox.Location = new System.Drawing.Point(205, 136); this.salaryDollarsTextBox.Location = new System.Drawing.Point(203, 104);
this.salaryDollarsTextBox.Name = "salaryDollarsTextBox"; this.salaryDollarsTextBox.Name = "salaryDollarsTextBox";
this.salaryDollarsTextBox.Size = new System.Drawing.Size(199, 29); this.salaryDollarsTextBox.Size = new System.Drawing.Size(199, 29);
this.salaryDollarsTextBox.TabIndex = 24; this.salaryDollarsTextBox.TabIndex = 24;
@@ -511,7 +516,7 @@
// salesPerManHourLabel // salesPerManHourLabel
// //
this.salesPerManHourLabel.AutoSize = true; this.salesPerManHourLabel.AutoSize = true;
this.salesPerManHourLabel.Location = new System.Drawing.Point(5, 38); this.salesPerManHourLabel.Location = new System.Drawing.Point(3, 34);
this.salesPerManHourLabel.Name = "salesPerManHourLabel"; this.salesPerManHourLabel.Name = "salesPerManHourLabel";
this.salesPerManHourLabel.Size = new System.Drawing.Size(194, 25); this.salesPerManHourLabel.Size = new System.Drawing.Size(194, 25);
this.salesPerManHourLabel.TabIndex = 0; this.salesPerManHourLabel.TabIndex = 0;
@@ -520,7 +525,7 @@
// salaryPercentageLabel // salaryPercentageLabel
// //
this.salaryPercentageLabel.AutoSize = true; this.salaryPercentageLabel.AutoSize = true;
this.salaryPercentageLabel.Location = new System.Drawing.Point(20, 87); this.salaryPercentageLabel.Location = new System.Drawing.Point(18, 69);
this.salaryPercentageLabel.Name = "salaryPercentageLabel"; this.salaryPercentageLabel.Name = "salaryPercentageLabel";
this.salaryPercentageLabel.Size = new System.Drawing.Size(179, 25); this.salaryPercentageLabel.Size = new System.Drawing.Size(179, 25);
this.salaryPercentageLabel.TabIndex = 1; this.salaryPercentageLabel.TabIndex = 1;
@@ -528,7 +533,7 @@
// //
// salesPerManHourTextBox // salesPerManHourTextBox
// //
this.salesPerManHourTextBox.Location = new System.Drawing.Point(205, 38); this.salesPerManHourTextBox.Location = new System.Drawing.Point(203, 34);
this.salesPerManHourTextBox.Name = "salesPerManHourTextBox"; this.salesPerManHourTextBox.Name = "salesPerManHourTextBox";
this.salesPerManHourTextBox.Size = new System.Drawing.Size(199, 29); this.salesPerManHourTextBox.Size = new System.Drawing.Size(199, 29);
this.salesPerManHourTextBox.TabIndex = 22; this.salesPerManHourTextBox.TabIndex = 22;
@@ -536,7 +541,7 @@
// salaryDollarsLabel // salaryDollarsLabel
// //
this.salaryDollarsLabel.AutoSize = true; this.salaryDollarsLabel.AutoSize = true;
this.salaryDollarsLabel.Location = new System.Drawing.Point(60, 136); this.salaryDollarsLabel.Location = new System.Drawing.Point(58, 104);
this.salaryDollarsLabel.Name = "salaryDollarsLabel"; this.salaryDollarsLabel.Name = "salaryDollarsLabel";
this.salaryDollarsLabel.Size = new System.Drawing.Size(139, 25); this.salaryDollarsLabel.Size = new System.Drawing.Size(139, 25);
this.salaryDollarsLabel.TabIndex = 2; this.salaryDollarsLabel.TabIndex = 2;
@@ -545,7 +550,7 @@
// suppliesLabel // suppliesLabel
// //
this.suppliesLabel.AutoSize = true; this.suppliesLabel.AutoSize = true;
this.suppliesLabel.Location = new System.Drawing.Point(105, 185); this.suppliesLabel.Location = new System.Drawing.Point(103, 139);
this.suppliesLabel.Name = "suppliesLabel"; this.suppliesLabel.Name = "suppliesLabel";
this.suppliesLabel.Size = new System.Drawing.Size(94, 25); this.suppliesLabel.Size = new System.Drawing.Size(94, 25);
this.suppliesLabel.TabIndex = 3; this.suppliesLabel.TabIndex = 3;
@@ -876,8 +881,7 @@
// //
// dateGroupBox // dateGroupBox
// //
this.dateGroupBox.Controls.Add(this.monthCalendarInstructionsLabel); this.dateGroupBox.Controls.Add(this.weekEndingCalendar);
this.dateGroupBox.Controls.Add(this.weekEndingMonthCalendar);
this.dateGroupBox.Dock = System.Windows.Forms.DockStyle.Fill; this.dateGroupBox.Dock = System.Windows.Forms.DockStyle.Fill;
this.dateGroupBox.Location = new System.Drawing.Point(3, 593); this.dateGroupBox.Location = new System.Drawing.Point(3, 593);
this.dateGroupBox.Name = "dateGroupBox"; this.dateGroupBox.Name = "dateGroupBox";
@@ -887,91 +891,49 @@
this.dateGroupBox.TabStop = false; this.dateGroupBox.TabStop = false;
this.dateGroupBox.Text = "Week Ending Date"; this.dateGroupBox.Text = "Week Ending Date";
// //
// monthCalendarInstructionsLabel // weekEndingCalendar
// //
this.monthCalendarInstructionsLabel.AutoSize = true; this.weekEndingCalendar.BackColor = System.Drawing.SystemColors.ControlLight;
this.monthCalendarInstructionsLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.142858F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.weekEndingCalendar.FirstDayOfWeek = System.Windows.Forms.Day.Sunday;
this.monthCalendarInstructionsLabel.Location = new System.Drawing.Point(57, 30); this.weekEndingCalendar.Location = new System.Drawing.Point(48, 34);
this.monthCalendarInstructionsLabel.Name = "monthCalendarInstructionsLabel"; this.weekEndingCalendar.MaxSelectionCount = 1;
this.monthCalendarInstructionsLabel.Size = new System.Drawing.Size(296, 25); this.weekEndingCalendar.Name = "weekEndingCalendar";
this.monthCalendarInstructionsLabel.TabIndex = 2; this.weekEndingCalendar.ShowTodayCircle = false;
this.monthCalendarInstructionsLabel.Text = "Select a date from the calendar..."; this.weekEndingCalendar.TabIndex = 2;
// this.weekEndingCalendar.TabStop = false;
// weekEndingMonthCalendar
//
this.weekEndingMonthCalendar.BackColor = System.Drawing.SystemColors.ControlLight;
this.weekEndingMonthCalendar.FirstDayOfWeek = System.Windows.Forms.Day.Sunday;
this.weekEndingMonthCalendar.Location = new System.Drawing.Point(49, 61);
this.weekEndingMonthCalendar.MaxSelectionCount = 1;
this.weekEndingMonthCalendar.Name = "weekEndingMonthCalendar";
this.weekEndingMonthCalendar.ShowTodayCircle = false;
this.weekEndingMonthCalendar.TabIndex = 2;
this.weekEndingMonthCalendar.TabStop = false;
this.weekEndingMonthCalendar.DateChanged += new System.Windows.Forms.DateRangeEventHandler(this.UpdateWeekEndingMaskedTextBox);
// //
// dateTimeMaskedTextBoxPanel // dateTimeMaskedTextBoxPanel
// //
this.dateTimeMaskedTextBoxPanel.Controls.Add(this.errorLabel); this.dateTimeMaskedTextBoxPanel.Controls.Add(this.informationLabel);
this.dateTimeMaskedTextBoxPanel.Controls.Add(this.weekEndingMaskedTextBox);
this.dateTimeMaskedTextBoxPanel.Controls.Add(this.weekEndingMaskedTextBoxInstructionLabel);
this.dateTimeMaskedTextBoxPanel.Dock = System.Windows.Forms.DockStyle.Fill; this.dateTimeMaskedTextBoxPanel.Dock = System.Windows.Forms.DockStyle.Fill;
this.dateTimeMaskedTextBoxPanel.Location = new System.Drawing.Point(472, 824); this.dateTimeMaskedTextBoxPanel.Location = new System.Drawing.Point(472, 778);
this.dateTimeMaskedTextBoxPanel.Name = "dateTimeMaskedTextBoxPanel"; this.dateTimeMaskedTextBoxPanel.Name = "dateTimeMaskedTextBoxPanel";
this.dateTimeMaskedTextBoxPanel.Size = new System.Drawing.Size(463, 134); this.dateTimeMaskedTextBoxPanel.Size = new System.Drawing.Size(463, 180);
this.dateTimeMaskedTextBoxPanel.TabIndex = 1; this.dateTimeMaskedTextBoxPanel.TabIndex = 1;
// //
// informationPanel
//
this.informationPanel.Controls.Add(this.errorLabel);
this.informationPanel.Controls.Add(this.addRecordButton);
this.informationPanel.Dock = System.Windows.Forms.DockStyle.Fill;
this.informationPanel.Location = new System.Drawing.Point(1410, 778);
this.informationPanel.Name = "informationPanel";
this.informationPanel.Size = new System.Drawing.Size(463, 180);
this.informationPanel.TabIndex = 25;
//
// errorLabel // errorLabel
// //
this.errorLabel.AutoSize = true; this.errorLabel.AutoSize = true;
this.errorLabel.ForeColor = System.Drawing.Color.Maroon; this.errorLabel.ForeColor = System.Drawing.Color.Maroon;
this.errorLabel.Location = new System.Drawing.Point(3, 31); this.errorLabel.Location = new System.Drawing.Point(-1, 7);
this.errorLabel.Name = "errorLabel"; this.errorLabel.Name = "errorLabel";
this.errorLabel.Size = new System.Drawing.Size(108, 25); this.errorLabel.Size = new System.Drawing.Size(0, 25);
this.errorLabel.TabIndex = 28; this.errorLabel.TabIndex = 28;
this.errorLabel.Text = "Errors here";
//
// weekEndingMaskedTextBox
//
this.weekEndingMaskedTextBox.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.weekEndingMaskedTextBox.Location = new System.Drawing.Point(277, 3);
this.weekEndingMaskedTextBox.Mask = "00/00/0000";
this.weekEndingMaskedTextBox.Name = "weekEndingMaskedTextBox";
this.weekEndingMaskedTextBox.Size = new System.Drawing.Size(115, 31);
this.weekEndingMaskedTextBox.TabIndex = 3;
this.weekEndingMaskedTextBox.ValidatingType = typeof(System.DateTime);
//
// weekEndingMaskedTextBoxInstructionLabel
//
this.weekEndingMaskedTextBoxInstructionLabel.AutoSize = true;
this.weekEndingMaskedTextBoxInstructionLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.142858F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.weekEndingMaskedTextBoxInstructionLabel.Location = new System.Drawing.Point(16, 6);
this.weekEndingMaskedTextBoxInstructionLabel.Name = "weekEndingMaskedTextBoxInstructionLabel";
this.weekEndingMaskedTextBoxInstructionLabel.Size = new System.Drawing.Size(245, 25);
this.weekEndingMaskedTextBoxInstructionLabel.TabIndex = 0;
this.weekEndingMaskedTextBoxInstructionLabel.Text = "... or manually enter it here:\r\n";
//
// informationPanel
//
this.informationPanel.Controls.Add(this.addRecordButton);
this.informationPanel.Dock = System.Windows.Forms.DockStyle.Fill;
this.informationPanel.Location = new System.Drawing.Point(1410, 824);
this.informationPanel.Name = "informationPanel";
this.informationPanel.Size = new System.Drawing.Size(463, 134);
this.informationPanel.TabIndex = 25;
//
// informationLabel
//
this.informationLabel.AutoSize = true;
this.informationLabel.Location = new System.Drawing.Point(1014, 26);
this.informationLabel.Name = "informationLabel";
this.informationLabel.Size = new System.Drawing.Size(152, 25);
this.informationLabel.TabIndex = 27;
this.informationLabel.Text = "Information here";
// //
// addRecordButton // addRecordButton
// //
this.addRecordButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.addRecordButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.addRecordButton.Location = new System.Drawing.Point(287, 84); this.addRecordButton.Location = new System.Drawing.Point(287, 130);
this.addRecordButton.Name = "addRecordButton"; this.addRecordButton.Name = "addRecordButton";
this.addRecordButton.Size = new System.Drawing.Size(167, 41); this.addRecordButton.Size = new System.Drawing.Size(167, 41);
this.addRecordButton.TabIndex = 26; this.addRecordButton.TabIndex = 26;
@@ -1017,10 +979,10 @@
this.taxableTabPage.ResumeLayout(false); this.taxableTabPage.ResumeLayout(false);
this.taxableTabPage.PerformLayout(); this.taxableTabPage.PerformLayout();
this.dateGroupBox.ResumeLayout(false); this.dateGroupBox.ResumeLayout(false);
this.dateGroupBox.PerformLayout();
this.dateTimeMaskedTextBoxPanel.ResumeLayout(false); this.dateTimeMaskedTextBoxPanel.ResumeLayout(false);
this.dateTimeMaskedTextBoxPanel.PerformLayout(); this.dateTimeMaskedTextBoxPanel.PerformLayout();
this.informationPanel.ResumeLayout(false); this.informationPanel.ResumeLayout(false);
this.informationPanel.PerformLayout();
this.ResumeLayout(false); this.ResumeLayout(false);
} }
@@ -1088,11 +1050,8 @@
private System.Windows.Forms.TabControl tabControl1; private System.Windows.Forms.TabControl tabControl1;
private System.Windows.Forms.TabPage weeklySalesTabPage; private System.Windows.Forms.TabPage weeklySalesTabPage;
private System.Windows.Forms.TabPage taxableTabPage; private System.Windows.Forms.TabPage taxableTabPage;
private System.Windows.Forms.Label monthCalendarInstructionsLabel; private System.Windows.Forms.MonthCalendar weekEndingCalendar;
private System.Windows.Forms.MonthCalendar weekEndingMonthCalendar;
private System.Windows.Forms.Panel dateTimeMaskedTextBoxPanel; private System.Windows.Forms.Panel dateTimeMaskedTextBoxPanel;
private System.Windows.Forms.MaskedTextBox weekEndingMaskedTextBox;
private System.Windows.Forms.Label weekEndingMaskedTextBoxInstructionLabel;
private System.Windows.Forms.TabPage debugTabPage; private System.Windows.Forms.TabPage debugTabPage;
private System.Windows.Forms.Panel informationPanel; private System.Windows.Forms.Panel informationPanel;
private System.Windows.Forms.Label errorLabel; private System.Windows.Forms.Label errorLabel;
+164 -182
View File
@@ -50,8 +50,6 @@ namespace AdvertsingProfitControl
//Assign the events for the comments text box and display the remaining character count for the user. //Assign the events for the comments text box and display the remaining character count for the user.
commentsTextBox.TextChanged += DisplayRemainingCommentCharacterCount; commentsTextBox.TextChanged += DisplayRemainingCommentCharacterCount;
commentsGroupBox.Text = @"Comments (Characters Remaining: " + commentsTextBox.MaxLength + @")"; commentsGroupBox.Text = @"Comments (Characters Remaining: " + commentsTextBox.MaxLength + @")";
//Set up the event for when the masked text box looses focus.
weekEndingMaskedTextBox.LostFocus += UpdateCalendarOnFocusLost;
//Setup the events for that the Projected and Actual Sales DataGridViews will share. //Setup the events for that the Projected and Actual Sales DataGridViews will share.
//Events are assigned with regard to which event gets triggered first and so on.. //Events are assigned with regard to which event gets triggered first and so on..
//Hook the row add event so we can paint a row number in the header cell of the row. //Hook the row add event so we can paint a row number in the header cell of the row.
@@ -881,8 +879,13 @@ namespace AdvertsingProfitControl
case (int)SalesTableColumns.IsDirty: case (int)SalesTableColumns.IsDirty:
rowContents[i] = true; rowContents[i] = true;
break; break;
case (int)SalesTableColumns.IsHeaderRow:
rowContents[i] = false;
break;
case (int)SalesTableColumns.IsMemberRow:
rowContents[i] = false;
break;
default: default:
if(i >= (int)SalesTableColumns.IsHeaderRow) continue;
rowContents[i] = ""; rowContents[i] = "";
break; break;
} }
@@ -903,14 +906,18 @@ namespace AdvertsingProfitControl
inventoryNewRow[(int)InventoryTableColumns.AdItem] = inventoryNewRow[(int)InventoryTableColumns.AdItem] =
projectionsDataGridView.Rows[e.RowIndex].Cells[i].EditedFormattedValue.ToString(); projectionsDataGridView.Rows[e.RowIndex].Cells[i].EditedFormattedValue.ToString();
break; break;
case (int)SalesTableColumns.IsDirty: case (int)InventoryTableColumns.IsDirty:
inventoryNewRow[(int)InventoryTableColumns.IsDirty] = true; inventoryNewRow[(int)InventoryTableColumns.IsDirty] = true;
break; break;
case (int)InventoryTableColumns.IsHeaderRow:
inventoryNewRow[(int)InventoryTableColumns.IsHeaderRow] = false;
break;
case (int)InventoryTableColumns.IsMemberRow:
inventoryNewRow[(int)InventoryTableColumns.IsMemberRow] = false;
break;
default: default:
if (i < (int) InventoryTableColumns.IsHeaderRow) if(i > (int)InventoryTableColumns.IsHeaderRow) continue;
{ inventoryNewRow[i] = "";
inventoryNewRow[i] = "";
}
break; break;
} }
} }
@@ -1185,11 +1192,13 @@ namespace AdvertsingProfitControl
case (int)SalesTableColumns.IsDirty: case (int)SalesTableColumns.IsDirty:
rowContents[i] = true; rowContents[i] = true;
break; break;
case (int)SalesTableColumns.IsHeaderRow:
rowContents[i] = false;
break;
case (int)SalesTableColumns.IsMemberRow:
rowContents[i] = false;
break;
default: default:
if (i >= (int) InventoryTableColumns.IsHeaderRow)
{
continue;
}
rowContents[i] = ""; rowContents[i] = "";
break; break;
} }
@@ -1337,8 +1346,13 @@ namespace AdvertsingProfitControl
case (int)SalesTableColumns.IsDirty: case (int)SalesTableColumns.IsDirty:
rowContents[i] = true; rowContents[i] = true;
break; break;
case (int)SalesTableColumns.IsHeaderRow:
rowContents[i] = false;
break;
case (int)SalesTableColumns.IsMemberRow:
rowContents[i] = false;
break;
default: default:
if (i >= (int)SalesTableColumns.IsHeaderRow) continue;
rowContents[i] = ""; rowContents[i] = "";
break; break;
} }
@@ -1359,11 +1373,15 @@ namespace AdvertsingProfitControl
case (int)SalesTableColumns.IsDirty: case (int)SalesTableColumns.IsDirty:
inventoryNewRow[(int)InventoryTableColumns.IsDirty] = true; inventoryNewRow[(int)InventoryTableColumns.IsDirty] = true;
break; break;
case (int)InventoryTableColumns.IsHeaderRow:
inventoryNewRow[(int)InventoryTableColumns.IsHeaderRow] = false;
break;
case (int)InventoryTableColumns.IsMemberRow:
inventoryNewRow[(int)InventoryTableColumns.IsMemberRow] = false;
break;
default: default:
if (i > (int)InventoryTableColumns.AdItem && i < (int)InventoryTableColumns.IsHeaderRow || i == (int)InventoryTableColumns.Id) if (i > (int)InventoryTableColumns.IsHeaderRow) continue;
{ inventoryNewRow[i] = "";
inventoryNewRow[i] = "";
}
break; break;
} }
} }
@@ -1844,114 +1862,29 @@ namespace AdvertsingProfitControl
#endregion #endregion
#region DateTime Events #region DateTime Events
/// <summary>
/// Updates the week ending masked text box with the selected date
/// using the format (MM/DD/YYYY).
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void UpdateWeekEndingMaskedTextBox(object sender, DateRangeEventArgs e)
{
var selectedDate = weekEndingMonthCalendar.SelectionStart;
if (!selectedDate.ToString("D").StartsWith("Saturday"))
{
weekEndingMaskedTextBox.ForeColor = Color.Maroon;
weekEndingMaskedTextBoxInstructionLabel.Text = @"... or manually enter it here: *";
errorLabel.Text = @"* The date you selected does not appear to be a week ending date.";
}
else
{
weekEndingMaskedTextBox.ForeColor = Color.Black;
weekEndingMaskedTextBoxInstructionLabel.Text = @"... or manually enter it here:";
errorLabel.Text = "";
}
weekEndingMaskedTextBox.Text = selectedDate.ToString("MM-dd-yyyy");
}
/// <summary>
/// Event Used: LostFocus
/// Attempts to set the selected date of the calendar to the date that
/// has been entered into the masked text box.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void UpdateCalendarOnFocusLost(object sender, EventArgs e)
{
//Replace any white space with zeros to pad out the mask.
weekEndingMaskedTextBox.Text = weekEndingMaskedTextBox.Text.Replace("/", "");
DateTime date;
//Try parsing the contents of the masked text box to see if the date is valid.
if (DateTime.TryParse(weekEndingMaskedTextBox.Text, out date))
{
//Update the text box's text with a nicely formatted date.
weekEndingMaskedTextBox.Text = date.ToString("MM/dd/yyyy");
//If it is update the calendar with the manually entered date.
weekEndingMonthCalendar.SelectionStart = date;
}
else
{
//Otherwise throw an error to day that the date isn't valid and clear the text box.
MessageBox.Show(@"The date entered appears to be invalid.", @"Invalid Date", MessageBoxButtons.OK, MessageBoxIcon.Error);
weekEndingMaskedTextBox.Text = "";
}
}
#endregion #endregion
private void AddRecordsButtonClick(object sender, EventArgs e) private void AddRecordsButtonClick(object sender, EventArgs e)
{ {
//Make sure the mask in the text box is completed.
if (!weekEndingMaskedTextBox.MaskCompleted)
{
MessageBox.Show(@"A valid date must be specified.", @"Invalid Date", MessageBoxButtons.OK,
MessageBoxIcon.Error);
return;
}
//Create the database interaction objects.
var dbT = new DatabaseTracker(); var dbT = new DatabaseTracker();
var dbW = new DatabaseWriter(dbT.DatabaseConnectionString); var dbW = new DatabaseWriter(dbT.DatabaseConnectionString);
var dbR = new DatabaseReader(); var dbR = new DatabaseReader();
DateTime dateTime;
//Attempt to parse the date entered to verify it's integrity.
if (DateTime.TryParseExact(weekEndingMaskedTextBox.Text, "MM/dd/yyyy", CultureInfo.InvariantCulture,
DateTimeStyles.None, out dateTime))
{
//Check to see if the date is before the store was even founded, though I think a date range starting at 2014 would work but eh.
if (dateTime.Year < 1958)
{
var result =
MessageBox.Show(
@"Fairly certain Allen's wasn't even founded at this time... Maybe try another date or year at least?",
@"Let Alone Used Computers This Fast", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (result == DialogResult.Yes)
{
weekEndingMaskedTextBox.Focus();
return;
}
MessageBox.Show(@"Alright if you insist since technically this date is valid.",
@"Technically Correct Is The Best Correct", MessageBoxButtons.OK);
}
}
else
{
MessageBox.Show(@"The date " + weekEndingMaskedTextBox.Text + @" is an invalid date.", @"Invalid Date", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
//Obtain the date ID. //Obtain the date ID.
int dateId; int dateId;
if ( if (
int.TryParse(dbR.RetrieveDateIdByDateString(dateTime.ToString("MM/dd/yyyy"), int.TryParse(dbR.RetrieveDateIdByDateString(weekEndingCalendar.SelectionStart.ToString("d"),
dbT.DatabaseConnectionString), out dateId)) dbT.DatabaseConnectionString), out dateId))
{ {
//If the ID is zero (0) that means the date isn't in the database so simply insert it. //If the ID is zero (0) that means the date isn't in the database so simply insert it.
if (dateId == 0) if (dateId == 0)
{ {
//Try inserting the date string. //Try inserting the date string.
if (dbW.InsertIntoWeekEnding(dateTime.ToString("MM/dd/yyyy"))) if (dbW.InsertIntoWeekEnding(weekEndingCalendar.SelectionStart.ToString("d")))
{ {
if ( if (
int.TryParse( int.TryParse(
dbR.RetrieveDateIdByDateString(dateTime.ToString("MM/dd/yyyy"), dbR.RetrieveDateIdByDateString(weekEndingCalendar.SelectionStart.ToString("d"),
dbT.DatabaseConnectionString), out dateId)) dbT.DatabaseConnectionString), out dateId))
{ {
//Now if its still zero (0) then that means something went really wrong and failed to insert. //Now if its still zero (0) then that means something went really wrong and failed to insert.
@@ -1974,24 +1907,17 @@ namespace AdvertsingProfitControl
else else
{ {
//The above method reports that it failed to insert the date into the database. //The above method reports that it failed to insert the date into the database.
MessageBox.Show(@"Failed insert the date " + weekEndingMaskedTextBox.Text + @" into the database.", @"Failed To Get Date ID", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show(@"Failed to insert the date '" + weekEndingCalendar.SelectionStart.ToString("d") + @"' into the database.", @"Failed To Get Date ID", MessageBoxButtons.OK, MessageBoxIcon.Error);
return; return;
} }
} }
} }
else informationLabel.Text = "";
{
//Seriously don't think this will happen, but eh might as well.
MessageBox.Show(
@"You really should not be able to see this message. If you are well that means something really weird happened converting text into a number, that is hard-coded to not fail on conversion. Either way I couldn't get the date ID due to some error, check the logs if you're curious.",
@"Well This Is Awkward...", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
//Run the row parsing engine on all the APC tables. //Run the row parsing engine on all the APC tables.
//Create the cleaned table objects that will be sent to the database. //Create the cleaned table objects that will be sent to the database.
DataTable trimmedTable; DataTable trimmedTable;
DataTable updateTable; DataTable updateTable;
informationLabel.Text = @"Compressing data tables..." + Environment.NewLine;
errorLabel.Text = ""; errorLabel.Text = "";
var operationStatus = ConstructCleanedSalesTable("Projections", dateId, out trimmedTable, out updateTable); var operationStatus = ConstructCleanedSalesTable("Projections", dateId, out trimmedTable, out updateTable);
if (operationStatus == TrimmingOperationResult.FailedToTrim) if (operationStatus == TrimmingOperationResult.FailedToTrim)
@@ -1999,45 +1925,75 @@ namespace AdvertsingProfitControl
errorLabel.Text = @"Failed to trim the Projections table."; errorLabel.Text = @"Failed to trim the Projections table.";
return; return;
} }
if (!ProcessTrimmingStatusResult(projectionsDataGridView, "Projections", operationStatus, trimmedTable, updateTable)) return; if (ProcessTrimmingStatusResult(projectionsDataGridView, "Projections", operationStatus, trimmedTable, updateTable))
trimmedTable.Rows.Clear();
updateTable.Rows.Clear();
operationStatus = ConstructCleanedInventoryTable(dateId, out trimmedTable, out updateTable);
if (operationStatus == TrimmingOperationResult.FailedToTrim)
{ {
errorLabel.Text = @"Failed to trim the Inventory table."; trimmedTable.Rows.Clear();
return; updateTable.Rows.Clear();
operationStatus = ConstructCleanedInventoryTable(dateId, out trimmedTable, out updateTable);
if (operationStatus == TrimmingOperationResult.FailedToTrim)
{
errorLabel.Text = @"Failed to trim the Inventory table.";
//Delete the Projections table.
dbW.DeleteApcDataEntriesByDate("Projections", dateId, dbT.DatabaseConnectionString);
}
else
{
//Add the Inventory table to the database.
if (ProcessTrimmingStatusForInventory(operationStatus, trimmedTable, updateTable))
{
trimmedTable.Rows.Clear();
updateTable.Rows.Clear();
operationStatus = ConstructCleanedSalesTable("ActualSales", dateId, out trimmedTable,
out updateTable);
if (operationStatus == TrimmingOperationResult.FailedToTrim)
{
errorLabel.Text = @"Failed to trim the Actual Sales table.";
//Delete the Projections table and the Inventory table.
dbW.DeleteApcDataEntriesByDate("Projections", dateId, dbT.DatabaseConnectionString);
dbW.DeleteApcDataEntriesByDate("Inventory", dateId, dbT.DatabaseConnectionString);
}
else
{
if (!ProcessTrimmingStatusResult(actualSalesDataGridView, "ActualSales", operationStatus, trimmedTable, updateTable))
{
//Delete the Projections and Inventory table.
dbW.DeleteApcDataEntriesByDate("Projections", dateId, dbT.DatabaseConnectionString);
dbW.DeleteApcDataEntriesByDate("Inventory", dateId, dbT.DatabaseConnectionString);
}
}
}
else
{
//Delete the Projections table.
dbW.DeleteApcDataEntriesByDate("Projections", dateId, dbT.DatabaseConnectionString);
}
}
} }
if (!ProcessTrimmingStatusForInventory(operationStatus, trimmedTable, updateTable)) return;
trimmedTable.Rows.Clear();
updateTable.Rows.Clear();
operationStatus = ConstructCleanedSalesTable("ActualSales", dateId, out trimmedTable, out updateTable);
if (operationStatus == TrimmingOperationResult.FailedToTrim)
{
errorLabel.Text = @"Failed to trim the Actual Sales table.";
return;
}
if (!ProcessTrimmingStatusResult(actualSalesDataGridView, "ActualSales", operationStatus, trimmedTable, updateTable)) return;
//Commit the Invoice table to the database. //Commit the Invoice table to the database.
var writerStatus = dbW.ProccessInvoiceTable(invoicesDataGridView, dateId, dbT.DatabaseConnectionString); var writerStatus = dbW.ProccessInvoiceTable(invoicesDataGridView, dateId, dbT.DatabaseConnectionString);
if (writerStatus.GetWritingOperationStatus() == WritingOperationStatus.Failed) if (writerStatus.GetWritingOperationStatus() == WritingOperationStatus.Failed)
{ {
informationLabel.Text += @"Failed to add Invoices to the database.";
errorLabel.Text = writerStatus.GetErrorMessage(); errorLabel.Text = writerStatus.GetErrorMessage();
} }
else
{
informationLabel.Text += writerStatus.GetErrorMessage() + Environment.NewLine;
}
//TODO: If the comments are null but there is a comment ID, delete the comments from the database. //TODO: If the comments are null but there is a comment ID, delete the comments from the database.
if (isCommentDirtyCheckBox.Checked) if (isCommentDirtyCheckBox.Checked)
{ {
if (isCommentDirtyCheckBox.Tag == null) if (isCommentDirtyCheckBox.Tag == null)
{ {
informationLabel.Text += @"Inserting Comment(s).";
var status = dbW.ProcessComments(commentsTextBox.Text, dateId, dbT.DatabaseConnectionString); var status = dbW.ProcessComments(commentsTextBox.Text, dateId, dbT.DatabaseConnectionString);
if (status.Status == WritingOperationStatus.Failed) if (status.Status == WritingOperationStatus.Failed)
{ {
informationLabel.Text += @"Failed to add Comments to the database." + Environment.NewLine;
errorLabel.Text = status.ErrorMessage; errorLabel.Text = status.ErrorMessage;
} }
else else
{ {
informationLabel.Text += @"Comment(s) processed successfully."; informationLabel.Text += @"Comment(s) processed successfully." + Environment.NewLine;
var id = status.Id; var id = status.Id;
isCommentDirtyCheckBox.Tag = id; isCommentDirtyCheckBox.Tag = id;
isCommentDirtyCheckBox.Text = @"IsCommentDirty (" + id + @")"; isCommentDirtyCheckBox.Text = @"IsCommentDirty (" + id + @")";
@@ -2048,19 +2004,24 @@ namespace AdvertsingProfitControl
{ {
//Check for a null comment box and delete the comment ID from the database. //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. //Then if all is successful clear the Tag in the isCommentsDirty check box.
informationLabel.Text += @"Updating Comment(s)."; var status = dbW.ProcessComments(commentsTextBox.Text, dateId, dbT.DatabaseConnectionString,
var status = dbW.ProcessComments(commentsTextBox.Text, dateId, dbT.DatabaseConnectionString, int.Parse(isCommentDirtyCheckBox.Tag.ToString())); int.Parse(isCommentDirtyCheckBox.Tag.ToString()));
if (status.Status == WritingOperationStatus.Failed) if (status.Status == WritingOperationStatus.Failed)
{ {
informationLabel.Text += @"Failed to add Comments to the database." + Environment.NewLine;
errorLabel.Text = status.ErrorMessage; errorLabel.Text = status.ErrorMessage;
} }
else else
{ {
isCommentDirtyCheckBox.Checked = false; isCommentDirtyCheckBox.Checked = false;
informationLabel.Text += @"Comment(s) processed successfully."; informationLabel.Text += @"Comment(s) processed successfully." + Environment.NewLine;
} }
} }
} }
else
{
informationLabel.Text += @"No changes detected for the comment(s)" + Environment.NewLine;
}
//Begin checking the Weekly Sales. //Begin checking the Weekly Sales.
if (isWeeklySalesDirtyCheckBox.Checked) if (isWeeklySalesDirtyCheckBox.Checked)
{ {
@@ -2070,23 +2031,27 @@ namespace AdvertsingProfitControl
weeklySales[1] = mondayWeeklySalesTextBox.Text == "" ? 0 : double.Parse(mondayWeeklySalesTextBox.Text); weeklySales[1] = mondayWeeklySalesTextBox.Text == "" ? 0 : double.Parse(mondayWeeklySalesTextBox.Text);
weeklySales[2] = tuesdayWeeklySalesTextBox.Text == "" ? 0 : double.Parse(tuesdayWeeklySalesTextBox.Text); weeklySales[2] = tuesdayWeeklySalesTextBox.Text == "" ? 0 : double.Parse(tuesdayWeeklySalesTextBox.Text);
weeklySales[3] = wednesdayTaxableTextBox.Text == "" ? 0 : double.Parse(wednesdayWeeklySalesTextBox.Text); weeklySales[3] = wednesdayTaxableTextBox.Text == "" ? 0 : double.Parse(wednesdayWeeklySalesTextBox.Text);
weeklySales[4] = thursdayWeeklySalesTextBox.Text == "" ? 0 : double.Parse(thursdayWeeklySalesTextBox.Text); weeklySales[4] = thursdayWeeklySalesTextBox.Text == ""
? 0
: double.Parse(thursdayWeeklySalesTextBox.Text);
weeklySales[5] = fridayWeeklySalesTextBox.Text == "" ? 0 : double.Parse(fridayWeeklySalesTextBox.Text); weeklySales[5] = fridayWeeklySalesTextBox.Text == "" ? 0 : double.Parse(fridayWeeklySalesTextBox.Text);
weeklySales[6] = saturdayWeeklySalesTextBox.Text == "" ? 0 : double.Parse(saturdayWeeklySalesTextBox.Text); weeklySales[6] = saturdayWeeklySalesTextBox.Text == ""
? 0
: double.Parse(saturdayWeeklySalesTextBox.Text);
weeklySales[7] = totalWeeklySalesTextBox.Text == "" ? 0 : double.Parse(totalWeeklySalesTextBox.Text); weeklySales[7] = totalWeeklySalesTextBox.Text == "" ? 0 : double.Parse(totalWeeklySalesTextBox.Text);
if (isWeeklySalesDirtyCheckBox.Tag == null) if (isWeeklySalesDirtyCheckBox.Tag == null)
{ {
//Weekly sales is not in the database. //Weekly sales is not in the database.
informationLabel.Text += @"Inserting weekly sales...";
var status = dbW.ProcessWeeklySales(weeklySales, dateId, dbT.DatabaseConnectionString); var status = dbW.ProcessWeeklySales(weeklySales, dateId, dbT.DatabaseConnectionString);
if (status.Status == WritingOperationStatus.Failed) if (status.Status == WritingOperationStatus.Failed)
{ {
informationLabel.Text += @"Failed to add Weekly Sales to the database." + Environment.NewLine;
errorLabel.Text = status.ErrorMessage; errorLabel.Text = status.ErrorMessage;
} }
else else
{ {
informationLabel.Text += @"Weekly Sales processed successfully."; informationLabel.Text += @"Weekly Sales processed successfully." + Environment.NewLine;
isWeeklySalesDirtyCheckBox.Tag = status.Id; isWeeklySalesDirtyCheckBox.Tag = status.Id;
isWeeklySalesDirtyCheckBox.Text = @"IsWeeklySalesDirty (" + status.Id + @")"; isWeeklySalesDirtyCheckBox.Text = @"IsWeeklySalesDirty (" + status.Id + @")";
isWeeklySalesDirtyCheckBox.Checked = false; isWeeklySalesDirtyCheckBox.Checked = false;
@@ -2094,19 +2059,24 @@ namespace AdvertsingProfitControl
} }
else else
{ {
informationLabel.Text += @"Updating Weekly Sales."; var status = dbW.ProcessWeeklySales(weeklySales, dateId, dbT.DatabaseConnectionString,
var status = dbW.ProcessWeeklySales(weeklySales, dateId, dbT.DatabaseConnectionString, int.Parse(isWeeklySalesDirtyCheckBox.Tag.ToString())); int.Parse(isWeeklySalesDirtyCheckBox.Tag.ToString()));
if (status.Status == WritingOperationStatus.Failed) if (status.Status == WritingOperationStatus.Failed)
{ {
informationLabel.Text += @"Failed to add Weekly Sales to the database." + Environment.NewLine;
errorLabel.Text = status.ErrorMessage; errorLabel.Text = status.ErrorMessage;
} }
else else
{ {
isWeeklySalesDirtyCheckBox.Checked = false; isWeeklySalesDirtyCheckBox.Checked = false;
informationLabel.Text += @"Weekly Sales updated successfully."; informationLabel.Text += @"Weekly Sales updated successfully." + Environment.NewLine;
} }
} }
} }
else
{
informationLabel.Text += @"No changes detected for Weekly Sales." + Environment.NewLine;
}
//Begin checking the Taxable. //Begin checking the Taxable.
if (isTaxableDirtyCheckBox.Checked) if (isTaxableDirtyCheckBox.Checked)
{ {
@@ -2124,15 +2094,15 @@ namespace AdvertsingProfitControl
if (isTaxableDirtyCheckBox.Tag == null) if (isTaxableDirtyCheckBox.Tag == null)
{ {
//Weekly sales is not in the database. //Weekly sales is not in the database.
informationLabel.Text += @"Inserting Taxable...";
var status = dbW.ProcessTaxable(taxable, dateId, dbT.DatabaseConnectionString); var status = dbW.ProcessTaxable(taxable, dateId, dbT.DatabaseConnectionString);
if (status.Status == WritingOperationStatus.Failed) if (status.Status == WritingOperationStatus.Failed)
{ {
informationLabel.Text += @"Failed to add Taxable to the database." + Environment.NewLine;
errorLabel.Text = status.ErrorMessage; errorLabel.Text = status.ErrorMessage;
} }
else else
{ {
informationLabel.Text += @"Taxable processed successfully."; informationLabel.Text += @"Taxable processed successfully." + Environment.NewLine;
isTaxableDirtyCheckBox.Tag = status.Id; isTaxableDirtyCheckBox.Tag = status.Id;
isTaxableDirtyCheckBox.Text = @"IsTaxableDirty (" + status.Id + @")"; isTaxableDirtyCheckBox.Text = @"IsTaxableDirty (" + status.Id + @")";
isTaxableDirtyCheckBox.Checked = false; isTaxableDirtyCheckBox.Checked = false;
@@ -2140,19 +2110,24 @@ namespace AdvertsingProfitControl
} }
else else
{ {
informationLabel.Text += @"Updating Taxable."; var status = dbW.ProcessTaxable(taxable, dateId, dbT.DatabaseConnectionString,
var status = dbW.ProcessTaxable(taxable, dateId, dbT.DatabaseConnectionString, int.Parse(isTaxableDirtyCheckBox.Tag.ToString())); int.Parse(isTaxableDirtyCheckBox.Tag.ToString()));
if (status.Status == WritingOperationStatus.Failed) if (status.Status == WritingOperationStatus.Failed)
{ {
informationLabel.Text += @"Failed to add Taxable to the database." + Environment.NewLine;
errorLabel.Text = status.ErrorMessage; errorLabel.Text = status.ErrorMessage;
} }
else else
{ {
isTaxableDirtyCheckBox.Checked = false; isTaxableDirtyCheckBox.Checked = false;
informationLabel.Text += @"Taxable updated successfully."; informationLabel.Text += @"Taxable updated successfully." + Environment.NewLine;
} }
} }
} }
else
{
informationLabel.Text += @"No changes detected for Taxable." + Environment.NewLine;
}
//Begin checking cost analysis. //Begin checking cost analysis.
if (isCostAnalysisDirtyCheckBox.Checked) if (isCostAnalysisDirtyCheckBox.Checked)
{ {
@@ -2166,15 +2141,15 @@ namespace AdvertsingProfitControl
if (isCostAnalysisDirtyCheckBox.Tag == null) if (isCostAnalysisDirtyCheckBox.Tag == null)
{ {
//Weekly sales is not in the database. //Weekly sales is not in the database.
informationLabel.Text += @"Inserting Cost Analysis...";
var status = dbW.ProcessCostAnalysis(costAnalysis, dateId, dbT.DatabaseConnectionString); var status = dbW.ProcessCostAnalysis(costAnalysis, dateId, dbT.DatabaseConnectionString);
if (status.Status == WritingOperationStatus.Failed) if (status.Status == WritingOperationStatus.Failed)
{ {
informationLabel.Text += @"Failed to add Cost Analysis to the database.";
errorLabel.Text = status.ErrorMessage; errorLabel.Text = status.ErrorMessage;
} }
else else
{ {
informationLabel.Text += @"Costs analysis processed successfully."; informationLabel.Text += @"Costs Analysis processed successfully.";
isCostAnalysisDirtyCheckBox.Tag = status.Id; isCostAnalysisDirtyCheckBox.Tag = status.Id;
isCostAnalysisDirtyCheckBox.Text = @"IsCostAnalysisDirty (" + status.Id + @")"; isCostAnalysisDirtyCheckBox.Text = @"IsCostAnalysisDirty (" + status.Id + @")";
isCostAnalysisDirtyCheckBox.Checked = false; isCostAnalysisDirtyCheckBox.Checked = false;
@@ -2182,19 +2157,24 @@ namespace AdvertsingProfitControl
} }
else else
{ {
informationLabel.Text += @"Updating cost analysis."; var status = dbW.ProcessCostAnalysis(costAnalysis, dateId, dbT.DatabaseConnectionString,
var status = dbW.ProcessCostAnalysis(costAnalysis, dateId, dbT.DatabaseConnectionString, int.Parse(isCostAnalysisDirtyCheckBox.Tag.ToString())); int.Parse(isCostAnalysisDirtyCheckBox.Tag.ToString()));
if (status.Status == WritingOperationStatus.Failed) if (status.Status == WritingOperationStatus.Failed)
{ {
informationLabel.Text += @"Failed to add Cost Analysis to the database.";
errorLabel.Text = status.ErrorMessage; errorLabel.Text = status.ErrorMessage;
} }
else else
{ {
isCostAnalysisDirtyCheckBox.Checked = false; isCostAnalysisDirtyCheckBox.Checked = false;
informationLabel.Text += @"Cost analysis updated successfully."; informationLabel.Text += @"Cost Analysis updated successfully.";
} }
} }
} }
else
{
informationLabel.Text += @"No changes made to Cost Analysis.";
}
//Create the transaction scope. //Create the transaction scope.
//By default the TransactionScopeOption is "Required", so if an ambient transaction does not //By default the TransactionScopeOption is "Required", so if an ambient transaction does not
//exist then the new transaction that is made (in the first method) becomes the root transaction. //exist then the new transaction that is made (in the first method) becomes the root transaction.
@@ -2672,11 +2652,10 @@ namespace AdvertsingProfitControl
switch (operationStatus) switch (operationStatus)
{ {
case TrimmingOperationResult.NoChangesRequired: case TrimmingOperationResult.NoChangesRequired:
informationLabel.Text += Environment.NewLine + @"No changes to the " + TextFormat.AddSpacesToSentence(tableName, false) + @" table detected."; informationLabel.Text += @"No changes to the " + TextFormat.AddSpacesToSentence(tableName, false) + @" table detected." + Environment.NewLine;
successful = true; successful = true;
break; break;
case TrimmingOperationResult.CreatedNewInsertionTable: case TrimmingOperationResult.CreatedNewInsertionTable:
informationLabel.Text += Environment.NewLine + @"Inserting new changes to the " + TextFormat.AddSpacesToSentence(tableName, false) + @" table.";
dbWriterStatus = dbW.InsertIntoSalesTable(trimmedTable, dbT.DatabaseConnectionString); dbWriterStatus = dbW.InsertIntoSalesTable(trimmedTable, dbT.DatabaseConnectionString);
if (dbWriterStatus.GetErrorMessage() == string.Empty) if (dbWriterStatus.GetErrorMessage() == string.Empty)
{ {
@@ -2685,17 +2664,17 @@ namespace AdvertsingProfitControl
{ {
dataGridView.Rows[rowIndex.Key - 1].Cells[(int) SalesTableColumns.Id].Value = rowIndex.Value; 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].Cells[(int) SalesTableColumns.IsDirty].Value = false;
dataGridView.Rows[rowIndex.Key - 1].HeaderCell.Style.BackColor = ApplicationColors.EditingSaved;
} }
informationLabel.Text += Environment.NewLine + TextFormat.AddSpacesToSentence(tableName, false) + @" table successfully added to the database."; informationLabel.Text += TextFormat.AddSpacesToSentence(tableName, false) + @" table successfully added to the database." + Environment.NewLine;
successful = true; successful = true;
} }
else else
{ {
errorLabel.Text = @"Failed to insert " + trimmedTable + @" into the database."; errorLabel.Text = @"Failed to insert " + trimmedTable + @" into the database." + Environment.NewLine;
} }
break; break;
case TrimmingOperationResult.CreatedUpdateTable: case TrimmingOperationResult.CreatedUpdateTable:
informationLabel.Text += Environment.NewLine + @"Updating changes made to the " + TextFormat.AddSpacesToSentence(tableName, false) + @" table.";
dbWriterStatus = dbW.UpdateSalesTable(updateTable, dbT.DatabaseConnectionString); dbWriterStatus = dbW.UpdateSalesTable(updateTable, dbT.DatabaseConnectionString);
if (dbWriterStatus.GetErrorMessage() == string.Empty) if (dbWriterStatus.GetErrorMessage() == string.Empty)
{ {
@@ -2704,35 +2683,36 @@ namespace AdvertsingProfitControl
{ {
//Only reset the IsDirty value to false since the updates when through. //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].Cells[(int)SalesTableColumns.IsDirty].Value = false;
dataGridView.Rows[rowIndex.Key - 1].HeaderCell.Style.BackColor = ApplicationColors.EditingSaved;
} }
informationLabel.Text += Environment.NewLine + TextFormat.AddSpacesToSentence(tableName, false) + @" table successfully updated."; informationLabel.Text += TextFormat.AddSpacesToSentence(tableName, false) + @" table successfully updated." + Environment.NewLine;
successful = true; successful = true;
} }
else else
{ {
errorLabel.Text = @"Failed to update the " + trimmedTable + @" table."; errorLabel.Text = @"Failed to update the " + trimmedTable + @" table." + Environment.NewLine;
} }
break; break;
case TrimmingOperationResult.CreatedNewInsertionAndUpdateTables: case TrimmingOperationResult.CreatedNewInsertionAndUpdateTables:
//Insert the new values... //Insert the new values...
informationLabel.Text += Environment.NewLine + @"Inserting new changes to the " + TextFormat.AddSpacesToSentence(tableName, false) + @" table.";
dbWriterStatus = dbW.InsertIntoSalesTable(trimmedTable, dbT.DatabaseConnectionString); dbWriterStatus = dbW.InsertIntoSalesTable(trimmedTable, dbT.DatabaseConnectionString);
if (dbWriterStatus.GetErrorMessage() == string.Empty) if (dbWriterStatus.GetErrorMessage() == string.Empty)
{ {
//Spin through the collection and update the affected rows. //Spin through the collection and update the affected rows.
foreach (var rowIndex in dbWriterStatus.GetRowCollection()) 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.Id].Value = rowIndex.Value;
dataGridView.Rows[rowIndex.Key - 1].Cells[(int)SalesTableColumns.IsDirty].Value = false; dataGridView.Rows[rowIndex.Key - 1].Cells[(int)SalesTableColumns.IsDirty].Value = false;
dataGridView.Rows[rowIndex.Key - 1].HeaderCell.Style.BackColor = ApplicationColors.EditingSaved;
} }
informationLabel.Text += Environment.NewLine + TextFormat.AddSpacesToSentence(tableName, false) + @" table successfully added to the database."; informationLabel.Text += TextFormat.AddSpacesToSentence(tableName, false) + @" table successfully added to the database." + Environment.NewLine;
} }
else else
{ {
errorLabel.Text = @"Failed to insert " + trimmedTable + @" into the database."; errorLabel.Text = @"Failed to insert " + trimmedTable + @" into the database." + Environment.NewLine;
} }
//... and update the existing values. //... and update the existing values.
informationLabel.Text += Environment.NewLine + @"Updating changes made to the " + TextFormat.AddSpacesToSentence(tableName, false) + @" table.";
dbWriterStatus = dbW.UpdateSalesTable(updateTable, dbT.DatabaseConnectionString); dbWriterStatus = dbW.UpdateSalesTable(updateTable, dbT.DatabaseConnectionString);
if (dbWriterStatus.GetErrorMessage() == string.Empty) if (dbWriterStatus.GetErrorMessage() == string.Empty)
{ {
@@ -2741,13 +2721,14 @@ namespace AdvertsingProfitControl
{ {
//Only reset the IsDirty value to false since the updates when through. //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].Cells[(int)SalesTableColumns.IsDirty].Value = false;
dataGridView.Rows[rowIndex.Key - 1].HeaderCell.Style.BackColor = ApplicationColors.EditingSaved;
} }
informationLabel.Text += Environment.NewLine + TextFormat.AddSpacesToSentence(tableName, false) + @" table successfully updated."; informationLabel.Text += TextFormat.AddSpacesToSentence(tableName, false) + @" table successfully updated." + Environment.NewLine;
successful = true; successful = true;
} }
else else
{ {
errorLabel.Text = @"Failed to update the " + trimmedTable + @" table."; errorLabel.Text = @"Failed to update the " + trimmedTable + @" table." + Environment.NewLine;
} }
break; break;
} }
@@ -2765,11 +2746,10 @@ namespace AdvertsingProfitControl
switch (operationStatus) switch (operationStatus)
{ {
case TrimmingOperationResult.NoChangesRequired: case TrimmingOperationResult.NoChangesRequired:
informationLabel.Text += Environment.NewLine + @"No changes to the Inventory table detected."; informationLabel.Text += @"No changes to the Inventory table detected." + Environment.NewLine;
successful = true; successful = true;
break; break;
case TrimmingOperationResult.CreatedNewInsertionTable: case TrimmingOperationResult.CreatedNewInsertionTable:
informationLabel.Text += Environment.NewLine + @"Inserting new changes to the Inventory table.";
dbWriterStatus = dbW.InsertIntoInventoryTable(trimmedTable, dbT.DatabaseConnectionString); dbWriterStatus = dbW.InsertIntoInventoryTable(trimmedTable, dbT.DatabaseConnectionString);
if (dbWriterStatus.GetErrorMessage() == string.Empty) if (dbWriterStatus.GetErrorMessage() == string.Empty)
{ {
@@ -2778,17 +2758,17 @@ namespace AdvertsingProfitControl
{ {
inventoryDataGridView.Rows[rowIndex.Key - 1].Cells[(int)InventoryTableColumns.Id].Value = rowIndex.Value; 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].Cells[(int)InventoryTableColumns.IsDirty].Value = false;
inventoryDataGridView.Rows[rowIndex.Key - 1].HeaderCell.Style.BackColor = ApplicationColors.EditingSaved;
} }
informationLabel.Text += Environment.NewLine + @"Inventory table successfully added to the database."; informationLabel.Text += @"Inventory table successfully added to the database." + Environment.NewLine;
successful = true; successful = true;
} }
else else
{ {
errorLabel.Text = @"Failed to insert Inventory table into the database."; errorLabel.Text = @"Failed to insert Inventory table into the database." + Environment.NewLine;
} }
break; break;
case TrimmingOperationResult.CreatedUpdateTable: case TrimmingOperationResult.CreatedUpdateTable:
informationLabel.Text += Environment.NewLine + @"Updating changes made to the Inventory table.";
dbWriterStatus = dbW.UpdateInventoryTable(updateTable, dbT.DatabaseConnectionString); dbWriterStatus = dbW.UpdateInventoryTable(updateTable, dbT.DatabaseConnectionString);
if (dbWriterStatus.GetErrorMessage() == string.Empty) if (dbWriterStatus.GetErrorMessage() == string.Empty)
{ {
@@ -2797,33 +2777,35 @@ namespace AdvertsingProfitControl
{ {
//Only reset the IsDirty value to false since the updates when through. //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].Cells[(int)InventoryTableColumns.IsDirty].Value = false;
inventoryDataGridView.Rows[rowIndex.Key - 1].HeaderCell.Style.BackColor = ApplicationColors.EditingSaved;
} }
informationLabel.Text += Environment.NewLine + @"Inventory table successfully updated."; informationLabel.Text += @"Inventory table successfully updated." + Environment.NewLine;
successful = true; successful = true;
} }
else else
{ {
errorLabel.Text = @"Failed to update the changes in the Inventory table."; errorLabel.Text = @"Failed to update the changes in the Inventory table." + Environment.NewLine;
} }
break; break;
case TrimmingOperationResult.CreatedNewInsertionAndUpdateTables: case TrimmingOperationResult.CreatedNewInsertionAndUpdateTables:
//Insert the new values... //Insert the new values...
informationLabel.Text += Environment.NewLine + @"Inserting new changes to the Inventory table.";
dbWriterStatus = dbW.InsertIntoInventoryTable(trimmedTable, dbT.DatabaseConnectionString); dbWriterStatus = dbW.InsertIntoInventoryTable(trimmedTable, dbT.DatabaseConnectionString);
if (dbWriterStatus.GetErrorMessage() == string.Empty) if (dbWriterStatus.GetErrorMessage() == string.Empty)
{ {
//Spin through the collection and update the affected rows. //Spin through the collection and update the affected rows.
foreach (var rowIndex in dbWriterStatus.GetRowCollection()) 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.Id].Value = rowIndex.Value;
inventoryDataGridView.Rows[rowIndex.Key - 1].Cells[(int)InventoryTableColumns.IsDirty].Value = false; inventoryDataGridView.Rows[rowIndex.Key - 1].Cells[(int)InventoryTableColumns.IsDirty].Value = false;
inventoryDataGridView.Rows[rowIndex.Key - 1].HeaderCell.Style.BackColor = ApplicationColors.EditingSaved;
} }
informationLabel.Text += Environment.NewLine + @"Inventory table successfully added to the database."; informationLabel.Text += @"Inventory table successfully added to the database." + Environment.NewLine;
successful = true; successful = true;
} }
else else
{ {
errorLabel.Text = @"Failed to insert Inventory table into the database."; errorLabel.Text = @"Failed to insert Inventory table into the database." + Environment.NewLine;
} }
dbWriterStatus = dbW.UpdateInventoryTable(updateTable, dbT.DatabaseConnectionString); dbWriterStatus = dbW.UpdateInventoryTable(updateTable, dbT.DatabaseConnectionString);
if (dbWriterStatus.GetErrorMessage() == string.Empty) if (dbWriterStatus.GetErrorMessage() == string.Empty)
@@ -2832,15 +2814,15 @@ namespace AdvertsingProfitControl
foreach (var rowIndex in dbWriterStatus.GetRowCollection()) foreach (var rowIndex in dbWriterStatus.GetRowCollection())
{ {
//Only reset the IsDirty value to false since the updates when through. //Only reset the IsDirty value to false since the updates when through.
inventoryDataGridView.Rows[rowIndex.Key - 1].Cells[(int) InventoryTableColumns.IsDirty] inventoryDataGridView.Rows[rowIndex.Key - 1].Cells[(int) InventoryTableColumns.IsDirty].Value = false;
.Value = false; inventoryDataGridView.Rows[rowIndex.Key - 1].HeaderCell.Style.BackColor = ApplicationColors.EditingSaved;
} }
informationLabel.Text += Environment.NewLine + @"Inventory table successfully updated."; informationLabel.Text += @"Inventory table successfully updated." + Environment.NewLine;
successful = true; successful = true;
} }
else else
{ {
errorLabel.Text = @"Failed to update the changes in the Inventory table."; errorLabel.Text = @"Failed to update the changes in the Inventory table." + Environment.NewLine;
} }
break; break;
} }
@@ -120,9 +120,6 @@
<metadata name="mainMenuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <metadata name="mainMenuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value> <value>17, 17</value>
</metadata> </metadata>
<metadata name="mainMenuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> <assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> <data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value> <value>
@@ -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>0ciZORzVO0teig7ltOqRbCAT8SY4vWnHXeZQzuXDQso=</dsig:DigestValue> <dsig:DigestValue>awuF53zQVe9V3zUNL3d5T6YCMzmHhsse6PclfUp46TM=</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="3546624"> <dependentAssembly dependencyType="install" allowDelayedBinding="true" codebase="AdvertsingProfitControl.exe" size="3544576">
<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>J37ovQ2w2uLSWexQjta/p83ZtKKy+IC5/Dlnu814/qs=</dsig:DigestValue> <dsig:DigestValue>UU8qwZxBBKymnYncKNbRY9vyIqD6hwiqMecESA476/8=</dsig:DigestValue>
</hash> </hash>
</dependentAssembly> </dependentAssembly>
</dependency> </dependency>
@@ -84,7 +84,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>OTOg6k+3pem3uA+Xpy/Nu0Ifwo+hXeYq3hn83njXnT4=</dsig:DigestValue> <dsig:DigestValue>vIWbpHhaPK+/SPRL5GUWOfjJsfzpB/rCMLUdLPlUB+s=</dsig:DigestValue>
</hash> </hash>
</file> </file>
<file name="Stretched Logo Collection.ico" size="370070"> <file name="Stretched Logo Collection.ico" size="370070">