diff --git a/AdvertsingProfitControl/APCDatabase.accdb b/AdvertsingProfitControl/APCDatabase.accdb
index 2cfb184..763f584 100644
Binary files a/AdvertsingProfitControl/APCDatabase.accdb and b/AdvertsingProfitControl/APCDatabase.accdb differ
diff --git a/AdvertsingProfitControl/FrmMain.Designer.cs b/AdvertsingProfitControl/FrmMain.Designer.cs
index 129a96b..8ad4488 100644
--- a/AdvertsingProfitControl/FrmMain.Designer.cs
+++ b/AdvertsingProfitControl/FrmMain.Designer.cs
@@ -85,6 +85,7 @@
this.taxableDataGridView = new System.Windows.Forms.DataGridView();
this.debugTabPage = new System.Windows.Forms.TabPage();
this.monthCalendar = new System.Windows.Forms.MonthCalendar();
+ this.newModifyRecordToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.mainTableLayoutPanel.SuspendLayout();
this.mainMenu.SuspendLayout();
this.commentMainTableLayoutPanel.SuspendLayout();
@@ -164,7 +165,8 @@
this.addRecordsToolStripMenuItem,
this.modifyRecordMainMenu,
this.deleteRecordsMainMenu,
- this.newFormTestToolStripMenuItem});
+ this.newFormTestToolStripMenuItem,
+ this.newModifyRecordToolStripMenuItem});
this.recordsToolStripMenuItem.Name = "recordsToolStripMenuItem";
this.recordsToolStripMenuItem.Size = new System.Drawing.Size(98, 35);
this.recordsToolStripMenuItem.Text = "&Records";
@@ -760,6 +762,13 @@
this.monthCalendar.TabIndex = 0;
this.monthCalendar.TabStop = false;
//
+ // newModifyRecordToolStripMenuItem
+ //
+ this.newModifyRecordToolStripMenuItem.Name = "newModifyRecordToolStripMenuItem";
+ this.newModifyRecordToolStripMenuItem.Size = new System.Drawing.Size(323, 34);
+ this.newModifyRecordToolStripMenuItem.Text = "New Modify Record";
+ this.newModifyRecordToolStripMenuItem.Click += new System.EventHandler(this.newModifyRecordToolStripMenuItem_Click);
+ //
// FrmMain
//
this.AutoScaleDimensions = new System.Drawing.SizeF(168F, 168F);
@@ -865,6 +874,7 @@
private System.Windows.Forms.DataGridView taxableDataGridView;
private System.Windows.Forms.TabPage debugTabPage;
private System.Windows.Forms.MonthCalendar monthCalendar;
+ private System.Windows.Forms.ToolStripMenuItem newModifyRecordToolStripMenuItem;
}
}
diff --git a/AdvertsingProfitControl/FrmMain.cs b/AdvertsingProfitControl/FrmMain.cs
index 5c19020..5d674fd 100644
--- a/AdvertsingProfitControl/FrmMain.cs
+++ b/AdvertsingProfitControl/FrmMain.cs
@@ -647,14 +647,11 @@ namespace AdvertsingProfitControl
private void modifyRecordMainMenu_Click(object sender, EventArgs e)
{
- //var modifyForm = new FrmModifyRecord();
- //modifyForm.ShowDialog();
+ var modifyForm = new FrmModifyRecord();
+ modifyForm.ShowDialog();
//BuildAndFillDataGridTables();
//CalculateProfitAnalysis();
//CalculateGrossProfit();
- var date = DateTime.Parse(monthComboBox.SelectedItem + @"/" + dayComboBox.SelectedItem + @"/" + yearComboBox.SelectedItem);
- var form = new NewModifyRecord(date);
- form.ShowDialog();
}
private void manageItemsToolsMainMenu_Click(object sender, EventArgs e)
@@ -761,6 +758,13 @@ namespace AdvertsingProfitControl
form.ShowDialog();
}
+
+ private void newModifyRecordToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ var date = DateTime.Parse(monthComboBox.SelectedItem + @"/" + dayComboBox.SelectedItem + @"/" + yearComboBox.SelectedItem);
+ var form = new NewModifyRecord(date);
+ form.ShowDialog();
+ }
}
//http://stackoverflow.com/questions/487661/how-do-i-suspend-painting-for-a-control-and-its-children
diff --git a/AdvertsingProfitControl/FrmModifyRecord.cs b/AdvertsingProfitControl/FrmModifyRecord.cs
index e2dc1b6..d33a64c 100644
--- a/AdvertsingProfitControl/FrmModifyRecord.cs
+++ b/AdvertsingProfitControl/FrmModifyRecord.cs
@@ -404,7 +404,7 @@ namespace AdvertsingProfitControl
invoicesDataGridView.Rows.Add(row.ItemArray);
}
inventoryDataGridView.Columns.Remove("RowAttribute");
- inventoryDataGridView.Columns.Remove("FK_GroupID");
+ //inventoryDataGridView.Columns.Remove("FK_GroupID");
var weeklySalesTable = databaseReader.ReturnWeeklySalesFromDateId(dateId,
databaseTracker.DatabaseConnectionString);
@@ -563,7 +563,7 @@ namespace AdvertsingProfitControl
}
}
dataGridView.Columns.Remove("RowAttribute");
- dataGridView.Columns.Remove("Fk_GroupID");
+ //dataGridView.Columns.Remove("FK_AdSpecialName");
}
private void BuildDataGridViewInventoryTable(DataTable dataTable, DataGridView dataGridView)
diff --git a/AdvertsingProfitControl/NewModifyRecord.cs b/AdvertsingProfitControl/NewModifyRecord.cs
index 938d54e..abe57ea 100644
--- a/AdvertsingProfitControl/NewModifyRecord.cs
+++ b/AdvertsingProfitControl/NewModifyRecord.cs
@@ -1027,7 +1027,11 @@ namespace AdvertsingProfitControl
{
var adItemText = projectionsDataGridView.Rows[e.RowIndex].Cells[adItemIndex].EditedFormattedValue.ToString();
actualSalesDataGridView.Rows[e.RowIndex].Cells[adItemIndex].Value = adItemText;
+ actualSalesDataGridView.Rows[e.RowIndex].Cells[(int) SalesTableColumns.IsDirty].Value = true;
+ actualSalesDataGridView.Rows[e.RowIndex].HeaderCell.Style.BackColor = ApplicationColors.PendingEdit;
inventoryDataGridView.Rows[e.RowIndex].Cells[adItemIndex].Value = adItemText;
+ inventoryDataGridView.Rows[e.RowIndex].Cells[(int) InventoryTableColumns.IsDirty].Value = true;
+ inventoryDataGridView.Rows[e.RowIndex].HeaderCell.Style.BackColor = ApplicationColors.PendingEdit;
projectionsDataGridView.RefreshEdit();
//Remove the last ad item from the UsedAdItem array, the new one will be added in the OnRowLeave event handler.
if (_adSpecialIndex == -1 || e.RowIndex < _adSpecialIndex)
@@ -1385,7 +1389,11 @@ namespace AdvertsingProfitControl
{
var adItemText = inventoryDataGridView.Rows[e.RowIndex].Cells[adItemIndex].EditedFormattedValue.ToString();
projectionsDataGridView.Rows[e.RowIndex].Cells[adItemIndex].Value = adItemText;
+ projectionsDataGridView.Rows[e.RowIndex].Cells[(int) SalesTableColumns.IsDirty].Value = true;
+ projectionsDataGridView.Rows[e.RowIndex].HeaderCell.Style.BackColor = ApplicationColors.PendingEdit;
actualSalesDataGridView.Rows[e.RowIndex].Cells[adItemIndex].Value = adItemText;
+ actualSalesDataGridView.Rows[e.RowIndex].Cells[(int) SalesTableColumns.IsDirty].Value = true;
+ actualSalesDataGridView.Rows[e.RowIndex].HeaderCell.Style.BackColor = ApplicationColors.PendingEdit;
//inventoryDataGridView.RefreshEdit();
//Remove the last ad item from the UsedAdItem array, the new one will be added in the OnRowLeave event handler.
if (_adSpecialIndex == -1 || e.RowIndex < _adSpecialIndex)
@@ -1542,7 +1550,11 @@ namespace AdvertsingProfitControl
{
var adItemText = actualSalesDataGridView.Rows[e.RowIndex].Cells[adItemIndex].EditedFormattedValue.ToString();
projectionsDataGridView.Rows[e.RowIndex].Cells[adItemIndex].Value = adItemText;
+ projectionsDataGridView.Rows[e.RowIndex].Cells[(int) SalesTableColumns.IsDirty].Value = true;
+ projectionsDataGridView.Rows[e.RowIndex].HeaderCell.Style.BackColor = ApplicationColors.PendingEdit;
inventoryDataGridView.Rows[e.RowIndex].Cells[adItemIndex].Value = adItemText;
+ inventoryDataGridView.Rows[e.RowIndex].Cells[(int) InventoryTableColumns.IsDirty].Value = true;
+ inventoryDataGridView.Rows[e.RowIndex].HeaderCell.Style.BackColor = ApplicationColors.PendingEdit;
//projectionsDataGridView.RefreshEdit();
//Remove the last ad item from the UsedAdItem array, the new one will be added in the OnRowLeave event handler.
if (_adSpecialIndex == -1 || e.RowIndex < _adSpecialIndex)
@@ -2127,15 +2139,27 @@ namespace AdvertsingProfitControl
var projections = databaseReader.ReturnProjectionsTable(dateId, databaseTracker.DatabaseConnectionString);
var inventory = databaseReader.ReturnInventoryTable(dateId, databaseTracker.DatabaseConnectionString);
var actualSales = databaseReader.ReturnActualSales(dateId, databaseTracker.DatabaseConnectionString);
- LoadApcTables(projections, inventory, actualSales);
+ LoadProjectionsTable(projections);
+ LoadInventory(inventory);
+ LoadActualSales(actualSales);
var invoices = databaseReader.ReturnInvoiceTable(dateId, databaseTracker.DatabaseConnectionString);
+
+ //Re-enable the events
projectionsDataGridView.CellEnter += StoreBeginningCellValue;
projectionsDataGridView.RowLeave += UpdateUsedAdItemCollectionOnRowLeave;
projectionsDataGridView.CellValidating += ValidateSalesDataGridViewCellContents;
projectionsDataGridView.RowValidating += ValidateProjectedRow;
+ inventoryDataGridView.CellEnter += StoreBeginningCellValue;
+ inventoryDataGridView.RowLeave += UpdateUsedAdItemCollectionOnRowLeave;
+ inventoryDataGridView.CellValidating += ValidateInventoryCellContents;
+ inventoryDataGridView.RowValidating += ValidateInventoryRow;
+ actualSalesDataGridView.CellEnter += StoreBeginningCellValue;
+ actualSalesDataGridView.RowLeave += UpdateUsedAdItemCollectionOnRowLeave;
+ actualSalesDataGridView.CellValidating += ValidateSalesDataGridViewCellContents;
+ actualSalesDataGridView.RowValidating += ValidateActualSalesRow;
}
- private void LoadApcTables(DataTable projections, DataTable inventory, DataTable actualSales)
+ private void LoadProjectionsTable(DataTable projections)
{
//Assuming all the tables are correctly aligned.
//Disable the relevant events in the DataGridViews
@@ -2144,17 +2168,17 @@ namespace AdvertsingProfitControl
projectionsDataGridView.CellValidating -= ValidateSalesDataGridViewCellContents;
projectionsDataGridView.RowValidating -= ValidateProjectedRow;
- for(var i = 0; i < projections.Rows.Count; i++)
+ for(var rowIndex = 0; rowIndex < projections.Rows.Count; rowIndex++)
{
var newRow = new DataGridViewRow();
- for (var cellIndex = 0; cellIndex < projections.Rows[i].ItemArray.Length; cellIndex++)
+ for (var cellIndex = 0; cellIndex < projections.Rows[rowIndex].ItemArray.Length; cellIndex++)
{
//ID and Ad Item.
if (cellIndex <= 1)
{
var cell = new DataGridViewTextBoxCell
{
- Value = projections.Rows[i].ItemArray[cellIndex].ToString()
+ Value = projections.Rows[rowIndex].ItemArray[cellIndex].ToString()
};
newRow.Cells.Add(cell);
continue;
@@ -2162,14 +2186,14 @@ namespace AdvertsingProfitControl
//Everything in between the ad item cell and the row attribute cells.
if (cellIndex > 1 && cellIndex <= 7)
{
- if (projections.Rows[i].ItemArray[cellIndex].ToString() == "0")
+ if (projections.Rows[rowIndex].ItemArray[cellIndex].ToString() == "0")
{
var cell = new DataGridViewTextBoxCell {Value = ""};
newRow.Cells.Add(cell);
}
else
{
- var cell = new DataGridViewTextBoxCell { Value = projections.Rows[i].ItemArray[cellIndex].ToString() };
+ var cell = new DataGridViewTextBoxCell { Value = projections.Rows[rowIndex].ItemArray[cellIndex].ToString() };
newRow.Cells.Add(cell);
}
continue;
@@ -2179,7 +2203,7 @@ namespace AdvertsingProfitControl
{
var isHeaderCell = new DataGridViewCheckBoxCell(false);
var isMemberCell = new DataGridViewCheckBoxCell(false);
- var rowAttribute = int.Parse(projections.Rows[i].ItemArray[cellIndex].ToString());
+ var rowAttribute = int.Parse(projections.Rows[rowIndex].ItemArray[cellIndex].ToString());
switch (rowAttribute)
{
case 1:
@@ -2200,25 +2224,198 @@ namespace AdvertsingProfitControl
//Check the group it is part of if any.
if (cellIndex == 9)
{
- if (projections.Rows[i].ItemArray[cellIndex].ToString() != "0" && _adSpecialIndex == -1)
+ if (projections.Rows[rowIndex].ItemArray[cellIndex].ToString() != "0" && _adSpecialIndex == -1)
{
var databaseTracker = new DatabaseTracker();
var databaseReader = new DatabaseReader();
var groupName =
databaseReader.ReturnGroupNameFromGroupId(
- projections.Rows[i].ItemArray[cellIndex].ToString(),
+ projections.Rows[rowIndex].ItemArray[cellIndex].ToString(),
databaseTracker.DatabaseConnectionString);
var adSpecialRow = new DataGridViewRow();
projectionsDataGridView.Rows.Add(adSpecialRow);
- projectionsDataGridView.Rows[i].Cells[1].Value = groupName;
- projectionsDataGridView.Rows[i].DefaultCellStyle.BackColor = ApplicationColors.AdSpecial;
- _adSpecialIndex = i;
+ projectionsDataGridView.Rows[rowIndex].Cells[1].Value = groupName;
+ projectionsDataGridView.Rows[rowIndex].DefaultCellStyle.BackColor = ApplicationColors.AdSpecial;
+ _adSpecialIndex = rowIndex;
}
}
}
projectionsDataGridView.Rows.Add(newRow);
}
- //Re-enable the events
+ }
+
+ private void LoadInventory(DataTable inventoryTable)
+ {
+ //Assuming all the tables are correctly aligned.
+ //Disable the relevant events in the DataGridViews
+ inventoryDataGridView.CellEnter -= StoreBeginningCellValue;
+ inventoryDataGridView.RowLeave -= UpdateUsedAdItemCollectionOnRowLeave;
+ inventoryDataGridView.CellValidating -= ValidateInventoryCellContents;
+ inventoryDataGridView.RowValidating -= ValidateInventoryRow;
+ //Create a local ad special index since Projections should have filled the ad special index in for the class.
+ var adSpecialIndex = -1;
+
+ for (var rowIndex = 0; rowIndex < inventoryTable.Rows.Count; rowIndex++)
+ {
+ var newRow = new DataGridViewRow();
+ for (var cellIndex = 0; cellIndex < inventoryTable.Rows[rowIndex].ItemArray.Length; cellIndex++)
+ {
+ //ID and Ad Item.
+ if (cellIndex <= 1)
+ {
+ var cell = new DataGridViewTextBoxCell
+ {
+ Value = inventoryTable.Rows[rowIndex].ItemArray[cellIndex].ToString()
+ };
+ newRow.Cells.Add(cell);
+ continue;
+ }
+ //Everything in between the ad item cell and the row attribute cells.
+ if (cellIndex > 1 && cellIndex <= 5)
+ {
+ if (inventoryTable.Rows[rowIndex].ItemArray[cellIndex].ToString() == "0")
+ {
+ var cell = new DataGridViewTextBoxCell { Value = "" };
+ newRow.Cells.Add(cell);
+ }
+ else
+ {
+ var cell = new DataGridViewTextBoxCell { Value = inventoryTable.Rows[rowIndex].ItemArray[cellIndex].ToString() };
+ newRow.Cells.Add(cell);
+ }
+ continue;
+ }
+ //Check the attribute cell.
+ if (cellIndex == 6)
+ {
+ var isHeaderCell = new DataGridViewCheckBoxCell(false);
+ var isMemberCell = new DataGridViewCheckBoxCell(false);
+ var rowAttribute = int.Parse(inventoryTable.Rows[rowIndex].ItemArray[cellIndex].ToString());
+ switch (rowAttribute)
+ {
+ case 1:
+ //Header row
+ isHeaderCell.Value = true;
+ newRow.DefaultCellStyle.BackColor = ApplicationColors.HeaderRow;
+ break;
+ case 2:
+ //Member Row
+ isMemberCell.Value = true;
+ newRow.DefaultCellStyle.BackColor = ApplicationColors.MemberRow;
+ break;
+ }
+ newRow.Cells.Add(isHeaderCell);
+ newRow.Cells.Add(isMemberCell);
+ continue;
+ }
+ //Check the group it is part of if any.
+ if (cellIndex == 7)
+ {
+ if (inventoryTable.Rows[rowIndex].ItemArray[cellIndex].ToString() != "0" && adSpecialIndex == -1)
+ {
+ var databaseTracker = new DatabaseTracker();
+ var databaseReader = new DatabaseReader();
+ var groupName =
+ databaseReader.ReturnGroupNameFromGroupId(
+ inventoryTable.Rows[rowIndex].ItemArray[cellIndex].ToString(),
+ databaseTracker.DatabaseConnectionString);
+ var adSpecialRow = new DataGridViewRow();
+ inventoryDataGridView.Rows.Add(adSpecialRow);
+ inventoryDataGridView.Rows[rowIndex].Cells[1].Value = groupName;
+ inventoryDataGridView.Rows[rowIndex].DefaultCellStyle.BackColor = ApplicationColors.AdSpecial;
+ adSpecialIndex = rowIndex;
+ }
+ }
+ }
+ inventoryDataGridView.Rows.Add(newRow);
+ }
+ }
+
+ public void LoadActualSales(DataTable actualSales)
+ {
+ //Assuming all the tables are correctly aligned.
+ //Disable the relevant events in the DataGridViews
+ actualSalesDataGridView.CellEnter -= StoreBeginningCellValue;
+ actualSalesDataGridView.RowLeave -= UpdateUsedAdItemCollectionOnRowLeave;
+ actualSalesDataGridView.CellValidating -= ValidateSalesDataGridViewCellContents;
+ actualSalesDataGridView.RowValidating -= ValidateActualSalesRow;
+ //Create a local ad special index since Projections should have filled the ad special index in for the class.
+ var adSpecialIndex = -1;
+
+ for (var rowIndex = 0; rowIndex < actualSales.Rows.Count; rowIndex++)
+ {
+ var newRow = new DataGridViewRow();
+ for (var cellIndex = 0; cellIndex < actualSales.Rows[rowIndex].ItemArray.Length; cellIndex++)
+ {
+ //ID and Ad Item.
+ if (cellIndex <= 1)
+ {
+ var cell = new DataGridViewTextBoxCell
+ {
+ Value = actualSales.Rows[rowIndex].ItemArray[cellIndex].ToString()
+ };
+ newRow.Cells.Add(cell);
+ continue;
+ }
+ //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")
+ {
+ var cell = new DataGridViewTextBoxCell { Value = "" };
+ newRow.Cells.Add(cell);
+ }
+ else
+ {
+ var cell = new DataGridViewTextBoxCell { Value = actualSales.Rows[rowIndex].ItemArray[cellIndex].ToString() };
+ newRow.Cells.Add(cell);
+ }
+ continue;
+ }
+ //Check the attribute cell.
+ if (cellIndex == 8)
+ {
+ var isHeaderCell = new DataGridViewCheckBoxCell(false);
+ var isMemberCell = new DataGridViewCheckBoxCell(false);
+ var rowAttribute = int.Parse(actualSales.Rows[rowIndex].ItemArray[cellIndex].ToString());
+ switch (rowAttribute)
+ {
+ case 1:
+ //Header row
+ isHeaderCell.Value = true;
+ newRow.DefaultCellStyle.BackColor = ApplicationColors.HeaderRow;
+ break;
+ case 2:
+ //Member Row
+ isMemberCell.Value = true;
+ newRow.DefaultCellStyle.BackColor = ApplicationColors.MemberRow;
+ break;
+ }
+ newRow.Cells.Add(isHeaderCell);
+ newRow.Cells.Add(isMemberCell);
+ continue;
+ }
+ //Check the group it is part of if any.
+ if (cellIndex == 9)
+ {
+ if (actualSales.Rows[rowIndex].ItemArray[cellIndex].ToString() != "0" && adSpecialIndex == -1)
+ {
+ var databaseTracker = new DatabaseTracker();
+ var databaseReader = new DatabaseReader();
+ var groupName =
+ databaseReader.ReturnGroupNameFromGroupId(
+ actualSales.Rows[rowIndex].ItemArray[cellIndex].ToString(),
+ databaseTracker.DatabaseConnectionString);
+ var adSpecialRow = new DataGridViewRow();
+ actualSalesDataGridView.Rows.Add(adSpecialRow);
+ actualSalesDataGridView.Rows[rowIndex].Cells[1].Value = groupName;
+ actualSalesDataGridView.Rows[rowIndex].DefaultCellStyle.BackColor = ApplicationColors.AdSpecial;
+ adSpecialIndex = rowIndex;
+ }
+ }
+ }
+ actualSalesDataGridView.Rows.Add(newRow);
+ }
}
private void NormalizeApcTables(DataTable projetions, DataTable inventory, DataTable actualSales, string dateId)
diff --git a/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.vshost.application b/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.vshost.application
index a398cd7..1e6f4da 100644
--- a/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.vshost.application
+++ b/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.vshost.application
@@ -14,7 +14,7 @@
- BL2VwteFPdU1C5eFgLcNJB6t71bYUCKbAJpayKyfE2c=
+ hjoJ6F3S2mx0T7+16nfA9mg2vO2CJ4FO+GQ/EyPYf58=
diff --git a/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.vshost.exe.manifest b/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.vshost.exe.manifest
index 0f96fbd..e78bcf3 100644
--- a/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.vshost.exe.manifest
+++ b/AdvertsingProfitControl/bin/Debug/AdvertsingProfitControl.vshost.exe.manifest
@@ -43,14 +43,14 @@
-
+
- E5XDgx2BUQtUy2BTSxYDHOSv9/kMPusOEpgSdyhYHzk=
+ vZ/15zn6UnQyxvEn4XYMV+E1MUxIXiQdJmnSal6RNFc=
@@ -93,7 +93,7 @@
- UQFU3HlwUiJQK2YXuAkDK9mSdSFJnVT3pbRsOpcjnAg=
+ ZGKhdhvn6U66O06l/eGiap8UW45ciijpPInT3o/xuMc=