Created the first version of the table normalizing function to correct unbalanced tables. Can only add or update rows by scanning downward from the top of a table; cannot detect fragmentation in the middle of a table. (Think Drag and Drop/row position update fails.)
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -123,7 +123,6 @@
|
||||
<DependentUpon>NewModifyRecord.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="TextFormat.cs" />
|
||||
<Compile Include="APCDatabaseWriter.cs" />
|
||||
<Compile Include="BackPageGenerator.cs" />
|
||||
<Compile Include="DatabaseReader.cs" />
|
||||
<Compile Include="DatabaseTracker.cs" />
|
||||
|
||||
@@ -9,7 +9,6 @@ namespace AdvertsingProfitControl
|
||||
internal class DbWriterStatus
|
||||
{
|
||||
public string ErrorMessage;
|
||||
public string Message;
|
||||
public int Id;
|
||||
public WritingOperationStatus Status;
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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;
|
||||
|
||||
+20
-10
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -37,7 +37,6 @@ namespace AdvertsingProfitControl
|
||||
private DateTime _currentActiveDate;
|
||||
//
|
||||
private bool _isFormDirty;
|
||||
private TabPage _debugTabPage;
|
||||
|
||||
public NewModifyRecord(DateTime date)
|
||||
{
|
||||
@@ -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<string>();
|
||||
_usedAdItems[1] = new List<string>();
|
||||
//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
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
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;
|
||||
@@ -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()
|
||||
@@ -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);
|
||||
@@ -2563,18 +2749,13 @@ 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
|
||||
{
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
@@ -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
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
@@ -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)
|
||||
@@ -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);
|
||||
switch (result)
|
||||
{
|
||||
case DialogResult.Yes:
|
||||
SaveRecords(false);
|
||||
break;
|
||||
case DialogResult.Cancel:
|
||||
e.Cancel = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
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(false);
|
||||
SaveRecords();
|
||||
}
|
||||
else if (result == DialogResult.Cancel)
|
||||
{
|
||||
e.Cancel = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private void NewModifyRecord_Load(object sender, EventArgs e)
|
||||
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()
|
||||
{
|
||||
|
||||
//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;
|
||||
}
|
||||
|
||||
//private void NormalizeApcTables(DataTable projections, DataTable inventory, DataTable actualSales, string dateId)
|
||||
//{
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,7 +120,4 @@
|
||||
<metadata name="mainMenuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</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>
|
||||
</root>
|
||||
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<asmv1:assembly xsi:schemaLocation="urn:schemas-microsoft-com:asm.v1 assembly.adaptive.xsd" manifestVersion="1.0" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns="urn:schemas-microsoft-com:asm.v2" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xrml="urn:mpeg:mpeg21:2003:01-REL-R-NS" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3" xmlns:dsig="http://www.w3.org/2000/09/xmldsig#" xmlns:co.v1="urn:schemas-microsoft-com:clickonce.v1" xmlns:co.v2="urn:schemas-microsoft-com:clickonce.v2">
|
||||
<assemblyIdentity name="AdvertsingProfitControl.application" version="1.0.0.1" publicKeyToken="0000000000000000" language="neutral" processorArchitecture="amd64" xmlns="urn:schemas-microsoft-com:asm.v1" />
|
||||
<description asmv2:publisher="AdvertsingProfitControl" asmv2:product="AdvertsingProfitControl" xmlns="urn:schemas-microsoft-com:asm.v1" />
|
||||
<deployment install="true" mapFileExtensions="true" />
|
||||
<compatibleFrameworks xmlns="urn:schemas-microsoft-com:clickonce.v2">
|
||||
<framework targetVersion="4.5" profile="Full" supportedRuntime="4.0.30319" />
|
||||
</compatibleFrameworks>
|
||||
<dependency>
|
||||
<dependentAssembly dependencyType="install" codebase="AdvertsingProfitControl.exe.manifest" size="7492">
|
||||
<assemblyIdentity name="AdvertsingProfitControl.exe" version="1.0.0.1" publicKeyToken="0000000000000000" language="neutral" processorArchitecture="amd64" type="win32" />
|
||||
<hash>
|
||||
<dsig:Transforms>
|
||||
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
|
||||
</dsig:Transforms>
|
||||
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
|
||||
<dsig:DigestValue>qslhA++lVLBctd11zuiyGxsc1HQGD2NdhJMAlbYkvSA=</dsig:DigestValue>
|
||||
</hash>
|
||||
</dependentAssembly>
|
||||
</dependency>
|
||||
</asmv1:assembly>
|
||||
@@ -0,0 +1,139 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<asmv1:assembly xsi:schemaLocation="urn:schemas-microsoft-com:asm.v1 assembly.adaptive.xsd" manifestVersion="1.0" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns="urn:schemas-microsoft-com:asm.v2" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:co.v1="urn:schemas-microsoft-com:clickonce.v1" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3" xmlns:dsig="http://www.w3.org/2000/09/xmldsig#" xmlns:co.v2="urn:schemas-microsoft-com:clickonce.v2">
|
||||
<asmv1:assemblyIdentity name="AdvertsingProfitControl.exe" version="1.0.0.1" publicKeyToken="0000000000000000" language="neutral" processorArchitecture="amd64" type="win32" />
|
||||
<description asmv2:iconFile="Stretched Logo Collection.ico" xmlns="urn:schemas-microsoft-com:asm.v1" />
|
||||
<application />
|
||||
<entryPoint>
|
||||
<assemblyIdentity name="AdvertsingProfitControl" version="1.9.2.0" language="neutral" processorArchitecture="amd64" />
|
||||
<commandLine file="AdvertsingProfitControl.exe" parameters="" />
|
||||
</entryPoint>
|
||||
<trustInfo>
|
||||
<security>
|
||||
<applicationRequestMinimum>
|
||||
<PermissionSet version="1" class="System.Security.NamedPermissionSet" Name="LocalIntranet" Description="Default rights given to applications on the local intranet" Unrestricted="true" ID="Custom" SameSite="site" />
|
||||
<defaultAssemblyRequest permissionSetReference="Custom" />
|
||||
</applicationRequestMinimum>
|
||||
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||
<!-- UAC Manifest Options
|
||||
If you want to change the Windows User Account Control level replace the
|
||||
requestedExecutionLevel node with one of the following.
|
||||
|
||||
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
|
||||
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
|
||||
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />
|
||||
|
||||
Specifying requestedExecutionLevel element will disable file and registry virtualization.
|
||||
Remove this element if your application requires this virtualization for backwards
|
||||
compatibility.
|
||||
-->
|
||||
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
|
||||
</requestedPrivileges>
|
||||
</security>
|
||||
</trustInfo>
|
||||
<dependency>
|
||||
<dependentOS>
|
||||
<osVersionInfo>
|
||||
<os majorVersion="5" minorVersion="1" buildNumber="2600" servicePackMajor="0" />
|
||||
</osVersionInfo>
|
||||
</dependentOS>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<dependentAssembly dependencyType="preRequisite" allowDelayedBinding="true">
|
||||
<assemblyIdentity name="Microsoft.Windows.CommonLanguageRuntime" version="4.0.30319.0" />
|
||||
</dependentAssembly>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<dependentAssembly dependencyType="install" allowDelayedBinding="true" codebase="AdvertsingProfitControl.exe" size="3652096">
|
||||
<assemblyIdentity name="AdvertsingProfitControl" version="1.9.2.0" language="neutral" processorArchitecture="amd64" />
|
||||
<hash>
|
||||
<dsig:Transforms>
|
||||
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
|
||||
</dsig:Transforms>
|
||||
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
|
||||
<dsig:DigestValue>hvMMYVQ3UshVHNWRVBHGms+WBonEb7cFKwhPKPfr7zw=</dsig:DigestValue>
|
||||
</hash>
|
||||
</dependentAssembly>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<dependentAssembly dependencyType="install" allowDelayedBinding="true" codebase="HtmlRenderer.dll" size="222208">
|
||||
<assemblyIdentity name="HtmlRenderer" version="1.5.0.6" language="neutral" processorArchitecture="msil" />
|
||||
<hash>
|
||||
<dsig:Transforms>
|
||||
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
|
||||
</dsig:Transforms>
|
||||
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
|
||||
<dsig:DigestValue>VGr+ZzYUr4vMefSbFien3axjDZd7ylgpjfrMKI12ink=</dsig:DigestValue>
|
||||
</hash>
|
||||
</dependentAssembly>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<dependentAssembly dependencyType="install" allowDelayedBinding="true" codebase="HtmlRenderer.WinForms.dll" size="60416">
|
||||
<assemblyIdentity name="HtmlRenderer.WinForms" version="1.5.0.6" language="neutral" processorArchitecture="msil" />
|
||||
<hash>
|
||||
<dsig:Transforms>
|
||||
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
|
||||
</dsig:Transforms>
|
||||
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
|
||||
<dsig:DigestValue>WF/zxFwKgeKM8FANZnlU0EY/IhL18w1Px1iKE75KJWM=</dsig:DigestValue>
|
||||
</hash>
|
||||
</dependentAssembly>
|
||||
</dependency>
|
||||
<file name="APCDatabase Template Script.sql" size="5400">
|
||||
<hash>
|
||||
<dsig:Transforms>
|
||||
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
|
||||
</dsig:Transforms>
|
||||
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
|
||||
<dsig:DigestValue>e48EkTyChGHXYJETENSLw7RKQ1LZ5ZDUghEtiv5DmqY=</dsig:DigestValue>
|
||||
</hash>
|
||||
</file>
|
||||
<file name="APCDatabase.accdb" size="864256">
|
||||
<hash>
|
||||
<dsig:Transforms>
|
||||
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
|
||||
</dsig:Transforms>
|
||||
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
|
||||
<dsig:DigestValue>APFHPCEQI/gZQZnqXRRCyHlaT6i2bDRte4X6ug1A8W8=</dsig:DigestValue>
|
||||
</hash>
|
||||
</file>
|
||||
<file name="APCTemplate.accdb" size="819200">
|
||||
<hash>
|
||||
<dsig:Transforms>
|
||||
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
|
||||
</dsig:Transforms>
|
||||
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
|
||||
<dsig:DigestValue>HWMXjUaEQtZd0vBm2k4ValXtZwmVzcqV0rERViSzOOc=</dsig:DigestValue>
|
||||
</hash>
|
||||
</file>
|
||||
<file name="Stretched Logo Collection.ico" size="370070">
|
||||
<hash>
|
||||
<dsig:Transforms>
|
||||
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
|
||||
</dsig:Transforms>
|
||||
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
|
||||
<dsig:DigestValue>EhpcVkhatavmpmzYIlqLL5P0WB1QFP8mU66foV/5u+c=</dsig:DigestValue>
|
||||
</hash>
|
||||
</file>
|
||||
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
|
||||
<application>
|
||||
<!-- A list of the Windows versions that this application has been tested on and is
|
||||
is designed to work with. Uncomment the appropriate elements and Windows will
|
||||
automatically selected the most compatible environment. -->
|
||||
<!-- Windows Vista -->
|
||||
<!--<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" />-->
|
||||
<!-- Windows 7 -->
|
||||
<!--<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />-->
|
||||
<!-- Windows 8 -->
|
||||
<!--<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />-->
|
||||
<!-- Windows 8.1 -->
|
||||
<!--<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />-->
|
||||
<!-- Windows 10 -->
|
||||
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />
|
||||
</application>
|
||||
</compatibility>
|
||||
<application xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||
<windowsSettings>
|
||||
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true/PM</dpiAware>
|
||||
</windowsSettings>
|
||||
</application>
|
||||
</asmv1:assembly>
|
||||
Reference in New Issue
Block a user