Updated the table class files to allow a nullable ad special ID and changed the enum in the new modify record form to a boolean. Added a form to manage ad special keywords, still needs to handle removing them properly.
This commit is contained in:
@@ -29,7 +29,7 @@ namespace AdvertsingProfitControl
|
||||
private void frmMain_Load(object sender, EventArgs e)
|
||||
{
|
||||
var db = new AdvertisingProfitControlModel();
|
||||
monthCalendar.BoldedDates = db.WeekEndingDates.Select(zdate => zdate.EndingDate).ToArray();
|
||||
RefreshDateListing();
|
||||
ConstructApcDataGridViews();
|
||||
ConstructInvoicesDataGridView();
|
||||
RowParsing.AdSpecialGroups.AddRange(db.AdSpecials.Select(x => x.Name));
|
||||
@@ -135,6 +135,7 @@ namespace AdvertsingProfitControl
|
||||
form.ShowDialog();
|
||||
//One the user has closed the add record form, check to see if there is a newer date
|
||||
//available. If so, reload the form.
|
||||
RefreshDateListing();
|
||||
var date = db.WeekEndingDates.OrderByDescending(x => x.EndingDate).FirstOrDefault();
|
||||
if (date == null) return;
|
||||
if (date.EndingDate == _currentActiveDate) return;
|
||||
@@ -157,6 +158,7 @@ namespace AdvertsingProfitControl
|
||||
{
|
||||
var form = new NewModifyRecord(_currentActiveDate);
|
||||
form.ShowDialog();
|
||||
RefreshDateListing();
|
||||
//On return reload the date that was just modified by the modify record form.
|
||||
LoadDate(_currentActiveDate);
|
||||
}
|
||||
@@ -347,16 +349,6 @@ namespace AdvertsingProfitControl
|
||||
private void LoadDate(DateTime date)
|
||||
{
|
||||
var db = new AdvertisingProfitControlModel();
|
||||
if (monthCalendar.BoldedDates.Length == 0)
|
||||
{
|
||||
//The database is most likely empty so halt everything.
|
||||
dateTimeGroupBox.Text = @"The database appears to be empty.";
|
||||
modifyRecordMainMenu.Enabled = false;
|
||||
modifyRecordMainMenu.ToolTipText = @"There are no records to modify.";
|
||||
return;
|
||||
}
|
||||
modifyRecordMainMenu.Enabled = true;
|
||||
modifyRecordMainMenu.ToolTipText = @"";
|
||||
var dateRecord = db.WeekEndingDates.SingleOrDefault(x => x.EndingDate == date);
|
||||
if (dateRecord == null)
|
||||
{
|
||||
@@ -413,7 +405,7 @@ namespace AdvertsingProfitControl
|
||||
projectionsDataGridView.Rows[index].DefaultCellStyle.BackColor = ApplicationColors.MemberRow;
|
||||
}
|
||||
|
||||
if (p.FkAdSpecialId != 0 && adSpecialIndex == -1)
|
||||
if (p.FkAdSpecialId != null && adSpecialIndex == -1)
|
||||
{
|
||||
//TODO: Fix null reference when no object is found.
|
||||
adSpecialIndex = index;
|
||||
@@ -469,7 +461,7 @@ namespace AdvertsingProfitControl
|
||||
inventoryDataGridView.Rows[index].DefaultCellStyle.BackColor = ApplicationColors.MemberRow;
|
||||
}
|
||||
|
||||
if (i.FkAdSpecialId != 0 && adSpecialIndex == -1)
|
||||
if (i.FkAdSpecialId != null && adSpecialIndex == -1)
|
||||
{
|
||||
adSpecialIndex = index;
|
||||
inventoryDataGridView.Rows.Insert(index, 1);
|
||||
@@ -509,7 +501,7 @@ namespace AdvertsingProfitControl
|
||||
actualSalesDataGridView.Rows[index].DefaultCellStyle.BackColor = ApplicationColors.MemberRow;
|
||||
}
|
||||
|
||||
if (a.FkAdSpecialId != 0 && adSpecialIndex == -1)
|
||||
if (a.FkAdSpecialId != null && adSpecialIndex == -1)
|
||||
{
|
||||
adSpecialIndex = index;
|
||||
actualSalesDataGridView.Rows.Insert(index, 1);
|
||||
@@ -781,6 +773,17 @@ namespace AdvertsingProfitControl
|
||||
{
|
||||
var db = new AdvertisingProfitControlModel();
|
||||
monthCalendar.BoldedDates = db.WeekEndingDates.Select(zdate => zdate.EndingDate).ToArray();
|
||||
if (monthCalendar.BoldedDates.Length > 0)
|
||||
{
|
||||
modifyRecordMainMenu.Enabled = true;
|
||||
modifyRecordMainMenu.ToolTipText = @"";
|
||||
}
|
||||
else
|
||||
{
|
||||
dateTimeGroupBox.Text = @"No records found in the database.";
|
||||
modifyRecordMainMenu.Enabled = false;
|
||||
modifyRecordMainMenu.ToolTipText = @"There are no records to modify.";
|
||||
}
|
||||
}
|
||||
|
||||
private void clearSelectedDateToolsMainMenu_Click(object sender, EventArgs e)
|
||||
@@ -845,6 +848,7 @@ namespace AdvertsingProfitControl
|
||||
db.WeekEndingDates.Remove(dateRecord);
|
||||
db.SaveChanges();
|
||||
scope.Complete();
|
||||
ClearForm();
|
||||
}
|
||||
catch (DbUpdateException ex)
|
||||
{
|
||||
@@ -854,7 +858,11 @@ namespace AdvertsingProfitControl
|
||||
}
|
||||
|
||||
RefreshDateListing();
|
||||
LoadDate(db.WeekEndingDates.OrderByDescending(x => x.EndingDate).FirstOrDefault().EndingDate);
|
||||
var mostRecentDate = db.WeekEndingDates.OrderByDescending(x => x.EndingDate).FirstOrDefault();
|
||||
if (mostRecentDate != null)
|
||||
{
|
||||
LoadDate(mostRecentDate.EndingDate);
|
||||
}
|
||||
}
|
||||
|
||||
private void addRecordToolStripMenuItem_Click_1(object sender, EventArgs e)
|
||||
@@ -867,6 +875,12 @@ namespace AdvertsingProfitControl
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void adSpecialKeyWordsToolsMainMenu_Click(object sender, EventArgs e)
|
||||
{
|
||||
var form = new FrmRegisterAdSpecial();
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
}
|
||||
//http://stackoverflow.com/questions/487661/how-do-i-suspend-painting-for-a-control-and-its-children
|
||||
|
||||
Reference in New Issue
Block a user