diff --git a/AdvertsingProfitControl/APCDatabaseWriter.cs b/AdvertsingProfitControl/APCDatabaseWriter.cs
deleted file mode 100644
index 52e2727..0000000
--- a/AdvertsingProfitControl/APCDatabaseWriter.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Data.OleDb;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace AdvertsingProfitControl
-{
- internal class ApcDatabaseWriter
- {
- private readonly FrmLogConsole _logConsole = FrmLogConsole.GetStaticInstance;
- private OleDbConnection oleDbConnection;
-
-
- }
-}
diff --git a/AdvertsingProfitControl/AdvertsingProfitControl.csproj b/AdvertsingProfitControl/AdvertsingProfitControl.csproj
index b28db10..8be484f 100644
--- a/AdvertsingProfitControl/AdvertsingProfitControl.csproj
+++ b/AdvertsingProfitControl/AdvertsingProfitControl.csproj
@@ -123,7 +123,6 @@
NewModifyRecord.cs
-
diff --git a/AdvertsingProfitControl/DbWriterStatus.cs b/AdvertsingProfitControl/DbWriterStatus.cs
index 72bc5be..0b637d0 100644
--- a/AdvertsingProfitControl/DbWriterStatus.cs
+++ b/AdvertsingProfitControl/DbWriterStatus.cs
@@ -9,7 +9,6 @@ namespace AdvertsingProfitControl
internal class DbWriterStatus
{
public string ErrorMessage;
- public string Message;
public int Id;
public WritingOperationStatus Status;
}
diff --git a/AdvertsingProfitControl/FrmMain.cs b/AdvertsingProfitControl/FrmMain.cs
index 665f90f..e3ea211 100644
--- a/AdvertsingProfitControl/FrmMain.cs
+++ b/AdvertsingProfitControl/FrmMain.cs
@@ -126,7 +126,7 @@ namespace AdvertsingProfitControl
{
var databaseTracker = new DatabaseTracker();
var databaseReader = new DatabaseReader();
- var form = new NewAddRecord();
+ var form = new NewModifyRecord();
form.ShowDialog();
//One the user has closed the add record form, check to see if there is a newer date
//available. If so, reload the form.
diff --git a/AdvertsingProfitControl/NewAddRecord.cs b/AdvertsingProfitControl/NewAddRecord.cs
index ef7869b..92684ca 100644
--- a/AdvertsingProfitControl/NewAddRecord.cs
+++ b/AdvertsingProfitControl/NewAddRecord.cs
@@ -32,7 +32,6 @@ namespace AdvertsingProfitControl
//Flag showing whether or not the AdSpecialRow has been made in this session.
private int _adSpecialIndex = -1;
private readonly AdvertisingProfitControlTableHelper _tableHelperFunctions = new AdvertisingProfitControlTableHelper();
- private TabPage _debugTabPage;
public NewAddRecord()
{
@@ -147,7 +146,6 @@ namespace AdvertsingProfitControl
suppliesTextBox.Enter += StoreBeginningTextBoxValue;
suppliesTextBox.Validating += ValidateCostAnalysisValues;
//
- _debugTabPage = mainTabControl.TabPages[4];
mainTabControl.TabPages.Remove(mainTabControl.TabPages[4]);
//Select Saturday if it is not already set.
if (weekEndingCalendar.SelectionStart.DayOfWeek == DayOfWeek.Saturday) return;
diff --git a/AdvertsingProfitControl/NewModifyRecord.Designer.cs b/AdvertsingProfitControl/NewModifyRecord.Designer.cs
index 79224c1..084e025 100644
--- a/AdvertsingProfitControl/NewModifyRecord.Designer.cs
+++ b/AdvertsingProfitControl/NewModifyRecord.Designer.cs
@@ -33,7 +33,6 @@
this.FileMainMenu = new System.Windows.Forms.ToolStripMenuItem();
this.clearFormFileMainMenu = new System.Windows.Forms.ToolStripMenuItem();
this.exitFileMainMenu = new System.Windows.Forms.ToolStripMenuItem();
- this.debugMainMenu = new System.Windows.Forms.ToolStripMenuItem();
this.mainTabControl = new System.Windows.Forms.TabControl();
this.projectionTabPage = new System.Windows.Forms.TabPage();
this.projectionsDataGridView = new System.Windows.Forms.DataGridView();
@@ -107,6 +106,8 @@
this.informationPanel = new System.Windows.Forms.Panel();
this.errorLabel = new System.Windows.Forms.Label();
this.addRecordButton = new System.Windows.Forms.Button();
+ this.editMainMenu = new System.Windows.Forms.ToolStripMenuItem();
+ this.createNewRecordEditMainMenu = new System.Windows.Forms.ToolStripMenuItem();
this.mainLayoutPanel.SuspendLayout();
this.mainMenuStrip.SuspendLayout();
this.mainTabControl.SuspendLayout();
@@ -163,7 +164,7 @@
this.mainMenuStrip.ImageScalingSize = new System.Drawing.Size(24, 24);
this.mainMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.FileMainMenu,
- this.debugMainMenu});
+ this.editMainMenu});
this.mainMenuStrip.Location = new System.Drawing.Point(0, 0);
this.mainMenuStrip.Name = "mainMenuStrip";
this.mainMenuStrip.Padding = new System.Windows.Forms.Padding(7, 2, 0, 2);
@@ -192,12 +193,6 @@
this.exitFileMainMenu.Size = new System.Drawing.Size(205, 34);
this.exitFileMainMenu.Text = "E&xit";
//
- // debugMainMenu
- //
- this.debugMainMenu.Name = "debugMainMenu";
- this.debugMainMenu.Size = new System.Drawing.Size(87, 31);
- this.debugMainMenu.Text = "&Debug";
- //
// mainTabControl
//
this.mainLayoutPanel.SetColumnSpan(this.mainTabControl, 4);
@@ -944,6 +939,21 @@
this.addRecordButton.UseVisualStyleBackColor = true;
this.addRecordButton.Click += new System.EventHandler(this.addRecordButton_Click);
//
+ // editMainMenu
+ //
+ this.editMainMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.createNewRecordEditMainMenu});
+ this.editMainMenu.Name = "editMainMenu";
+ this.editMainMenu.Size = new System.Drawing.Size(60, 31);
+ this.editMainMenu.Text = "&Edit";
+ //
+ // createNewRecordEditMainMenu
+ //
+ this.createNewRecordEditMainMenu.Name = "createNewRecordEditMainMenu";
+ this.createNewRecordEditMainMenu.Size = new System.Drawing.Size(283, 34);
+ this.createNewRecordEditMainMenu.Text = "&Create New Record";
+ this.createNewRecordEditMainMenu.Click += new System.EventHandler(this.createNewRecordEditMainMenu_Click);
+ //
// NewModifyRecord
//
this.AutoScaleDimensions = new System.Drawing.SizeF(11F, 24F);
@@ -955,7 +965,6 @@
this.Text = "Modify Record";
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.NewModifyRecord_FormClosing);
- this.Load += new System.EventHandler(this.NewModifyRecord_Load);
this.mainLayoutPanel.ResumeLayout(false);
this.mainLayoutPanel.PerformLayout();
this.mainMenuStrip.ResumeLayout(false);
@@ -997,7 +1006,6 @@
private System.Windows.Forms.ToolStripMenuItem FileMainMenu;
private System.Windows.Forms.ToolStripMenuItem clearFormFileMainMenu;
private System.Windows.Forms.ToolStripMenuItem exitFileMainMenu;
- private System.Windows.Forms.ToolStripMenuItem debugMainMenu;
private System.Windows.Forms.TabControl mainTabControl;
private System.Windows.Forms.TabPage projectionTabPage;
private System.Windows.Forms.DataGridView projectionsDataGridView;
@@ -1071,5 +1079,7 @@
private System.Windows.Forms.Panel informationPanel;
private System.Windows.Forms.Label errorLabel;
private System.Windows.Forms.Button addRecordButton;
+ private System.Windows.Forms.ToolStripMenuItem editMainMenu;
+ private System.Windows.Forms.ToolStripMenuItem createNewRecordEditMainMenu;
}
}
\ No newline at end of file
diff --git a/AdvertsingProfitControl/NewModifyRecord.cs b/AdvertsingProfitControl/NewModifyRecord.cs
index 3691828..c5f160a 100644
--- a/AdvertsingProfitControl/NewModifyRecord.cs
+++ b/AdvertsingProfitControl/NewModifyRecord.cs
@@ -37,7 +37,6 @@ namespace AdvertsingProfitControl
private DateTime _currentActiveDate;
//
private bool _isFormDirty;
- private TabPage _debugTabPage;
public NewModifyRecord(DateTime date)
{
@@ -46,9 +45,9 @@ namespace AdvertsingProfitControl
var databaseTracker = new DatabaseTracker();
var databaseReader = new DatabaseReader();
weekEndingCalendar.BoldedDates = databaseReader.RetrieveDates(databaseTracker.DatabaseConnectionString).ToArray();
- weekEndingCalendar.SelectionStart = date;
- _currentActiveDate = date;
- weekEndingCalendar.DateChanged += ValidateDateChanged;
+ weekEndingCalendar.SelectionStart = date;
+ _currentActiveDate = date;
+ weekEndingCalendar.DateChanged += ValidateDateChanged;
//next pull all the ad items into memory.
_adItemCollection = databaseReader.GetAdItemsSuggestionList(databaseTracker.DatabaseConnectionString);
//Now pull all the suppliers and the ad special list into memory.
@@ -156,12 +155,134 @@ namespace AdvertsingProfitControl
suppliesTextBox.Enter += StoreBeginningTextBoxValue;
suppliesTextBox.Validating += ValidateCostAnalysisValues;
//
- _debugTabPage = mainTabControl.TabPages[4];
- mainTabControl.TabPages.Remove(mainTabControl.TabPages[4]);
- Text = @"Modify Record (Current Record: " + date.ToString("d") + @")";
+ //_debugTabPage = mainTabControl.TabPages[4];
+ //mainTabControl.TabPages.Remove(mainTabControl.TabPages[4]);
+ Text = @"Modify Record (Current Record: " + date.ToShortDateString() + @")";
LoadDate(date);
}
+ public NewModifyRecord()
+ {
+ InitializeComponent();
+ //Start by grabbing all the AdItems and putting them into memory.
+ var databaseTracker = new DatabaseTracker();
+ var databaseReader = new DatabaseReader();
+ weekEndingCalendar.BoldedDates = databaseReader.RetrieveDates(databaseTracker.DatabaseConnectionString).ToArray();
+ SetNewRecordDate(databaseReader.RetrieveMostRecentDate(databaseTracker.DatabaseConnectionString), 2);
+ _currentActiveDate = weekEndingCalendar.SelectionStart;
+ //next pull all the ad items into memory.
+ _adItemCollection = databaseReader.GetAdItemsSuggestionList(databaseTracker.DatabaseConnectionString);
+ //Now pull all the suppliers and the ad special list into memory.
+ _supplierCollection = databaseReader.GetSupplierSuggestionList(databaseTracker.DatabaseConnectionString);
+ _adSpecialList = databaseReader.RetrieveAdSpecialList(databaseTracker.DatabaseConnectionString);
+ //Initialize the used ad item collection.
+ _usedAdItems[0] = new List();
+ _usedAdItems[1] = new List();
+ //Assign the events for the comments text box and display the remaining character count for the user.
+ commentsTextBox.TextChanged += DisplayRemainingCommentCharacterCount;
+ commentsGroupBox.Text = @"Comments (Characters Remaining: " + commentsTextBox.MaxLength + @")";
+ //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..
+ //Hook the row add event so we can paint a row number in the header cell of the row.
+ projectionsDataGridView.RowsAdded += DisplayRowNumbers;
+ inventoryDataGridView.RowsAdded += DisplayRowNumbers;
+ actualSalesDataGridView.RowsAdded += DisplayRowNumbers;
+ //Assign all the tables to store the cell's contents on enter so changes (if any) can be detected and flagged (marked as dirty).
+ projectionsDataGridView.CellEnter += StoreBeginningCellValue;
+ inventoryDataGridView.CellEnter += StoreBeginningCellValue;
+ actualSalesDataGridView.CellEnter += StoreBeginningCellValue;
+ //Update the contents of the used as item list on row leave.
+ projectionsDataGridView.RowLeave += UpdateUsedAdItemCollectionOnRowLeave;
+ inventoryDataGridView.RowLeave += UpdateUsedAdItemCollectionOnRowLeave;
+ actualSalesDataGridView.RowLeave += UpdateUsedAdItemCollectionOnRowLeave;
+ //Validate, clean and format the contents of the cell that fires the cell validating event.
+ projectionsDataGridView.CellValidating += ValidateSalesDataGridViewCellContents;
+ inventoryDataGridView.CellValidating += ValidateInventoryCellContents;
+ actualSalesDataGridView.CellValidating += ValidateSalesDataGridViewCellContents;
+ //Validate that the row the user is trying to leave is legal (has at least an ad item entered) and prevent the user from leaving the row is its not.
+ projectionsDataGridView.RowValidating += ValidateProjectedRow;
+ inventoryDataGridView.RowValidating += ValidateInventoryRow;
+ actualSalesDataGridView.RowValidating += ValidateActualSalesRow;
+ //Update the used ad item collection by removing the contents of the ad item column when a row is deleted.
+ projectionsDataGridView.UserDeletingRow += UpdateUsedAdItemCollectionOnRowRemoving;
+ inventoryDataGridView.UserDeletingRow += UpdateUsedAdItemCollectionOnRowRemoving;
+ actualSalesDataGridView.UserDeletingRow += UpdateUsedAdItemCollectionOnRowRemoving;
+ //Once a row has been removed update the other tables keep them uniform.
+ projectionsDataGridView.RowsRemoved += ProjectionRowRemoved;
+ inventoryDataGridView.RowsRemoved += InventoryRowRemoved;
+ actualSalesDataGridView.RowsRemoved += ActualSalesRowRemoved;
+ //Grab the underlying text box object in the ad item cell, and build an auto complete list for the user.
+ projectionsDataGridView.EditingControlShowing += DisplayAutoCompleteOnEditingControlShowing;
+ inventoryDataGridView.EditingControlShowing += DisplayAutoCompleteOnEditingControlShowing;
+ actualSalesDataGridView.EditingControlShowing += DisplayAutoCompleteOnEditingControlShowing;
+ //After all events have been set, construct the DataGridVeiws for use.
+ ConstructApcDataGridViews();
+ //Set-up events for the Invoice table.
+ invoicesDataGridView.CellEnter += StoreBeginningCellValue;
+ //Validate that the row the user is trying to leave is legal (has at least an ad item entered) and prevent the user from leaving the row is its not.
+ invoicesDataGridView.RowValidating += ValidateInvoiceRow;
+ //Validate, clean and format the contents of the cell that fires the cell validating event.
+ invoicesDataGridView.CellValidating += ValidateInvoicesCellContents;
+ //Grab the underlying text box object in the ad item cell, and build an auto complete list for the user.
+ invoicesDataGridView.EditingControlShowing += DisplaySupplierAutoComleteOnEditingShadowControl;
+ //Subscribe the method to allow the user to delete saved rows from the Invoices table.
+ invoicesDataGridView.UserDeletingRow += UpdateInvoicesOnRowDeleting;
+ //Finally build the last DataGridView for the form.
+ ConstructInvoicesDataGridView();//No weekly sales table is nice.
+ //Subscribe the comments text box to check if changes have been made on leave.
+ commentsTextBox.Enter += StoreBeginningTextBoxValue;
+ commentsTextBox.KeyDown += CheckForKeyCommand;
+ commentsTextBox.Leave += CheckForTextChangeOnLeave;
+ //Subscribe the weekly sales text boxes to validation, update required checks and auto-complete methods.
+ sundayWeeklySalesTextBox.Enter += StoreBeginningTextBoxValue;
+ sundayWeeklySalesTextBox.Validating += ValidateWeeklySales;
+ mondayWeeklySalesTextBox.Enter += StoreBeginningTextBoxValue;
+ mondayWeeklySalesTextBox.Validating += ValidateWeeklySales;
+ tuesdayWeeklySalesTextBox.Enter += StoreBeginningTextBoxValue;
+ tuesdayWeeklySalesTextBox.Validating += ValidateWeeklySales;
+ wednesdayWeeklySalesTextBox.Enter += StoreBeginningTextBoxValue;
+ wednesdayWeeklySalesTextBox.Validating += ValidateWeeklySales;
+ thursdayWeeklySalesTextBox.Enter += StoreBeginningTextBoxValue;
+ thursdayWeeklySalesTextBox.Validating += ValidateWeeklySales;
+ fridayWeeklySalesTextBox.Enter += StoreBeginningTextBoxValue;
+ fridayWeeklySalesTextBox.Validating += ValidateWeeklySales;
+ saturdayWeeklySalesTextBox.Enter += StoreBeginningTextBoxValue;
+ saturdayWeeklySalesTextBox.Validating += ValidateWeeklySales;
+ totalWeeklySalesTextBox.Enter += StoreBeginningTextBoxValue;
+ totalWeeklySalesTextBox.Validating += ValidateWeeklySales;
+ //Subscribe the taxable text boxes to validation and update events.
+ sundayTaxableTextBox.Enter += StoreBeginningTextBoxValue;
+ sundayTaxableTextBox.Validating += ValidateTaxableFields;
+ mondayTaxableTextBox.Enter += StoreBeginningTextBoxValue;
+ mondayTaxableTextBox.Validating += ValidateTaxableFields;
+ tuesdayTaxableTextBox.Enter += StoreBeginningTextBoxValue;
+ tuesdayTaxableTextBox.Validating += ValidateTaxableFields;
+ wednesdayTaxableTextBox.Enter += StoreBeginningTextBoxValue;
+ wednesdayTaxableTextBox.Validating += ValidateTaxableFields;
+ thursdayTaxableTextBox.Enter += StoreBeginningTextBoxValue;
+ thursdayTaxableTextBox.Validating += ValidateTaxableFields;
+ fridayTaxableTextBox.Enter += StoreBeginningTextBoxValue;
+ fridayTaxableTextBox.Validating += ValidateTaxableFields;
+ saturdayTaxableTextBox.Enter += StoreBeginningTextBoxValue;
+ saturdayTaxableTextBox.Validating += ValidateTaxableFields;
+ totalTaxableTextBox.Enter += StoreBeginningTextBoxValue;
+ totalTaxableTextBox.Validating += ValidateTaxableFields;
+ //Subscribe the Cost Analysis text boxes to the validation and update events.
+ salesPerManHourTextBox.Enter += StoreBeginningTextBoxValue;
+ salesPerManHourTextBox.Validating += ValidateCostAnalysisValues;
+ salaryPercentageTextBox.Enter += StoreBeginningTextBoxValue;
+ salaryPercentageTextBox.Validating += ValidateCostAnalysisValues;
+ salaryDollarsTextBox.Enter += StoreBeginningTextBoxValue;
+ salaryDollarsTextBox.Validating += ValidateCostAnalysisValues;
+ suppliesTextBox.Enter += StoreBeginningTextBoxValue;
+ suppliesTextBox.Validating += ValidateCostAnalysisValues;
+ //
+ //_debugTabPage = mainTabControl.TabPages[4];
+ //mainTabControl.TabPages.Remove(mainTabControl.TabPages[4]);
+ Text = @"Add New Record (Current Record: " + _currentActiveDate.ToShortDateString() + @")";
+ addRecordButton.Text = @"Add Record";
+ }
+
public sealed override string Text
{
get { return base.Text; }
@@ -425,7 +546,7 @@ namespace AdvertsingProfitControl
///
///
///
- private void DisplayRowNumbers(object sender, DataGridViewRowsAddedEventArgs e)
+ private static void DisplayRowNumbers(object sender, DataGridViewRowsAddedEventArgs e)
{
var table = ((DataGridView)sender);
table.Rows[e.RowIndex].HeaderCell.Value = (e.RowIndex + 1).ToString();
@@ -1041,11 +1162,20 @@ namespace AdvertsingProfitControl
projectionsDataGridView.Rows[e.RowIndex].Cells[adItemIndex].Selected = true;
e.Cancel = true;
}
+ //Check to see if the other tables have more then one additional row. If the tables have two or more rows than the Projections table then that means
+ //the tables have become unbalanced and need to be repaired. If the difference is only one row than that means the user is simply adding this row as
+ //a new entry to the Projections table.
+ if (projectionsDataGridView.RowCount - actualSalesDataGridView.RowCount > 1 || projectionsDataGridView.RowCount - inventoryDataGridView.RowCount > 1)
+ {
+ NormalizeApcTables();
+ return;
+ }
//Check to see if the user left a row that already exists and doesn't require being copied over.
if (projectionsDataGridView.Rows[e.RowIndex].Cells[adItemIndex].EditedFormattedValue.ToString() == actualSalesDataGridView.Rows[e.RowIndex].Cells[adItemIndex].EditedFormattedValue.ToString())
{
return;
}
+ _isFormDirty = true;
//Next check to see if the user changed the ad item is the corresponding row.
if (projectionsDataGridView.Rows[e.RowIndex].Cells[adItemIndex].EditedFormattedValue.ToString() != actualSalesDataGridView.Rows[e.RowIndex].Cells[adItemIndex].EditedFormattedValue.ToString())
{
@@ -1197,6 +1327,8 @@ namespace AdvertsingProfitControl
LogConsole.WriteToLog(FrmLogConsole.Level.Error, "Inventory Row Count: " + inventoryDataGridView.RowCount);
LogConsole.WriteToLog(FrmLogConsole.Level.Error, "Actual Sales Row Count: " + actualSalesDataGridView.RowCount);
errorLabel.Text = @"Error removing rows from Actual Sales and Inventory.";
+ NormalizeApcTables();
+ return;
}
//... After all the row removal has been finished re-enable the row removal events.
inventoryDataGridView.UserDeletingRow += UpdateUsedAdItemCollectionOnRowRemoving;
@@ -1305,7 +1437,7 @@ namespace AdvertsingProfitControl
else
{
_usedAdItems[_adSpecialIndex == -1 || e.RowIndex < _adSpecialIndex ? 0 : 1].Remove(_beginningCellValue);
- dataGridView.Rows[e.RowIndex].Cells[(int)InventoryTableColumns.IsDirty].Value = true;
+ dataGridView.Rows[e.RowIndex].Cells[(int)InventoryTableColumns.IsDirty].Value = true;
}
}
else if (userInput != _beginningCellValue)
@@ -1413,11 +1545,20 @@ namespace AdvertsingProfitControl
inventoryDataGridView.Rows[e.RowIndex].Cells[adItemIndex].Selected = true;
e.Cancel = true;
}
+ //Check to see if the other tables have more then one additional row. If the tables have two or more rows than the Inventory table then that means
+ //the tables have become unbalanced and need to be repaired. If the difference is only one row than that means the user is simply adding this row as
+ //a new entry to the Inventory table.
+ if (inventoryDataGridView.RowCount - projectionsDataGridView.RowCount > 1 || inventoryDataGridView.RowCount - actualSalesDataGridView.RowCount > 1)
+ {
+ NormalizeApcTables();
+ return;
+ }
//Check to see if the user left a row that already exists and doesn't require being copied over.
if (inventoryDataGridView.Rows[e.RowIndex].Cells[adItemIndex].EditedFormattedValue.ToString() == actualSalesDataGridView.Rows[e.RowIndex].Cells[adItemIndex].EditedFormattedValue.ToString())
{
return;
}
+ _isFormDirty = true;
//Next check to see if the user changed the ad item is the corresponding row.
if (inventoryDataGridView.Rows[e.RowIndex].Cells[adItemIndex].EditedFormattedValue.ToString() != actualSalesDataGridView.Rows[e.RowIndex].Cells[adItemIndex].EditedFormattedValue.ToString())
{
@@ -1530,6 +1671,8 @@ namespace AdvertsingProfitControl
LogConsole.WriteToLog(FrmLogConsole.Level.Error, "Inventory Row Count: " + inventoryDataGridView.RowCount);
LogConsole.WriteToLog(FrmLogConsole.Level.Error, "Actual Sales Row Count: " + actualSalesDataGridView.RowCount);
errorLabel.Text = @"Error removing rows from Actual Sales and Inventory.";
+ NormalizeApcTables();
+ return;
}
//... After all the row removal has been finished re-enable the row removal events.
projectionsDataGridView.UserDeletingRow += UpdateUsedAdItemCollectionOnRowRemoving;
@@ -1581,11 +1724,20 @@ namespace AdvertsingProfitControl
actualSalesDataGridView.Rows[e.RowIndex].Cells[adItemIndex].Selected = true;
e.Cancel = true;
}
+ //Check to see if the other tables have more then one additional row. If the tables have two or more rows than the Actual Sales table then that means
+ //the tables have become unbalanced and need to be repaired. If the difference is only one row than that means the user is simply adding this row as
+ //a new entry to the Actual Sales table.
+ if (actualSalesDataGridView.RowCount - projectionsDataGridView.RowCount > 1 || actualSalesDataGridView.RowCount - inventoryDataGridView.RowCount > 1)
+ {
+ NormalizeApcTables();
+ return;
+ }
//Check to see if the user left a row that already exists and doesn't require being copied over.
if (actualSalesDataGridView.Rows[e.RowIndex].Cells[adItemIndex].EditedFormattedValue.ToString() == projectionsDataGridView.Rows[e.RowIndex].Cells[adItemIndex].EditedFormattedValue.ToString())
{
return;
}
+ _isFormDirty = true;
//Next check to see if the user changed the ad item is the corresponding row.
if (actualSalesDataGridView.Rows[e.RowIndex].Cells[adItemIndex].EditedFormattedValue.ToString() != projectionsDataGridView.Rows[e.RowIndex].Cells[adItemIndex].EditedFormattedValue.ToString())
{
@@ -1735,6 +1887,8 @@ namespace AdvertsingProfitControl
LogConsole.WriteToLog(FrmLogConsole.Level.Error, "Inventory Row Count: " + inventoryDataGridView.RowCount);
LogConsole.WriteToLog(FrmLogConsole.Level.Error, "Actual Sales Row Count: " + actualSalesDataGridView.RowCount);
errorLabel.Text = @"Error removing rows from Actual Sales and Inventory.";
+ NormalizeApcTables();
+ return;
}
//... After all the row removal has been finished re-enable the row removal events.
projectionsDataGridView.UserDeletingRow += UpdateUsedAdItemCollectionOnRowRemoving;
@@ -2202,6 +2356,7 @@ namespace AdvertsingProfitControl
private void ValidateDateChanged(object sender, DateRangeEventArgs e)
{
if (e.Start == _currentActiveDate || !weekEndingCalendar.BoldedDates.Contains(e.Start)) return;
+ //If the form is dirty then prompt the user to save changes.
if (_isFormDirty)
{
var result = MessageBox.Show(@"Would you like to save the changes you have made to this record?", @"Changes Detected", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
@@ -2227,12 +2382,45 @@ namespace AdvertsingProfitControl
}
_currentActiveDate = e.Start;
Text = @"Modify Record (Current Record: " + e.Start.ToString("d") + @")";
+ addRecordButton.Text = @"Update Record";
//Clear the form state.
ClearFormState();
//Load the specified date from the database.
LoadDate(e.Start);
}
+ private void SetNewRecordDate(DateTime date, int weeksAhead = 0)
+ {
+ weekEndingCalendar.DateChanged -= ValidateDateChanged;
+ switch (date.DayOfWeek)
+ {
+ case DayOfWeek.Sunday:
+ weekEndingCalendar.SelectionStart = date.AddDays(6 + (weeksAhead * 7));
+ break;
+ case DayOfWeek.Monday:
+ weekEndingCalendar.SelectionStart = date.AddDays(5 + (weeksAhead * 7));
+ break;
+ case DayOfWeek.Tuesday:
+ weekEndingCalendar.SelectionStart = date.AddDays(4 + (weeksAhead * 7));
+ break;
+ case DayOfWeek.Wednesday:
+ weekEndingCalendar.SelectionStart = date.AddDays(3 + (weeksAhead * 7));
+ break;
+ case DayOfWeek.Thursday:
+ weekEndingCalendar.SelectionStart = date.AddDays(2 + (weeksAhead * 7));
+ break;
+ case DayOfWeek.Friday:
+ weekEndingCalendar.SelectionStart = date.AddDays(1 + (weeksAhead * 7));
+ break;
+ case DayOfWeek.Saturday:
+ weekEndingCalendar.SelectionStart = date.AddDays((weeksAhead * 7));
+ break;
+ default:
+ return;
+ }
+ weekEndingCalendar.DateChanged += ValidateDateChanged;
+ }
+
#endregion
private void ClearFormState()
@@ -2311,8 +2499,8 @@ namespace AdvertsingProfitControl
//Reset the form's dirty flag
_isFormDirty = false;
//Clear the used ad items
- _usedAdItems[0].Clear(); //regular ad items (section 1)
- _usedAdItems[1].Clear(); //ad special items (section 2)
+ _usedAdItems[0].Clear(); //regular ad items (section 1)
+ _usedAdItems[1].Clear(); //ad special items (section 2)
//Clear invoices
invoicesDataGridView.Rows.Clear();
//Clear comments
@@ -2451,8 +2639,7 @@ namespace AdvertsingProfitControl
{
informationLabel.Text += @"No comments to display." + Environment.NewLine;
}
- var weeklySales = databaseReader.ReturnWeeklySalesFromDateId(dateId,
- databaseTracker.DatabaseConnectionString);
+ var weeklySales = databaseReader.ReturnWeeklySalesFromDateId(dateId, databaseTracker.DatabaseConnectionString);
if (weeklySales.Rows.Count == 1)
{
LoadWeeklySales(weeklySales);
@@ -2472,8 +2659,7 @@ namespace AdvertsingProfitControl
informationLabel.Text += @"No taxable data to display." + Environment.NewLine;
}
LoadInvoices(invoices);
- var costAnalysis = databaseReader.ReturnCostAnalysis(dateId,
- databaseTracker.DatabaseConnectionString);
+ var costAnalysis = databaseReader.ReturnCostAnalysis(dateId, databaseTracker.DatabaseConnectionString);
if (costAnalysis.Rows.Count == 1)
{
LoadCostAnalysis(costAnalysis);
@@ -2493,7 +2679,7 @@ namespace AdvertsingProfitControl
projectionsDataGridView.CellValidating -= ValidateSalesDataGridViewCellContents;
projectionsDataGridView.RowValidating -= ValidateProjectedRow;
- for(var rowIndex = 0; rowIndex < projections.Rows.Count; rowIndex++)
+ for (var rowIndex = 0; rowIndex < projections.Rows.Count; rowIndex++)
{
var newRow = new DataGridViewRow();
for (var cellIndex = 0; cellIndex < projections.Rows[rowIndex].ItemArray.Length; cellIndex++)
@@ -2518,7 +2704,7 @@ namespace AdvertsingProfitControl
}
else
{
- var cell = new DataGridViewTextBoxCell { Value = projections.Rows[rowIndex].ItemArray[cellIndex].ToString() };
+ var cell = new DataGridViewTextBoxCell {Value = projections.Rows[rowIndex].ItemArray[cellIndex].ToString()};
newRow.Cells.Add(cell);
}
continue;
@@ -2563,25 +2749,20 @@ namespace AdvertsingProfitControl
{
var databaseTracker = new DatabaseTracker();
var databaseReader = new DatabaseReader();
- var groupName =
- databaseReader.ReturnGroupNameFromGroupId(
- projections.Rows[rowIndex].ItemArray[cellIndex].ToString(),
- databaseTracker.DatabaseConnectionString);
+ var groupName = databaseReader.ReturnGroupNameFromGroupId(projections.Rows[rowIndex].ItemArray[cellIndex].ToString(), databaseTracker.DatabaseConnectionString);
var adSpecialRow = new DataGridViewRow();
projectionsDataGridView.Rows.Add(adSpecialRow);
projectionsDataGridView.Rows[rowIndex].Cells[1].Value = groupName;
- projectionsDataGridView.Rows[rowIndex].DefaultCellStyle.BackColor =
- ApplicationColors.AdSpecial;
+ projectionsDataGridView.Rows[rowIndex].DefaultCellStyle.BackColor = ApplicationColors.AdSpecial;
_adSpecialIndex = rowIndex;
}
-
}
else
{
//The ad item belongs in section one (1) of the used ad item array.
_usedAdItems[0].Add(projections.Rows[rowIndex].ItemArray[1].ToString());
}
- }
+ }
}
//Set the is dirty cell to false.
var isDirtyCell = new DataGridViewCheckBoxCell
@@ -2631,12 +2812,12 @@ namespace AdvertsingProfitControl
{
if (inventoryTable.Rows[rowIndex].ItemArray[cellIndex].ToString() == "0")
{
- var cell = new DataGridViewTextBoxCell { Value = string.Empty };
+ var cell = new DataGridViewTextBoxCell {Value = string.Empty};
newRow.Cells.Add(cell);
}
else
{
- var cell = new DataGridViewTextBoxCell { Value = inventoryTable.Rows[rowIndex].ItemArray[cellIndex].ToString() };
+ var cell = new DataGridViewTextBoxCell {Value = inventoryTable.Rows[rowIndex].ItemArray[cellIndex].ToString()};
newRow.Cells.Add(cell);
}
continue;
@@ -2675,10 +2856,7 @@ namespace AdvertsingProfitControl
{
var databaseTracker = new DatabaseTracker();
var databaseReader = new DatabaseReader();
- var groupName =
- databaseReader.ReturnGroupNameFromGroupId(
- inventoryTable.Rows[rowIndex].ItemArray[cellIndex].ToString(),
- databaseTracker.DatabaseConnectionString);
+ var groupName = databaseReader.ReturnGroupNameFromGroupId(inventoryTable.Rows[rowIndex].ItemArray[cellIndex].ToString(), databaseTracker.DatabaseConnectionString);
var adSpecialRow = new DataGridViewRow();
inventoryDataGridView.Rows.Add(adSpecialRow);
inventoryDataGridView.Rows[rowIndex].Cells[1].Value = groupName;
@@ -2735,12 +2913,12 @@ namespace AdvertsingProfitControl
{
if (actualSales.Rows[rowIndex].ItemArray[cellIndex].ToString() == "0.0000")
{
- var cell = new DataGridViewTextBoxCell { Value = string.Empty };
+ var cell = new DataGridViewTextBoxCell {Value = string.Empty};
newRow.Cells.Add(cell);
}
else
{
- var cell = new DataGridViewTextBoxCell { Value = actualSales.Rows[rowIndex].ItemArray[cellIndex].ToString() };
+ var cell = new DataGridViewTextBoxCell {Value = actualSales.Rows[rowIndex].ItemArray[cellIndex].ToString()};
newRow.Cells.Add(cell);
}
continue;
@@ -2779,10 +2957,7 @@ namespace AdvertsingProfitControl
{
var databaseTracker = new DatabaseTracker();
var databaseReader = new DatabaseReader();
- var groupName =
- databaseReader.ReturnGroupNameFromGroupId(
- actualSales.Rows[rowIndex].ItemArray[cellIndex].ToString(),
- databaseTracker.DatabaseConnectionString);
+ var groupName = databaseReader.ReturnGroupNameFromGroupId(actualSales.Rows[rowIndex].ItemArray[cellIndex].ToString(), databaseTracker.DatabaseConnectionString);
var adSpecialRow = new DataGridViewRow();
actualSalesDataGridView.Rows.Add(adSpecialRow);
actualSalesDataGridView.Rows[rowIndex].Cells[1].Value = groupName;
@@ -2830,11 +3005,11 @@ namespace AdvertsingProfitControl
var formattedNumber = Math.Round(double.Parse(invoices.Rows[rowIndex].ItemArray[cellIndex].ToString()), 2).ToString("N", new CultureInfo("en-US"));
if (formattedNumber != "0.00")
{
- cell.Value = formattedNumber;
+ cell.Value = formattedNumber;
}
row.Cells.Add(cell);
continue;
- }
+ }
//No special formatting rules here so just put the value in and move on.
cell.Value = invoices.Rows[rowIndex].ItemArray[cellIndex].ToString();
row.Cells.Add(cell);
@@ -3190,12 +3365,9 @@ namespace AdvertsingProfitControl
//Spin through the collection and update the affected rows.
foreach (var rowIndex in writerResult.GetRowCollection())
{
- projectionsDataGridView.Rows[rowIndex.Key - 1].Cells[(int) SalesTableColumns.Id].Value =
- rowIndex.Value;
- projectionsDataGridView.Rows[rowIndex.Key - 1].Cells[(int) SalesTableColumns.IsDirty].Value
- = false;
- projectionsDataGridView.Rows[rowIndex.Key - 1].HeaderCell.Style.BackColor =
- ApplicationColors.EditingSaved;
+ projectionsDataGridView.Rows[rowIndex.Key - 1].Cells[(int) SalesTableColumns.Id].Value = rowIndex.Value;
+ projectionsDataGridView.Rows[rowIndex.Key - 1].Cells[(int) SalesTableColumns.IsDirty].Value = false;
+ projectionsDataGridView.Rows[rowIndex.Key - 1].HeaderCell.Style.BackColor = ApplicationColors.EditingSaved;
}
}
else
@@ -3213,10 +3385,8 @@ namespace AdvertsingProfitControl
foreach (var rowIndex in writerResult.GetRowCollection())
{
//Only reset the IsDirty value to false since the updates when through.
- projectionsDataGridView.Rows[rowIndex.Key - 1].Cells[(int) SalesTableColumns.IsDirty].Value
- = false;
- projectionsDataGridView.Rows[rowIndex.Key - 1].HeaderCell.Style.BackColor =
- ApplicationColors.EditingSaved;
+ projectionsDataGridView.Rows[rowIndex.Key - 1].Cells[(int) SalesTableColumns.IsDirty].Value = false;
+ projectionsDataGridView.Rows[rowIndex.Key - 1].HeaderCell.Style.BackColor = ApplicationColors.EditingSaved;
}
}
else
@@ -3248,12 +3418,9 @@ namespace AdvertsingProfitControl
foreach (var rowIndex in writerResult.GetRowCollection())
{
//Only reset the IsDirty value to false since the updates when through.
- 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;
+ 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;
}
}
else
@@ -3271,7 +3438,7 @@ namespace AdvertsingProfitControl
foreach (var rowIndex in writerResult.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].Cells[(int) InventoryTableColumns.IsDirty].Value = false;
inventoryDataGridView.Rows[rowIndex.Key - 1].HeaderCell.Style.BackColor = ApplicationColors.EditingSaved;
}
}
@@ -3304,8 +3471,8 @@ namespace AdvertsingProfitControl
//Spin through the collection and update the affected rows.
foreach (var rowIndex in writerResult.GetRowCollection())
{
- actualSalesDataGridView.Rows[rowIndex.Key - 1].Cells[(int)SalesTableColumns.Id].Value = rowIndex.Value;
- actualSalesDataGridView.Rows[rowIndex.Key - 1].Cells[(int)SalesTableColumns.IsDirty].Value = false;
+ actualSalesDataGridView.Rows[rowIndex.Key - 1].Cells[(int) SalesTableColumns.Id].Value = rowIndex.Value;
+ actualSalesDataGridView.Rows[rowIndex.Key - 1].Cells[(int) SalesTableColumns.IsDirty].Value = false;
actualSalesDataGridView.Rows[rowIndex.Key - 1].HeaderCell.Style.BackColor = ApplicationColors.EditingSaved;
}
}
@@ -3324,7 +3491,7 @@ namespace AdvertsingProfitControl
foreach (var rowIndex in writerResult.GetRowCollection())
{
//Only reset the IsDirty value to false since the updates when through.
- actualSalesDataGridView.Rows[rowIndex.Key - 1].Cells[(int)SalesTableColumns.IsDirty].Value = false;
+ actualSalesDataGridView.Rows[rowIndex.Key - 1].Cells[(int) SalesTableColumns.IsDirty].Value = false;
actualSalesDataGridView.Rows[rowIndex.Key - 1].HeaderCell.Style.BackColor = ApplicationColors.EditingSaved;
}
}
@@ -3343,7 +3510,7 @@ namespace AdvertsingProfitControl
{
errorLabel.Text += @"Failed to process actual sales." + Environment.NewLine;
}
- if (SaveInvoices(dateId, displayInformation))
+ if (!SaveInvoices(dateId, displayInformation))
{
success = false;
}
@@ -3367,7 +3534,11 @@ namespace AdvertsingProfitControl
if (success)
{
_isFormDirty = false;
+ addRecordButton.Text = @"Update Record";
+ Text = @"Modify Record (Current Record: " + _currentActiveDate.ToShortDateString() + @")";
}
+ weekEndingCalendar.AddBoldedDate(_currentActiveDate);
+ weekEndingCalendar.Invalidate();
return success;
}
@@ -3409,7 +3580,7 @@ namespace AdvertsingProfitControl
errorLabel.Text = writerStatus.GetErrorMessage();
return false;
}
- if(displayInformation) informationLabel.Text += writerStatus.GetErrorMessage() + Environment.NewLine;
+ if (displayInformation) informationLabel.Text += writerStatus.GetErrorMessage() + Environment.NewLine;
return true;
}
@@ -3428,7 +3599,7 @@ namespace AdvertsingProfitControl
errorLabel.Text = status.ErrorMessage;
return false;
}
- if(displayInformation) informationLabel.Text += @"Comment(s) processed successfully." + Environment.NewLine;
+ if (displayInformation) informationLabel.Text += @"Comment(s) processed successfully." + Environment.NewLine;
var id = status.Id;
isCommentDirtyCheckBox.Tag = id;
isCommentDirtyCheckBox.Text = @"IsCommentDirty (" + id + @")";
@@ -3439,8 +3610,7 @@ namespace AdvertsingProfitControl
{
//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()));
+ var status = dbW.ProcessComments(commentsTextBox.Text, dateId, dbT.DatabaseConnectionString, int.Parse(isCommentDirtyCheckBox.Tag.ToString()));
if (status.Status == WritingOperationStatus.Failed)
{
errorLabel.Text = status.ErrorMessage;
@@ -3468,13 +3638,9 @@ namespace AdvertsingProfitControl
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[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[6] = saturdayWeeklySalesTextBox.Text == "" ? 0 : double.Parse(saturdayWeeklySalesTextBox.Text);
weeklySales[7] = totalWeeklySalesTextBox.Text == "" ? 0 : double.Parse(totalWeeklySalesTextBox.Text);
if (isWeeklySalesDirtyCheckBox.Tag == null)
@@ -3494,8 +3660,7 @@ namespace AdvertsingProfitControl
}
else
{
- var status = dbW.ProcessWeeklySales(weeklySales, dateId, dbT.DatabaseConnectionString,
- int.Parse(isWeeklySalesDirtyCheckBox.Tag.ToString()));
+ var status = dbW.ProcessWeeklySales(weeklySales, dateId, dbT.DatabaseConnectionString, int.Parse(isWeeklySalesDirtyCheckBox.Tag.ToString()));
if (status.Status == WritingOperationStatus.Failed)
{
errorLabel.Text = status.ErrorMessage;
@@ -3544,8 +3709,7 @@ namespace AdvertsingProfitControl
}
else
{
- var status = dbW.ProcessTaxable(taxable, dateId, dbT.DatabaseConnectionString,
- int.Parse(isTaxableDirtyCheckBox.Tag.ToString()));
+ var status = dbW.ProcessTaxable(taxable, dateId, dbT.DatabaseConnectionString, int.Parse(isTaxableDirtyCheckBox.Tag.ToString()));
if (status.Status == WritingOperationStatus.Failed)
{
errorLabel.Text = status.ErrorMessage;
@@ -3591,8 +3755,7 @@ namespace AdvertsingProfitControl
}
else
{
- var status = dbW.ProcessCostAnalysis(costAnalysis, dateId, dbT.DatabaseConnectionString,
- int.Parse(isCostAnalysisDirtyCheckBox.Tag.ToString()));
+ var status = dbW.ProcessCostAnalysis(costAnalysis, dateId, dbT.DatabaseConnectionString, int.Parse(isCostAnalysisDirtyCheckBox.Tag.ToString()));
if (status.Status == WritingOperationStatus.Failed)
{
errorLabel.Text = status.ErrorMessage;
@@ -3606,6 +3769,7 @@ namespace AdvertsingProfitControl
if (displayInformation) informationLabel.Text += @"No changes made to Cost Analysis." + Environment.NewLine;
return true;
}
+
#endregion
#region Table Trimming Operations
@@ -3629,8 +3793,7 @@ namespace AdvertsingProfitControl
//Construct a list of column names for the projections/actual sales DataGridViews and the inventory DataGirdView.
string[] saleColumnNames =
{
- "ID", "Sold", "SalePrice", "TotalSales", "Cost", "ProfitReturn",
- "TotalProfitReturn", "AdItemID", "RowAttribute", "AdSpecialID", "RowPosition", "DateID"
+ "ID", "Sold", "SalePrice", "TotalSales", "Cost", "ProfitReturn", "TotalProfitReturn", "AdItemID", "RowAttribute", "AdSpecialID", "RowPosition", "DateID"
};
foreach (var columnName in saleColumnNames)
{
@@ -3652,9 +3815,7 @@ namespace AdvertsingProfitControl
if (_adSpecialIndex != -1)
{
//An ad special does exist so grab its ID from the database.
- int.TryParse(databaseReader.RetrieveGroupIdByString(
- dataGridView.Rows[_adSpecialIndex].Cells[(int)SalesTableColumns.AdItem]
- .EditedFormattedValue.ToString(), databaseTracker.DatabaseConnectionString), out adSpecialId);
+ int.TryParse(databaseReader.RetrieveGroupIdByString(dataGridView.Rows[_adSpecialIndex].Cells[(int) SalesTableColumns.AdItem].EditedFormattedValue.ToString(), databaseTracker.DatabaseConnectionString), out adSpecialId);
}
//Begin spinning through all the rows in the projections table.
foreach (DataGridViewRow row in dataGridView.Rows)
@@ -3667,20 +3828,20 @@ namespace AdvertsingProfitControl
continue;
}
//Check to see if the row is dirty.
- if (!(bool)row.Cells[(int)SalesTableColumns.IsDirty].EditedFormattedValue)
+ if (!(bool) row.Cells[(int) SalesTableColumns.IsDirty].EditedFormattedValue)
{
//If it is not then continue on to the next row.
continue;
}
//Try grabbing the row's ID number (the number that it is in the database).
- var rowIdNumber = row.Cells[(int)SalesTableColumns.Id].EditedFormattedValue.ToString() == "" ? 0 : int.Parse(row.Cells[(int)SalesTableColumns.Id].EditedFormattedValue.ToString());
+ var rowIdNumber = row.Cells[(int) SalesTableColumns.Id].EditedFormattedValue.ToString() == "" ? 0 : int.Parse(row.Cells[(int) SalesTableColumns.Id].EditedFormattedValue.ToString());
//Grab the ad item ID.
- var adItemId = int.Parse(databaseReader.RetrieveAdItemId(row.Cells[(int)SalesTableColumns.AdItem].EditedFormattedValue.ToString(), databaseTracker.DatabaseConnectionString));
+ var adItemId = int.Parse(databaseReader.RetrieveAdItemId(row.Cells[(int) SalesTableColumns.AdItem].EditedFormattedValue.ToString(), databaseTracker.DatabaseConnectionString));
//If the return value is zero (0) then the ad item is not in the database so try to add it.
if (adItemId == 0)
{
//Add the item to the database.
- adItemId = databaseWriter.InsertNewAdItem(row.Cells[(int)SalesTableColumns.AdItem].EditedFormattedValue.ToString());
+ adItemId = databaseWriter.InsertNewAdItem(row.Cells[(int) SalesTableColumns.AdItem].EditedFormattedValue.ToString());
if (adItemId == 0)
{
//TODO: Throw an exception, this can not be allowed.
@@ -3693,11 +3854,11 @@ namespace AdvertsingProfitControl
}
//Determine the row's attribute.
var rowAttribute = 0; //Zero (0) means no grouping, its not a header nor a member.
- if ((bool)row.Cells[(int)SalesTableColumns.IsHeaderRow].EditedFormattedValue && !(bool)row.Cells[(int)SalesTableColumns.IsMemberRow].EditedFormattedValue)
+ if ((bool) row.Cells[(int) SalesTableColumns.IsHeaderRow].EditedFormattedValue && !(bool) row.Cells[(int) SalesTableColumns.IsMemberRow].EditedFormattedValue)
{
rowAttribute = 1;
}
- else if ((bool)row.Cells[(int)SalesTableColumns.IsMemberRow].EditedFormattedValue && !(bool)row.Cells[(int)SalesTableColumns.IsHeaderRow].EditedFormattedValue)
+ else if ((bool) row.Cells[(int) SalesTableColumns.IsMemberRow].EditedFormattedValue && !(bool) row.Cells[(int) SalesTableColumns.IsHeaderRow].EditedFormattedValue)
{
rowAttribute = 2;
}
@@ -3706,12 +3867,12 @@ namespace AdvertsingProfitControl
{
//This table is full of data not in the database so the ID column isn't needed.
var newRow = new object[11];
- newRow[0] = row.Cells[(int)SalesTableColumns.Sold].EditedFormattedValue.ToString();//Sold, is string
- newRow[1] = row.Cells[(int)SalesTableColumns.SalePrice].EditedFormattedValue.ToString();//SalePrice, is string
- newRow[2] = row.Cells[(int)SalesTableColumns.TotalSales].EditedFormattedValue.ToString() == "" ? 0 : double.Parse(row.Cells[(int)SalesTableColumns.TotalSales].EditedFormattedValue.ToString());//TotalSales, must be a number
- newRow[3] = row.Cells[(int)SalesTableColumns.Cost].EditedFormattedValue.ToString() == "" ? 0 : double.Parse(row.Cells[(int)SalesTableColumns.Cost].EditedFormattedValue.ToString());//Cost, must be a number
- newRow[4] = row.Cells[(int)SalesTableColumns.ProfitReturn].EditedFormattedValue.ToString() == "" ? 0 : double.Parse(row.Cells[(int)SalesTableColumns.ProfitReturn].EditedFormattedValue.ToString());//ProfitReturn, must be a number
- newRow[5] = row.Cells[(int)SalesTableColumns.TotalProfitReturn].EditedFormattedValue.ToString() == "" ? 0 : double.Parse(row.Cells[(int)SalesTableColumns.TotalProfitReturn].EditedFormattedValue.ToString());//TotalProfitReturn, must be a number
+ newRow[0] = row.Cells[(int) SalesTableColumns.Sold].EditedFormattedValue.ToString(); //Sold, is string
+ newRow[1] = row.Cells[(int) SalesTableColumns.SalePrice].EditedFormattedValue.ToString(); //SalePrice, is string
+ newRow[2] = row.Cells[(int) SalesTableColumns.TotalSales].EditedFormattedValue.ToString() == "" ? 0 : double.Parse(row.Cells[(int) SalesTableColumns.TotalSales].EditedFormattedValue.ToString()); //TotalSales, must be a number
+ newRow[3] = row.Cells[(int) SalesTableColumns.Cost].EditedFormattedValue.ToString() == "" ? 0 : double.Parse(row.Cells[(int) SalesTableColumns.Cost].EditedFormattedValue.ToString()); //Cost, must be a number
+ newRow[4] = row.Cells[(int) SalesTableColumns.ProfitReturn].EditedFormattedValue.ToString() == "" ? 0 : double.Parse(row.Cells[(int) SalesTableColumns.ProfitReturn].EditedFormattedValue.ToString()); //ProfitReturn, must be a number
+ newRow[5] = row.Cells[(int) SalesTableColumns.TotalProfitReturn].EditedFormattedValue.ToString() == "" ? 0 : double.Parse(row.Cells[(int) SalesTableColumns.TotalProfitReturn].EditedFormattedValue.ToString()); //TotalProfitReturn, must be a number
newRow[6] = adItemId;
newRow[7] = rowAttribute;
if (_adSpecialIndex != -1 && row.Index > _adSpecialIndex)
@@ -3732,12 +3893,12 @@ namespace AdvertsingProfitControl
//This table is full of data that is already in the database.
var newRow = new object[12];
newRow[0] = rowIdNumber;
- newRow[1] = row.Cells[(int)SalesTableColumns.Sold].EditedFormattedValue.ToString();//Sold, is string
- newRow[2] = row.Cells[(int)SalesTableColumns.SalePrice].EditedFormattedValue.ToString();//SalePrice, is string
- newRow[3] = row.Cells[(int)SalesTableColumns.TotalSales].EditedFormattedValue.ToString() == "" ? 0 : double.Parse(row.Cells[(int)SalesTableColumns.TotalSales].EditedFormattedValue.ToString());//TotalSales, must be a number
- newRow[4] = row.Cells[(int)SalesTableColumns.Cost].EditedFormattedValue.ToString() == "" ? 0 : double.Parse(row.Cells[(int)SalesTableColumns.Cost].EditedFormattedValue.ToString());//Cost, must be a number
- newRow[5] = row.Cells[(int)SalesTableColumns.ProfitReturn].EditedFormattedValue.ToString() == "" ? 0 : double.Parse(row.Cells[(int)SalesTableColumns.ProfitReturn].EditedFormattedValue.ToString());//ProfitReturn, must be a number
- newRow[6] = row.Cells[(int)SalesTableColumns.TotalProfitReturn].EditedFormattedValue.ToString() == "" ? 0 : double.Parse(row.Cells[(int)SalesTableColumns.TotalProfitReturn].EditedFormattedValue.ToString());//TotalProfitReturn, must be a number
+ newRow[1] = row.Cells[(int) SalesTableColumns.Sold].EditedFormattedValue.ToString(); //Sold, is string
+ newRow[2] = row.Cells[(int) SalesTableColumns.SalePrice].EditedFormattedValue.ToString(); //SalePrice, is string
+ newRow[3] = row.Cells[(int) SalesTableColumns.TotalSales].EditedFormattedValue.ToString() == "" ? 0 : double.Parse(row.Cells[(int) SalesTableColumns.TotalSales].EditedFormattedValue.ToString()); //TotalSales, must be a number
+ newRow[4] = row.Cells[(int) SalesTableColumns.Cost].EditedFormattedValue.ToString() == "" ? 0 : double.Parse(row.Cells[(int) SalesTableColumns.Cost].EditedFormattedValue.ToString()); //Cost, must be a number
+ newRow[5] = row.Cells[(int) SalesTableColumns.ProfitReturn].EditedFormattedValue.ToString() == "" ? 0 : double.Parse(row.Cells[(int) SalesTableColumns.ProfitReturn].EditedFormattedValue.ToString()); //ProfitReturn, must be a number
+ newRow[6] = row.Cells[(int) SalesTableColumns.TotalProfitReturn].EditedFormattedValue.ToString() == "" ? 0 : double.Parse(row.Cells[(int) SalesTableColumns.TotalProfitReturn].EditedFormattedValue.ToString()); //TotalProfitReturn, must be a number
newRow[7] = adItemId;
newRow[8] = rowAttribute;
if (_adSpecialIndex != -1 && row.Index > _adSpecialIndex)
@@ -3785,8 +3946,7 @@ namespace AdvertsingProfitControl
//Construct a list of column names for the projections/actual sales DataGridViews and the inventory DataGirdView.
string[] saleColumnNames =
{
- "ID", "Sold", "SalePrice", "TotalSales", "Cost", "ProfitReturn",
- "TotalProfitReturn", "AdItemID", "RowAttribute", "AdSpecialID", "RowPosition", "DateID"
+ "ID", "Sold", "SalePrice", "TotalSales", "Cost", "ProfitReturn", "TotalProfitReturn", "AdItemID", "RowAttribute", "AdSpecialID", "RowPosition", "DateID"
};
foreach (var columnName in saleColumnNames)
{
@@ -3808,9 +3968,7 @@ namespace AdvertsingProfitControl
if (_adSpecialIndex != -1)
{
//An ad special does exist so grab its ID from the database.
- int.TryParse(databaseReader.RetrieveGroupIdByString(
- inventoryDataGridView.Rows[_adSpecialIndex].Cells[(int)InventoryTableColumns.AdItem]
- .EditedFormattedValue.ToString(), databaseTracker.DatabaseConnectionString), out adSpecialId);
+ int.TryParse(databaseReader.RetrieveGroupIdByString(inventoryDataGridView.Rows[_adSpecialIndex].Cells[(int) InventoryTableColumns.AdItem].EditedFormattedValue.ToString(), databaseTracker.DatabaseConnectionString), out adSpecialId);
}
//Begin spinning through all the rows in the projections table.
foreach (DataGridViewRow row in inventoryDataGridView.Rows)
@@ -3824,20 +3982,20 @@ namespace AdvertsingProfitControl
continue;
}
//Check to see if the row is dirty.
- if (!(bool)row.Cells[(int)InventoryTableColumns.IsDirty].EditedFormattedValue)
+ if (!(bool) row.Cells[(int) InventoryTableColumns.IsDirty].EditedFormattedValue)
{
//If it is not then continue on to the next row.
continue;
}
//Try grabbing the row's ID number (the number that it is in the database).
- var rowIdNumber = row.Cells[(int)InventoryTableColumns.Id].EditedFormattedValue.ToString() == "" ? 0 : int.Parse(row.Cells[(int)InventoryTableColumns.Id].EditedFormattedValue.ToString());
+ var rowIdNumber = row.Cells[(int) InventoryTableColumns.Id].EditedFormattedValue.ToString() == "" ? 0 : int.Parse(row.Cells[(int) InventoryTableColumns.Id].EditedFormattedValue.ToString());
//Grab the ad item ID.
- var adItemId = int.Parse(databaseReader.RetrieveAdItemId(row.Cells[(int)InventoryTableColumns.AdItem].EditedFormattedValue.ToString(), databaseTracker.DatabaseConnectionString));
+ var adItemId = int.Parse(databaseReader.RetrieveAdItemId(row.Cells[(int) InventoryTableColumns.AdItem].EditedFormattedValue.ToString(), databaseTracker.DatabaseConnectionString));
//If the return value is zero (0) then the ad item is not in the database so try to add it.
if (adItemId == 0)
{
//Add the item to the database.
- adItemId = databaseWriter.InsertNewAdItem(row.Cells[(int)InventoryTableColumns.AdItem].EditedFormattedValue.ToString());
+ adItemId = databaseWriter.InsertNewAdItem(row.Cells[(int) InventoryTableColumns.AdItem].EditedFormattedValue.ToString());
if (adItemId == 0)
{
//TODO: Throw an exception, this can not be allowed.
@@ -3849,11 +4007,11 @@ namespace AdvertsingProfitControl
}
//Determine the row's attribute.
var rowAttribute = 0; //Zero (0) means no grouping, its not a header nor a member.
- if ((bool)row.Cells[(int)InventoryTableColumns.IsHeaderRow].EditedFormattedValue && !(bool)row.Cells[(int)InventoryTableColumns.IsMemberRow].EditedFormattedValue)
+ if ((bool) row.Cells[(int) InventoryTableColumns.IsHeaderRow].EditedFormattedValue && !(bool) row.Cells[(int) InventoryTableColumns.IsMemberRow].EditedFormattedValue)
{
rowAttribute = 1;
}
- else if ((bool)row.Cells[(int)InventoryTableColumns.IsMemberRow].EditedFormattedValue && !(bool)row.Cells[(int)InventoryTableColumns.IsHeaderRow].EditedFormattedValue)
+ else if ((bool) row.Cells[(int) InventoryTableColumns.IsMemberRow].EditedFormattedValue && !(bool) row.Cells[(int) InventoryTableColumns.IsHeaderRow].EditedFormattedValue)
{
rowAttribute = 2;
}
@@ -3862,10 +4020,10 @@ namespace AdvertsingProfitControl
{
//This table is full of data not in the database so the ID column isn't needed.
var newRow = new object[9];
- newRow[0] = row.Cells[(int)InventoryTableColumns.BeginningInventory].EditedFormattedValue.ToString();//Beginning inventory, is string
- newRow[1] = row.Cells[(int)InventoryTableColumns.Recieved].EditedFormattedValue.ToString();//Received, is string
- newRow[2] = row.Cells[(int)InventoryTableColumns.Total].EditedFormattedValue.ToString();//Total inventory. is string
- newRow[3] = row.Cells[(int)InventoryTableColumns.EndingInventory].EditedFormattedValue.ToString(); //Ending inventory, is string
+ newRow[0] = row.Cells[(int) InventoryTableColumns.BeginningInventory].EditedFormattedValue.ToString(); //Beginning inventory, is string
+ newRow[1] = row.Cells[(int) InventoryTableColumns.Recieved].EditedFormattedValue.ToString(); //Received, is string
+ newRow[2] = row.Cells[(int) InventoryTableColumns.Total].EditedFormattedValue.ToString(); //Total inventory. is string
+ newRow[3] = row.Cells[(int) InventoryTableColumns.EndingInventory].EditedFormattedValue.ToString(); //Ending inventory, is string
newRow[4] = adItemId;
newRow[5] = rowAttribute;
if (_adSpecialIndex != -1 && row.Index > _adSpecialIndex)
@@ -3886,10 +4044,10 @@ namespace AdvertsingProfitControl
//This table is full of data that is already in the database.
var newRow = new object[10];
newRow[0] = rowIdNumber;
- newRow[1] = row.Cells[(int)InventoryTableColumns.BeginningInventory].EditedFormattedValue.ToString();//Beginning inventory, is string
- newRow[2] = row.Cells[(int)InventoryTableColumns.Recieved].EditedFormattedValue.ToString();//Received, is string
- newRow[3] = row.Cells[(int)InventoryTableColumns.Total].EditedFormattedValue.ToString();//Total inventory. is string
- newRow[4] = row.Cells[(int)InventoryTableColumns.EndingInventory].EditedFormattedValue.ToString(); //Ending inventory, is string
+ newRow[1] = row.Cells[(int) InventoryTableColumns.BeginningInventory].EditedFormattedValue.ToString(); //Beginning inventory, is string
+ newRow[2] = row.Cells[(int) InventoryTableColumns.Recieved].EditedFormattedValue.ToString(); //Received, is string
+ newRow[3] = row.Cells[(int) InventoryTableColumns.Total].EditedFormattedValue.ToString(); //Total inventory. is string
+ newRow[4] = row.Cells[(int) InventoryTableColumns.EndingInventory].EditedFormattedValue.ToString(); //Ending inventory, is string
newRow[5] = adItemId;
newRow[6] = rowAttribute;
if (_adSpecialIndex != -1 && row.Index > _adSpecialIndex)
@@ -3933,24 +4091,193 @@ namespace AdvertsingProfitControl
{
if (!_isFormDirty) return;
var result = MessageBox.Show(@"Would you like to save the changes you have made?", @"Save Changes", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
- if (result == DialogResult.Yes)
+ switch (result)
{
- SaveRecords(false);
- }
- else if(result == DialogResult.Cancel)
- {
- e.Cancel = true;
+ case DialogResult.Yes:
+ SaveRecords(false);
+ break;
+ case DialogResult.Cancel:
+ e.Cancel = true;
+ break;
}
}
- private void NewModifyRecord_Load(object sender, EventArgs e)
+ private void createNewRecordEditMainMenu_Click(object sender, EventArgs e)
{
+ if (_isFormDirty)
+ {
+ var result = MessageBox.Show(@"Do you wish to save the changes you have made before creating a new record?", @"Save Changes", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
+ if (result == DialogResult.Yes)
+ {
+ SaveRecords();
+ }
+ else if (result == DialogResult.Cancel)
+ {
+ return;
+ }
+ }
+
+ ClearFormState();
+ addRecordButton.Text = @"Add Record";
+ var databaseTracker = new DatabaseTracker();
+ var databaseReader = new DatabaseReader();
+ _currentActiveDate = databaseReader.RetrieveMostRecentDate(databaseTracker.DatabaseConnectionString).AddDays(7);
+ weekEndingCalendar.SelectionStart = _currentActiveDate;
+ Text = @"Add New Record (Current Date: " + _currentActiveDate.ToShortDateString() + @")";
+ informationLabel.Text = string.Empty;
+ errorLabel.Text = string.Empty;
}
- //private void NormalizeApcTables(DataTable projections, DataTable inventory, DataTable actualSales, string dateId)
- //{
+ private void NormalizeApcTables()
+ {
+ //Disable validation events in the APC tables.
+ projectionsDataGridView.CellEnter -= StoreBeginningCellValue;
+ inventoryDataGridView.CellEnter -= StoreBeginningCellValue;
+ actualSalesDataGridView.CellEnter -= StoreBeginningCellValue;
+ projectionsDataGridView.RowLeave -= UpdateUsedAdItemCollectionOnRowLeave;
+ inventoryDataGridView.RowLeave -= UpdateUsedAdItemCollectionOnRowLeave;
+ actualSalesDataGridView.RowLeave -= UpdateUsedAdItemCollectionOnRowLeave;
+ projectionsDataGridView.CellValidating -= ValidateSalesDataGridViewCellContents;
+ inventoryDataGridView.CellValidating -= ValidateInventoryCellContents;
+ actualSalesDataGridView.CellValidating -= ValidateSalesDataGridViewCellContents;
+ projectionsDataGridView.RowValidating -= ValidateProjectedRow;
+ inventoryDataGridView.RowValidating -= ValidateInventoryRow;
+ actualSalesDataGridView.RowValidating -= ValidateActualSalesRow;
+ //END DISABLE EVENTS
+ informationLabel.Text = string.Empty;
+ errorLabel.Text = @"Tables unbalanced, attempting repairs.";
+ var dataGridView = projectionsDataGridView.RowCount > inventoryDataGridView.RowCount
+ ? projectionsDataGridView
+ : inventoryDataGridView;
+ dataGridView = dataGridView.RowCount > actualSalesDataGridView.RowCount
+ ? dataGridView
+ : actualSalesDataGridView;
+ var maxRowCount = dataGridView.RowCount;
+ //MessageBox.Show(dataGridView.Name);
+ var rowParser = new RowParsing();
+ for (var i = 0; i < maxRowCount; i++)
+ {
+ if (rowParser.GetRowAttribute(dataGridView.Rows[i]) == RowAttribute.AdSpecialRow)
+ {
+ _adSpecialIndex = i;
+ }
- //}
+ if (maxRowCount != projectionsDataGridView.RowCount)
+ {
+ if (i < projectionsDataGridView.RowCount)
+ {
+ //Force update the existing row with whatever the fuller table has.
+ if (
+ projectionsDataGridView.Rows[i].Cells[(int) SalesTableColumns.AdItem].EditedFormattedValue !=
+ dataGridView.Rows[i].Cells[(int) SalesTableColumns.AdItem].EditedFormattedValue)
+ {
+ //Force the creation of the NewRow in the DataGridView.
+ projectionsDataGridView.Rows.Add();
+ }
+ }
+ else
+ {
+ //Add the new row to the projections DataGridView
+ projectionsDataGridView.Rows.Insert(i - 1);
+ }
+
+ projectionsDataGridView.Rows[i].Cells[(int)SalesTableColumns.AdItem].Value = dataGridView.Rows[i].Cells[(int)SalesTableColumns.AdItem].EditedFormattedValue;
+ projectionsDataGridView.Rows[i].Cells[(int)SalesTableColumns.IsDirty].Value = true;
+ if (i != _adSpecialIndex)
+ {
+ projectionsDataGridView.Rows[i].HeaderCell.Style.BackColor = ApplicationColors.PendingEdit;
+ }
+
+ if (dataGridView == actualSalesDataGridView)
+ {
+ projectionsDataGridView.Rows[i].Cells[(int) SalesTableColumns.SalePrice].Value =
+ dataGridView.Rows[i].Cells[(int) SalesTableColumns.SalePrice].EditedFormattedValue;
+ projectionsDataGridView.Rows[i].Cells[(int)SalesTableColumns.Cost].Value = dataGridView.Rows[i].Cells[(int)SalesTableColumns.Cost].EditedFormattedValue;
+ projectionsDataGridView.Rows[i].Cells[(int)SalesTableColumns.ProfitReturn].Value = dataGridView.Rows[i].Cells[(int)SalesTableColumns.ProfitReturn].EditedFormattedValue;
+ }
+ }
+
+ if (maxRowCount != inventoryDataGridView.RowCount)
+ {
+ if (i < inventoryDataGridView.RowCount)
+ {
+ //Force update the existing row with whatever the fuller table has.
+ if (
+ inventoryDataGridView.Rows[i].Cells[(int)InventoryTableColumns.AdItem].EditedFormattedValue !=
+ dataGridView.Rows[i].Cells[(int)InventoryTableColumns.AdItem].EditedFormattedValue)
+ {
+ inventoryDataGridView.Rows.Add();
+ }
+ }
+ else
+ {
+ //Add the new row to the projections DataGridView
+ inventoryDataGridView.Rows.Insert(i - 1);
+ }
+
+ inventoryDataGridView.Rows[i].Cells[(int)InventoryTableColumns.AdItem].Value = dataGridView.Rows[i].Cells[(int)InventoryTableColumns.AdItem].EditedFormattedValue;
+ inventoryDataGridView.Rows[i].Cells[(int)InventoryTableColumns.IsDirty].Value = true;
+ if (i != _adSpecialIndex)
+ {
+ inventoryDataGridView.Rows[i].HeaderCell.Style.BackColor = ApplicationColors.PendingEdit;
+ }
+ }
+
+ if (maxRowCount != actualSalesDataGridView.RowCount)
+ {
+ if (i < actualSalesDataGridView.RowCount)
+ {
+ //Force update the existing row with whatever the fuller table has.
+ if (
+ actualSalesDataGridView.Rows[i].Cells[(int)SalesTableColumns.AdItem].EditedFormattedValue !=
+ dataGridView.Rows[i].Cells[(int)SalesTableColumns.AdItem].EditedFormattedValue)
+ {
+ //Force the creation of the NewRow in the DataGridView.
+ actualSalesDataGridView.Rows.Add();
+ }
+ }
+ else
+ {
+ //Add the new row to the projections DataGridView
+ actualSalesDataGridView.Rows.Insert(i - 1);
+ }
+
+ actualSalesDataGridView.Rows[i].Cells[(int)SalesTableColumns.AdItem].Value = dataGridView.Rows[i].Cells[(int)SalesTableColumns.AdItem].EditedFormattedValue;
+ actualSalesDataGridView.Rows[i].Cells[(int)SalesTableColumns.IsDirty].Value = true;
+ if (i != _adSpecialIndex)
+ {
+ actualSalesDataGridView.Rows[i].HeaderCell.Style.BackColor = ApplicationColors.PendingEdit;
+ }
+
+ if (dataGridView == projectionsDataGridView)
+ {
+ actualSalesDataGridView.Rows[i].Cells[(int)SalesTableColumns.SalePrice].Value =
+ dataGridView.Rows[i].Cells[(int)SalesTableColumns.SalePrice].EditedFormattedValue;
+ actualSalesDataGridView.Rows[i].Cells[(int)SalesTableColumns.Cost].Value = dataGridView.Rows[i].Cells[(int)SalesTableColumns.Cost].EditedFormattedValue;
+ actualSalesDataGridView.Rows[i].Cells[(int)SalesTableColumns.ProfitReturn].Value = dataGridView.Rows[i].Cells[(int)SalesTableColumns.ProfitReturn].EditedFormattedValue;
+ }
+ }
+ }
+ informationLabel.Text = @"Tables balanced.";
+ //Update the NewRow's header cell text.
+ projectionsDataGridView.Rows[projectionsDataGridView.RowCount - 1].HeaderCell.Value = projectionsDataGridView.RowCount.ToString();
+ inventoryDataGridView.Rows[inventoryDataGridView.RowCount - 1].HeaderCell.Value = inventoryDataGridView.RowCount.ToString();
+ actualSalesDataGridView.Rows[actualSalesDataGridView.RowCount - 1].HeaderCell.Value = actualSalesDataGridView.RowCount.ToString();
+ //Enable validation events in the APC tables.
+ projectionsDataGridView.CellEnter += StoreBeginningCellValue;
+ inventoryDataGridView.CellEnter += StoreBeginningCellValue;
+ actualSalesDataGridView.CellEnter += StoreBeginningCellValue;
+ projectionsDataGridView.RowLeave += UpdateUsedAdItemCollectionOnRowLeave;
+ inventoryDataGridView.RowLeave += UpdateUsedAdItemCollectionOnRowLeave;
+ actualSalesDataGridView.RowLeave += UpdateUsedAdItemCollectionOnRowLeave;
+ projectionsDataGridView.CellValidating += ValidateSalesDataGridViewCellContents;
+ inventoryDataGridView.CellValidating += ValidateInventoryCellContents;
+ actualSalesDataGridView.CellValidating += ValidateSalesDataGridViewCellContents;
+ projectionsDataGridView.RowValidating += ValidateProjectedRow;
+ inventoryDataGridView.RowValidating += ValidateInventoryRow;
+ actualSalesDataGridView.RowValidating += ValidateActualSalesRow;
+ //END ENABLE EVENTS
+ }
}
}
diff --git a/AdvertsingProfitControl/NewModifyRecord.resx b/AdvertsingProfitControl/NewModifyRecord.resx
index d5065fd..f80b0f3 100644
--- a/AdvertsingProfitControl/NewModifyRecord.resx
+++ b/AdvertsingProfitControl/NewModifyRecord.resx
@@ -120,7 +120,4 @@
17, 17
-
- 17, 17
-
\ No newline at end of file
diff --git a/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.vshost.application b/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.vshost.application
new file mode 100644
index 0000000..a534414
--- /dev/null
+++ b/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.vshost.application
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ qslhA++lVLBctd11zuiyGxsc1HQGD2NdhJMAlbYkvSA=
+
+
+
+
\ No newline at end of file
diff --git a/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.vshost.exe.manifest b/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.vshost.exe.manifest
new file mode 100644
index 0000000..f1e259e
--- /dev/null
+++ b/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.vshost.exe.manifest
@@ -0,0 +1,139 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ hvMMYVQ3UshVHNWRVBHGms+WBonEb7cFKwhPKPfr7zw=
+
+
+
+
+
+
+
+
+
+
+
+ VGr+ZzYUr4vMefSbFien3axjDZd7ylgpjfrMKI12ink=
+
+
+
+
+
+
+
+
+
+
+
+ WF/zxFwKgeKM8FANZnlU0EY/IhL18w1Px1iKE75KJWM=
+
+
+
+
+
+
+
+
+
+ e48EkTyChGHXYJETENSLw7RKQ1LZ5ZDUghEtiv5DmqY=
+
+
+
+
+
+
+
+
+ APFHPCEQI/gZQZnqXRRCyHlaT6i2bDRte4X6ug1A8W8=
+
+
+
+
+
+
+
+
+ HWMXjUaEQtZd0vBm2k4ValXtZwmVzcqV0rERViSzOOc=
+
+
+
+
+
+
+
+
+ EhpcVkhatavmpmzYIlqLL5P0WB1QFP8mU66foV/5u+c=
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true/PM
+
+
+
\ No newline at end of file
diff --git a/StringInputParseTester/obj/Debug/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs b/StringInputParseTester/obj/Debug/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs
new file mode 100644
index 0000000..e69de29
diff --git a/StringInputParseTester/obj/Debug/TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs b/StringInputParseTester/obj/Debug/TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs
new file mode 100644
index 0000000..e69de29
diff --git a/StringInputParseTester/obj/Debug/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs b/StringInputParseTester/obj/Debug/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs
new file mode 100644
index 0000000..e69de29