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:
@@ -1052,6 +1052,7 @@ namespace AdvertsingProfitControl
|
||||
}
|
||||
}
|
||||
actualSalesDataGridView.Rows.Add(rowContents);
|
||||
actualSalesDataGridView.Rows[e.RowIndex + 1].HeaderCell.Value = (e.RowIndex + 2).ToString();
|
||||
//Build a collection of objects for the inventory table to use.
|
||||
var inventoryNewRow = new object[inventoryDataGridView.ColumnCount];
|
||||
//Spin through the DataGridViewCells in the row and add their contents to an array.
|
||||
@@ -1083,6 +1084,7 @@ namespace AdvertsingProfitControl
|
||||
}
|
||||
}
|
||||
inventoryDataGridView.Rows.Add(inventoryNewRow);
|
||||
inventoryDataGridView.Rows[e.RowIndex + 1].HeaderCell.Value = (e.RowIndex + 2).ToString();
|
||||
//Set the row headers of the other tables to show up as pending; this row is valid without a doubt.
|
||||
if (e.RowIndex != _adSpecialIndex)
|
||||
{
|
||||
@@ -1398,7 +1400,9 @@ namespace AdvertsingProfitControl
|
||||
}
|
||||
}
|
||||
projectionsDataGridView.Rows.Add(rowContents);
|
||||
projectionsDataGridView.Rows[e.RowIndex + 1].HeaderCell.Value = (e.RowIndex + 2).ToString();
|
||||
actualSalesDataGridView.Rows.Add(rowContents);
|
||||
actualSalesDataGridView.Rows[e.RowIndex + 1].HeaderCell.Value = (e.RowIndex + 2).ToString();
|
||||
if (e.RowIndex != _adSpecialIndex)
|
||||
{
|
||||
//Apply color coding to the respective row headers on the other tables.
|
||||
@@ -1570,6 +1574,7 @@ namespace AdvertsingProfitControl
|
||||
}
|
||||
}
|
||||
projectionsDataGridView.Rows.Add(rowContents);
|
||||
projectionsDataGridView.Rows[e.RowIndex + 1].HeaderCell.Value = (e.RowIndex + 2).ToString();
|
||||
//Build a collection of objects for the inventory table to use.
|
||||
var inventoryNewRow = new object[inventoryDataGridView.ColumnCount];
|
||||
//Spin through the DataGridViewCells in the row and add their contents to an array.
|
||||
@@ -1598,7 +1603,7 @@ namespace AdvertsingProfitControl
|
||||
}
|
||||
}
|
||||
inventoryDataGridView.Rows.Add(inventoryNewRow);
|
||||
|
||||
inventoryDataGridView.Rows[e.RowIndex + 1].HeaderCell.Value = (e.RowIndex + 2).ToString();
|
||||
if (e.RowIndex != _adSpecialIndex)
|
||||
{
|
||||
//Apply color coding to the respective row headers on the other tables.
|
||||
@@ -2094,47 +2099,31 @@ namespace AdvertsingProfitControl
|
||||
var dbW = new DatabaseWriter(dbT.DatabaseConnectionString);
|
||||
var dbR = new DatabaseReader();
|
||||
//Obtain the date ID.
|
||||
int dateId;
|
||||
if (
|
||||
int.TryParse(dbR.RetrieveDateIdByDateString(weekEndingCalendar.SelectionStart.ToString("d"),
|
||||
dbT.DatabaseConnectionString), out dateId))
|
||||
var dateId = dbR.RetrieveDateIdByDateString(weekEndingCalendar.SelectionStart.ToString("d"), dbT.DatabaseConnectionString);
|
||||
//If the ID is zero (0) that means the date isn't in the database so simply insert it.
|
||||
if (dateId == 0)
|
||||
{
|
||||
//If the ID is zero (0) that means the date isn't in the database so simply insert it.
|
||||
if (dateId == 0)
|
||||
//Try inserting the date string.
|
||||
if (dbW.InsertIntoWeekEnding(weekEndingCalendar.SelectionStart.ToString("d")))
|
||||
{
|
||||
//Try inserting the date string.
|
||||
if (dbW.InsertIntoWeekEnding(weekEndingCalendar.SelectionStart.ToString("d")))
|
||||
dateId = dbR.RetrieveDateIdByDateString(weekEndingCalendar.SelectionStart.ToString("d"), dbT.DatabaseConnectionString);
|
||||
//Now if its still zero (0) then that means something went really wrong and failed to insert.
|
||||
if (dateId == 0)
|
||||
{
|
||||
if (
|
||||
int.TryParse(
|
||||
dbR.RetrieveDateIdByDateString(weekEndingCalendar.SelectionStart.ToString("d"),
|
||||
dbT.DatabaseConnectionString), out dateId))
|
||||
{
|
||||
//Now if its still zero (0) then that means something went really wrong and failed to insert.
|
||||
if (dateId == 0)
|
||||
{
|
||||
MessageBox.Show(
|
||||
@"Failed to retrieve date ID after supposedly inserting the date into the database.",
|
||||
@"Failed To Get Date ID", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show(
|
||||
@"You really should not be able to see this message. If you are well that means something really weird happened converting text into a number, that is hard-coded to not fail on conversion. Either way I couldn't get the date ID due to some error, check the logs if you're curious.",
|
||||
@"Well This Is Awkwardly Nested...", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//The above method reports that it failed to insert the date into the database.
|
||||
MessageBox.Show(@"Failed to insert the date '" + weekEndingCalendar.SelectionStart.ToString("d") + @"' into the database.", @"Failed To Get Date ID", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
MessageBox.Show(
|
||||
@"Failed to retrieve date ID after supposedly inserting the date into the database.",
|
||||
@"Failed To Get Date ID", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//The above method reports that it failed to insert the date into the database.
|
||||
MessageBox.Show(@"Failed to insert the date '" + weekEndingCalendar.SelectionStart.ToString("d") + @"' into the database.", @"Failed To Get Date ID", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
informationLabel.Text = "";
|
||||
//Run the row parsing engine on all the APC tables.
|
||||
|
||||
@@ -2242,7 +2231,7 @@ namespace AdvertsingProfitControl
|
||||
weeklySales[0] = sundayWeeklySalesTextBox.Text == "" ? 0 : double.Parse(sundayWeeklySalesTextBox.Text);
|
||||
weeklySales[1] = mondayWeeklySalesTextBox.Text == "" ? 0 : double.Parse(mondayWeeklySalesTextBox.Text);
|
||||
weeklySales[2] = tuesdayWeeklySalesTextBox.Text == "" ? 0 : double.Parse(tuesdayWeeklySalesTextBox.Text);
|
||||
weeklySales[3] = wednesdayTaxableTextBox.Text == "" ? 0 : double.Parse(wednesdayWeeklySalesTextBox.Text);
|
||||
weeklySales[3] = wednesdayWeeklySalesTextBox.Text == "" ? 0 : double.Parse(wednesdayWeeklySalesTextBox.Text);
|
||||
weeklySales[4] = thursdayWeeklySalesTextBox.Text == ""
|
||||
? 0
|
||||
: double.Parse(thursdayWeeklySalesTextBox.Text);
|
||||
|
||||
Reference in New Issue
Block a user