From 4b96f6c1fa18d4aa1795725fcd0973c77040c490 Mon Sep 17 00:00:00 2001 From: Garritt McCune Date: Sun, 12 Nov 2017 02:27:22 -0600 Subject: [PATCH] Moved the text formatting class to the data table parsing class. Slightly organized the code in the NewModifyRecord form. --- .../Properties/AssemblyInfo.cs | 1 - .../AdvertsingProfitControl.csproj | 1 - .../FrmChangeShrink.Designer.cs | 1 - AdvertsingProfitControl/FrmChangeShrink.cs | 6 - AdvertsingProfitControl/FrmManageAdItems.cs | 1 + .../NewModifyRecord.Designer.cs | 6 +- AdvertsingProfitControl/NewModifyRecord.cs | 638 +++++++++--------- .../Properties/AssemblyInfo.cs | 4 +- .../DataTableParsingEngine.csproj | 1 + .../Properties/AssemblyInfo.cs | 4 +- .../TextFormat.cs | 14 +- 11 files changed, 341 insertions(+), 336 deletions(-) rename {AdvertsingProfitControl => DataTableParsingEngine}/TextFormat.cs (98%) diff --git a/AdvertisingProfitControlData/Properties/AssemblyInfo.cs b/AdvertisingProfitControlData/Properties/AssemblyInfo.cs index f2ca177..d87bdb4 100644 --- a/AdvertisingProfitControlData/Properties/AssemblyInfo.cs +++ b/AdvertisingProfitControlData/Properties/AssemblyInfo.cs @@ -1,5 +1,4 @@ using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following diff --git a/AdvertsingProfitControl/AdvertsingProfitControl.csproj b/AdvertsingProfitControl/AdvertsingProfitControl.csproj index 79a8140..8624a2c 100644 --- a/AdvertsingProfitControl/AdvertsingProfitControl.csproj +++ b/AdvertsingProfitControl/AdvertsingProfitControl.csproj @@ -188,7 +188,6 @@ Resources.resx - Form diff --git a/AdvertsingProfitControl/FrmChangeShrink.Designer.cs b/AdvertsingProfitControl/FrmChangeShrink.Designer.cs index cc887cb..4830ec9 100644 --- a/AdvertsingProfitControl/FrmChangeShrink.Designer.cs +++ b/AdvertsingProfitControl/FrmChangeShrink.Designer.cs @@ -54,7 +54,6 @@ this.shrinkAcceptButton.TabIndex = 1; this.shrinkAcceptButton.Text = "Accept"; this.shrinkAcceptButton.UseVisualStyleBackColor = true; - this.shrinkAcceptButton.Click += new System.EventHandler(this.shrinkAcceptButton_Click); // // FrmChangeShrink // diff --git a/AdvertsingProfitControl/FrmChangeShrink.cs b/AdvertsingProfitControl/FrmChangeShrink.cs index 5d276e1..413eda0 100644 --- a/AdvertsingProfitControl/FrmChangeShrink.cs +++ b/AdvertsingProfitControl/FrmChangeShrink.cs @@ -18,11 +18,5 @@ namespace AdvertsingProfitControl shrinkNumericUpDown.Value = shrink; Shrink = shrink; } - - private void shrinkAcceptButton_Click(object sender, System.EventArgs e) - { - Shrink = int.Parse(shrinkNumericUpDown.Text); - Close(); - } } } diff --git a/AdvertsingProfitControl/FrmManageAdItems.cs b/AdvertsingProfitControl/FrmManageAdItems.cs index f7223d7..5006104 100644 --- a/AdvertsingProfitControl/FrmManageAdItems.cs +++ b/AdvertsingProfitControl/FrmManageAdItems.cs @@ -6,6 +6,7 @@ using System.Linq; using System.Transactions; using System.Windows.Forms; using AdvertisingProfitControlData; +using DataTableParsingEngine; namespace AdvertsingProfitControl { diff --git a/AdvertsingProfitControl/NewModifyRecord.Designer.cs b/AdvertsingProfitControl/NewModifyRecord.Designer.cs index cf5f8d5..b626ea9 100644 --- a/AdvertsingProfitControl/NewModifyRecord.Designer.cs +++ b/AdvertsingProfitControl/NewModifyRecord.Designer.cs @@ -203,7 +203,7 @@ 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); + this.createNewRecordEditMainMenu.Click += new System.EventHandler(this.CreateNewRecordEditMainMenuOnClick); // // helpMainMenu // @@ -972,7 +972,7 @@ this.addRecordButton.TabIndex = 26; this.addRecordButton.Text = "Update Record"; this.addRecordButton.UseVisualStyleBackColor = true; - this.addRecordButton.Click += new System.EventHandler(this.addRecordButton_Click); + this.addRecordButton.Click += new System.EventHandler(this.SaveRecordOnAddRecordButtonClick); // // NewModifyRecord // @@ -985,7 +985,7 @@ this.Name = "NewModifyRecord"; this.Text = "Modify Record"; 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.CheckFormStateOnClosing); this.mainLayoutPanel.ResumeLayout(false); this.mainLayoutPanel.PerformLayout(); this.mainMenuStrip.ResumeLayout(false); diff --git a/AdvertsingProfitControl/NewModifyRecord.cs b/AdvertsingProfitControl/NewModifyRecord.cs index 7a663b4..a710828 100644 --- a/AdvertsingProfitControl/NewModifyRecord.cs +++ b/AdvertsingProfitControl/NewModifyRecord.cs @@ -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(); - _usedAdItems[1] = new List(); - //Assign the events for the comments text box and display the remaining character count for the user. - commentsTextBox.TextChanged += DisplayRemainingCommentCharacterCount; - commentsGroupBox.Text = @"Comments (Characters Remaining: " + commentsTextBox.MaxLength + @")"; - //Setup the events for that the Projected and Actual Sales DataGridViews will share. - //Events are assigned with regard to which event gets triggered first and so on.. - //Hook the row add event so we can paint a row number in the header cell of the row. - projectionsDataGridView.RowsAdded += DisplayRowNumbers; - inventoryDataGridView.RowsAdded += DisplayRowNumbers; - actualSalesDataGridView.RowsAdded += DisplayRowNumbers; - //Assign all the tables to store the cell's contents on enter so changes (if any) can be detected and flagged (marked as dirty). - projectionsDataGridView.CellEnter += StoreBeginningCellValue; - inventoryDataGridView.CellEnter += StoreBeginningCellValue; - actualSalesDataGridView.CellEnter += StoreBeginningCellValue; - //Update the 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(); + _usedAdItems[1] = new List(); + //Assign the events for the comments text box and display the remaining character count for the user. + commentsTextBox.TextChanged += DisplayRemainingCommentCharacterCount; + commentsGroupBox.Text = @"Comments (Characters Remaining: " + commentsTextBox.MaxLength + @")"; + //Setup the events for that the Projected and Actual Sales DataGridViews will share. + //Events are assigned with regard to which event gets triggered first and so on.. + //Hook the row add event so we can paint a row number in the header cell of the row. + projectionsDataGridView.RowsAdded += DisplayRowNumbers; + inventoryDataGridView.RowsAdded += DisplayRowNumbers; + actualSalesDataGridView.RowsAdded += DisplayRowNumbers; + //Assign all the tables to store the cell's contents on enter so changes (if any) can be detected and flagged (marked as dirty). + projectionsDataGridView.CellEnter += StoreBeginningCellValue; + inventoryDataGridView.CellEnter += StoreBeginningCellValue; + actualSalesDataGridView.CellEnter += StoreBeginningCellValue; + //Update the 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 } } diff --git a/AdvertsingProfitControl/Properties/AssemblyInfo.cs b/AdvertsingProfitControl/Properties/AssemblyInfo.cs index 49f20b9..d96e68a 100644 --- a/AdvertsingProfitControl/Properties/AssemblyInfo.cs +++ b/AdvertsingProfitControl/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("3.4.1.0")] -[assembly: AssemblyFileVersion("3.4.1.0")] +[assembly: AssemblyVersion("3.5.1.0")] +[assembly: AssemblyFileVersion("3.5.1.0")] diff --git a/DataTableParsingEngine/DataTableParsingEngine.csproj b/DataTableParsingEngine/DataTableParsingEngine.csproj index e8040b4..be5ff1d 100644 --- a/DataTableParsingEngine/DataTableParsingEngine.csproj +++ b/DataTableParsingEngine/DataTableParsingEngine.csproj @@ -54,6 +54,7 @@ + diff --git a/DataTableParsingEngine/Properties/AssemblyInfo.cs b/DataTableParsingEngine/Properties/AssemblyInfo.cs index 53ea4d4..7dfb2c4 100644 --- a/DataTableParsingEngine/Properties/AssemblyInfo.cs +++ b/DataTableParsingEngine/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.6.0.0")] -[assembly: AssemblyFileVersion("1.6.0.0")] +[assembly: AssemblyVersion("1.6.1.0")] +[assembly: AssemblyFileVersion("1.6.1.0")] diff --git a/AdvertsingProfitControl/TextFormat.cs b/DataTableParsingEngine/TextFormat.cs similarity index 98% rename from AdvertsingProfitControl/TextFormat.cs rename to DataTableParsingEngine/TextFormat.cs index 19d6044..14d9ded 100644 --- a/AdvertsingProfitControl/TextFormat.cs +++ b/DataTableParsingEngine/TextFormat.cs @@ -3,12 +3,12 @@ using System.Collections.Generic; using System.Linq; using System.Text; -namespace AdvertsingProfitControl +namespace DataTableParsingEngine { /// /// Contains methods that assist with managing ad item names. /// - internal static class TextFormat + public static class TextFormat { //private static readonly FrmLogConsole LogConsole = FrmLogConsole.GetStaticInstance; @@ -22,8 +22,6 @@ namespace AdvertsingProfitControl { //Trim all beginning and trailing whitespace characters to start. adItemText = adItemText.Trim(); - var abbreviations = new List(); - var words = new List(); var isInsideBrackets = false; //This just makes the code a bit more readable rather then doing "adItemText[currentCharacter - 1]" to access the previous character. var isPreviousCharWhiteSpace = false; @@ -82,9 +80,11 @@ namespace AdvertsingProfitControl //Clear the current working word. isInsideBrackets = false; continue; - } + } //IF the current character is not a number and the previous character is a white space character //then capitalize the current character and add it to the string. + List abbreviations; + List words; if (!char.IsNumber(adItemText[currentCharacter]) && isPreviousCharWhiteSpace) { //Check to see the length of the string and determine if the word with the number needs to be capitalized. @@ -311,7 +311,7 @@ namespace AdvertsingProfitControl /// /// Determines whether or not a string is an abbreviation or a word. /// A word is defined as being at least three (3) characters long and having - /// at least one (1) vowel. Where as an abbreviation is defined as less then + /// at least one (1) vowel. Where as an abbreviation is defined as less then or equal to /// three (3) characters long but has at least one (1) character, whether or not /// the string that is two (2) or one (1) characters long has a vowel is meaningless /// or being exactly three characters long but having zero (0) vowels. @@ -392,7 +392,7 @@ namespace AdvertsingProfitControl binCountString = "1 Bin"; } success = true; - } + } } return success;