Updated the main form with a slightly new look. Finished all the code for the main for to pull in all the data from the database and perform calculations on it. Currently can only load the most recent date. Added detection for holidays in the weekly and taxable lists.

This commit is contained in:
2017-01-21 18:38:19 -06:00
parent d429f2b931
commit 96e61546c3
13 changed files with 1821 additions and 1257 deletions
Binary file not shown.
@@ -109,6 +109,7 @@
<Compile Include="ApplicationColors.cs" />
<Compile Include="DbTableWriterStatus.cs" />
<Compile Include="DbWriterStatus.cs" />
<Compile Include="Holiday.cs" />
<Compile Include="NewModifyRecord.cs">
<SubType>Form</SubType>
</Compile>
+1 -1
View File
@@ -36,7 +36,7 @@ namespace AdvertsingProfitControl
}
}
public void GenerateWeeklyInventoryControlPage(string dateId)
public void GenerateWeeklyInventoryControlPage(int dateId)
{
var databaseTracker = new DatabaseTracker();
var databaseReader = new DatabaseReader();
+43 -44
View File
@@ -42,10 +42,10 @@ namespace AdvertsingProfitControl
/// </summary>
/// <param name="connectionString">The connection string for the database.</param>
/// <returns>The ID number as a string.</returns>
public string RetrieveMostRecentDateId(string connectionString)
public int RetrieveMostRecentDateId(string connectionString)
{
var dateId = "0";
var oleDbCommand = new OleDbCommand()
int dateId = 0;
var oleDbCommand = new OleDbCommand
{
CommandText = "SELECT WeekEnding.ID FROM WeekEnding WHERE WeekEnding.EndOfWeekDate = (SELECT MAX(WeekEnding.EndOfWeekDate) FROM WeekEnding)"
};
@@ -61,7 +61,7 @@ namespace AdvertsingProfitControl
{
while (reader != null && reader.Read())
{
dateId = reader[0].ToString();
dateId = int.Parse(reader[0].ToString());
}
}
}
@@ -70,6 +70,34 @@ namespace AdvertsingProfitControl
return dateId;
}
public DateTime RetrieveMostRecentDate(string connectionString)
{
var date = new DateTime();
var oleDbCommand = new OleDbCommand
{
CommandText = "SELECT WeekEnding.EndOfWeekDate FROM WeekEnding WHERE WeekEnding.EndOfWeekDate = (SELECT MAX(WeekEnding.EndOfWeekDate) FROM WeekEnding)"
};
var connection = new OleDbConnection(connectionString);
oleDbCommand.Connection = connection;
using (connection)
{
using (oleDbCommand)
{
connection.Open();
using (var reader = oleDbCommand.ExecuteReader())
{
while (reader != null && reader.Read())
{
date = DateTime.Parse(reader[0].ToString());
}
}
}
}
return date;
}
/// <summary>
/// Returns the date ID of the date string that is passed.
/// Preferred format is short date (1/20/2017).
@@ -106,7 +134,7 @@ namespace AdvertsingProfitControl
return dateId;
}
public string RetrieveDateStringById(string dateId, string connectionString)
public string RetrieveDateStringById(int dateId, string connectionString)
{
string dateString = "";
var oleDbCommand = new OleDbCommand()
@@ -222,7 +250,7 @@ namespace AdvertsingProfitControl
public DateTime RetrieveMostRecentDateString(string connectionString)
{
DateTime dateTimeObject = new DateTime();
var dateTimeObject = new DateTime();
var oleDbCommand = new OleDbCommand()
{
CommandText = "SELECT WeekEnding.EndOfWeekDate FROM WeekEnding WHERE WeekEnding.EndOfWeekDate = (SELECT MAX(WeekEnding.EndOfWeekDate) FROM WeekEnding)"
@@ -370,7 +398,7 @@ namespace AdvertsingProfitControl
return id;
}
public List<string> RetrieveUsedAdItemListByDateId(string dateId, string connectionString)
public List<string> RetrieveUsedAdItemListByDateId(int dateId, string connectionString)
{
var adItemList = new List<string>();
var oleDbCommand = new OleDbCommand
@@ -444,35 +472,6 @@ namespace AdvertsingProfitControl
#region Comment Functions
public string RetrieveComments(string dateId, string connectionString)
{
var comments = "";
var oleDbCommand = new OleDbCommand()
{
CommandText = "SELECT 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 reader = oleDbCommand.ExecuteReader())
{
while(reader != null && reader.Read())
{
comments = reader[0].ToString();
}
}
}
}
return comments;
}
/// <summary>
/// Created for the new modify record form, returns the ID of the comment being grabbed.
/// </summary>
@@ -715,7 +714,7 @@ namespace AdvertsingProfitControl
#region Table Return Functions
public DataTable ReturnApcTableForReport(string dateId, string connectionString)
public DataTable ReturnApcTableForReport(int dateId, string connectionString)
{
var dataTable = new DataTable();
var oleDbCommand = new OleDbCommand()
@@ -741,7 +740,7 @@ namespace AdvertsingProfitControl
return dataTable;
}
public DataTable ReturnProjectionsTable(string dateId, string connectionString)
public DataTable ReturnProjectionsTable(int dateId, string connectionString)
{
var dataTable = new DataTable();
var oleDbCommand = new OleDbCommand()
@@ -766,7 +765,7 @@ namespace AdvertsingProfitControl
return dataTable;
}
public DataTable ReturnActualSales(string dateId, string connectionString)
public DataTable ReturnActualSales(int dateId, string connectionString)
{
var dataTable = new DataTable();
var oleDbCommand = new OleDbCommand()
@@ -791,7 +790,7 @@ namespace AdvertsingProfitControl
return dataTable;
}
public DataTable ReturnInventoryTable(string dateId, string connectionString)
public DataTable ReturnInventoryTable(int dateId, string connectionString)
{
var dataTable = new DataTable();
var oleDbCommand = new OleDbCommand()
@@ -817,7 +816,7 @@ namespace AdvertsingProfitControl
}
public DataTable ReturnInvoiceTable(string dateId, string connectionString)
public DataTable ReturnInvoiceTable(int dateId, string connectionString)
{
var dataTable = new DataTable();
var oleDbCommand = new OleDbCommand()
@@ -842,7 +841,7 @@ namespace AdvertsingProfitControl
return dataTable;
}
public DataTable ReturnWeeklySalesFromDateId(string dateId, string connectionString)
public DataTable ReturnWeeklySalesFromDateId(int dateId, string connectionString)
{
var dataTable = new DataTable();
var oleDbCommand = new OleDbCommand()
@@ -867,7 +866,7 @@ namespace AdvertsingProfitControl
return dataTable;
}
public DataTable ReturnTaxableFromDateId(string dateId, string connectionString)
public DataTable ReturnTaxableFromDateId(int dateId, string connectionString)
{
var dataTable = new DataTable();
var oleDbCommand = new OleDbCommand
@@ -948,7 +947,7 @@ namespace AdvertsingProfitControl
#region Supplier And Invoices Functions
public string RetrieveSupplierNameById(string supplierId, string connectionString)
public string RetrieveSupplierNameById(int supplierId, string connectionString)
{
var supplierName = "";
var oleDbCommand = new OleDbCommand()
+7 -7
View File
@@ -164,27 +164,27 @@ namespace AdvertsingProfitControl
var databaseTracker = new DatabaseTracker();
var dataBaseReader = new DatabaseReader();
string dateId;
int dateId;
//Check to see if a parameter has been passed.
if (dateString == "")
{
//IF non were, then grab the most recent date ID from the database and use that.
dateId = dataBaseReader.RetrieveMostRecentDateId(databaseTracker.DatabaseConnectionString);
_console.WriteToLog(FrmLogConsole.Level.Info, dateId != "0" ? "Most recent date ID is " + dateId : "Most recent date ID is unavailable.");
_console.WriteToLog(FrmLogConsole.Level.Info, dateId != 0 ? "Most recent date ID is " + dateId : "Most recent date ID is unavailable.");
}
else
{
//ELSE IF one was passed, then use it's ID to build the tables.
dateId = dataBaseReader.RetrieveDateIdByDateString(dateString, databaseTracker.DatabaseConnectionString).ToString();
_console.WriteToLog(FrmLogConsole.Level.Info, dateId != "0" ? "Date ID for " + dateString + " is resolved to have the ID of " + dateId + "." : "The date " + dateString + " could not be found in the database.");
if (dateId == "0")
dateId = dataBaseReader.RetrieveDateIdByDateString(dateString, databaseTracker.DatabaseConnectionString);
_console.WriteToLog(FrmLogConsole.Level.Info, dateId != 0 ? "Date ID for " + dateString + " is resolved to have the ID of " + dateId + "." : "The date " + dateString + " could not be found in the database.");
if (dateId == 0)
{
_gDateStringCollection.Remove(dateString);
}
}
//Now check to make sure there were no errors grabbing the ID, IF there were return.
if (dateId == "0") return;
if (dateId == 0) return;
//Clear all DataGridViews since the date supplied is valid and in the database.
projectionsDataGridView.DataSource = null;
inventoryDataGridView.DataSource = null;
@@ -198,7 +198,7 @@ namespace AdvertsingProfitControl
suppliersDataGridView.DataSource = dataBaseReader.ReturnInvoiceTable(dateId, databaseTracker.DatabaseConnectionString);
weeklySalesDataGridView.DataSource = dataBaseReader.ReturnWeeklySalesFromDateId(dateId, databaseTracker.DatabaseConnectionString);
commentsTextBox.Text = dataBaseReader.RetrieveComments(dateId, databaseTracker.DatabaseConnectionString);
commentsTextBox.Text = dataBaseReader.RetrieveComments(dateId, databaseTracker.DatabaseConnectionString)[1];
if (commentsTextBox.Text.StartsWith("No comments"))
{
commentsTextBox.Enabled = false;
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+5 -72
View File
@@ -347,16 +347,16 @@ namespace AdvertsingProfitControl
//Re factor later....
#region DataGridView Filling Methods
private void FillDataGridViews(string dateId = "")
private void FillDataGridViews(int dateId = 0)
{
var databaseTracker = new DatabaseTracker();
var databaseReader = new DatabaseReader();
BuildDataGridViewEvents(false);
if (dateId == "")
if (dateId == 0)
{
dateId = databaseReader.RetrieveMostRecentDateId(databaseTracker.DatabaseConnectionString);
//dateId = databaseReader.RetrieveMostRecentDateId(databaseTracker.DatabaseConnectionString);
}
//Clear the DataGridViews and the last used ad item.
projectionsDataGridView.DataSource = null;
@@ -423,7 +423,7 @@ namespace AdvertsingProfitControl
weeklySalesDataGridView.Rows.Add(row.ItemArray);
}
commentsTextBox.Text = databaseReader.RetrieveComments(dateId, databaseTracker.DatabaseConnectionString);
commentsTextBox.Text = databaseReader.RetrieveComments(dateId, databaseTracker.DatabaseConnectionString)[1];
BuildDataGridViewEvents();
}
@@ -640,7 +640,7 @@ namespace AdvertsingProfitControl
{
var databaseTracker = new DatabaseTracker();
var databaseReader = new DatabaseReader();
FillDataGridViews(databaseReader.RetrieveDateIdByDateString(monthComboBox.SelectedItem + "/" + dayComboBox.SelectedItem + "/" + yearComboBox.Text, databaseTracker.DatabaseConnectionString).ToString());
FillDataGridViews(databaseReader.RetrieveDateIdByDateString(monthComboBox.SelectedItem + "/" + dayComboBox.SelectedItem + "/" + yearComboBox.Text, databaseTracker.DatabaseConnectionString));
}
private void FillDateSuggestionComboBoxes()
@@ -666,7 +666,6 @@ namespace AdvertsingProfitControl
yearComboBox.Items.Clear();
monthComboBox.SelectedIndexChanged -= UpdateDaysOfMonth;
dayComboBox.SelectedIndexChanged -= UpdateDataGridViewInformation;
yearComboBox.SelectedIndexChanged -= UpdateDaysOfMonthByYear;
//Now spin through the oneYearDatesTable and fill the class wide object with all the dates for the most recent year.
for (var i = 0; i < datesList.Count; i++)
{
@@ -727,7 +726,6 @@ namespace AdvertsingProfitControl
}
monthComboBox.SelectedIndexChanged += UpdateDaysOfMonth;
dayComboBox.SelectedIndexChanged += UpdateDataGridViewInformation;
yearComboBox.SelectedIndexChanged += UpdateDaysOfMonthByYear;
DrawingControl.ResumeDrawing(dateSelectorGroupBox);
}
@@ -754,71 +752,6 @@ namespace AdvertsingProfitControl
}
}
/// <summary>
/// Fires when the Year combo box's index changes.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void UpdateDaysOfMonthByYear(object sender, EventArgs e)
{
//Obligatory database retrieval call...
var databaseTracker = new DatabaseTracker();
var databaseReader = new DatabaseReader();
//First, grab the year and the month from their respective combo boxes.
var year = yearComboBox.SelectedItem.ToString();
//Since we can more or less be certain that nothing is null, clear the current date collection.
_dateStringCollection.Clear();
var months = databaseReader.RetrieveUniqueMonthsList(year, databaseTracker.DatabaseConnectionString);
var mostRecentMonth = months.Max();
if (mostRecentMonth.Length == 1)
{
mostRecentMonth = "0" + mostRecentMonth;
}
var datesList = databaseReader.RetrieveDateListByYear(year, databaseTracker.DatabaseConnectionString);
for (var i = 0; i < datesList.Count; i++)
{
_dateStringCollection.Add(datesList[i].ToString("MM/dd/yyyy"));
}
//Clear the month and day combo boxes and unregister their event handlers.
dayComboBox.Items.Clear();
monthComboBox.Items.Clear();
monthComboBox.SelectedIndexChanged -= UpdateDaysOfMonth;
dayComboBox.SelectedIndexChanged -= UpdateDataGridViewInformation;
for (var i = 0; i < _dateStringCollection.Count; i++)
{
var dateArray = _dateStringCollection[i].Split('/');
var month = dateArray[0];
//Declare the patterns to look for when enumerating the combo boxes.
var dayBasedOnMonthAndYeaRegex = new Regex(@"^(" + mostRecentMonth + @"\/\d{2}\/" + year + ")"); //Only allows days that are actually part of the month and year.
var day = dateArray[1];
if (dayBasedOnMonthAndYeaRegex.IsMatch( _dateStringCollection[i]))
{
dayComboBox.Items.Add(day);
}
if (!monthComboBox.Items.Contains(month))
{
monthComboBox.Items.Add(month);
}
}
if (dayComboBox.Items.Count > 0)
{
dayComboBox.SelectedIndex = dayComboBox.Items.Count - 1;
}
if (monthComboBox.Items.Count > 0)
{
monthComboBox.SelectedIndex = monthComboBox.Items.Count - 1;
}
//Now re-register the event handlers
monthComboBox.SelectedIndexChanged += UpdateDaysOfMonth;
dayComboBox.SelectedIndexChanged += UpdateDataGridViewInformation;
FillDataGridViews(databaseReader.RetrieveDateIdByDateString(monthComboBox.SelectedItem + "/" + dayComboBox.SelectedItem + "/" + year, databaseTracker.DatabaseConnectionString).ToString());
}
#endregion
#region Third Party Code
@@ -38,7 +38,7 @@ namespace AdvertsingProfitControl
}
}
public void BuildFormFrontCompressedLayout(string dateId, double departmentSales, double salesProducedByAdItems, double remainingSales, double totalProfitReturnFromAdItems, double totalProfitReturnFromRemainingSales, double totalProfitReturn, string comments)
public void BuildFormFrontCompressedLayout(int dateId, double departmentSales, double salesProducedByAdItems, double remainingSales, double totalProfitReturnFromAdItems, double totalProfitReturnFromRemainingSales, double totalProfitReturn, string comments)
{
var databaseTracker = new DatabaseTracker();
var databaseReader = new DatabaseReader();
+89
View File
@@ -0,0 +1,89 @@
using System;
using System.Linq;
namespace AdvertsingProfitControl
{
internal class Holiday
{
public static Holidays IsHoliday(DateTime date)
{
if(IsNewYearsDay(date) == Holidays.NewYearsDay) return Holidays.NewYearsDay;
if(IsFourthOfJuly(date) == Holidays.FourthOfJuly) return Holidays.FourthOfJuly;
if(IsThanksgivingDay(date) == Holidays.Thanksgiving) return Holidays.Thanksgiving;
return IsChristmasDay(date) == Holidays.Christmas ? Holidays.Christmas : Holidays.NoHoliday;
}
public static Holidays IsNewYearsEve(DateTime date)
{
return date.DayOfYear == AdjustForWeekendHoliday(new DateTime(date.Year, 12, 31)).DayOfYear ? Holidays.NewYearsEve : Holidays.NoHoliday;
}
public static Holidays IsNewYearsDay(DateTime date)
{
return date.DayOfYear == AdjustForWeekendHoliday(new DateTime(date.Year, 1, 1)).DayOfYear ? Holidays.NewYearsDay : Holidays.NoHoliday;
}
public static Holidays IsMemorialDay(DateTime date)
{ //Last Monday in May
var memorialDay = new DateTime(date.Year, 5, 31);
var dayOfWeek = memorialDay.DayOfWeek;
while (dayOfWeek != DayOfWeek.Monday)
{
memorialDay = memorialDay.AddDays(-1);
dayOfWeek = memorialDay.DayOfWeek;
}
return date.DayOfYear == memorialDay.DayOfYear ? Holidays.MemorialDay : Holidays.NoHoliday;
}
public static Holidays IsFourthOfJuly(DateTime date)
{
return date.DayOfYear == AdjustForWeekendHoliday(new DateTime(date.Year, 7, 4)).DayOfYear ? Holidays.FourthOfJuly : Holidays.NoHoliday;
}
public static Holidays IsLaborDay(DateTime date)
{ // First Monday in September
var laborDay = new DateTime(date.Year, 9, 1);
var dayOfWeek = laborDay.DayOfWeek;
while (dayOfWeek != DayOfWeek.Monday)
{
laborDay = laborDay.AddDays(1);
dayOfWeek = laborDay.DayOfWeek;
}
return date.DayOfYear == laborDay.DayOfYear ? Holidays.LaborDay : Holidays.NoHoliday;
}
public static Holidays IsThanksgivingDay(DateTime date)
{//4th Thursday in November
var thanksgiving = (from day in Enumerable.Range(1, 30)
where new DateTime(date.Year, 11, day).DayOfWeek == DayOfWeek.Thursday
select day).ElementAt(3);
var thanksgivingDay = new DateTime(date.Year, 11, thanksgiving);
return date.DayOfYear == thanksgivingDay.DayOfYear ? Holidays.Thanksgiving : Holidays.NoHoliday;
}
public static Holidays IsChristmasEve(DateTime date)
{
return date.DayOfYear == AdjustForWeekendHoliday(new DateTime(date.Year, 12, 24)).DayOfYear ? Holidays.ChristmasEve : Holidays.NoHoliday;
}
public static Holidays IsChristmasDay(DateTime date)
{
return date.DayOfYear == new DateTime(date.Year, 12, 25).DayOfYear ? Holidays.Christmas : Holidays.NoHoliday;
}
private static DateTime AdjustForWeekendHoliday(DateTime holiday)
{
switch (holiday.DayOfWeek)
{
case DayOfWeek.Saturday:
return holiday.AddDays(-1);
case DayOfWeek.Sunday:
return holiday.AddDays(1);
}
return holiday;
}
}
public enum Holidays
{
NoHoliday = 0,
NewYearsEve = 1,
NewYearsDay = 2,
MemorialDay = 3,
FourthOfJuly = 4,
LaborDay = 5,
Thanksgiving = 6,
ChristmasEve = 7,
Christmas = 8
}
}
+46 -43
View File
@@ -2171,6 +2171,14 @@ namespace AdvertsingProfitControl
if (result == DialogResult.Yes)
{
//Save the changes made to the database then clear and load the date picked by the user.
if (SaveRecords(false))
{
informationLabel.Text = @"Saved all changes successfully." + Environment.NewLine;
}
else
{
errorLabel.Text = @"Failed to save all changes." + Environment.NewLine;
}
}
else if (result == DialogResult.Cancel)
{
@@ -2253,9 +2261,6 @@ namespace AdvertsingProfitControl
salaryDollarsTextBox.Validating -= ValidateCostAnalysisValues;
suppliesTextBox.Enter -= StoreBeginningTextBoxValue;
suppliesTextBox.Validating -= ValidateCostAnalysisValues;
//Clear errors and information.
informationLabel.Text = string.Empty;
errorLabel.Text = string.Empty;
//Clear projections
projectionsDataGridView.Rows.Clear();
//Clear inventory
@@ -2387,13 +2392,19 @@ namespace AdvertsingProfitControl
var databaseTracker = new DatabaseTracker();
var databaseReader = new DatabaseReader();
var dateId = databaseReader.RetrieveDateIdByDateString(date.ToString("d"), databaseTracker.DatabaseConnectionString);
var projections = databaseReader.ReturnProjectionsTable(dateId.ToString(), databaseTracker.DatabaseConnectionString);
var inventory = databaseReader.ReturnInventoryTable(dateId.ToString(), databaseTracker.DatabaseConnectionString);
var actualSales = databaseReader.ReturnActualSales(dateId.ToString(), databaseTracker.DatabaseConnectionString);
if (dateId == 0)
{
errorLabel.Text = @"Failed to get the date ID number, aborting load operation." + Environment.NewLine;
return;
}
informationLabel.Text = @"Loading data for " + _currentActiveDate.ToString("d") + "." + Environment.NewLine;
var projections = databaseReader.ReturnProjectionsTable(dateId, databaseTracker.DatabaseConnectionString);
var inventory = databaseReader.ReturnInventoryTable(dateId, databaseTracker.DatabaseConnectionString);
var actualSales = databaseReader.ReturnActualSales(dateId, databaseTracker.DatabaseConnectionString);
LoadProjectionsTable(projections);
LoadInventory(inventory);
LoadActualSales(actualSales);
var invoices = databaseReader.ReturnInvoiceTable(dateId.ToString(), databaseTracker.DatabaseConnectionString);
var invoices = databaseReader.ReturnInvoiceTable(dateId, databaseTracker.DatabaseConnectionString);
var comments = databaseReader.RetrieveComments(int.Parse(dateId.ToString()), databaseTracker.DatabaseConnectionString);
if (comments.Count == 2)
{
@@ -2403,7 +2414,7 @@ namespace AdvertsingProfitControl
{
informationLabel.Text += @"No comments to display." + Environment.NewLine;
}
var weeklySales = databaseReader.ReturnWeeklySalesFromDateId(dateId.ToString(),
var weeklySales = databaseReader.ReturnWeeklySalesFromDateId(dateId,
databaseTracker.DatabaseConnectionString);
if (weeklySales.Rows.Count == 1)
{
@@ -2414,7 +2425,7 @@ namespace AdvertsingProfitControl
informationLabel.Text += @"No sales to display." + Environment.NewLine;
}
var taxable = databaseReader.ReturnTaxableFromDateId(dateId.ToString(), databaseTracker.DatabaseConnectionString);
var taxable = databaseReader.ReturnTaxableFromDateId(dateId, databaseTracker.DatabaseConnectionString);
if (taxable.Rows.Count == 1)
{
LoadTaxable(taxable);
@@ -2463,7 +2474,7 @@ namespace AdvertsingProfitControl
//Everything in between the ad item cell and the row attribute cells.
if (cellIndex > 1 && cellIndex <= 7)
{
if (projections.Rows[rowIndex].ItemArray[cellIndex].ToString() == "0")
if (projections.Rows[rowIndex].ItemArray[cellIndex].ToString() == "0.0000")
{
var cell = new DataGridViewTextBoxCell {Value = string.Empty};
newRow.Cells.Add(cell);
@@ -2656,7 +2667,7 @@ namespace AdvertsingProfitControl
inventoryDataGridView.RowValidating += ValidateInventoryRow;
}
public void LoadActualSales(DataTable actualSales)
private void LoadActualSales(DataTable actualSales)
{
//Assuming all the tables are correctly aligned.
//Disable the relevant events in the DataGridViews
@@ -2685,7 +2696,7 @@ namespace AdvertsingProfitControl
//Everything in between the ad item cell and the row attribute cells.
if (cellIndex > 1 && cellIndex <= 7)
{
if (actualSales.Rows[rowIndex].ItemArray[cellIndex].ToString() == "0")
if (actualSales.Rows[rowIndex].ItemArray[cellIndex].ToString() == "0.0000")
{
var cell = new DataGridViewTextBoxCell { Value = string.Empty };
newRow.Cells.Add(cell);
@@ -3295,11 +3306,11 @@ namespace AdvertsingProfitControl
{
errorLabel.Text += @"Failed to process actual sales." + Environment.NewLine;
}
if (!SaveInvoices(dateId)) return false;
if (!SaveComments(dateId)) return false;
if (!SaveWeeklySales(dateId)) return false;
if (!SaveTaxable(dateId)) return false;
return SaveCostAnalysis(dateId) && success;
if (!SaveInvoices(dateId, displayInformation)) return false;
if (!SaveComments(dateId, displayInformation)) return false;
if (!SaveWeeklySales(dateId, displayInformation)) return false;
if (!SaveTaxable(dateId, displayInformation)) return false;
return SaveCostAnalysis(dateId, displayInformation) && success;
}
/// <summary>
@@ -3329,7 +3340,7 @@ namespace AdvertsingProfitControl
return dateId;
}
private bool SaveInvoices(int dateId)
private bool SaveInvoices(int dateId, bool displayInformation = true)
{
var dbT = new DatabaseTracker();
var dbW = new DatabaseWriter(dbT.DatabaseConnectionString);
@@ -3340,11 +3351,11 @@ namespace AdvertsingProfitControl
errorLabel.Text = writerStatus.GetErrorMessage();
return false;
}
informationLabel.Text += writerStatus.GetErrorMessage() + Environment.NewLine;
if(displayInformation) informationLabel.Text += writerStatus.GetErrorMessage() + Environment.NewLine;
return true;
}
private bool SaveComments(int dateId)
private bool SaveComments(int dateId, bool displayInformation = true)
{
var dbT = new DatabaseTracker();
var dbW = new DatabaseWriter(dbT.DatabaseConnectionString);
@@ -3356,11 +3367,10 @@ namespace AdvertsingProfitControl
var status = dbW.ProcessComments(commentsTextBox.Text, dateId, dbT.DatabaseConnectionString);
if (status.Status == WritingOperationStatus.Failed)
{
informationLabel.Text += @"Failed to add Comments to the database." + Environment.NewLine;
errorLabel.Text = status.ErrorMessage;
return false;
}
informationLabel.Text += @"Comment(s) processed successfully." + Environment.NewLine;
if(displayInformation) informationLabel.Text += @"Comment(s) processed successfully." + Environment.NewLine;
var id = status.Id;
isCommentDirtyCheckBox.Tag = id;
isCommentDirtyCheckBox.Text = @"IsCommentDirty (" + id + @")";
@@ -3375,20 +3385,19 @@ namespace AdvertsingProfitControl
int.Parse(isCommentDirtyCheckBox.Tag.ToString()));
if (status.Status == WritingOperationStatus.Failed)
{
informationLabel.Text += @"Failed to add Comments to the database." + Environment.NewLine;
errorLabel.Text = status.ErrorMessage;
return false;
}
isCommentDirtyCheckBox.Checked = false;
informationLabel.Text += @"Comment(s) processed successfully." + Environment.NewLine;
if (displayInformation) informationLabel.Text += @"Comment(s) processed successfully." + Environment.NewLine;
return true;
}
}
informationLabel.Text += @"No changes detected for the comment(s)" + Environment.NewLine;
if (displayInformation) informationLabel.Text += @"No changes detected for the comment(s)" + Environment.NewLine;
return true;
}
private bool SaveWeeklySales(int dateId)
private bool SaveWeeklySales(int dateId, bool displayInformation = true)
{
var dbT = new DatabaseTracker();
var dbW = new DatabaseWriter(dbT.DatabaseConnectionString);
@@ -3416,11 +3425,10 @@ namespace AdvertsingProfitControl
var status = dbW.ProcessWeeklySales(weeklySales, dateId, dbT.DatabaseConnectionString);
if (status.Status == WritingOperationStatus.Failed)
{
informationLabel.Text += @"Failed to add Weekly Sales to the database." + Environment.NewLine;
errorLabel.Text = status.ErrorMessage;
return false;
}
informationLabel.Text += @"Weekly Sales processed successfully." + Environment.NewLine;
if (displayInformation) informationLabel.Text += @"Weekly Sales processed successfully." + Environment.NewLine;
isWeeklySalesDirtyCheckBox.Tag = status.Id;
isWeeklySalesDirtyCheckBox.Text = @"IsWeeklySalesDirty (" + status.Id + @")";
isWeeklySalesDirtyCheckBox.Checked = false;
@@ -3432,20 +3440,19 @@ namespace AdvertsingProfitControl
int.Parse(isWeeklySalesDirtyCheckBox.Tag.ToString()));
if (status.Status == WritingOperationStatus.Failed)
{
informationLabel.Text += @"Failed to add Weekly Sales to the database." + Environment.NewLine;
errorLabel.Text = status.ErrorMessage;
return false;
}
isWeeklySalesDirtyCheckBox.Checked = false;
informationLabel.Text += @"Weekly Sales updated successfully." + Environment.NewLine;
if (displayInformation) informationLabel.Text += @"Weekly Sales updated successfully." + Environment.NewLine;
return true;
}
}
informationLabel.Text += @"No changes detected for Weekly Sales." + Environment.NewLine;
if (displayInformation) informationLabel.Text += @"No changes detected for Weekly Sales." + Environment.NewLine;
return true;
}
private bool SaveTaxable(int dateId)
private bool SaveTaxable(int dateId, bool displayInformation = true)
{
var dbT = new DatabaseTracker();
var dbW = new DatabaseWriter(dbT.DatabaseConnectionString);
@@ -3469,11 +3476,10 @@ namespace AdvertsingProfitControl
var status = dbW.ProcessTaxable(taxable, dateId, dbT.DatabaseConnectionString);
if (status.Status == WritingOperationStatus.Failed)
{
informationLabel.Text += @"Failed to add Taxable to the database." + Environment.NewLine;
errorLabel.Text = status.ErrorMessage;
return false;
}
informationLabel.Text += @"Taxable processed successfully." + Environment.NewLine;
if (displayInformation) informationLabel.Text += @"Taxable processed successfully." + Environment.NewLine;
isTaxableDirtyCheckBox.Tag = status.Id;
isTaxableDirtyCheckBox.Text = @"IsTaxableDirty (" + status.Id + @")";
return true;
@@ -3484,20 +3490,19 @@ namespace AdvertsingProfitControl
int.Parse(isTaxableDirtyCheckBox.Tag.ToString()));
if (status.Status == WritingOperationStatus.Failed)
{
informationLabel.Text += @"Failed to add Taxable to the database." + Environment.NewLine;
errorLabel.Text = status.ErrorMessage;
return false;
}
isTaxableDirtyCheckBox.Checked = false;
informationLabel.Text += @"Taxable updated successfully." + Environment.NewLine;
if (displayInformation) informationLabel.Text += @"Taxable updated successfully." + Environment.NewLine;
return true;
}
}
informationLabel.Text += @"No changes detected for Taxable." + Environment.NewLine;
if (displayInformation) informationLabel.Text += @"No changes detected for Taxable." + Environment.NewLine;
return true;
}
private bool SaveCostAnalysis(int dateId)
private bool SaveCostAnalysis(int dateId, bool displayInformation = true)
{
var dbT = new DatabaseTracker();
var dbW = new DatabaseWriter(dbT.DatabaseConnectionString);
@@ -3517,11 +3522,10 @@ namespace AdvertsingProfitControl
var status = dbW.ProcessCostAnalysis(costAnalysis, dateId, dbT.DatabaseConnectionString);
if (status.Status == WritingOperationStatus.Failed)
{
informationLabel.Text += @"Failed to add Cost Analysis to the database." + Environment.NewLine;
errorLabel.Text = status.ErrorMessage;
return false;
}
informationLabel.Text += @"Costs Analysis processed successfully." + Environment.NewLine;
if (displayInformation) informationLabel.Text += @"Costs Analysis processed successfully." + Environment.NewLine;
isCostAnalysisDirtyCheckBox.Tag = status.Id;
isCostAnalysisDirtyCheckBox.Text = @"IsCostAnalysisDirty (" + status.Id + @")";
isCostAnalysisDirtyCheckBox.Checked = false;
@@ -3533,16 +3537,15 @@ namespace AdvertsingProfitControl
int.Parse(isCostAnalysisDirtyCheckBox.Tag.ToString()));
if (status.Status == WritingOperationStatus.Failed)
{
informationLabel.Text += @"Failed to add Cost Analysis to the database." + Environment.NewLine;
errorLabel.Text = status.ErrorMessage;
return false;
}
isCostAnalysisDirtyCheckBox.Checked = false;
informationLabel.Text += @"Cost Analysis updated successfully." + Environment.NewLine;
if (displayInformation) informationLabel.Text += @"Cost Analysis updated successfully." + Environment.NewLine;
return true;
}
}
informationLabel.Text += @"No changes made to Cost Analysis." + Environment.NewLine;
if (displayInformation) informationLabel.Text += @"No changes made to Cost Analysis." + Environment.NewLine;
return true;
}
#endregion
@@ -14,7 +14,7 @@
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
</dsig:Transforms>
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
<dsig:DigestValue>1Hy88d0pyLqSm+LXJWOGDCgRmXG4f4D5il87bOZtle0=</dsig:DigestValue>
<dsig:DigestValue>YwflYtfjVV9x9+eYf7fKZfD6BpJXoaFqTjumSTnk4Aw=</dsig:DigestValue>
</hash>
</dependentAssembly>
</dependency>
@@ -43,14 +43,14 @@
</dependentAssembly>
</dependency>
<dependency>
<dependentAssembly dependencyType="install" allowDelayedBinding="true" codebase="AdvertsingProfitControl.exe" size="3617792">
<dependentAssembly dependencyType="install" allowDelayedBinding="true" codebase="AdvertsingProfitControl.exe" size="3624448">
<assemblyIdentity name="AdvertsingProfitControl" version="0.9.5.2" language="neutral" processorArchitecture="amd64" />
<hash>
<dsig:Transforms>
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
</dsig:Transforms>
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
<dsig:DigestValue>9J9ugoTiC4+wY6MW3l8lpcH7ZE4DSPiDNUUMrWgEDvE=</dsig:DigestValue>
<dsig:DigestValue>msc2oqq6RpSLr/3P5XGCDPYZql/YogX5J9EV62lCzlM=</dsig:DigestValue>
</hash>
</dependentAssembly>
</dependency>
@@ -93,7 +93,7 @@
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
</dsig:Transforms>
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
<dsig:DigestValue>h0U0mLzUnhEKHaiuXsTC+7xvKixcE9+lG0nu0vBTYdI=</dsig:DigestValue>
<dsig:DigestValue>BhxzzAVktfxM46PKaURg6/dVO+AoTuOm4bm2CLmjz1A=</dsig:DigestValue>
</hash>
</file>
<file name="Stretched Logo Collection.ico" size="370070">