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>
|
<DependentUpon>NewModifyRecord.cs</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="TextFormat.cs" />
|
<Compile Include="TextFormat.cs" />
|
||||||
<Compile Include="APCDatabaseWriter.cs" />
|
|
||||||
<Compile Include="BackPageGenerator.cs" />
|
<Compile Include="BackPageGenerator.cs" />
|
||||||
<Compile Include="DatabaseReader.cs" />
|
<Compile Include="DatabaseReader.cs" />
|
||||||
<Compile Include="DatabaseTracker.cs" />
|
<Compile Include="DatabaseTracker.cs" />
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ namespace AdvertsingProfitControl
|
|||||||
internal class DbWriterStatus
|
internal class DbWriterStatus
|
||||||
{
|
{
|
||||||
public string ErrorMessage;
|
public string ErrorMessage;
|
||||||
public string Message;
|
|
||||||
public int Id;
|
public int Id;
|
||||||
public WritingOperationStatus Status;
|
public WritingOperationStatus Status;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ namespace AdvertsingProfitControl
|
|||||||
{
|
{
|
||||||
var databaseTracker = new DatabaseTracker();
|
var databaseTracker = new DatabaseTracker();
|
||||||
var databaseReader = new DatabaseReader();
|
var databaseReader = new DatabaseReader();
|
||||||
var form = new NewAddRecord();
|
var form = new NewModifyRecord();
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
//One the user has closed the add record form, check to see if there is a newer date
|
//One the user has closed the add record form, check to see if there is a newer date
|
||||||
//available. If so, reload the form.
|
//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.
|
//Flag showing whether or not the AdSpecialRow has been made in this session.
|
||||||
private int _adSpecialIndex = -1;
|
private int _adSpecialIndex = -1;
|
||||||
private readonly AdvertisingProfitControlTableHelper _tableHelperFunctions = new AdvertisingProfitControlTableHelper();
|
private readonly AdvertisingProfitControlTableHelper _tableHelperFunctions = new AdvertisingProfitControlTableHelper();
|
||||||
private TabPage _debugTabPage;
|
|
||||||
|
|
||||||
public NewAddRecord()
|
public NewAddRecord()
|
||||||
{
|
{
|
||||||
@@ -147,7 +146,6 @@ namespace AdvertsingProfitControl
|
|||||||
suppliesTextBox.Enter += StoreBeginningTextBoxValue;
|
suppliesTextBox.Enter += StoreBeginningTextBoxValue;
|
||||||
suppliesTextBox.Validating += ValidateCostAnalysisValues;
|
suppliesTextBox.Validating += ValidateCostAnalysisValues;
|
||||||
//
|
//
|
||||||
_debugTabPage = mainTabControl.TabPages[4];
|
|
||||||
mainTabControl.TabPages.Remove(mainTabControl.TabPages[4]);
|
mainTabControl.TabPages.Remove(mainTabControl.TabPages[4]);
|
||||||
//Select Saturday if it is not already set.
|
//Select Saturday if it is not already set.
|
||||||
if (weekEndingCalendar.SelectionStart.DayOfWeek == DayOfWeek.Saturday) return;
|
if (weekEndingCalendar.SelectionStart.DayOfWeek == DayOfWeek.Saturday) return;
|
||||||
|
|||||||
+20
-10
@@ -33,7 +33,6 @@
|
|||||||
this.FileMainMenu = new System.Windows.Forms.ToolStripMenuItem();
|
this.FileMainMenu = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.clearFormFileMainMenu = new System.Windows.Forms.ToolStripMenuItem();
|
this.clearFormFileMainMenu = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.exitFileMainMenu = 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.mainTabControl = new System.Windows.Forms.TabControl();
|
||||||
this.projectionTabPage = new System.Windows.Forms.TabPage();
|
this.projectionTabPage = new System.Windows.Forms.TabPage();
|
||||||
this.projectionsDataGridView = new System.Windows.Forms.DataGridView();
|
this.projectionsDataGridView = new System.Windows.Forms.DataGridView();
|
||||||
@@ -107,6 +106,8 @@
|
|||||||
this.informationPanel = new System.Windows.Forms.Panel();
|
this.informationPanel = new System.Windows.Forms.Panel();
|
||||||
this.errorLabel = new System.Windows.Forms.Label();
|
this.errorLabel = new System.Windows.Forms.Label();
|
||||||
this.addRecordButton = new System.Windows.Forms.Button();
|
this.addRecordButton = new System.Windows.Forms.Button();
|
||||||
|
this.editMainMenu = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.createNewRecordEditMainMenu = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.mainLayoutPanel.SuspendLayout();
|
this.mainLayoutPanel.SuspendLayout();
|
||||||
this.mainMenuStrip.SuspendLayout();
|
this.mainMenuStrip.SuspendLayout();
|
||||||
this.mainTabControl.SuspendLayout();
|
this.mainTabControl.SuspendLayout();
|
||||||
@@ -163,7 +164,7 @@
|
|||||||
this.mainMenuStrip.ImageScalingSize = new System.Drawing.Size(24, 24);
|
this.mainMenuStrip.ImageScalingSize = new System.Drawing.Size(24, 24);
|
||||||
this.mainMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
this.mainMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||||
this.FileMainMenu,
|
this.FileMainMenu,
|
||||||
this.debugMainMenu});
|
this.editMainMenu});
|
||||||
this.mainMenuStrip.Location = new System.Drawing.Point(0, 0);
|
this.mainMenuStrip.Location = new System.Drawing.Point(0, 0);
|
||||||
this.mainMenuStrip.Name = "mainMenuStrip";
|
this.mainMenuStrip.Name = "mainMenuStrip";
|
||||||
this.mainMenuStrip.Padding = new System.Windows.Forms.Padding(7, 2, 0, 2);
|
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.Size = new System.Drawing.Size(205, 34);
|
||||||
this.exitFileMainMenu.Text = "E&xit";
|
this.exitFileMainMenu.Text = "E&xit";
|
||||||
//
|
//
|
||||||
// debugMainMenu
|
|
||||||
//
|
|
||||||
this.debugMainMenu.Name = "debugMainMenu";
|
|
||||||
this.debugMainMenu.Size = new System.Drawing.Size(87, 31);
|
|
||||||
this.debugMainMenu.Text = "&Debug";
|
|
||||||
//
|
|
||||||
// mainTabControl
|
// mainTabControl
|
||||||
//
|
//
|
||||||
this.mainLayoutPanel.SetColumnSpan(this.mainTabControl, 4);
|
this.mainLayoutPanel.SetColumnSpan(this.mainTabControl, 4);
|
||||||
@@ -944,6 +939,21 @@
|
|||||||
this.addRecordButton.UseVisualStyleBackColor = true;
|
this.addRecordButton.UseVisualStyleBackColor = true;
|
||||||
this.addRecordButton.Click += new System.EventHandler(this.addRecordButton_Click);
|
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
|
// NewModifyRecord
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(11F, 24F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(11F, 24F);
|
||||||
@@ -955,7 +965,6 @@
|
|||||||
this.Text = "Modify Record";
|
this.Text = "Modify Record";
|
||||||
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
|
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
|
||||||
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.NewModifyRecord_FormClosing);
|
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.NewModifyRecord_FormClosing);
|
||||||
this.Load += new System.EventHandler(this.NewModifyRecord_Load);
|
|
||||||
this.mainLayoutPanel.ResumeLayout(false);
|
this.mainLayoutPanel.ResumeLayout(false);
|
||||||
this.mainLayoutPanel.PerformLayout();
|
this.mainLayoutPanel.PerformLayout();
|
||||||
this.mainMenuStrip.ResumeLayout(false);
|
this.mainMenuStrip.ResumeLayout(false);
|
||||||
@@ -997,7 +1006,6 @@
|
|||||||
private System.Windows.Forms.ToolStripMenuItem FileMainMenu;
|
private System.Windows.Forms.ToolStripMenuItem FileMainMenu;
|
||||||
private System.Windows.Forms.ToolStripMenuItem clearFormFileMainMenu;
|
private System.Windows.Forms.ToolStripMenuItem clearFormFileMainMenu;
|
||||||
private System.Windows.Forms.ToolStripMenuItem exitFileMainMenu;
|
private System.Windows.Forms.ToolStripMenuItem exitFileMainMenu;
|
||||||
private System.Windows.Forms.ToolStripMenuItem debugMainMenu;
|
|
||||||
private System.Windows.Forms.TabControl mainTabControl;
|
private System.Windows.Forms.TabControl mainTabControl;
|
||||||
private System.Windows.Forms.TabPage projectionTabPage;
|
private System.Windows.Forms.TabPage projectionTabPage;
|
||||||
private System.Windows.Forms.DataGridView projectionsDataGridView;
|
private System.Windows.Forms.DataGridView projectionsDataGridView;
|
||||||
@@ -1071,5 +1079,7 @@
|
|||||||
private System.Windows.Forms.Panel informationPanel;
|
private System.Windows.Forms.Panel informationPanel;
|
||||||
private System.Windows.Forms.Label errorLabel;
|
private System.Windows.Forms.Label errorLabel;
|
||||||
private System.Windows.Forms.Button addRecordButton;
|
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 DateTime _currentActiveDate;
|
||||||
//
|
//
|
||||||
private bool _isFormDirty;
|
private bool _isFormDirty;
|
||||||
private TabPage _debugTabPage;
|
|
||||||
|
|
||||||
public NewModifyRecord(DateTime date)
|
public NewModifyRecord(DateTime date)
|
||||||
{
|
{
|
||||||
@@ -156,12 +155,134 @@ namespace AdvertsingProfitControl
|
|||||||
suppliesTextBox.Enter += StoreBeginningTextBoxValue;
|
suppliesTextBox.Enter += StoreBeginningTextBoxValue;
|
||||||
suppliesTextBox.Validating += ValidateCostAnalysisValues;
|
suppliesTextBox.Validating += ValidateCostAnalysisValues;
|
||||||
//
|
//
|
||||||
_debugTabPage = mainTabControl.TabPages[4];
|
//_debugTabPage = mainTabControl.TabPages[4];
|
||||||
mainTabControl.TabPages.Remove(mainTabControl.TabPages[4]);
|
//mainTabControl.TabPages.Remove(mainTabControl.TabPages[4]);
|
||||||
Text = @"Modify Record (Current Record: " + date.ToString("d") + @")";
|
Text = @"Modify Record (Current Record: " + date.ToShortDateString() + @")";
|
||||||
LoadDate(date);
|
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
|
public sealed override string Text
|
||||||
{
|
{
|
||||||
get { return base.Text; }
|
get { return base.Text; }
|
||||||
@@ -425,7 +546,7 @@ namespace AdvertsingProfitControl
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="sender"></param>
|
/// <param name="sender"></param>
|
||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private void DisplayRowNumbers(object sender, DataGridViewRowsAddedEventArgs e)
|
private static void DisplayRowNumbers(object sender, DataGridViewRowsAddedEventArgs e)
|
||||||
{
|
{
|
||||||
var table = ((DataGridView)sender);
|
var table = ((DataGridView)sender);
|
||||||
table.Rows[e.RowIndex].HeaderCell.Value = (e.RowIndex + 1).ToString();
|
table.Rows[e.RowIndex].HeaderCell.Value = (e.RowIndex + 1).ToString();
|
||||||
@@ -1041,11 +1162,20 @@ namespace AdvertsingProfitControl
|
|||||||
projectionsDataGridView.Rows[e.RowIndex].Cells[adItemIndex].Selected = true;
|
projectionsDataGridView.Rows[e.RowIndex].Cells[adItemIndex].Selected = true;
|
||||||
e.Cancel = 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.
|
//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())
|
if (projectionsDataGridView.Rows[e.RowIndex].Cells[adItemIndex].EditedFormattedValue.ToString() == actualSalesDataGridView.Rows[e.RowIndex].Cells[adItemIndex].EditedFormattedValue.ToString())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
_isFormDirty = true;
|
||||||
//Next check to see if the user changed the ad item is the corresponding row.
|
//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())
|
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, "Inventory Row Count: " + inventoryDataGridView.RowCount);
|
||||||
LogConsole.WriteToLog(FrmLogConsole.Level.Error, "Actual Sales Row Count: " + actualSalesDataGridView.RowCount);
|
LogConsole.WriteToLog(FrmLogConsole.Level.Error, "Actual Sales Row Count: " + actualSalesDataGridView.RowCount);
|
||||||
errorLabel.Text = @"Error removing rows from Actual Sales and Inventory.";
|
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.
|
//... After all the row removal has been finished re-enable the row removal events.
|
||||||
inventoryDataGridView.UserDeletingRow += UpdateUsedAdItemCollectionOnRowRemoving;
|
inventoryDataGridView.UserDeletingRow += UpdateUsedAdItemCollectionOnRowRemoving;
|
||||||
@@ -1413,11 +1545,20 @@ namespace AdvertsingProfitControl
|
|||||||
inventoryDataGridView.Rows[e.RowIndex].Cells[adItemIndex].Selected = true;
|
inventoryDataGridView.Rows[e.RowIndex].Cells[adItemIndex].Selected = true;
|
||||||
e.Cancel = 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.
|
//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())
|
if (inventoryDataGridView.Rows[e.RowIndex].Cells[adItemIndex].EditedFormattedValue.ToString() == actualSalesDataGridView.Rows[e.RowIndex].Cells[adItemIndex].EditedFormattedValue.ToString())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
_isFormDirty = true;
|
||||||
//Next check to see if the user changed the ad item is the corresponding row.
|
//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())
|
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, "Inventory Row Count: " + inventoryDataGridView.RowCount);
|
||||||
LogConsole.WriteToLog(FrmLogConsole.Level.Error, "Actual Sales Row Count: " + actualSalesDataGridView.RowCount);
|
LogConsole.WriteToLog(FrmLogConsole.Level.Error, "Actual Sales Row Count: " + actualSalesDataGridView.RowCount);
|
||||||
errorLabel.Text = @"Error removing rows from Actual Sales and Inventory.";
|
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.
|
//... After all the row removal has been finished re-enable the row removal events.
|
||||||
projectionsDataGridView.UserDeletingRow += UpdateUsedAdItemCollectionOnRowRemoving;
|
projectionsDataGridView.UserDeletingRow += UpdateUsedAdItemCollectionOnRowRemoving;
|
||||||
@@ -1581,11 +1724,20 @@ namespace AdvertsingProfitControl
|
|||||||
actualSalesDataGridView.Rows[e.RowIndex].Cells[adItemIndex].Selected = true;
|
actualSalesDataGridView.Rows[e.RowIndex].Cells[adItemIndex].Selected = true;
|
||||||
e.Cancel = 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.
|
//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())
|
if (actualSalesDataGridView.Rows[e.RowIndex].Cells[adItemIndex].EditedFormattedValue.ToString() == projectionsDataGridView.Rows[e.RowIndex].Cells[adItemIndex].EditedFormattedValue.ToString())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
_isFormDirty = true;
|
||||||
//Next check to see if the user changed the ad item is the corresponding row.
|
//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())
|
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, "Inventory Row Count: " + inventoryDataGridView.RowCount);
|
||||||
LogConsole.WriteToLog(FrmLogConsole.Level.Error, "Actual Sales Row Count: " + actualSalesDataGridView.RowCount);
|
LogConsole.WriteToLog(FrmLogConsole.Level.Error, "Actual Sales Row Count: " + actualSalesDataGridView.RowCount);
|
||||||
errorLabel.Text = @"Error removing rows from Actual Sales and Inventory.";
|
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.
|
//... After all the row removal has been finished re-enable the row removal events.
|
||||||
projectionsDataGridView.UserDeletingRow += UpdateUsedAdItemCollectionOnRowRemoving;
|
projectionsDataGridView.UserDeletingRow += UpdateUsedAdItemCollectionOnRowRemoving;
|
||||||
@@ -2202,6 +2356,7 @@ namespace AdvertsingProfitControl
|
|||||||
private void ValidateDateChanged(object sender, DateRangeEventArgs e)
|
private void ValidateDateChanged(object sender, DateRangeEventArgs e)
|
||||||
{
|
{
|
||||||
if (e.Start == _currentActiveDate || !weekEndingCalendar.BoldedDates.Contains(e.Start)) return;
|
if (e.Start == _currentActiveDate || !weekEndingCalendar.BoldedDates.Contains(e.Start)) return;
|
||||||
|
//If the form is dirty then prompt the user to save changes.
|
||||||
if (_isFormDirty)
|
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);
|
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;
|
_currentActiveDate = e.Start;
|
||||||
Text = @"Modify Record (Current Record: " + e.Start.ToString("d") + @")";
|
Text = @"Modify Record (Current Record: " + e.Start.ToString("d") + @")";
|
||||||
|
addRecordButton.Text = @"Update Record";
|
||||||
//Clear the form state.
|
//Clear the form state.
|
||||||
ClearFormState();
|
ClearFormState();
|
||||||
//Load the specified date from the database.
|
//Load the specified date from the database.
|
||||||
LoadDate(e.Start);
|
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
|
#endregion
|
||||||
|
|
||||||
private void ClearFormState()
|
private void ClearFormState()
|
||||||
@@ -2311,8 +2499,8 @@ namespace AdvertsingProfitControl
|
|||||||
//Reset the form's dirty flag
|
//Reset the form's dirty flag
|
||||||
_isFormDirty = false;
|
_isFormDirty = false;
|
||||||
//Clear the used ad items
|
//Clear the used ad items
|
||||||
_usedAdItems[0].Clear(); //regular ad items (section 1)
|
_usedAdItems[0].Clear(); //regular ad items (section 1)
|
||||||
_usedAdItems[1].Clear(); //ad special items (section 2)
|
_usedAdItems[1].Clear(); //ad special items (section 2)
|
||||||
//Clear invoices
|
//Clear invoices
|
||||||
invoicesDataGridView.Rows.Clear();
|
invoicesDataGridView.Rows.Clear();
|
||||||
//Clear comments
|
//Clear comments
|
||||||
@@ -2451,8 +2639,7 @@ namespace AdvertsingProfitControl
|
|||||||
{
|
{
|
||||||
informationLabel.Text += @"No comments to display." + Environment.NewLine;
|
informationLabel.Text += @"No comments to display." + Environment.NewLine;
|
||||||
}
|
}
|
||||||
var weeklySales = databaseReader.ReturnWeeklySalesFromDateId(dateId,
|
var weeklySales = databaseReader.ReturnWeeklySalesFromDateId(dateId, databaseTracker.DatabaseConnectionString);
|
||||||
databaseTracker.DatabaseConnectionString);
|
|
||||||
if (weeklySales.Rows.Count == 1)
|
if (weeklySales.Rows.Count == 1)
|
||||||
{
|
{
|
||||||
LoadWeeklySales(weeklySales);
|
LoadWeeklySales(weeklySales);
|
||||||
@@ -2472,8 +2659,7 @@ namespace AdvertsingProfitControl
|
|||||||
informationLabel.Text += @"No taxable data to display." + Environment.NewLine;
|
informationLabel.Text += @"No taxable data to display." + Environment.NewLine;
|
||||||
}
|
}
|
||||||
LoadInvoices(invoices);
|
LoadInvoices(invoices);
|
||||||
var costAnalysis = databaseReader.ReturnCostAnalysis(dateId,
|
var costAnalysis = databaseReader.ReturnCostAnalysis(dateId, databaseTracker.DatabaseConnectionString);
|
||||||
databaseTracker.DatabaseConnectionString);
|
|
||||||
if (costAnalysis.Rows.Count == 1)
|
if (costAnalysis.Rows.Count == 1)
|
||||||
{
|
{
|
||||||
LoadCostAnalysis(costAnalysis);
|
LoadCostAnalysis(costAnalysis);
|
||||||
@@ -2493,7 +2679,7 @@ namespace AdvertsingProfitControl
|
|||||||
projectionsDataGridView.CellValidating -= ValidateSalesDataGridViewCellContents;
|
projectionsDataGridView.CellValidating -= ValidateSalesDataGridViewCellContents;
|
||||||
projectionsDataGridView.RowValidating -= ValidateProjectedRow;
|
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();
|
var newRow = new DataGridViewRow();
|
||||||
for (var cellIndex = 0; cellIndex < projections.Rows[rowIndex].ItemArray.Length; cellIndex++)
|
for (var cellIndex = 0; cellIndex < projections.Rows[rowIndex].ItemArray.Length; cellIndex++)
|
||||||
@@ -2518,7 +2704,7 @@ namespace AdvertsingProfitControl
|
|||||||
}
|
}
|
||||||
else
|
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);
|
newRow.Cells.Add(cell);
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
@@ -2563,18 +2749,13 @@ namespace AdvertsingProfitControl
|
|||||||
{
|
{
|
||||||
var databaseTracker = new DatabaseTracker();
|
var databaseTracker = new DatabaseTracker();
|
||||||
var databaseReader = new DatabaseReader();
|
var databaseReader = new DatabaseReader();
|
||||||
var groupName =
|
var groupName = databaseReader.ReturnGroupNameFromGroupId(projections.Rows[rowIndex].ItemArray[cellIndex].ToString(), databaseTracker.DatabaseConnectionString);
|
||||||
databaseReader.ReturnGroupNameFromGroupId(
|
|
||||||
projections.Rows[rowIndex].ItemArray[cellIndex].ToString(),
|
|
||||||
databaseTracker.DatabaseConnectionString);
|
|
||||||
var adSpecialRow = new DataGridViewRow();
|
var adSpecialRow = new DataGridViewRow();
|
||||||
projectionsDataGridView.Rows.Add(adSpecialRow);
|
projectionsDataGridView.Rows.Add(adSpecialRow);
|
||||||
projectionsDataGridView.Rows[rowIndex].Cells[1].Value = groupName;
|
projectionsDataGridView.Rows[rowIndex].Cells[1].Value = groupName;
|
||||||
projectionsDataGridView.Rows[rowIndex].DefaultCellStyle.BackColor =
|
projectionsDataGridView.Rows[rowIndex].DefaultCellStyle.BackColor = ApplicationColors.AdSpecial;
|
||||||
ApplicationColors.AdSpecial;
|
|
||||||
_adSpecialIndex = rowIndex;
|
_adSpecialIndex = rowIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -2631,12 +2812,12 @@ namespace AdvertsingProfitControl
|
|||||||
{
|
{
|
||||||
if (inventoryTable.Rows[rowIndex].ItemArray[cellIndex].ToString() == "0")
|
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);
|
newRow.Cells.Add(cell);
|
||||||
}
|
}
|
||||||
else
|
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);
|
newRow.Cells.Add(cell);
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
@@ -2675,10 +2856,7 @@ namespace AdvertsingProfitControl
|
|||||||
{
|
{
|
||||||
var databaseTracker = new DatabaseTracker();
|
var databaseTracker = new DatabaseTracker();
|
||||||
var databaseReader = new DatabaseReader();
|
var databaseReader = new DatabaseReader();
|
||||||
var groupName =
|
var groupName = databaseReader.ReturnGroupNameFromGroupId(inventoryTable.Rows[rowIndex].ItemArray[cellIndex].ToString(), databaseTracker.DatabaseConnectionString);
|
||||||
databaseReader.ReturnGroupNameFromGroupId(
|
|
||||||
inventoryTable.Rows[rowIndex].ItemArray[cellIndex].ToString(),
|
|
||||||
databaseTracker.DatabaseConnectionString);
|
|
||||||
var adSpecialRow = new DataGridViewRow();
|
var adSpecialRow = new DataGridViewRow();
|
||||||
inventoryDataGridView.Rows.Add(adSpecialRow);
|
inventoryDataGridView.Rows.Add(adSpecialRow);
|
||||||
inventoryDataGridView.Rows[rowIndex].Cells[1].Value = groupName;
|
inventoryDataGridView.Rows[rowIndex].Cells[1].Value = groupName;
|
||||||
@@ -2735,12 +2913,12 @@ namespace AdvertsingProfitControl
|
|||||||
{
|
{
|
||||||
if (actualSales.Rows[rowIndex].ItemArray[cellIndex].ToString() == "0.0000")
|
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);
|
newRow.Cells.Add(cell);
|
||||||
}
|
}
|
||||||
else
|
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);
|
newRow.Cells.Add(cell);
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
@@ -2779,10 +2957,7 @@ namespace AdvertsingProfitControl
|
|||||||
{
|
{
|
||||||
var databaseTracker = new DatabaseTracker();
|
var databaseTracker = new DatabaseTracker();
|
||||||
var databaseReader = new DatabaseReader();
|
var databaseReader = new DatabaseReader();
|
||||||
var groupName =
|
var groupName = databaseReader.ReturnGroupNameFromGroupId(actualSales.Rows[rowIndex].ItemArray[cellIndex].ToString(), databaseTracker.DatabaseConnectionString);
|
||||||
databaseReader.ReturnGroupNameFromGroupId(
|
|
||||||
actualSales.Rows[rowIndex].ItemArray[cellIndex].ToString(),
|
|
||||||
databaseTracker.DatabaseConnectionString);
|
|
||||||
var adSpecialRow = new DataGridViewRow();
|
var adSpecialRow = new DataGridViewRow();
|
||||||
actualSalesDataGridView.Rows.Add(adSpecialRow);
|
actualSalesDataGridView.Rows.Add(adSpecialRow);
|
||||||
actualSalesDataGridView.Rows[rowIndex].Cells[1].Value = groupName;
|
actualSalesDataGridView.Rows[rowIndex].Cells[1].Value = groupName;
|
||||||
@@ -3190,12 +3365,9 @@ namespace AdvertsingProfitControl
|
|||||||
//Spin through the collection and update the affected rows.
|
//Spin through the collection and update the affected rows.
|
||||||
foreach (var rowIndex in writerResult.GetRowCollection())
|
foreach (var rowIndex in writerResult.GetRowCollection())
|
||||||
{
|
{
|
||||||
projectionsDataGridView.Rows[rowIndex.Key - 1].Cells[(int) SalesTableColumns.Id].Value =
|
projectionsDataGridView.Rows[rowIndex.Key - 1].Cells[(int) SalesTableColumns.Id].Value = rowIndex.Value;
|
||||||
rowIndex.Value;
|
projectionsDataGridView.Rows[rowIndex.Key - 1].Cells[(int) SalesTableColumns.IsDirty].Value = false;
|
||||||
projectionsDataGridView.Rows[rowIndex.Key - 1].Cells[(int) SalesTableColumns.IsDirty].Value
|
projectionsDataGridView.Rows[rowIndex.Key - 1].HeaderCell.Style.BackColor = ApplicationColors.EditingSaved;
|
||||||
= false;
|
|
||||||
projectionsDataGridView.Rows[rowIndex.Key - 1].HeaderCell.Style.BackColor =
|
|
||||||
ApplicationColors.EditingSaved;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -3213,10 +3385,8 @@ namespace AdvertsingProfitControl
|
|||||||
foreach (var rowIndex in writerResult.GetRowCollection())
|
foreach (var rowIndex in writerResult.GetRowCollection())
|
||||||
{
|
{
|
||||||
//Only reset the IsDirty value to false since the updates when through.
|
//Only reset the IsDirty value to false since the updates when through.
|
||||||
projectionsDataGridView.Rows[rowIndex.Key - 1].Cells[(int) SalesTableColumns.IsDirty].Value
|
projectionsDataGridView.Rows[rowIndex.Key - 1].Cells[(int) SalesTableColumns.IsDirty].Value = false;
|
||||||
= false;
|
projectionsDataGridView.Rows[rowIndex.Key - 1].HeaderCell.Style.BackColor = ApplicationColors.EditingSaved;
|
||||||
projectionsDataGridView.Rows[rowIndex.Key - 1].HeaderCell.Style.BackColor =
|
|
||||||
ApplicationColors.EditingSaved;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -3248,12 +3418,9 @@ namespace AdvertsingProfitControl
|
|||||||
foreach (var rowIndex in writerResult.GetRowCollection())
|
foreach (var rowIndex in writerResult.GetRowCollection())
|
||||||
{
|
{
|
||||||
//Only reset the IsDirty value to false since the updates when through.
|
//Only reset the IsDirty value to false since the updates when through.
|
||||||
inventoryDataGridView.Rows[rowIndex.Key - 1].Cells[(int) InventoryTableColumns.Id].Value =
|
inventoryDataGridView.Rows[rowIndex.Key - 1].Cells[(int) InventoryTableColumns.Id].Value = rowIndex.Value;
|
||||||
rowIndex.Value;
|
inventoryDataGridView.Rows[rowIndex.Key - 1].Cells[(int) InventoryTableColumns.IsDirty].Value = false;
|
||||||
inventoryDataGridView.Rows[rowIndex.Key - 1].Cells[(int) InventoryTableColumns.IsDirty]
|
inventoryDataGridView.Rows[rowIndex.Key - 1].HeaderCell.Style.BackColor = ApplicationColors.EditingSaved;
|
||||||
.Value = false;
|
|
||||||
inventoryDataGridView.Rows[rowIndex.Key - 1].HeaderCell.Style.BackColor =
|
|
||||||
ApplicationColors.EditingSaved;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -3271,7 +3438,7 @@ namespace AdvertsingProfitControl
|
|||||||
foreach (var rowIndex in writerResult.GetRowCollection())
|
foreach (var rowIndex in writerResult.GetRowCollection())
|
||||||
{
|
{
|
||||||
//Only reset the IsDirty value to false since the updates when through.
|
//Only reset the IsDirty value to false since the updates when through.
|
||||||
inventoryDataGridView.Rows[rowIndex.Key - 1].Cells[(int)InventoryTableColumns.IsDirty].Value = false;
|
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].HeaderCell.Style.BackColor = ApplicationColors.EditingSaved;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3304,8 +3471,8 @@ namespace AdvertsingProfitControl
|
|||||||
//Spin through the collection and update the affected rows.
|
//Spin through the collection and update the affected rows.
|
||||||
foreach (var rowIndex in writerResult.GetRowCollection())
|
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.Id].Value = rowIndex.Value;
|
||||||
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;
|
actualSalesDataGridView.Rows[rowIndex.Key - 1].HeaderCell.Style.BackColor = ApplicationColors.EditingSaved;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3324,7 +3491,7 @@ namespace AdvertsingProfitControl
|
|||||||
foreach (var rowIndex in writerResult.GetRowCollection())
|
foreach (var rowIndex in writerResult.GetRowCollection())
|
||||||
{
|
{
|
||||||
//Only reset the IsDirty value to false since the updates when through.
|
//Only reset the IsDirty value to false since the updates when through.
|
||||||
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;
|
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;
|
errorLabel.Text += @"Failed to process actual sales." + Environment.NewLine;
|
||||||
}
|
}
|
||||||
if (SaveInvoices(dateId, displayInformation))
|
if (!SaveInvoices(dateId, displayInformation))
|
||||||
{
|
{
|
||||||
success = false;
|
success = false;
|
||||||
}
|
}
|
||||||
@@ -3367,7 +3534,11 @@ namespace AdvertsingProfitControl
|
|||||||
if (success)
|
if (success)
|
||||||
{
|
{
|
||||||
_isFormDirty = false;
|
_isFormDirty = false;
|
||||||
|
addRecordButton.Text = @"Update Record";
|
||||||
|
Text = @"Modify Record (Current Record: " + _currentActiveDate.ToShortDateString() + @")";
|
||||||
}
|
}
|
||||||
|
weekEndingCalendar.AddBoldedDate(_currentActiveDate);
|
||||||
|
weekEndingCalendar.Invalidate();
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3409,7 +3580,7 @@ namespace AdvertsingProfitControl
|
|||||||
errorLabel.Text = writerStatus.GetErrorMessage();
|
errorLabel.Text = writerStatus.GetErrorMessage();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(displayInformation) informationLabel.Text += writerStatus.GetErrorMessage() + Environment.NewLine;
|
if (displayInformation) informationLabel.Text += writerStatus.GetErrorMessage() + Environment.NewLine;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3428,7 +3599,7 @@ namespace AdvertsingProfitControl
|
|||||||
errorLabel.Text = status.ErrorMessage;
|
errorLabel.Text = status.ErrorMessage;
|
||||||
return false;
|
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;
|
var id = status.Id;
|
||||||
isCommentDirtyCheckBox.Tag = id;
|
isCommentDirtyCheckBox.Tag = id;
|
||||||
isCommentDirtyCheckBox.Text = @"IsCommentDirty (" + 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.
|
//Check for a null comment box and delete the comment ID from the database.
|
||||||
//Then if all is successful clear the Tag in the isCommentsDirty check box.
|
//Then if all is successful clear the Tag in the isCommentsDirty check box.
|
||||||
var status = dbW.ProcessComments(commentsTextBox.Text, dateId, dbT.DatabaseConnectionString,
|
var status = dbW.ProcessComments(commentsTextBox.Text, dateId, dbT.DatabaseConnectionString, int.Parse(isCommentDirtyCheckBox.Tag.ToString()));
|
||||||
int.Parse(isCommentDirtyCheckBox.Tag.ToString()));
|
|
||||||
if (status.Status == WritingOperationStatus.Failed)
|
if (status.Status == WritingOperationStatus.Failed)
|
||||||
{
|
{
|
||||||
errorLabel.Text = status.ErrorMessage;
|
errorLabel.Text = status.ErrorMessage;
|
||||||
@@ -3468,13 +3638,9 @@ namespace AdvertsingProfitControl
|
|||||||
weeklySales[1] = mondayWeeklySalesTextBox.Text == "" ? 0 : double.Parse(mondayWeeklySalesTextBox.Text);
|
weeklySales[1] = mondayWeeklySalesTextBox.Text == "" ? 0 : double.Parse(mondayWeeklySalesTextBox.Text);
|
||||||
weeklySales[2] = tuesdayWeeklySalesTextBox.Text == "" ? 0 : double.Parse(tuesdayWeeklySalesTextBox.Text);
|
weeklySales[2] = tuesdayWeeklySalesTextBox.Text == "" ? 0 : double.Parse(tuesdayWeeklySalesTextBox.Text);
|
||||||
weeklySales[3] = wednesdayWeeklySalesTextBox.Text == "" ? 0 : double.Parse(wednesdayWeeklySalesTextBox.Text);
|
weeklySales[3] = wednesdayWeeklySalesTextBox.Text == "" ? 0 : double.Parse(wednesdayWeeklySalesTextBox.Text);
|
||||||
weeklySales[4] = thursdayWeeklySalesTextBox.Text == ""
|
weeklySales[4] = thursdayWeeklySalesTextBox.Text == "" ? 0 : double.Parse(thursdayWeeklySalesTextBox.Text);
|
||||||
? 0
|
|
||||||
: double.Parse(thursdayWeeklySalesTextBox.Text);
|
|
||||||
weeklySales[5] = fridayWeeklySalesTextBox.Text == "" ? 0 : double.Parse(fridayWeeklySalesTextBox.Text);
|
weeklySales[5] = fridayWeeklySalesTextBox.Text == "" ? 0 : double.Parse(fridayWeeklySalesTextBox.Text);
|
||||||
weeklySales[6] = saturdayWeeklySalesTextBox.Text == ""
|
weeklySales[6] = saturdayWeeklySalesTextBox.Text == "" ? 0 : double.Parse(saturdayWeeklySalesTextBox.Text);
|
||||||
? 0
|
|
||||||
: double.Parse(saturdayWeeklySalesTextBox.Text);
|
|
||||||
weeklySales[7] = totalWeeklySalesTextBox.Text == "" ? 0 : double.Parse(totalWeeklySalesTextBox.Text);
|
weeklySales[7] = totalWeeklySalesTextBox.Text == "" ? 0 : double.Parse(totalWeeklySalesTextBox.Text);
|
||||||
|
|
||||||
if (isWeeklySalesDirtyCheckBox.Tag == null)
|
if (isWeeklySalesDirtyCheckBox.Tag == null)
|
||||||
@@ -3494,8 +3660,7 @@ namespace AdvertsingProfitControl
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var status = dbW.ProcessWeeklySales(weeklySales, dateId, dbT.DatabaseConnectionString,
|
var status = dbW.ProcessWeeklySales(weeklySales, dateId, dbT.DatabaseConnectionString, int.Parse(isWeeklySalesDirtyCheckBox.Tag.ToString()));
|
||||||
int.Parse(isWeeklySalesDirtyCheckBox.Tag.ToString()));
|
|
||||||
if (status.Status == WritingOperationStatus.Failed)
|
if (status.Status == WritingOperationStatus.Failed)
|
||||||
{
|
{
|
||||||
errorLabel.Text = status.ErrorMessage;
|
errorLabel.Text = status.ErrorMessage;
|
||||||
@@ -3544,8 +3709,7 @@ namespace AdvertsingProfitControl
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var status = dbW.ProcessTaxable(taxable, dateId, dbT.DatabaseConnectionString,
|
var status = dbW.ProcessTaxable(taxable, dateId, dbT.DatabaseConnectionString, int.Parse(isTaxableDirtyCheckBox.Tag.ToString()));
|
||||||
int.Parse(isTaxableDirtyCheckBox.Tag.ToString()));
|
|
||||||
if (status.Status == WritingOperationStatus.Failed)
|
if (status.Status == WritingOperationStatus.Failed)
|
||||||
{
|
{
|
||||||
errorLabel.Text = status.ErrorMessage;
|
errorLabel.Text = status.ErrorMessage;
|
||||||
@@ -3591,8 +3755,7 @@ namespace AdvertsingProfitControl
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var status = dbW.ProcessCostAnalysis(costAnalysis, dateId, dbT.DatabaseConnectionString,
|
var status = dbW.ProcessCostAnalysis(costAnalysis, dateId, dbT.DatabaseConnectionString, int.Parse(isCostAnalysisDirtyCheckBox.Tag.ToString()));
|
||||||
int.Parse(isCostAnalysisDirtyCheckBox.Tag.ToString()));
|
|
||||||
if (status.Status == WritingOperationStatus.Failed)
|
if (status.Status == WritingOperationStatus.Failed)
|
||||||
{
|
{
|
||||||
errorLabel.Text = status.ErrorMessage;
|
errorLabel.Text = status.ErrorMessage;
|
||||||
@@ -3606,6 +3769,7 @@ namespace AdvertsingProfitControl
|
|||||||
if (displayInformation) informationLabel.Text += @"No changes made to Cost Analysis." + Environment.NewLine;
|
if (displayInformation) informationLabel.Text += @"No changes made to Cost Analysis." + Environment.NewLine;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Table Trimming Operations
|
#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.
|
//Construct a list of column names for the projections/actual sales DataGridViews and the inventory DataGirdView.
|
||||||
string[] saleColumnNames =
|
string[] saleColumnNames =
|
||||||
{
|
{
|
||||||
"ID", "Sold", "SalePrice", "TotalSales", "Cost", "ProfitReturn",
|
"ID", "Sold", "SalePrice", "TotalSales", "Cost", "ProfitReturn", "TotalProfitReturn", "AdItemID", "RowAttribute", "AdSpecialID", "RowPosition", "DateID"
|
||||||
"TotalProfitReturn", "AdItemID", "RowAttribute", "AdSpecialID", "RowPosition", "DateID"
|
|
||||||
};
|
};
|
||||||
foreach (var columnName in saleColumnNames)
|
foreach (var columnName in saleColumnNames)
|
||||||
{
|
{
|
||||||
@@ -3652,9 +3815,7 @@ namespace AdvertsingProfitControl
|
|||||||
if (_adSpecialIndex != -1)
|
if (_adSpecialIndex != -1)
|
||||||
{
|
{
|
||||||
//An ad special does exist so grab its ID from the database.
|
//An ad special does exist so grab its ID from the database.
|
||||||
int.TryParse(databaseReader.RetrieveGroupIdByString(
|
int.TryParse(databaseReader.RetrieveGroupIdByString(dataGridView.Rows[_adSpecialIndex].Cells[(int) SalesTableColumns.AdItem].EditedFormattedValue.ToString(), databaseTracker.DatabaseConnectionString), out adSpecialId);
|
||||||
dataGridView.Rows[_adSpecialIndex].Cells[(int)SalesTableColumns.AdItem]
|
|
||||||
.EditedFormattedValue.ToString(), databaseTracker.DatabaseConnectionString), out adSpecialId);
|
|
||||||
}
|
}
|
||||||
//Begin spinning through all the rows in the projections table.
|
//Begin spinning through all the rows in the projections table.
|
||||||
foreach (DataGridViewRow row in dataGridView.Rows)
|
foreach (DataGridViewRow row in dataGridView.Rows)
|
||||||
@@ -3667,20 +3828,20 @@ namespace AdvertsingProfitControl
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
//Check to see if the row is dirty.
|
//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.
|
//If it is not then continue on to the next row.
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
//Try grabbing the row's ID number (the number that it is in the database).
|
//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.
|
//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 the return value is zero (0) then the ad item is not in the database so try to add it.
|
||||||
if (adItemId == 0)
|
if (adItemId == 0)
|
||||||
{
|
{
|
||||||
//Add the item to the database.
|
//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)
|
if (adItemId == 0)
|
||||||
{
|
{
|
||||||
//TODO: Throw an exception, this can not be allowed.
|
//TODO: Throw an exception, this can not be allowed.
|
||||||
@@ -3693,11 +3854,11 @@ namespace AdvertsingProfitControl
|
|||||||
}
|
}
|
||||||
//Determine the row's attribute.
|
//Determine the row's attribute.
|
||||||
var rowAttribute = 0; //Zero (0) means no grouping, its not a header nor a member.
|
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;
|
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;
|
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.
|
//This table is full of data not in the database so the ID column isn't needed.
|
||||||
var newRow = new object[11];
|
var newRow = new object[11];
|
||||||
newRow[0] = row.Cells[(int)SalesTableColumns.Sold].EditedFormattedValue.ToString();//Sold, is string
|
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[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[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[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[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[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[6] = adItemId;
|
||||||
newRow[7] = rowAttribute;
|
newRow[7] = rowAttribute;
|
||||||
if (_adSpecialIndex != -1 && row.Index > _adSpecialIndex)
|
if (_adSpecialIndex != -1 && row.Index > _adSpecialIndex)
|
||||||
@@ -3732,12 +3893,12 @@ namespace AdvertsingProfitControl
|
|||||||
//This table is full of data that is already in the database.
|
//This table is full of data that is already in the database.
|
||||||
var newRow = new object[12];
|
var newRow = new object[12];
|
||||||
newRow[0] = rowIdNumber;
|
newRow[0] = rowIdNumber;
|
||||||
newRow[1] = row.Cells[(int)SalesTableColumns.Sold].EditedFormattedValue.ToString();//Sold, is string
|
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[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[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[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[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[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[7] = adItemId;
|
||||||
newRow[8] = rowAttribute;
|
newRow[8] = rowAttribute;
|
||||||
if (_adSpecialIndex != -1 && row.Index > _adSpecialIndex)
|
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.
|
//Construct a list of column names for the projections/actual sales DataGridViews and the inventory DataGirdView.
|
||||||
string[] saleColumnNames =
|
string[] saleColumnNames =
|
||||||
{
|
{
|
||||||
"ID", "Sold", "SalePrice", "TotalSales", "Cost", "ProfitReturn",
|
"ID", "Sold", "SalePrice", "TotalSales", "Cost", "ProfitReturn", "TotalProfitReturn", "AdItemID", "RowAttribute", "AdSpecialID", "RowPosition", "DateID"
|
||||||
"TotalProfitReturn", "AdItemID", "RowAttribute", "AdSpecialID", "RowPosition", "DateID"
|
|
||||||
};
|
};
|
||||||
foreach (var columnName in saleColumnNames)
|
foreach (var columnName in saleColumnNames)
|
||||||
{
|
{
|
||||||
@@ -3808,9 +3968,7 @@ namespace AdvertsingProfitControl
|
|||||||
if (_adSpecialIndex != -1)
|
if (_adSpecialIndex != -1)
|
||||||
{
|
{
|
||||||
//An ad special does exist so grab its ID from the database.
|
//An ad special does exist so grab its ID from the database.
|
||||||
int.TryParse(databaseReader.RetrieveGroupIdByString(
|
int.TryParse(databaseReader.RetrieveGroupIdByString(inventoryDataGridView.Rows[_adSpecialIndex].Cells[(int) InventoryTableColumns.AdItem].EditedFormattedValue.ToString(), databaseTracker.DatabaseConnectionString), out adSpecialId);
|
||||||
inventoryDataGridView.Rows[_adSpecialIndex].Cells[(int)InventoryTableColumns.AdItem]
|
|
||||||
.EditedFormattedValue.ToString(), databaseTracker.DatabaseConnectionString), out adSpecialId);
|
|
||||||
}
|
}
|
||||||
//Begin spinning through all the rows in the projections table.
|
//Begin spinning through all the rows in the projections table.
|
||||||
foreach (DataGridViewRow row in inventoryDataGridView.Rows)
|
foreach (DataGridViewRow row in inventoryDataGridView.Rows)
|
||||||
@@ -3824,20 +3982,20 @@ namespace AdvertsingProfitControl
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
//Check to see if the row is dirty.
|
//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.
|
//If it is not then continue on to the next row.
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
//Try grabbing the row's ID number (the number that it is in the database).
|
//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.
|
//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 the return value is zero (0) then the ad item is not in the database so try to add it.
|
||||||
if (adItemId == 0)
|
if (adItemId == 0)
|
||||||
{
|
{
|
||||||
//Add the item to the database.
|
//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)
|
if (adItemId == 0)
|
||||||
{
|
{
|
||||||
//TODO: Throw an exception, this can not be allowed.
|
//TODO: Throw an exception, this can not be allowed.
|
||||||
@@ -3849,11 +4007,11 @@ namespace AdvertsingProfitControl
|
|||||||
}
|
}
|
||||||
//Determine the row's attribute.
|
//Determine the row's attribute.
|
||||||
var rowAttribute = 0; //Zero (0) means no grouping, its not a header nor a member.
|
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;
|
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;
|
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.
|
//This table is full of data not in the database so the ID column isn't needed.
|
||||||
var newRow = new object[9];
|
var newRow = new object[9];
|
||||||
newRow[0] = row.Cells[(int)InventoryTableColumns.BeginningInventory].EditedFormattedValue.ToString();//Beginning 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[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[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[3] = row.Cells[(int) InventoryTableColumns.EndingInventory].EditedFormattedValue.ToString(); //Ending inventory, is string
|
||||||
newRow[4] = adItemId;
|
newRow[4] = adItemId;
|
||||||
newRow[5] = rowAttribute;
|
newRow[5] = rowAttribute;
|
||||||
if (_adSpecialIndex != -1 && row.Index > _adSpecialIndex)
|
if (_adSpecialIndex != -1 && row.Index > _adSpecialIndex)
|
||||||
@@ -3886,10 +4044,10 @@ namespace AdvertsingProfitControl
|
|||||||
//This table is full of data that is already in the database.
|
//This table is full of data that is already in the database.
|
||||||
var newRow = new object[10];
|
var newRow = new object[10];
|
||||||
newRow[0] = rowIdNumber;
|
newRow[0] = rowIdNumber;
|
||||||
newRow[1] = row.Cells[(int)InventoryTableColumns.BeginningInventory].EditedFormattedValue.ToString();//Beginning 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[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[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[4] = row.Cells[(int) InventoryTableColumns.EndingInventory].EditedFormattedValue.ToString(); //Ending inventory, is string
|
||||||
newRow[5] = adItemId;
|
newRow[5] = adItemId;
|
||||||
newRow[6] = rowAttribute;
|
newRow[6] = rowAttribute;
|
||||||
if (_adSpecialIndex != -1 && row.Index > _adSpecialIndex)
|
if (_adSpecialIndex != -1 && row.Index > _adSpecialIndex)
|
||||||
@@ -3933,24 +4091,193 @@ namespace AdvertsingProfitControl
|
|||||||
{
|
{
|
||||||
if (!_isFormDirty) return;
|
if (!_isFormDirty) return;
|
||||||
var result = MessageBox.Show(@"Would you like to save the changes you have made?", @"Save Changes", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
|
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);
|
case DialogResult.Yes:
|
||||||
}
|
SaveRecords(false);
|
||||||
else if(result == DialogResult.Cancel)
|
break;
|
||||||
{
|
case DialogResult.Cancel:
|
||||||
e.Cancel = true;
|
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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -120,7 +120,4 @@
|
|||||||
<metadata name="mainMenuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
<metadata name="mainMenuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
<value>17, 17</value>
|
<value>17, 17</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
<metadata name="mainMenuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
|
||||||
<value>17, 17</value>
|
|
||||||
</metadata>
|
|
||||||
</root>
|
</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