Cleaned up the code in the new modify record form and changed the return value from string to integer in the date ID get method. Fixed a crash bug in the new add record form and fixed the row number bug in both forms.

This commit is contained in:
2017-01-20 18:30:36 -06:00
parent 84f43538d1
commit 9fa2e3c44a
9 changed files with 253 additions and 195 deletions
+11 -11
View File
@@ -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));
FillDataGridViews(databaseReader.RetrieveDateIdByDateString(monthComboBox.SelectedItem + "/" + dayComboBox.SelectedItem + "/" + yearComboBox.Text, databaseTracker.DatabaseConnectionString).ToString());
}
private void FillDateSuggestionComboBoxes()
@@ -817,7 +817,7 @@ namespace AdvertsingProfitControl
//Now re-register the event handlers
monthComboBox.SelectedIndexChanged += UpdateDaysOfMonth;
dayComboBox.SelectedIndexChanged += UpdateDataGridViewInformation;
FillDataGridViews(databaseReader.RetrieveDateIdByDateString(monthComboBox.SelectedItem + "/" + dayComboBox.SelectedItem + "/" + year, databaseTracker.DatabaseConnectionString));
FillDataGridViews(databaseReader.RetrieveDateIdByDateString(monthComboBox.SelectedItem + "/" + dayComboBox.SelectedItem + "/" + year, databaseTracker.DatabaseConnectionString).ToString());
}
#endregion
@@ -1334,7 +1334,7 @@ namespace AdvertsingProfitControl
if (_adSpecialIndex == -1 || currentRowIndex < _adSpecialIndex)
{
//Clear the database of the item.
var count = databaseWriter.RemoveRecord(adItemId, dateId);
var count = databaseWriter.RemoveRecord(adItemId, dateId.ToString());
if (count == 1)
{
@@ -1356,7 +1356,7 @@ namespace AdvertsingProfitControl
else if (currentRowIndex > _adSpecialIndex)
{
//Clear the database of the item.
var count = databaseWriter.RemoveRecord(adItemId, dateId);
var count = databaseWriter.RemoveRecord(adItemId, dateId.ToString());
if (count == 1)
{
@@ -1398,7 +1398,7 @@ namespace AdvertsingProfitControl
if (adItemName == "") break;
adItemId = databaseReader.RetrieveAdItemId(adItemName, databaseTracker.DatabaseConnectionString);
//Clear the database of the item.
var count = databaseWriter.RemoveRecord(adItemId, dateId);
var count = databaseWriter.RemoveRecord(adItemId, dateId.ToString());
if (count == 1)
{
@@ -2497,8 +2497,8 @@ namespace AdvertsingProfitControl
var dateId =
databaseReader.RetrieveDateIdByDateString(monthComboBox.Text + "/" + dayComboBox.Text + "/" +
yearComboBox.Text, databaseTracker.DatabaseConnectionString);
if (dateId == "0") { notificationLabel.Text = "unable to find date in database."; return; }
var recordsAffected = databaseWriter.UpdateCommentsByDateId(commentsTextBox.Text, dateId);
if (dateId == 0) { notificationLabel.Text = "unable to find date in database."; return; }
var recordsAffected = databaseWriter.UpdateCommentsByDateId(commentsTextBox.Text, dateId.ToString());
if (recordsAffected == true)
{
notificationLabel.Text = "Successfully updated the comments for the selected date.";
@@ -2506,7 +2506,7 @@ namespace AdvertsingProfitControl
else
{
//Try adding a new record as there could be no comments in the database.
var rowsEffected = databaseWriter.RedundantlessInsertIntoComments(commentsTextBox.Text, dateId);
var rowsEffected = databaseWriter.RedundantlessInsertIntoComments(commentsTextBox.Text, dateId.ToString());
if (rowsEffected)
{
notificationLabel.Text = "Successfully added the comments for the selected date.";
@@ -2654,9 +2654,9 @@ namespace AdvertsingProfitControl
var databaseTracker = new DatabaseTracker();
var databaseReader = new DatabaseReader();
var dateId = databaseReader.RetrieveDateIdByDateString(monthComboBox.Text + "/" + dayComboBox.Text + "/" + yearComboBox.Text, databaseTracker.DatabaseConnectionString);
UpdateApcTables(dateId);
UpdateInvoicesTable(dateId);
UpdateWeeklySales(dateId);
UpdateApcTables(dateId.ToString());
UpdateInvoicesTable(dateId.ToString());
UpdateWeeklySales(dateId.ToString());
}
}
}