|
|
|
@@ -46,19 +46,6 @@ namespace AdvertsingProfitControl
|
|
|
|
|
|
|
|
|
|
private int _selectedRowIndex = -1;
|
|
|
|
|
|
|
|
|
|
public NewModifyRecord(DateTime date)
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
//
|
|
|
|
|
weekEndingCalendar.SelectionStart = date;
|
|
|
|
|
_currentActiveDate = date;
|
|
|
|
|
InitializeForm();
|
|
|
|
|
mainTabControl.TabPages.Remove(mainTabControl.TabPages[4]);
|
|
|
|
|
Text = @"Modify Record (Current Record: " + date.ToShortDateString() + @")";
|
|
|
|
|
_isModifyingRecord = true;
|
|
|
|
|
LoadDate(date);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public NewModifyRecord()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
@@ -84,121 +71,17 @@ namespace AdvertsingProfitControl
|
|
|
|
|
addRecordButton.Text = @"Add Record";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void InitializeForm()
|
|
|
|
|
public NewModifyRecord(DateTime date)
|
|
|
|
|
{
|
|
|
|
|
var db = new AdvertisingProfitControlDbContext();
|
|
|
|
|
weekEndingCalendar.BoldedDates = db.WeekEndingDates.Select(zdate => zdate.EndingDate).ToArray();
|
|
|
|
|
weekEndingCalendar.DateChanged += ValidateDateChanged;
|
|
|
|
|
//next pull all the ad items into memory.
|
|
|
|
|
_adItemCollection = db.AdItems.Select(x => x.Name).ToList();
|
|
|
|
|
//Now pull all the suppliers and the ad special list into memory.
|
|
|
|
|
_supplierCollection.AddRange(db.Suppliers.Select(x => x.Name).ToArray());
|
|
|
|
|
_adSpecialList.AddRange(db.AdSpecials.Select(x => x.Name).ToArray());
|
|
|
|
|
//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 selected row index field.
|
|
|
|
|
projectionsDataGridView.RowEnter += UpdateSelectedRowIndexOnEnter;
|
|
|
|
|
inventoryDataGridView.RowEnter += UpdateSelectedRowIndexOnEnter;
|
|
|
|
|
actualSalesDataGridView.RowEnter += UpdateSelectedRowIndexOnEnter;
|
|
|
|
|
//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;
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
//
|
|
|
|
|
weekEndingCalendar.SelectionStart = date;
|
|
|
|
|
_currentActiveDate = date;
|
|
|
|
|
InitializeForm();
|
|
|
|
|
mainTabControl.TabPages.Remove(mainTabControl.TabPages[4]);
|
|
|
|
|
Text = @"Modify Record (Current Record: " + date.ToShortDateString() + @")";
|
|
|
|
|
_isModifyingRecord = true;
|
|
|
|
|
LoadDate(date);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public sealed override string Text
|
|
|
|
@@ -2666,6 +2549,125 @@ out double beginningBinCount, out string _))
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Form State Methods
|
|
|
|
|
|
|
|
|
|
public void InitializeForm()
|
|
|
|
|
{
|
|
|
|
|
var db = new AdvertisingProfitControlDbContext();
|
|
|
|
|
weekEndingCalendar.BoldedDates = db.WeekEndingDates.Select(zdate => zdate.EndingDate).ToArray();
|
|
|
|
|
weekEndingCalendar.DateChanged += ValidateDateChanged;
|
|
|
|
|
//next pull all the ad items into memory.
|
|
|
|
|
_adItemCollection = db.AdItems.Select(x => x.Name).ToList();
|
|
|
|
|
//Now pull all the suppliers and the ad special list into memory.
|
|
|
|
|
_supplierCollection.AddRange(db.Suppliers.Select(x => x.Name).ToArray());
|
|
|
|
|
_adSpecialList.AddRange(db.AdSpecials.Select(x => x.Name).ToArray());
|
|
|
|
|
//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 selected row index field.
|
|
|
|
|
projectionsDataGridView.RowEnter += UpdateSelectedRowIndexOnEnter;
|
|
|
|
|
inventoryDataGridView.RowEnter += UpdateSelectedRowIndexOnEnter;
|
|
|
|
|
actualSalesDataGridView.RowEnter += UpdateSelectedRowIndexOnEnter;
|
|
|
|
|
//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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ClearFormState()
|
|
|
|
|
{
|
|
|
|
|
projectionsDataGridView.CellEnter -= StoreBeginningCellValue;
|
|
|
|
@@ -2856,6 +2858,191 @@ out double beginningBinCount, out string _))
|
|
|
|
|
suppliesTextBox.Validating += ValidateCostAnalysisValues;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ClearRow(int rowIndex)
|
|
|
|
|
{
|
|
|
|
|
foreach (DataGridViewCell cell in projectionsDataGridView.Rows[rowIndex].Cells)
|
|
|
|
|
{
|
|
|
|
|
if (cell.ColumnIndex == (int)TableGroupParser.SalesTableColumns.AdItem) continue;
|
|
|
|
|
var actualSalesCell = actualSalesDataGridView.Rows[rowIndex].Cells[cell.ColumnIndex];
|
|
|
|
|
if (cell.ColumnIndex < (int)TableGroupParser.SalesTableColumns.IsHeaderRow)
|
|
|
|
|
{
|
|
|
|
|
cell.Value = string.Empty;
|
|
|
|
|
actualSalesCell.Value = string.Empty;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
cell.Value = false;
|
|
|
|
|
actualSalesCell.Value = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach (DataGridViewCell cell in inventoryDataGridView.Rows[rowIndex].Cells)
|
|
|
|
|
{
|
|
|
|
|
if (cell.ColumnIndex == (int)TableGroupParser.InventoryTableColumns.AdItem) continue;
|
|
|
|
|
if (cell.ColumnIndex < (int)TableGroupParser.InventoryTableColumns.IsHeaderRow)
|
|
|
|
|
{
|
|
|
|
|
cell.Value = string.Empty;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
cell.Value = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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 RowParser();
|
|
|
|
|
for (var i = 0; i < maxRowCount; i++)
|
|
|
|
|
{
|
|
|
|
|
if (rowParser.GetRowAttribute(dataGridView.Rows[i]) == RowParser.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)TableGroupParser.SalesTableColumns.AdItem].EditedFormattedValue !=
|
|
|
|
|
dataGridView.Rows[i].Cells[(int)TableGroupParser.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)TableGroupParser.SalesTableColumns.AdItem].Value = dataGridView.Rows[i].Cells[(int)TableGroupParser.SalesTableColumns.AdItem].EditedFormattedValue;
|
|
|
|
|
projectionsDataGridView.Rows[i].Cells[(int)TableGroupParser.SalesTableColumns.IsDirty].Value = true;
|
|
|
|
|
if (i != _adSpecialIndex)
|
|
|
|
|
{
|
|
|
|
|
projectionsDataGridView.Rows[i].HeaderCell.Style.BackColor = TableColors.PendingEdit;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (dataGridView == actualSalesDataGridView)
|
|
|
|
|
{
|
|
|
|
|
projectionsDataGridView.Rows[i].Cells[(int)TableGroupParser.SalesTableColumns.SalePrice].Value =
|
|
|
|
|
dataGridView.Rows[i].Cells[(int)TableGroupParser.SalesTableColumns.SalePrice].EditedFormattedValue;
|
|
|
|
|
projectionsDataGridView.Rows[i].Cells[(int)TableGroupParser.SalesTableColumns.Cost].Value = dataGridView.Rows[i].Cells[(int)TableGroupParser.SalesTableColumns.Cost].EditedFormattedValue;
|
|
|
|
|
projectionsDataGridView.Rows[i].Cells[(int)TableGroupParser.SalesTableColumns.ProfitReturn].Value = dataGridView.Rows[i].Cells[(int)TableGroupParser.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)TableGroupParser.InventoryTableColumns.AdItem].EditedFormattedValue !=
|
|
|
|
|
dataGridView.Rows[i].Cells[(int)TableGroupParser.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)TableGroupParser.InventoryTableColumns.AdItem].Value = dataGridView.Rows[i].Cells[(int)TableGroupParser.InventoryTableColumns.AdItem].EditedFormattedValue;
|
|
|
|
|
inventoryDataGridView.Rows[i].Cells[(int)TableGroupParser.InventoryTableColumns.IsDirty].Value = true;
|
|
|
|
|
if (i != _adSpecialIndex)
|
|
|
|
|
{
|
|
|
|
|
inventoryDataGridView.Rows[i].HeaderCell.Style.BackColor = TableColors.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)TableGroupParser.SalesTableColumns.AdItem].EditedFormattedValue !=
|
|
|
|
|
dataGridView.Rows[i].Cells[(int)TableGroupParser.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)TableGroupParser.SalesTableColumns.AdItem].Value = dataGridView.Rows[i].Cells[(int)TableGroupParser.SalesTableColumns.AdItem].EditedFormattedValue;
|
|
|
|
|
actualSalesDataGridView.Rows[i].Cells[(int)TableGroupParser.SalesTableColumns.IsDirty].Value = true;
|
|
|
|
|
if (i != _adSpecialIndex)
|
|
|
|
|
{
|
|
|
|
|
actualSalesDataGridView.Rows[i].HeaderCell.Style.BackColor = TableColors.PendingEdit;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (dataGridView == projectionsDataGridView)
|
|
|
|
|
{
|
|
|
|
|
actualSalesDataGridView.Rows[i].Cells[(int)TableGroupParser.SalesTableColumns.SalePrice].Value =
|
|
|
|
|
dataGridView.Rows[i].Cells[(int)TableGroupParser.SalesTableColumns.SalePrice].EditedFormattedValue;
|
|
|
|
|
actualSalesDataGridView.Rows[i].Cells[(int)TableGroupParser.SalesTableColumns.Cost].Value = dataGridView.Rows[i].Cells[(int)TableGroupParser.SalesTableColumns.Cost].EditedFormattedValue;
|
|
|
|
|
actualSalesDataGridView.Rows[i].Cells[(int)TableGroupParser.SalesTableColumns.ProfitReturn].Value = dataGridView.Rows[i].Cells[(int)TableGroupParser.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
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Data Loading Methods
|
|
|
|
|
|
|
|
|
|
private void LoadDate(DateTime date)
|
|
|
|
@@ -4415,6 +4602,8 @@ out double beginningBinCount, out string _))
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Sales Table Calculation Methods
|
|
|
|
|
|
|
|
|
|
private static void CalculateTotalPofitReturn(DataGridViewRow salesTableRow)
|
|
|
|
|
{
|
|
|
|
|
var sold = salesTableRow.Cells[(int) TableGroupParser.SalesTableColumns.Sold].EditedFormattedValue.ToString();
|
|
|
|
@@ -4460,12 +4649,16 @@ out double beginningBinCount, out string _))
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void addRecordButton_Click(object sender, EventArgs e)
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
private void SaveRecordOnAddRecordButtonClick(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
SaveRecords();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void NewModifyRecord_FormClosing(object sender, FormClosingEventArgs e)
|
|
|
|
|
#region Menu Item Click Events
|
|
|
|
|
|
|
|
|
|
private void CheckFormStateOnClosing(object sender, FormClosingEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (!_isFormDirty) return;
|
|
|
|
|
var result = MessageBox.Show(@"Would you like to save the changes you have made?", @"Save Changes", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
|
|
|
|
@@ -4480,7 +4673,7 @@ out double beginningBinCount, out string _))
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void createNewRecordEditMainMenu_Click(object sender, EventArgs e)
|
|
|
|
|
private void CreateNewRecordEditMainMenuOnClick(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (_isFormDirty)
|
|
|
|
|
{
|
|
|
|
@@ -4513,189 +4706,6 @@ out double beginningBinCount, out string _))
|
|
|
|
|
_isModifyingRecord = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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 RowParser();
|
|
|
|
|
for (var i = 0; i < maxRowCount; i++)
|
|
|
|
|
{
|
|
|
|
|
if (rowParser.GetRowAttribute(dataGridView.Rows[i]) == RowParser.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) TableGroupParser.SalesTableColumns.AdItem].EditedFormattedValue !=
|
|
|
|
|
dataGridView.Rows[i].Cells[(int) TableGroupParser.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)TableGroupParser.SalesTableColumns.AdItem].Value = dataGridView.Rows[i].Cells[(int)TableGroupParser.SalesTableColumns.AdItem].EditedFormattedValue;
|
|
|
|
|
projectionsDataGridView.Rows[i].Cells[(int)TableGroupParser.SalesTableColumns.IsDirty].Value = true;
|
|
|
|
|
if (i != _adSpecialIndex)
|
|
|
|
|
{
|
|
|
|
|
projectionsDataGridView.Rows[i].HeaderCell.Style.BackColor = TableColors.PendingEdit;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (dataGridView == actualSalesDataGridView)
|
|
|
|
|
{
|
|
|
|
|
projectionsDataGridView.Rows[i].Cells[(int) TableGroupParser.SalesTableColumns.SalePrice].Value =
|
|
|
|
|
dataGridView.Rows[i].Cells[(int) TableGroupParser.SalesTableColumns.SalePrice].EditedFormattedValue;
|
|
|
|
|
projectionsDataGridView.Rows[i].Cells[(int)TableGroupParser.SalesTableColumns.Cost].Value = dataGridView.Rows[i].Cells[(int)TableGroupParser.SalesTableColumns.Cost].EditedFormattedValue;
|
|
|
|
|
projectionsDataGridView.Rows[i].Cells[(int)TableGroupParser.SalesTableColumns.ProfitReturn].Value = dataGridView.Rows[i].Cells[(int)TableGroupParser.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)TableGroupParser.InventoryTableColumns.AdItem].EditedFormattedValue !=
|
|
|
|
|
dataGridView.Rows[i].Cells[(int)TableGroupParser.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)TableGroupParser.InventoryTableColumns.AdItem].Value = dataGridView.Rows[i].Cells[(int)TableGroupParser.InventoryTableColumns.AdItem].EditedFormattedValue;
|
|
|
|
|
inventoryDataGridView.Rows[i].Cells[(int)TableGroupParser.InventoryTableColumns.IsDirty].Value = true;
|
|
|
|
|
if (i != _adSpecialIndex)
|
|
|
|
|
{
|
|
|
|
|
inventoryDataGridView.Rows[i].HeaderCell.Style.BackColor = TableColors.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)TableGroupParser.SalesTableColumns.AdItem].EditedFormattedValue !=
|
|
|
|
|
dataGridView.Rows[i].Cells[(int)TableGroupParser.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)TableGroupParser.SalesTableColumns.AdItem].Value = dataGridView.Rows[i].Cells[(int)TableGroupParser.SalesTableColumns.AdItem].EditedFormattedValue;
|
|
|
|
|
actualSalesDataGridView.Rows[i].Cells[(int)TableGroupParser.SalesTableColumns.IsDirty].Value = true;
|
|
|
|
|
if (i != _adSpecialIndex)
|
|
|
|
|
{
|
|
|
|
|
actualSalesDataGridView.Rows[i].HeaderCell.Style.BackColor = TableColors.PendingEdit;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (dataGridView == projectionsDataGridView)
|
|
|
|
|
{
|
|
|
|
|
actualSalesDataGridView.Rows[i].Cells[(int)TableGroupParser.SalesTableColumns.SalePrice].Value =
|
|
|
|
|
dataGridView.Rows[i].Cells[(int)TableGroupParser.SalesTableColumns.SalePrice].EditedFormattedValue;
|
|
|
|
|
actualSalesDataGridView.Rows[i].Cells[(int)TableGroupParser.SalesTableColumns.Cost].Value = dataGridView.Rows[i].Cells[(int)TableGroupParser.SalesTableColumns.Cost].EditedFormattedValue;
|
|
|
|
|
actualSalesDataGridView.Rows[i].Cells[(int)TableGroupParser.SalesTableColumns.ProfitReturn].Value = dataGridView.Rows[i].Cells[(int)TableGroupParser.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
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ClearRow(int rowIndex)
|
|
|
|
|
{
|
|
|
|
|
foreach (DataGridViewCell cell in projectionsDataGridView.Rows[rowIndex].Cells)
|
|
|
|
|
{
|
|
|
|
|
if (cell.ColumnIndex == (int) TableGroupParser.SalesTableColumns.AdItem) continue;
|
|
|
|
|
var actualSalesCell = actualSalesDataGridView.Rows[rowIndex].Cells[cell.ColumnIndex];
|
|
|
|
|
if (cell.ColumnIndex < (int) TableGroupParser.SalesTableColumns.IsHeaderRow)
|
|
|
|
|
{
|
|
|
|
|
cell.Value = string.Empty;
|
|
|
|
|
actualSalesCell.Value = string.Empty;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
cell.Value = false;
|
|
|
|
|
actualSalesCell.Value = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach (DataGridViewCell cell in inventoryDataGridView.Rows[rowIndex].Cells)
|
|
|
|
|
{
|
|
|
|
|
if (cell.ColumnIndex == (int)TableGroupParser.InventoryTableColumns.AdItem) continue;
|
|
|
|
|
if (cell.ColumnIndex < (int)TableGroupParser.InventoryTableColumns.IsHeaderRow)
|
|
|
|
|
{
|
|
|
|
|
cell.Value = string.Empty;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
cell.Value = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ViewLogFiles(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
var form = new FrmLogFileViewer();
|
|
|
|
@@ -4713,5 +4723,7 @@ out double beginningBinCount, out string _))
|
|
|
|
|
LogConsole.Show();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|