From a57ef93addccd4186ec0b6497b63df25694f417f Mon Sep 17 00:00:00 2001 From: Garritt McCune Date: Wed, 18 Jan 2017 00:43:20 -0600 Subject: [PATCH] Added code to pull in all items in the new modify record form. Updated the database reader code and broke the main form. Fixed a bug where weekly sales and taxable would not set the dirty flag if text was cleared from a text box after pulling from the database. Known bug: when an ad special row's group is changed to another ad special group, i.e. "Weekend Ad" to "New Years Ad", the pending edit color is not shown in the header cells of the members and only the ad special row. --- AdvertsingProfitControl/APCDatabase.accdb | Bin 2932736 -> 2932736 bytes AdvertsingProfitControl/DatabaseReader.cs | 68 +- AdvertsingProfitControl/FrmMain.cs | 4 +- AdvertsingProfitControl/NewModifyRecord.cs | 611 +++++++++++++++++- ...AdvertsingProfitControl.vshost.application | 2 +- ...dvertsingProfitControl.vshost.exe.manifest | 6 +- 6 files changed, 665 insertions(+), 26 deletions(-) diff --git a/AdvertsingProfitControl/APCDatabase.accdb b/AdvertsingProfitControl/APCDatabase.accdb index 763f5848acf08f4ba006ad601fff5d1cafa58a72..b12af87ef561c28ef04202c43df0ba79683b54be 100644 GIT binary patch delta 8951 zcmZo@*vtsR8<_Ywjg@vXF)=bSGHw>+d(SvofsbvIz*c@qCI$ut1_lNOUd9=}tJggB z|NsB@|Nr0r|2sYToV+CSzdhe4zmkvSV`c`afna9l&4CJ^_?eiQC&vcJZ%#3=v*Bl9 zaA06zVBlx~E0LJE&~38(d@eyo1{MYfCKd(e zeLjo&bcgdye48)i&u5=3|44~ZaP!3SJdRBb&n74(Sn7S2eelEqWTq!W9zz*JK0_u$ zGD9lE$>Kk}3=Ryxr{BHLrMz8RkZ~?A>#>=yxD=+Jm1C4-Qus6dZa#-{JGVSzJGVU3 zc5Zp*jTab&w(ot<>?&Y)nPUYb$VdhTNrv_Oar{E(kDaSJr+4nr*=c9J&i*^I=}g)g zsWazJH=Q;+{p!@bQ$eQ~xi)ZaIJx0u%1L3)jSDYxC<-x1GB7YWGcYiSGcYhbWn^Gz z;$>h^Vqjp1WME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K7so4PLp@-Sh7vN;{vWTRCbkB~ z=_@5Q(d)^t%+ukc-2;+?)BU!jA|osogj9nA+*cr3PCG>Dv*-^$EqD!>-Z$iNtk zq-2|c@Ds-EPY#O6@J(}oL~Q_)^b{V8c8doh?G_J2+btf5wOc$8Z?||LvEAZ<ef7Q@Z*}U)ga|Iz2E~M>-5qM(n1{2p;xBq{U7)wL_w_@ zY5E2q$8F_pn;^Aqg0zAHyMd7a=l^OY?K-T{MFYy0=Jy;QhyX61>|IB+C86>v*HA!vaow%U}oX`@O-|{g@FimfqFXcXQ zgZXraeQZh~!g%5aArP(8_CUJrflS*2*|rCA+aAa>J>dSzm;i0b8BXUtppd-X=m^_a zMiy3vm5kF9ukuPww?C&K**@oxLi?OUitTd_DYefzq})E|kV^ZUL#pj_4ym=zIi%h` z=a5GGoI{%1=N!^XtL3TUhlDf(gAI5{p>lh_qxKcvjT<-^HCe!;2><`_Gn^>qVc=q5 bWMIcGG~G~=Igte<*Z$F8d;3R!9sU9Up7Jr7 diff --git a/AdvertsingProfitControl/DatabaseReader.cs b/AdvertsingProfitControl/DatabaseReader.cs index a1101c9..ed5d404 100644 --- a/AdvertsingProfitControl/DatabaseReader.cs +++ b/AdvertsingProfitControl/DatabaseReader.cs @@ -466,6 +466,40 @@ namespace AdvertsingProfitControl return comments; } + ///

