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:
@@ -45,14 +45,14 @@ namespace AdvertsingProfitControl
|
||||
var databaseWriter = new DatabaseWriter(databaseTracker.DatabaseConnectionString);
|
||||
|
||||
var dateId = databaseReader.RetrieveDateIdByDateString(monthComboBox.Text + "/" + dayComboBox.Text + "/" + yearComboBox.Text, databaseTracker.DatabaseConnectionString);
|
||||
if (dateId == "0")
|
||||
if (dateId == 0)
|
||||
{
|
||||
informationLabel.Text = "An error has occurred trying to obtain the ID\nfor the date " +
|
||||
monthComboBox.Text + "/" + dayComboBox.Text + "/" + yearComboBox.Text + ".";
|
||||
}
|
||||
var supplierName = dataGridView.Rows[e.Row.Index].Cells[0].EditedFormattedValue.ToString();
|
||||
var invoiceNumber = dataGridView.Rows[e.Row.Index].Cells[1].EditedFormattedValue.ToString();
|
||||
var count = databaseWriter.RemoveInvoice(invoiceNumber, dateId);
|
||||
var count = databaseWriter.RemoveInvoice(invoiceNumber, dateId.ToString());
|
||||
|
||||
if (count == 1)
|
||||
{
|
||||
@@ -85,8 +85,8 @@ namespace AdvertsingProfitControl
|
||||
var dateId =
|
||||
databaseReader.RetrieveDateIdByDateString(monthComboBox.Text + "/" + dayComboBox.Text + "/" +
|
||||
yearComboBox.Text, databaseTracker.DatabaseConnectionString);
|
||||
if (dateId == "0"){ informationLabel.Text = "unable to find date in database."; return; }
|
||||
var recordsAffected = datbaseWriter.UpdateCommentsByDateId(commentsTextBox.Text, dateId);
|
||||
if (dateId == 0){ informationLabel.Text = "unable to find date in database."; return; }
|
||||
var recordsAffected = datbaseWriter.UpdateCommentsByDateId(commentsTextBox.Text, dateId.ToString());
|
||||
if (recordsAffected == true)
|
||||
{
|
||||
informationLabel.Text = "Successfully updated the comments for the selected date.";
|
||||
@@ -115,7 +115,7 @@ namespace AdvertsingProfitControl
|
||||
var dateId = databaseReader.RetrieveDateIdByDateString(monthComboBox.Text + "/" + dayComboBox.Text + "/" + yearComboBox.Text, databaseTracker.DatabaseConnectionString);
|
||||
var adItemName = e.Row.Cells[0].EditedFormattedValue.ToString();
|
||||
var adItemId = databaseReader.RetrieveAdItemId(adItemName, databaseTracker.DatabaseConnectionString);
|
||||
var count = databaseWriter.RemoveRecord(adItemId, dateId);
|
||||
var count = databaseWriter.RemoveRecord(adItemId, dateId.ToString());
|
||||
|
||||
if (count == 1)
|
||||
{
|
||||
@@ -176,7 +176,7 @@ namespace AdvertsingProfitControl
|
||||
else
|
||||
{
|
||||
//ELSE IF one was passed, then use it's ID to build the tables.
|
||||
dateId = dataBaseReader.RetrieveDateIdByDateString(dateString, databaseTracker.DatabaseConnectionString);
|
||||
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")
|
||||
{
|
||||
@@ -424,7 +424,7 @@ namespace AdvertsingProfitControl
|
||||
var dateId =
|
||||
databaseReader.RetrieveDateIdByDateString(monthComboBox.Text + "/" + dayComboBox.Text + "/" +
|
||||
yearComboBox.Text, databaseTracker.DatabaseConnectionString);
|
||||
var recordsAffected = databaseWriter.RemoveAllEntriesAndYearById(dateId);
|
||||
var recordsAffected = databaseWriter.RemoveAllEntriesAndYearById(dateId.ToString());
|
||||
if (recordsAffected > 0)
|
||||
{
|
||||
informationLabel.Text = "Successfully removed " + recordsAffected.ToString() +
|
||||
|
||||
Reference in New Issue
Block a user