+ /// Created for the new modify record form, returns the ID of the comment being grabbed. + /// + /// + /// + /// + public List RetrieveComments(int dateId, string connectionString) + { + var dataTable = new DataTable(); + var oleDbCommand = new OleDbCommand + { + CommandText = "SELECT Comment.ID, Comment.Comment FROM Comment WHERE Comment.FK_DateID = ?" + }; + oleDbCommand.Parameters.AddWithValue("DateID", dateId); + var connection = new OleDbConnection(connectionString); + oleDbCommand.Connection = connection; + using (connection) + { + using (oleDbCommand) + { + connection.Open(); + using (var dataAdapter = new OleDbDataAdapter(oleDbCommand)) + { + dataAdapter.Fill(dataTable); + } + } + } + var comments = new List(); + if (dataTable.Rows.Count != 1) return comments; + comments.Add(dataTable.Rows[0].ItemArray[0].ToString()); + comments.Add(dataTable.Rows[0].ItemArray[1].ToString()); + return comments; + } + #endregion #region Ad Special Functions @@ -781,7 +815,7 @@ namespace AdvertsingProfitControl var dataTable = new DataTable(); var oleDbCommand = new OleDbCommand() { - CommandText = "SELECT Supplier.SupplierName, Invoice.InvoiceNumber, Invoice.InvoiceDate, Invoice.InvoiceNetAmountAtCost, Invoice.InvoiceNetAmount, Invoice.InvoiceNote FROM (Supplier INNER JOIN Invoice ON Supplier.ID = Invoice.FK_Supplier) WHERE FK_DateID = ?" + CommandText = "SELECT Invoice.ID, Invoice.InvoiceDate, Supplier.SupplierName, Invoice.InvoiceNumber, Invoice.InvoiceNetAmountAtCost, Invoice.InvoiceNetAmount, Invoice.InvoiceNote FROM (Supplier INNER JOIN Invoice ON Supplier.ID = Invoice.FK_Supplier) WHERE FK_DateID = ?" }; oleDbCommand.Parameters.AddWithValue("DateID", dateId); var connection = new OleDbConnection(connectionString); @@ -806,7 +840,7 @@ namespace AdvertsingProfitControl var dataTable = new DataTable(); var oleDbCommand = new OleDbCommand() { - CommandText = "SELECT WeeklySales.Sunday, WeeklySales.Monday, WeeklySales.Tuesday, WeeklySales.Wednesday, WeeklySales.Thursday, WeeklySales.Friday, WeeklySales.Saturday, WeeklySales.TotalSales FROM WeeklySales WHERE FK_DateID = ?" + CommandText = "SELECT WeeklySales.ID, WeeklySales.Sunday, WeeklySales.Monday, WeeklySales.Tuesday, WeeklySales.Wednesday, WeeklySales.Thursday, WeeklySales.Friday, WeeklySales.Saturday, WeeklySales.TotalSales FROM WeeklySales WHERE FK_DateID = ?" }; oleDbCommand.Parameters.AddWithValue("DateID", dateId); var connection = new OleDbConnection(connectionString); @@ -829,9 +863,9 @@ namespace AdvertsingProfitControl public DataTable ReturnTaxableFromDateId(string dateId, string connectionString) { var dataTable = new DataTable(); - var oleDbCommand = new OleDbCommand() + var oleDbCommand = new OleDbCommand { - CommandText = "SELECT Taxable.Sunday, Taxable.Monday, Taxable.Tuesday, Taxable.Wednesday, Taxable.Thursday, Taxable.Friday, Taxable.Saturday, Taxable.Total FROM Taxable WHERE FK_DateID = ?" + CommandText = "SELECT Taxable.ID, Taxable.Sunday, Taxable.Monday, Taxable.Tuesday, Taxable.Wednesday, Taxable.Thursday, Taxable.Friday, Taxable.Saturday, Taxable.Total FROM Taxable WHERE FK_DateID = ?" }; oleDbCommand.Parameters.AddWithValue("DateID", dateId); var connection = new OleDbConnection(connectionString); @@ -851,6 +885,32 @@ namespace AdvertsingProfitControl return dataTable; } + public DataTable ReturnCostAnalysis(int dateId, string connectionString) + { + var dataTable = new DataTable(); + var oleDbCommand = new OleDbCommand + { + CommandText = "SELECT CostOfSalesAnalysis.ID, CostOfSalesAnalysis.SalesPerManHour, CostOfSalesAnalysis.SalaryPercentage, CostOfSalesAnalysis.SalaryDollars, CostOfSalesAnalysis.Supplies FROM CostOfSalesAnalysis WHERE FK_DateID = ?" + }; + oleDbCommand.Parameters.AddWithValue("DateID", dateId); + var connection = new OleDbConnection(connectionString); + oleDbCommand.Connection = connection; + + using (connection) + { + using (oleDbCommand) + { + connection.Open(); + using (var dataAdapter = new OleDbDataAdapter(oleDbCommand)) + { + dataAdapter.Fill(dataTable); + } + } + } + + return dataTable; + } + public DataTable ReturnWeekEndingTable(string connectionString) { var dataTable = new DataTable(); diff --git a/AdvertsingProfitControl/FrmMain.cs b/AdvertsingProfitControl/FrmMain.cs index 5d674fd..100864e 100644 --- a/AdvertsingProfitControl/FrmMain.cs +++ b/AdvertsingProfitControl/FrmMain.cs @@ -416,8 +416,8 @@ namespace AdvertsingProfitControl _gCostOfSalesCalculatedTotal = costOfSalesSum; object[] invoiceTotalRow = new object[invoiceTable.Columns.Count]; - invoiceTotalRow[0] = "Total Purchases"; - invoiceTotalRow[4] = costOfSalesSum; + invoiceTotalRow[2] = "Total Purchases"; + invoiceTotalRow[5] = costOfSalesSum; invoiceTable.Rows.Add(invoiceTotalRow); return invoiceTable; diff --git a/AdvertsingProfitControl/NewModifyRecord.cs b/AdvertsingProfitControl/NewModifyRecord.cs index abe57ea..5a61e59 100644 --- a/AdvertsingProfitControl/NewModifyRecord.cs +++ b/AdvertsingProfitControl/NewModifyRecord.cs @@ -95,7 +95,6 @@ namespace AdvertsingProfitControl actualSalesDataGridView.EditingControlShowing += DisplayAutoCompleteOnEditingControlShowing; //After all events have been set, construct the DataGridVeiws for use. ConstructApcDataGridViews(); - LoadDate(date); //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. @@ -155,6 +154,7 @@ namespace AdvertsingProfitControl salaryDollarsTextBox.Validating += ValidateCostAnalysisValues; suppliesTextBox.Enter += StoreBeginningTextBoxValue; suppliesTextBox.Validating += ValidateCostAnalysisValues; + LoadDate(date); } public sealed override string Text @@ -163,16 +163,6 @@ namespace AdvertsingProfitControl set { base.Text = value; } } - //private void RestoreActiveDate(object sender, EventArgs e) - //{ - // var calendar = (MonthCalendar) sender; - // if (calendar.SelectionStart == _currentActiveDate || calendar.BoldedDates.Contains(calendar.SelectionStart)) return; - // MessageBox.Show(@"This date doesn't appear to be in the database.", @"Date not Found"); - // weekEndingCalendar.DateChanged -= ValidateDateChanged; - // weekEndingCalendar.SelectionStart = _currentActiveDate; - // weekEndingCalendar.DateChanged += ValidateDateChanged; - //} - #region Global Event Handlers /// @@ -1909,6 +1899,7 @@ namespace AdvertsingProfitControl #region Weekly Sales Events /// + /// Event Used: Validating /// Validates the contents of the weekly sales text boxes and adds up the total. /// /// @@ -1937,6 +1928,11 @@ namespace AdvertsingProfitControl textBox.Text = ""; } } + if (isWeeklySalesDirtyCheckBox.Tag != null) + { + isWeeklySalesDirtyCheckBox.Checked = true; + _isFormDirty = true; + } //Update the total sales text box before returning. var totalWeeklySales = 0.00; if (sundayWeeklySalesTextBox.Text != "") totalWeeklySales += double.Parse(sundayWeeklySalesTextBox.Text); @@ -2002,6 +1998,11 @@ namespace AdvertsingProfitControl textBox.Text = ""; } } + if (isTaxableDirtyCheckBox.Tag != null) + { + isTaxableDirtyCheckBox.Checked = true; + _isFormDirty = true; + } //Update the total sales text box before returning. var totalTaxable = 0.00; if (sundayTaxableTextBox.Text != "") totalTaxable += double.Parse(sundayTaxableTextBox.Text); @@ -2118,7 +2119,6 @@ namespace AdvertsingProfitControl if (result == DialogResult.Yes) { _currentActiveDate = e.Start; - _isFormDirty = false; } else { @@ -2127,8 +2127,10 @@ namespace AdvertsingProfitControl } } Text = @"Modify Record (Current Record: " + e.Start.ToString("d") + @")"; + //Clear the form state. + ClearFormState(); //Load the specified date from the database. - + LoadDate(e.Start); } private void LoadDate(DateTime date) @@ -2143,22 +2145,238 @@ namespace AdvertsingProfitControl LoadInventory(inventory); LoadActualSales(actualSales); var invoices = databaseReader.ReturnInvoiceTable(dateId, databaseTracker.DatabaseConnectionString); + var comments = databaseReader.RetrieveComments(int.Parse(dateId), databaseTracker.DatabaseConnectionString); + if (comments.Count == 2) + { + LoadComments(int.Parse(comments[0]), comments[1]); + } + else + { + LogConsole.WriteToLog(FrmLogConsole.Level.Info, "No comments to display for the date of " + _currentActiveDate.ToString("d") + "."); + informationLabel.Text += @"No comments to display." + Environment.NewLine; + } + var weeklySales = databaseReader.ReturnWeeklySalesFromDateId(dateId, + databaseTracker.DatabaseConnectionString); + if (weeklySales.Rows.Count == 1) + { + LoadWeeklySales(weeklySales); + } + else + { + informationLabel.Text += @"No weekly sales to display." + Environment.NewLine; + } - //Re-enable the events + var taxable = databaseReader.ReturnTaxableFromDateId(dateId, databaseTracker.DatabaseConnectionString); + if (taxable.Rows.Count == 1) + { + LoadTaxable(taxable); + } + else + { + informationLabel.Text += @"No taxable data to display." + Environment.NewLine; + } + LoadInvoices(invoices); + var costAnalysis = databaseReader.ReturnCostAnalysis(int.Parse(dateId), + databaseTracker.DatabaseConnectionString); + if (costAnalysis.Rows.Count == 1) + { + LoadCostAnalysis(costAnalysis); + } + else + { + informationLabel.Text += @"No cost analysis data to display." + Environment.NewLine; + } + } + + private void ClearFormState() + { + projectionsDataGridView.CellEnter -= StoreBeginningCellValue; + projectionsDataGridView.RowLeave -= UpdateUsedAdItemCollectionOnRowLeave; + projectionsDataGridView.CellValidating -= ValidateSalesDataGridViewCellContents; + projectionsDataGridView.RowValidating -= ValidateProjectedRow; + projectionsDataGridView.RowsRemoved -= ProjectionRowRemoved; + inventoryDataGridView.CellEnter -= StoreBeginningCellValue; + inventoryDataGridView.RowLeave -= UpdateUsedAdItemCollectionOnRowLeave; + inventoryDataGridView.CellValidating -= ValidateInventoryCellContents; + inventoryDataGridView.RowValidating -= ValidateInventoryRow; + inventoryDataGridView.RowsRemoved -= InventoryRowRemoved; + actualSalesDataGridView.CellEnter -= StoreBeginningCellValue; + actualSalesDataGridView.RowLeave -= UpdateUsedAdItemCollectionOnRowLeave; + actualSalesDataGridView.CellValidating -= ValidateSalesDataGridViewCellContents; + actualSalesDataGridView.RowValidating -= ValidateActualSalesRow; + actualSalesDataGridView.RowsRemoved -= ActualSalesRowRemoved; + invoicesDataGridView.CellEnter -= StoreBeginningCellValue; + invoicesDataGridView.RowValidating -= ValidateInvoiceRow; + invoicesDataGridView.CellValidating -= ValidateInvoicesCellContents; + commentsTextBox.Enter -= StoreBeginningTextBoxValue; + commentsTextBox.KeyDown -= CheckForKeyCommand; + commentsTextBox.Leave -= CheckForTextChangeOnLeave; + 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; + 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; + salesPerManHourTextBox.Enter -= StoreBeginningTextBoxValue; + salesPerManHourTextBox.Validating -= ValidateCostAnalysisValues; + salaryPercentageTextBox.Enter -= StoreBeginningTextBoxValue; + salaryPercentageTextBox.Validating -= ValidateCostAnalysisValues; + salaryDollarsTextBox.Enter -= StoreBeginningTextBoxValue; + salaryDollarsTextBox.Validating -= ValidateCostAnalysisValues; + suppliesTextBox.Enter -= StoreBeginningTextBoxValue; + suppliesTextBox.Validating -= ValidateCostAnalysisValues; + //Clear errors and information. + informationLabel.Text = ""; + errorLabel.Text = ""; + //Clear projections + projectionsDataGridView.Rows.Clear(); + //Clear inventory + inventoryDataGridView.Rows.Clear(); + //Clear actual sales + actualSalesDataGridView.Rows.Clear(); + //Reset the ad special index. + _adSpecialIndex = -1; + //Clear the beginning cell value variable. + _beginningCellValue = ""; + //Reset the form's dirty flag + _isFormDirty = false; + //Clear invoices + invoicesDataGridView.Rows.Clear(); + //Clear comments + isCommentDirtyCheckBox.Checked = false; + isCommentDirtyCheckBox.Text = @"IsCommentDirty"; + isCommentDirtyCheckBox.Tag = null; + commentsTextBox.Text = ""; + commentsGroupBox.Text = @"Comments (Characters Remaining: " + commentsTextBox.MaxLength + @")"; + //Clear weekly sales. + isWeeklySalesDirtyCheckBox.Checked = false; + isWeeklySalesDirtyCheckBox.Text = @"IsWeeklySalesDirty"; + isWeeklySalesDirtyCheckBox.Tag = null; + sundayWeeklySalesTextBox.Text = ""; + mondayWeeklySalesTextBox.Text = ""; + tuesdayWeeklySalesTextBox.Text = ""; + wednesdayWeeklySalesTextBox.Text = ""; + thursdayWeeklySalesTextBox.Text = ""; + fridayWeeklySalesTextBox.Text = ""; + saturdayWeeklySalesTextBox.Text = ""; + totalWeeklySalesTextBox.Text = ""; + //Clear taxable. + isTaxableDirtyCheckBox.Checked = false; + isTaxableDirtyCheckBox.Text = @"IsTaxableDirty"; + isTaxableDirtyCheckBox.Tag = null; + sundayTaxableTextBox.Text = ""; + mondayTaxableTextBox.Text = ""; + tuesdayTaxableTextBox.Text = ""; + wednesdayTaxableTextBox.Text = ""; + thursdayTaxableTextBox.Text = ""; + fridayTaxableTextBox.Text = ""; + saturdayTaxableTextBox.Text = ""; + totalTaxableTextBox.Text = ""; + //Clear cost analysis + isCostAnalysisDirtyCheckBox.Checked = false; + isCostAnalysisDirtyCheckBox.Text = @"IsCostAnalysisDirty"; + isCostAnalysisDirtyCheckBox.Tag = null; + salesPerManHourTextBox.Text = ""; + salaryPercentageTextBox.Text = ""; + salaryDollarsTextBox.Text = ""; + suppliesTextBox.Text = ""; + //Re-enable the events for all the controls. projectionsDataGridView.CellEnter += StoreBeginningCellValue; projectionsDataGridView.RowLeave += UpdateUsedAdItemCollectionOnRowLeave; projectionsDataGridView.CellValidating += ValidateSalesDataGridViewCellContents; projectionsDataGridView.RowValidating += ValidateProjectedRow; + projectionsDataGridView.RowsRemoved += ProjectionRowRemoved; inventoryDataGridView.CellEnter += StoreBeginningCellValue; inventoryDataGridView.RowLeave += UpdateUsedAdItemCollectionOnRowLeave; inventoryDataGridView.CellValidating += ValidateInventoryCellContents; inventoryDataGridView.RowValidating += ValidateInventoryRow; + inventoryDataGridView.RowsRemoved += InventoryRowRemoved; actualSalesDataGridView.CellEnter += StoreBeginningCellValue; actualSalesDataGridView.RowLeave += UpdateUsedAdItemCollectionOnRowLeave; actualSalesDataGridView.CellValidating += ValidateSalesDataGridViewCellContents; actualSalesDataGridView.RowValidating += ValidateActualSalesRow; + actualSalesDataGridView.RowsRemoved += ActualSalesRowRemoved; + + invoicesDataGridView.CellEnter += StoreBeginningCellValue; + invoicesDataGridView.RowValidating += ValidateInvoiceRow; + invoicesDataGridView.CellValidating += ValidateInvoicesCellContents; + + commentsTextBox.Enter += StoreBeginningTextBoxValue; + commentsTextBox.KeyDown += CheckForKeyCommand; + commentsTextBox.Leave += CheckForTextChangeOnLeave; + + 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; + + 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; + + salesPerManHourTextBox.Enter += StoreBeginningTextBoxValue; + salesPerManHourTextBox.Validating += ValidateCostAnalysisValues; + salaryPercentageTextBox.Enter += StoreBeginningTextBoxValue; + salaryPercentageTextBox.Validating += ValidateCostAnalysisValues; + salaryDollarsTextBox.Enter += StoreBeginningTextBoxValue; + salaryDollarsTextBox.Validating += ValidateCostAnalysisValues; + suppliesTextBox.Enter += StoreBeginningTextBoxValue; + suppliesTextBox.Validating += ValidateCostAnalysisValues; } + #region Data Loading Methods + private void LoadProjectionsTable(DataTable projections) { //Assuming all the tables are correctly aligned. @@ -2242,6 +2460,11 @@ namespace AdvertsingProfitControl } projectionsDataGridView.Rows.Add(newRow); } + //Re-enable the events + projectionsDataGridView.CellEnter += StoreBeginningCellValue; + projectionsDataGridView.RowLeave += UpdateUsedAdItemCollectionOnRowLeave; + projectionsDataGridView.CellValidating += ValidateSalesDataGridViewCellContents; + projectionsDataGridView.RowValidating += ValidateProjectedRow; } private void LoadInventory(DataTable inventoryTable) @@ -2329,6 +2552,11 @@ namespace AdvertsingProfitControl } inventoryDataGridView.Rows.Add(newRow); } + //Re-enable the events + inventoryDataGridView.CellEnter += StoreBeginningCellValue; + inventoryDataGridView.RowLeave += UpdateUsedAdItemCollectionOnRowLeave; + inventoryDataGridView.CellValidating += ValidateInventoryCellContents; + inventoryDataGridView.RowValidating += ValidateInventoryRow; } public void LoadActualSales(DataTable actualSales) @@ -2416,11 +2644,362 @@ namespace AdvertsingProfitControl } actualSalesDataGridView.Rows.Add(newRow); } + //Re-enable the events + actualSalesDataGridView.CellEnter += StoreBeginningCellValue; + actualSalesDataGridView.RowLeave += UpdateUsedAdItemCollectionOnRowLeave; + actualSalesDataGridView.CellValidating += ValidateSalesDataGridViewCellContents; + actualSalesDataGridView.RowValidating += ValidateActualSalesRow; } - private void NormalizeApcTables(DataTable projetions, DataTable inventory, DataTable actualSales, string dateId) + private void LoadInvoices(DataTable invoices) { - + for (var rowIndex = 0; rowIndex < invoices.Rows.Count; rowIndex++) + { + var row = new DataGridViewRow(); + for (var cellIndex = 0; cellIndex < invoices.Rows[rowIndex].ItemArray.Length; cellIndex++) + { + //Get the + //Format the invoice date. + if (cellIndex == 1) + { + var date = DateTime.Parse(invoices.Rows[rowIndex].ItemArray[cellIndex].ToString()); + var cell = new DataGridViewTextBoxCell + { + Value = date.ToString("d") + }; + row.Cells.Add(cell); + continue; + } + if (invoices.Rows[rowIndex].ItemArray[cellIndex].ToString() != "0") + { + var cell = new DataGridViewTextBoxCell + { + Value = invoices.Rows[rowIndex].ItemArray[cellIndex].ToString() + }; + row.Cells.Add(cell); + } + else + { + var cell = new DataGridViewTextBoxCell + { + Value = "" + }; + row.Cells.Add(cell); + } + } + invoicesDataGridView.Rows.Add(row); + } } + + private void LoadComments(int id, string comments) + { + //commentsTextBox.TextChanged -= DisplayRemainingCommentCharacterCount; + commentsTextBox.Enter -= StoreBeginningTextBoxValue; + commentsTextBox.KeyDown -= CheckForKeyCommand; + commentsTextBox.Leave -= CheckForTextChangeOnLeave; + + isCommentDirtyCheckBox.Text = @"isCommentsDirty (" + id + @")"; + isCommentDirtyCheckBox.Tag = id; + + commentsTextBox.Text = comments; + + //commentsGroupBox.Text = @"Comments (Characters Remaining: " + commentsTextBox.MaxLength + @")"; + //commentsTextBox.TextChanged += DisplayRemainingCommentCharacterCount; + commentsTextBox.Enter += StoreBeginningTextBoxValue; + commentsTextBox.KeyDown += CheckForKeyCommand; + commentsTextBox.Leave += CheckForTextChangeOnLeave; + } + + private void LoadWeeklySales(DataTable weeklySales) + { + 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; + + //Spin through the only row in the weekly sales table. Item in item + //array index zero (0) is the ID number of the weekly sales. + for (var cellIndex = 0; cellIndex < weeklySales.Rows[0].ItemArray.Length; cellIndex++) + { + if (cellIndex == 0) + { + //ID number + var id = int.Parse(weeklySales.Rows[0].ItemArray[cellIndex].ToString()); + isWeeklySalesDirtyCheckBox.Tag = id; + isWeeklySalesDirtyCheckBox.Text = @"IsWeeklySalesDirty (" + id + @")"; + continue; + } + string formattedNumber; + switch (cellIndex) + { + case 1: //Sunday + formattedNumber = Math.Round(double.Parse(weeklySales.Rows[0].ItemArray[cellIndex].ToString()), 2).ToString("N", new CultureInfo("en-US")); + if (formattedNumber != "0.00") + { + sundayWeeklySalesTextBox.Text = formattedNumber; + } + break; + case 2: //Monday + formattedNumber = Math.Round(double.Parse(weeklySales.Rows[0].ItemArray[cellIndex].ToString()), 2).ToString("N", new CultureInfo("en-US")); + if (formattedNumber != "0.00") + { + mondayWeeklySalesTextBox.Text = formattedNumber; + } + break; + case 3: //Tuesday + formattedNumber = Math.Round(double.Parse(weeklySales.Rows[0].ItemArray[cellIndex].ToString()), 2).ToString("N", new CultureInfo("en-US")); + if (formattedNumber != "0.00") + { + tuesdayWeeklySalesTextBox.Text = formattedNumber; + } + break; + case 4: //Wednesday + formattedNumber = Math.Round(double.Parse(weeklySales.Rows[0].ItemArray[cellIndex].ToString()), 2).ToString("N", new CultureInfo("en-US")); + if (formattedNumber != "0.00") + { + wednesdayWeeklySalesTextBox.Text = formattedNumber; + } + break; + case 5: //Thursday + formattedNumber = Math.Round(double.Parse(weeklySales.Rows[0].ItemArray[cellIndex].ToString()), 2).ToString("N", new CultureInfo("en-US")); + if (formattedNumber != "0.00") + { + thursdayWeeklySalesTextBox.Text = formattedNumber; + } + break; + case 6: //Friday + formattedNumber = Math.Round(double.Parse(weeklySales.Rows[0].ItemArray[cellIndex].ToString()), 2).ToString("N", new CultureInfo("en-US")); + if (formattedNumber != "0.00") + { + fridayWeeklySalesTextBox.Text = formattedNumber; + } + break; + case 7: //Saturday + formattedNumber = Math.Round(double.Parse(weeklySales.Rows[0].ItemArray[cellIndex].ToString()), 2).ToString("N", new CultureInfo("en-US")); + if (formattedNumber != "0.00") + { + saturdayWeeklySalesTextBox.Text = formattedNumber; + } + break; + case 8: //Total Sales + formattedNumber = Math.Round(double.Parse(weeklySales.Rows[0].ItemArray[cellIndex].ToString()), 2).ToString("N", new CultureInfo("en-US")); + if (formattedNumber != "0.00") + { + totalWeeklySalesTextBox.Text = formattedNumber; + } + break; + } + } + + 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; + } + + private void LoadTaxable(DataTable taxable) + { + 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; + //Spin through the only row in the taxable table. Item in item + //array index zero (0) is the ID number of the weekly sales. + for (var cellIndex = 0; cellIndex < taxable.Rows[0].ItemArray.Length; cellIndex++) + { + if (cellIndex == 0) + { + //ID number + var id = int.Parse(taxable.Rows[0].ItemArray[cellIndex].ToString()); + isTaxableDirtyCheckBox.Tag = id; + isTaxableDirtyCheckBox.Text = @"IsTaxableDirty (" + id + @")"; + continue; + } + string formattedNumber; + switch (cellIndex) + { + case 1: //Sunday + formattedNumber = Math.Round(double.Parse(taxable.Rows[0].ItemArray[cellIndex].ToString()), 2).ToString("N", new CultureInfo("en-US")); + if (formattedNumber != "0.00") + { + sundayTaxableTextBox.Text = formattedNumber; + } + break; + case 2: //Monday + formattedNumber = Math.Round(double.Parse(taxable.Rows[0].ItemArray[cellIndex].ToString()), 2).ToString("N", new CultureInfo("en-US")); + if (formattedNumber != "0.00") + { + mondayTaxableTextBox.Text = formattedNumber; + } + break; + case 3: //Tuesday + formattedNumber = Math.Round(double.Parse(taxable.Rows[0].ItemArray[cellIndex].ToString()), 2).ToString("N", new CultureInfo("en-US")); + if (formattedNumber != "0.00") + { + tuesdayTaxableTextBox.Text = formattedNumber; + } + break; + case 4: //Wednesday + formattedNumber = Math.Round(double.Parse(taxable.Rows[0].ItemArray[cellIndex].ToString()), 2).ToString("N", new CultureInfo("en-US")); + if (formattedNumber != "0.00") + { + wednesdayTaxableTextBox.Text = formattedNumber; + } + break; + case 5: //Thursday + formattedNumber = Math.Round(double.Parse(taxable.Rows[0].ItemArray[cellIndex].ToString()), 2).ToString("N", new CultureInfo("en-US")); + if (formattedNumber != "0.00") + { + thursdayTaxableTextBox.Text = formattedNumber; + } + break; + case 6: //Friday + formattedNumber = Math.Round(double.Parse(taxable.Rows[0].ItemArray[cellIndex].ToString()), 2).ToString("N", new CultureInfo("en-US")); + if (formattedNumber != "0.00") + { + fridayTaxableTextBox.Text = formattedNumber; + } + break; + case 7: //Saturday + formattedNumber = Math.Round(double.Parse(taxable.Rows[0].ItemArray[cellIndex].ToString()), 2).ToString("N", new CultureInfo("en-US")); + if (formattedNumber != "0.00") + { + saturdayTaxableTextBox.Text = formattedNumber; + } + break; + case 8: //Total Taxable + formattedNumber = Math.Round(double.Parse(taxable.Rows[0].ItemArray[cellIndex].ToString()), 2).ToString("N", new CultureInfo("en-US")); + if (formattedNumber != "0.00") + { + totalTaxableTextBox.Text = formattedNumber; + } + break; + } + } + 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; + } + + private void LoadCostAnalysis(DataTable costAnalysis) + { + salesPerManHourTextBox.Enter -= StoreBeginningTextBoxValue; + salesPerManHourTextBox.Validating -= ValidateCostAnalysisValues; + salaryPercentageTextBox.Enter -= StoreBeginningTextBoxValue; + salaryPercentageTextBox.Validating -= ValidateCostAnalysisValues; + salaryDollarsTextBox.Enter -= StoreBeginningTextBoxValue; + salaryDollarsTextBox.Validating -= ValidateCostAnalysisValues; + suppliesTextBox.Enter -= StoreBeginningTextBoxValue; + suppliesTextBox.Validating -= ValidateCostAnalysisValues; + //Spin through the only row in the taxable table. Item in item + //array index zero (0) is the ID number of the weekly sales. + for (var cellIndex = 0; cellIndex < costAnalysis.Rows[0].ItemArray.Length; cellIndex++) + { + if (cellIndex == 0) + { + //ID number + var id = int.Parse(costAnalysis.Rows[0].ItemArray[cellIndex].ToString()); + isCostAnalysisDirtyCheckBox.Tag = id; + isCostAnalysisDirtyCheckBox.Text = @"IsCostAnalysisDirty (" + id + @")"; + continue; + } + string formattedNumber; + switch (cellIndex) + { + case 1: //Sales per man hour + formattedNumber = Math.Round(double.Parse(costAnalysis.Rows[0].ItemArray[cellIndex].ToString()), 2).ToString("N", new CultureInfo("en-US")); + if (formattedNumber != "0.00") + { + salesPerManHourTextBox.Text = formattedNumber; + } + break; + case 2: //Salary Percentage + formattedNumber = Math.Round(double.Parse(costAnalysis.Rows[0].ItemArray[cellIndex].ToString()), 2).ToString("N", new CultureInfo("en-US")); + if (formattedNumber != "0.00") + { + salaryPercentageTextBox.Text = formattedNumber; + } + break; + case 3: //Salary Dollars + formattedNumber = Math.Round(double.Parse(costAnalysis.Rows[0].ItemArray[cellIndex].ToString()), 2).ToString("N", new CultureInfo("en-US")); + if (formattedNumber != "0.00") + { + salaryDollarsTextBox.Text = formattedNumber; + } + break; + case 4: //Supplies + formattedNumber = Math.Round(double.Parse(costAnalysis.Rows[0].ItemArray[cellIndex].ToString()), 2).ToString("N", new CultureInfo("en-US")); + if (formattedNumber != "0.00") + { + suppliesTextBox.Text = formattedNumber; + } + break; + } + } + salesPerManHourTextBox.Enter += StoreBeginningTextBoxValue; + salesPerManHourTextBox.Validating += ValidateCostAnalysisValues; + salaryPercentageTextBox.Enter += StoreBeginningTextBoxValue; + salaryPercentageTextBox.Validating += ValidateCostAnalysisValues; + salaryDollarsTextBox.Enter += StoreBeginningTextBoxValue; + salaryDollarsTextBox.Validating += ValidateCostAnalysisValues; + suppliesTextBox.Enter += StoreBeginningTextBoxValue; + suppliesTextBox.Validating += ValidateCostAnalysisValues; + } + + #endregion + + //private void NormalizeApcTables(DataTable projections, DataTable inventory, DataTable actualSales, string dateId) + //{ + + //} } } diff --git a/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.vshost.application b/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.vshost.application index 1e6f4da..e2cc48b 100644 --- a/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.vshost.application +++ b/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.vshost.application @@ -14,7 +14,7 @@ - hjoJ6F3S2mx0T7+16nfA9mg2vO2CJ4FO+GQ/EyPYf58= + v/vV1JQ1KwJ475DzlF/9pMJ1BiE2M9/K5exyQW56JdA= diff --git a/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.vshost.exe.manifest b/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.vshost.exe.manifest index e78bcf3..c56988c 100644 --- a/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.vshost.exe.manifest +++ b/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.vshost.exe.manifest @@ -43,14 +43,14 @@ - + - vZ/15zn6UnQyxvEn4XYMV+E1MUxIXiQdJmnSal6RNFc= + X9LoHKI4Q8rmL073oAPMcfETygEZnYWzLirYaKYjcvQ= @@ -93,7 +93,7 @@ - ZGKhdhvn6U66O06l/eGiap8UW45ciijpPInT3o/xuMc= + dJHxM6HPIKo4c5VqxwCZb6aI2vGij+MP5mUPlilWJ/A=