Added a tool to remove an entire date and all records associated with it. Updated row deletion code to handle unbalanced tables or missing row IDs.

This commit is contained in:
2017-01-24 13:45:25 -06:00
parent d7229c9499
commit 2657523888
12 changed files with 277 additions and 242 deletions
Binary file not shown.
+116 -40
View File
@@ -490,22 +490,6 @@ namespace AdvertsingProfitControl
table.Rows[rowIndex].Cells[(int)InvoiceTableColumns.IsDirty].Value = false;
table.Rows[rowIndex].HeaderCell.Style.BackColor = ApplicationColors.EditingSaved;
}
//foreach (DataGridViewRow row in table.Rows)
//{
// if(row.IsNewRow) continue;
// if (!rowsAdded.Contains(row.Index)) continue;
// var supplierId = RetrieveSupplierId(row.Cells[(int)InvoiceTableColumns.Supplier].EditedFormattedValue.ToString());
// var invoiceIdNumber =
// RetrieveInvoiceId(
// row.Cells[(int)InvoiceTableColumns.InvoiceDate].EditedFormattedValue
// .ToString(),
// long.Parse(
// row.Cells[(int)InvoiceTableColumns.InvoiceNumber].EditedFormattedValue
// .ToString()), supplierId, dateId);
// row.Cells[(int)InvoiceTableColumns.Id].Value = invoiceIdNumber;
// row.Cells[(int)InvoiceTableColumns.IsDirty].Value = false;
// row.HeaderCell.Style.BackColor = ApplicationColors.EditingSaved;
//}
table.RefreshEdit();
//Set the status.
status.SetStatus(WritingOperationStatus.InsertionSuccessful);
@@ -820,6 +804,36 @@ namespace AdvertsingProfitControl
}
}
public bool DeleteTableEntry(int rowId, string tableName, string connectionString)
{
var oleDbConnection = new OleDbConnection(connectionString);
var status = false;
var oleDbCommand = new OleDbCommand
{
Connection = oleDbConnection,
CommandText = "DELETE * FROM " + tableName + " WHERE ID = ?"
};
oleDbCommand.Parameters.AddWithValue("RowID", rowId);
try
{
oleDbConnection.Open();
oleDbCommand.ExecuteNonQuery();
status = true;
}
catch (OleDbException e)
{
_logConsole.WriteToLog(FrmLogConsole.Level.Error,
"Failed to delete the entries in " + tableName + " with the row ID of " + rowId + ".");
_logConsole.WriteToLog(FrmLogConsole.Level.Error, e.Message);
}
finally
{
oleDbConnection.Close();
}
return status;
}
/// <summary>
/// Inserts a new ad item into the database and returns the new item's ID number.
/// Supports rolling back as to not corrupt the database.
@@ -1084,11 +1098,11 @@ namespace AdvertsingProfitControl
/// <returns>True if the operation was successful; false if not.</returns>
public bool DeleteApcRow(int projectionsRowId, int inventoryRowId, int actualSalesRowId)
{
var result = false;
var result = true;
var tableName = "Projections"; //Starting point.
var oleDbCommand = new OleDbCommand
{
CommandText = "DELETE FROM Projections WHERE ID = ?",
CommandText = "DELETE * FROM Projections WHERE ID = ?",
Connection = _oleDbConnection
};
oleDbCommand.Parameters.AddWithValue("ID", projectionsRowId);
@@ -1098,41 +1112,54 @@ namespace AdvertsingProfitControl
_oleDbConnection.Open();
oleDbTransaction = _oleDbConnection.BeginTransaction();
oleDbCommand.Transaction = oleDbTransaction;
var rowsEffected = oleDbCommand.ExecuteNonQuery();
if (rowsEffected == 1)
var rowsEffected = 0;
if (projectionsRowId != 0)
{
tableName = "Inventory";
oleDbCommand.Parameters.Clear();
oleDbCommand.CommandText = "DELETE FROM Inventory WHERE ID = ?";
oleDbCommand.Parameters.AddWithValue("ID", inventoryRowId);
rowsEffected = oleDbCommand.ExecuteNonQuery();
if (rowsEffected == 1)
{
tableName = "ActualSales";
oleDbCommand.Parameters.Clear();
oleDbCommand.CommandText = "DELETE FROM ActualSales WHERE ID = ?";
oleDbCommand.Parameters.AddWithValue("ID", inventoryRowId);
rowsEffected = oleDbCommand.ExecuteNonQuery();
if (rowsEffected == 1)
{
result = true;
}
}
}
if (!result)
if (rowsEffected == 0)
{
oleDbTransaction?.Rollback();
_logConsole.WriteToLog(FrmLogConsole.Level.Error, "Failed to delete row with the ID of " + projectionsRowId + " from projections. (No Exception Thrown)");
return false;
}
else
}
tableName = "Inventory";
oleDbCommand.Parameters.Clear();
if (inventoryRowId != 0)
{
oleDbTransaction.Commit();
oleDbCommand.CommandText = "DELETE * FROM Inventory WHERE ID = ?";
oleDbCommand.Parameters.AddWithValue("ID", inventoryRowId);
rowsEffected = oleDbCommand.ExecuteNonQuery();
if (rowsEffected == 0)
{
oleDbTransaction?.Rollback();
_logConsole.WriteToLog(FrmLogConsole.Level.Error, "Failed to delete row with the ID of " + inventoryRowId + " from inventory. (No Exception Thrown)");
return false;
}
}
tableName = "ActualSales";
oleDbCommand.Parameters.Clear();
if (actualSalesRowId != 0)
{
oleDbCommand.CommandText = "DELETE * FROM ActualSales WHERE ID = ?";
oleDbCommand.Parameters.AddWithValue("ID", actualSalesRowId);
rowsEffected = oleDbCommand.ExecuteNonQuery();
if (rowsEffected == 0)
{
oleDbTransaction?.Rollback();
_logConsole.WriteToLog(FrmLogConsole.Level.Error, "Failed to delete row with the ID of " + actualSalesRowId + " from actual sales. (No Exception Thrown)");
return false;
}
}
oleDbTransaction?.Commit();
}
catch (OleDbException e)
{
_logConsole.WriteToLog(FrmLogConsole.Level.Error, "Failed to delete row with the ID of " + inventoryRowId + " from " + tableName + ".");
_logConsole.WriteToLog(FrmLogConsole.Level.Error, e.Message);
oleDbTransaction?.Rollback();
result = false;
}
finally
{
@@ -1142,6 +1169,55 @@ namespace AdvertsingProfitControl
return result;
}
public bool ClearDateById(int dateId)
{
var successful = true;
var oleDbCommand = new OleDbCommand
{
CommandText = "DELETE * FROM ActualSales WHERE FK_DateID = ?",
Connection = _oleDbConnection
};
oleDbCommand.Parameters.AddWithValue("DateID", dateId);
OleDbTransaction oleDbTransaction = null;
try
{
_oleDbConnection.Open();
oleDbTransaction = _oleDbConnection.BeginTransaction();
oleDbCommand.Transaction = oleDbTransaction;
oleDbCommand.ExecuteNonQuery();
oleDbCommand.CommandText = "DELETE * FROM Comment WHERE FK_DateID = ?";
oleDbCommand.Parameters.AddWithValue("DateID", dateId);
oleDbCommand.ExecuteNonQuery();
oleDbCommand.CommandText = "DELETE * FROM CostOfSalesAnalysis WHERE FK_DateID = ?";
oleDbCommand.Parameters.AddWithValue("DateID", dateId);
oleDbCommand.ExecuteNonQuery();
oleDbCommand.CommandText = "DELETE * FROM Inventory WHERE FK_DateID = ?";
oleDbCommand.ExecuteNonQuery();
oleDbCommand.CommandText = "DELETE * FROM Invoice WHERE FK_DateID = ?";
oleDbCommand.ExecuteNonQuery();
oleDbCommand.CommandText = "DELETE * FROM Projections WHERE FK_DateID = ?";
oleDbCommand.ExecuteNonQuery();
oleDbCommand.CommandText = "DELETE * FROM Taxable WHERE FK_DateID = ?";
oleDbCommand.ExecuteNonQuery();
oleDbCommand.CommandText = "DELETE * FROM WeekEnding WHERE ID = ?";
oleDbCommand.ExecuteNonQuery();
oleDbCommand.CommandText = "DELETE * FROM WeeklySales WHERE FK_DateID = ?";
oleDbCommand.ExecuteNonQuery();
oleDbTransaction.Commit();
}
catch (OleDbException e)
{
_logConsole.WriteToLog(FrmLogConsole.Level.Error, e.Message);
oleDbTransaction?.Rollback();
successful = false;
}
finally
{
_oleDbConnection.Close();
}
return successful;
}
public bool NormalizeApcTables(int dateId)
{
var successful = false;
+16 -4
View File
@@ -102,6 +102,7 @@
this.grossProfitEstimatedWeeklyDeptmartmentExpenseLabel = new System.Windows.Forms.Label();
this.perfectGrossProfitLabel = new System.Windows.Forms.Label();
this.grossProfitDollarGrossProfitLabel = new System.Windows.Forms.Label();
this.clearSelectedDateToolsMainMenu = new System.Windows.Forms.ToolStripMenuItem();
this.mainMenu.SuspendLayout();
this.mainTableLayoutPanel.SuspendLayout();
this.commentMainTableLayoutPanel.SuspendLayout();
@@ -206,23 +207,25 @@
//
this.toolsMainMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.adSpecialKeyWordsToolsMainMenu,
this.manageItemsToolsMainMenu});
this.manageItemsToolsMainMenu,
this.clearSelectedDateToolsMainMenu});
this.toolsMainMenu.Name = "toolsMainMenu";
this.toolsMainMenu.Size = new System.Drawing.Size(72, 34);
this.toolsMainMenu.Text = "&Tools";
this.toolsMainMenu.Visible = false;
//
// adSpecialKeyWordsToolsMainMenu
//
this.adSpecialKeyWordsToolsMainMenu.Name = "adSpecialKeyWordsToolsMainMenu";
this.adSpecialKeyWordsToolsMainMenu.Size = new System.Drawing.Size(282, 34);
this.adSpecialKeyWordsToolsMainMenu.Size = new System.Drawing.Size(286, 34);
this.adSpecialKeyWordsToolsMainMenu.Text = "&Register Ad Special";
this.adSpecialKeyWordsToolsMainMenu.Visible = false;
//
// manageItemsToolsMainMenu
//
this.manageItemsToolsMainMenu.Name = "manageItemsToolsMainMenu";
this.manageItemsToolsMainMenu.Size = new System.Drawing.Size(282, 34);
this.manageItemsToolsMainMenu.Size = new System.Drawing.Size(286, 34);
this.manageItemsToolsMainMenu.Text = "&Manage Ad Items";
this.manageItemsToolsMainMenu.Visible = false;
this.manageItemsToolsMainMenu.Click += new System.EventHandler(this.manageItemsToolsMainMenu_Click);
//
// helpMainMenu
@@ -928,6 +931,13 @@
this.grossProfitDollarGrossProfitLabel.TabIndex = 2;
this.grossProfitDollarGrossProfitLabel.Text = "Dollar Gross Profit: ";
//
// clearSelectedDateToolsMainMenu
//
this.clearSelectedDateToolsMainMenu.Name = "clearSelectedDateToolsMainMenu";
this.clearSelectedDateToolsMainMenu.Size = new System.Drawing.Size(286, 34);
this.clearSelectedDateToolsMainMenu.Text = "&Clear Selected Date";
this.clearSelectedDateToolsMainMenu.Click += new System.EventHandler(this.clearSelectedDateToolsMainMenu_Click);
//
// FrmMain
//
this.AutoScaleDimensions = new System.Drawing.SizeF(168F, 168F);
@@ -939,6 +949,7 @@
this.Name = "FrmMain";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Advertising Profit Control";
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
this.Load += new System.EventHandler(this.frmMain_Load);
this.mainMenu.ResumeLayout(false);
this.mainMenu.PerformLayout();
@@ -1048,6 +1059,7 @@
private System.Windows.Forms.DataGridView invoicesDataGridView;
private System.Windows.Forms.ToolStripMenuItem debugToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem debugToolStripMenuItem1;
private System.Windows.Forms.ToolStripMenuItem clearSelectedDateToolsMainMenu;
}
}
+37 -1
View File
@@ -157,7 +157,7 @@ namespace AdvertsingProfitControl
private void modifyRecordMainMenu_Click(object sender, EventArgs e)
{
var form = new NewModifyRecord(monthCalendar.SelectionStart);
var form = new NewModifyRecord(_currentActiveDate);
form.ShowDialog();
//On return reload the date that was just modified by the modify record form.
LoadDate(monthCalendar.SelectionStart);
@@ -1235,6 +1235,42 @@ namespace AdvertsingProfitControl
var databaseReader = new DatabaseReader();
monthCalendar.BoldedDates = databaseReader.RetrieveDates(databaseTracker.DatabaseConnectionString).ToArray();
}
public enum FormDefaultRoll
{
AddNewRecord = 0,
ModifyExistingRecord = 1
}
private void clearSelectedDateToolsMainMenu_Click(object sender, EventArgs e)
{
var result = MessageBox.Show(@"Are you sure you want to delete all records for the date " + _currentActiveDate.ToShortDateString() + @"?", @"Clear Date", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (result == DialogResult.No)
{
return;
}
var dbT = new DatabaseTracker();
var dbW = new DatabaseWriter(dbT.DatabaseConnectionString);
var dbR = new DatabaseReader();
var dateId = dbR.RetrieveDateIdByDateString(_currentActiveDate.ToShortDateString(), dbT.DatabaseConnectionString);
if (dateId != 0)
{
if (dbW.ClearDateById(dateId))
{
RefreshDateListing();
var date = dbR.RetrieveMostRecentDate(dbT.DatabaseConnectionString);
LoadDate(date);
}
else
{
errorLabel.Text = @"Failed to clear the selected date.";
}
}
else
{
errorLabel.Text = @"Failed to get the date ID number.";
}
}
}
}
//http://stackoverflow.com/questions/487661/how-do-i-suspend-painting-for-a-control-and-its-children
+9 -8
View File
@@ -56,6 +56,7 @@
this.FileMainMenu = new System.Windows.Forms.ToolStripMenuItem();
this.clearFormFileMainMenu = new System.Windows.Forms.ToolStripMenuItem();
this.exitFileMainMenu = new System.Windows.Forms.ToolStripMenuItem();
this.debugMainMenu = new System.Windows.Forms.ToolStripMenuItem();
this.mainLayoutPanel = new System.Windows.Forms.TableLayoutPanel();
this.costAnalysisGroupBox = new System.Windows.Forms.GroupBox();
this.suppliesTextBox = new System.Windows.Forms.TextBox();
@@ -107,7 +108,6 @@
this.informationPanel = new System.Windows.Forms.Panel();
this.errorLabel = new System.Windows.Forms.Label();
this.addRecordButton = new System.Windows.Forms.Button();
this.debugMainMenu = new System.Windows.Forms.ToolStripMenuItem();
this.commentsGroupBox.SuspendLayout();
this.mainTabControl.SuspendLayout();
this.projectionTabPage.SuspendLayout();
@@ -449,6 +449,13 @@
this.exitFileMainMenu.Size = new System.Drawing.Size(205, 34);
this.exitFileMainMenu.Text = "E&xit";
//
// debugMainMenu
//
this.debugMainMenu.Name = "debugMainMenu";
this.debugMainMenu.Size = new System.Drawing.Size(87, 31);
this.debugMainMenu.Text = "&Debug";
this.debugMainMenu.Click += new System.EventHandler(this.debugMainMenu_Click);
//
// mainLayoutPanel
//
this.mainLayoutPanel.ColumnCount = 4;
@@ -943,13 +950,6 @@
this.addRecordButton.UseVisualStyleBackColor = true;
this.addRecordButton.Click += new System.EventHandler(this.AddRecordsButtonClick);
//
// debugMainMenu
//
this.debugMainMenu.Name = "debugMainMenu";
this.debugMainMenu.Size = new System.Drawing.Size(87, 31);
this.debugMainMenu.Text = "&Debug";
this.debugMainMenu.Click += new System.EventHandler(this.debugMainMenu_Click);
//
// NewAddRecord
//
this.AutoScaleDimensions = new System.Drawing.SizeF(168F, 168F);
@@ -962,6 +962,7 @@
this.MinimumSize = new System.Drawing.Size(1000, 1000);
this.Name = "NewAddRecord";
this.Text = "Add New Record";
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
this.commentsGroupBox.ResumeLayout(false);
this.commentsGroupBox.PerformLayout();
this.mainTabControl.ResumeLayout(false);
+21 -9
View File
@@ -560,9 +560,13 @@ namespace AdvertsingProfitControl
if (result == DialogResult.Yes)
{
//Attempt to delete the row from the database by its ID number.
var projectionsRowId = int.Parse(projectionsDataGridView.Rows[currentRowIndex].Cells[(int)SalesTableColumns.Id].EditedFormattedValue.ToString());
var inventoryRowId = int.Parse(inventoryDataGridView.Rows[currentRowIndex].Cells[(int)SalesTableColumns.Id].EditedFormattedValue.ToString());
var actualSalesRowId = int.Parse(actualSalesDataGridView.Rows[currentRowIndex].Cells[(int)SalesTableColumns.Id].EditedFormattedValue.ToString());
int projectionsRowId;
int inventoryRowId;
int actualSalesRowId;
//Attempt to delete the row from the database by its ID number.
int.TryParse(projectionsDataGridView.Rows[currentRowIndex].Cells[(int)SalesTableColumns.Id].EditedFormattedValue.ToString(), out projectionsRowId);
int.TryParse(inventoryDataGridView.Rows[currentRowIndex].Cells[(int)SalesTableColumns.Id].EditedFormattedValue.ToString(), out inventoryRowId);
int.TryParse(actualSalesDataGridView.Rows[currentRowIndex].Cells[(int)SalesTableColumns.Id].EditedFormattedValue.ToString(), out actualSalesRowId);
if (dbWriter.DeleteApcRow(projectionsRowId, inventoryRowId, actualSalesRowId))
{
informationLabel.Text = @"Successfully removed row " + (currentRowIndex + 1) + @" from the database.";
@@ -589,9 +593,13 @@ namespace AdvertsingProfitControl
if (result == DialogResult.Yes)
{
//Attempt to delete the row from the database by its ID number.
var projectionsRowId = int.Parse(projectionsDataGridView.Rows[currentRowIndex].Cells[(int)SalesTableColumns.Id].EditedFormattedValue.ToString());
var inventoryRowId = int.Parse(inventoryDataGridView.Rows[currentRowIndex].Cells[(int)SalesTableColumns.Id].EditedFormattedValue.ToString());
var actualSalesRowId = int.Parse(actualSalesDataGridView.Rows[currentRowIndex].Cells[(int)SalesTableColumns.Id].EditedFormattedValue.ToString());
int projectionsRowId;
int inventoryRowId;
int actualSalesRowId;
//Attempt to delete the row from the database by its ID number.
int.TryParse(projectionsDataGridView.Rows[currentRowIndex].Cells[(int)SalesTableColumns.Id].EditedFormattedValue.ToString(), out projectionsRowId);
int.TryParse(inventoryDataGridView.Rows[currentRowIndex].Cells[(int)SalesTableColumns.Id].EditedFormattedValue.ToString(), out inventoryRowId);
int.TryParse(actualSalesDataGridView.Rows[currentRowIndex].Cells[(int)SalesTableColumns.Id].EditedFormattedValue.ToString(), out actualSalesRowId);
if (dbWriter.DeleteApcRow(projectionsRowId, inventoryRowId, actualSalesRowId))
{
informationLabel.Text = @"Successfully removed row " + (currentRowIndex + 1) + @" from the database.";
@@ -620,9 +628,13 @@ namespace AdvertsingProfitControl
if (result == DialogResult.Yes)
{
//Attempt to delete the row from the database by its ID number.
var projectionsRowId = int.Parse(projectionsDataGridView.Rows[currentRowIndex].Cells[(int) SalesTableColumns.Id].EditedFormattedValue.ToString());
var inventoryRowId = int.Parse(inventoryDataGridView.Rows[currentRowIndex].Cells[(int)SalesTableColumns.Id].EditedFormattedValue.ToString());
var actualSalesRowId = int.Parse(actualSalesDataGridView.Rows[currentRowIndex].Cells[(int)SalesTableColumns.Id].EditedFormattedValue.ToString());
int projectionsRowId;
int inventoryRowId;
int actualSalesRowId;
//Attempt to delete the row from the database by its ID number.
int.TryParse(projectionsDataGridView.Rows[currentRowIndex].Cells[(int)SalesTableColumns.Id].EditedFormattedValue.ToString(), out projectionsRowId);
int.TryParse(inventoryDataGridView.Rows[currentRowIndex].Cells[(int)SalesTableColumns.Id].EditedFormattedValue.ToString(), out inventoryRowId);
int.TryParse(actualSalesDataGridView.Rows[currentRowIndex].Cells[(int)SalesTableColumns.Id].EditedFormattedValue.ToString(), out actualSalesRowId);
if (dbWriter.DeleteApcRow(projectionsRowId, inventoryRowId, actualSalesRowId))
{
informationLabel.Text = @"Successfully removed row " + (currentRowIndex + 1) + @" from the database.";
+3
View File
@@ -953,6 +953,9 @@
this.MinimumSize = new System.Drawing.Size(1000, 1000);
this.Name = "NewModifyRecord";
this.Text = "Modify Record";
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.NewModifyRecord_FormClosing);
this.Load += new System.EventHandler(this.NewModifyRecord_Load);
this.mainLayoutPanel.ResumeLayout(false);
this.mainLayoutPanel.PerformLayout();
this.mainMenuStrip.ResumeLayout(false);
+69 -17
View File
@@ -47,9 +47,8 @@ namespace AdvertsingProfitControl
var databaseReader = new DatabaseReader();
weekEndingCalendar.BoldedDates = databaseReader.RetrieveDates(databaseTracker.DatabaseConnectionString).ToArray();
weekEndingCalendar.SelectionStart = date;
weekEndingCalendar.DateChanged += ValidateDateChanged;
_currentActiveDate = date;
Text = @"Modify Record (Current Record: " + date.ToString("d") + @")";
weekEndingCalendar.DateChanged += ValidateDateChanged;
//next pull all the ad items into memory.
_adItemCollection = databaseReader.GetAdItemsSuggestionList(databaseTracker.DatabaseConnectionString);
//Now pull all the suppliers and the ad special list into memory.
@@ -159,6 +158,7 @@ namespace AdvertsingProfitControl
//
_debugTabPage = mainTabControl.TabPages[4];
mainTabControl.TabPages.Remove(mainTabControl.TabPages[4]);
Text = @"Modify Record (Current Record: " + date.ToString("d") + @")";
LoadDate(date);
}
@@ -573,9 +573,13 @@ namespace AdvertsingProfitControl
if (result == DialogResult.Yes)
{
//Attempt to delete the row from the database by its ID number.
var projectionsRowId = int.Parse(projectionsDataGridView.Rows[currentRowIndex].Cells[(int)SalesTableColumns.Id].EditedFormattedValue.ToString());
var inventoryRowId = int.Parse(inventoryDataGridView.Rows[currentRowIndex].Cells[(int)SalesTableColumns.Id].EditedFormattedValue.ToString());
var actualSalesRowId = int.Parse(actualSalesDataGridView.Rows[currentRowIndex].Cells[(int)SalesTableColumns.Id].EditedFormattedValue.ToString());
int projectionsRowId;
int inventoryRowId;
int actualSalesRowId;
//Attempt to delete the row from the database by its ID number.
int.TryParse(projectionsDataGridView.Rows[currentRowIndex].Cells[(int)SalesTableColumns.Id].EditedFormattedValue.ToString(), out projectionsRowId);
int.TryParse(inventoryDataGridView.Rows[currentRowIndex].Cells[(int)SalesTableColumns.Id].EditedFormattedValue.ToString(), out inventoryRowId);
int.TryParse(actualSalesDataGridView.Rows[currentRowIndex].Cells[(int)SalesTableColumns.Id].EditedFormattedValue.ToString(), out actualSalesRowId);
if (dbWriter.DeleteApcRow(projectionsRowId, inventoryRowId, actualSalesRowId))
{
informationLabel.Text = @"Successfully removed row " + (currentRowIndex + 1) + @" from the database.";
@@ -602,9 +606,13 @@ namespace AdvertsingProfitControl
if (result == DialogResult.Yes)
{
//Attempt to delete the row from the database by its ID number.
var projectionsRowId = int.Parse(projectionsDataGridView.Rows[currentRowIndex].Cells[(int)SalesTableColumns.Id].EditedFormattedValue.ToString());
var inventoryRowId = int.Parse(inventoryDataGridView.Rows[currentRowIndex].Cells[(int)SalesTableColumns.Id].EditedFormattedValue.ToString());
var actualSalesRowId = int.Parse(actualSalesDataGridView.Rows[currentRowIndex].Cells[(int)SalesTableColumns.Id].EditedFormattedValue.ToString());
int projectionsRowId;
int inventoryRowId;
int actualSalesRowId;
//Attempt to delete the row from the database by its ID number.
int.TryParse(projectionsDataGridView.Rows[currentRowIndex].Cells[(int)SalesTableColumns.Id].EditedFormattedValue.ToString(), out projectionsRowId);
int.TryParse(inventoryDataGridView.Rows[currentRowIndex].Cells[(int)SalesTableColumns.Id].EditedFormattedValue.ToString(), out inventoryRowId);
int.TryParse(actualSalesDataGridView.Rows[currentRowIndex].Cells[(int)SalesTableColumns.Id].EditedFormattedValue.ToString(), out actualSalesRowId);
if (dbWriter.DeleteApcRow(projectionsRowId, inventoryRowId, actualSalesRowId))
{
informationLabel.Text = @"Successfully removed row " + (currentRowIndex + 1) + @" from the database.";
@@ -678,12 +686,16 @@ namespace AdvertsingProfitControl
if (dataGridView.Rows[currentRowIndex].Cells[(int)SalesTableColumns.Id].EditedFormattedValue.ToString() != string.Empty)
{
//Attempt to delete the row from the database by its ID number.
var projectionsRowId = int.Parse(projectionsDataGridView.Rows[currentRowIndex].Cells[(int)SalesTableColumns.Id].EditedFormattedValue.ToString());
var inventoryRowId = int.Parse(inventoryDataGridView.Rows[currentRowIndex].Cells[(int)SalesTableColumns.Id].EditedFormattedValue.ToString());
var actualSalesRowId = int.Parse(actualSalesDataGridView.Rows[currentRowIndex].Cells[(int)SalesTableColumns.Id].EditedFormattedValue.ToString());
int projectionsRowId;
int inventoryRowId;
int actualSalesRowId;
//Attempt to delete the row from the database by its ID number.
int.TryParse(projectionsDataGridView.Rows[currentRowIndex].Cells[(int)SalesTableColumns.Id].EditedFormattedValue.ToString(), out projectionsRowId);
int.TryParse(inventoryDataGridView.Rows[currentRowIndex].Cells[(int)SalesTableColumns.Id].EditedFormattedValue.ToString(), out inventoryRowId);
int.TryParse(actualSalesDataGridView.Rows[currentRowIndex].Cells[(int)SalesTableColumns.Id].EditedFormattedValue.ToString(), out actualSalesRowId);
if (dbWriter.DeleteApcRow(projectionsRowId, inventoryRowId, actualSalesRowId))
{
informationLabel.Text += @"Successfully removed row " + (currentRowIndex + 1) + @" from the database." + Environment.NewLine;
informationLabel.Text = @"Successfully removed row " + (currentRowIndex + 1) + @" from the database.";
}
else
{
@@ -3331,11 +3343,32 @@ namespace AdvertsingProfitControl
{
errorLabel.Text += @"Failed to process actual sales." + Environment.NewLine;
}
if (!SaveInvoices(dateId, displayInformation)) return false;
if (!SaveComments(dateId, displayInformation)) return false;
if (!SaveWeeklySales(dateId, displayInformation)) return false;
if (!SaveTaxable(dateId, displayInformation)) return false;
return SaveCostAnalysis(dateId, displayInformation) && success;
if (SaveInvoices(dateId, displayInformation))
{
success = false;
}
if (!SaveComments(dateId, displayInformation))
{
success = false;
}
if (!SaveWeeklySales(dateId, displayInformation))
{
success = false;
}
if (!SaveTaxable(dateId, displayInformation))
{
success = false;
}
if (!SaveCostAnalysis(dateId, displayInformation))
{
success = false;
}
//If everything went through properly then set the form as not dirty since all changes are saved.
if (success)
{
_isFormDirty = false;
}
return success;
}
/// <summary>
@@ -3896,6 +3929,25 @@ namespace AdvertsingProfitControl
SaveRecords();
}
private void NewModifyRecord_FormClosing(object sender, FormClosingEventArgs e)
{
if (!_isFormDirty) return;
var result = MessageBox.Show(@"Would you like to save the changes you have made?", @"Save Changes", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
if (result == DialogResult.Yes)
{
SaveRecords(false);
}
else if(result == DialogResult.Cancel)
{
e.Cancel = true;
}
}
private void NewModifyRecord_Load(object sender, EventArgs e)
{
}
//private void NormalizeApcTables(DataTable projections, DataTable inventory, DataTable actualSales, string dateId)
//{
@@ -120,4 +120,7 @@
<metadata name="mainMenuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="mainMenuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.9.0.0")]
[assembly: AssemblyFileVersion("1.9.0.0")]
[assembly: AssemblyVersion("1.9.2.0")]
[assembly: AssemblyFileVersion("1.9.2.0")]
@@ -1,21 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<asmv1:assembly xsi:schemaLocation="urn:schemas-microsoft-com:asm.v1 assembly.adaptive.xsd" manifestVersion="1.0" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns="urn:schemas-microsoft-com:asm.v2" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xrml="urn:mpeg:mpeg21:2003:01-REL-R-NS" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3" xmlns:dsig="http://www.w3.org/2000/09/xmldsig#" xmlns:co.v1="urn:schemas-microsoft-com:clickonce.v1" xmlns:co.v2="urn:schemas-microsoft-com:clickonce.v2">
<assemblyIdentity name="AdvertsingProfitControl.application" version="1.0.0.1" publicKeyToken="0000000000000000" language="neutral" processorArchitecture="amd64" xmlns="urn:schemas-microsoft-com:asm.v1" />
<description asmv2:publisher="AdvertsingProfitControl" asmv2:product="AdvertsingProfitControl" xmlns="urn:schemas-microsoft-com:asm.v1" />
<deployment install="true" mapFileExtensions="true" />
<compatibleFrameworks xmlns="urn:schemas-microsoft-com:clickonce.v2">
<framework targetVersion="4.5" profile="Full" supportedRuntime="4.0.30319" />
</compatibleFrameworks>
<dependency>
<dependentAssembly dependencyType="install" codebase="AdvertsingProfitControl.exe.manifest" size="7492">
<assemblyIdentity name="AdvertsingProfitControl.exe" version="1.0.0.1" publicKeyToken="0000000000000000" language="neutral" processorArchitecture="amd64" type="win32" />
<hash>
<dsig:Transforms>
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
</dsig:Transforms>
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
<dsig:DigestValue>wL0QcvSIuG+5RpyqBvd2ao+S04py2S9hhxRGkLgzCxI=</dsig:DigestValue>
</hash>
</dependentAssembly>
</dependency>
</asmv1:assembly>
@@ -1,139 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<asmv1:assembly xsi:schemaLocation="urn:schemas-microsoft-com:asm.v1 assembly.adaptive.xsd" manifestVersion="1.0" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns="urn:schemas-microsoft-com:asm.v2" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:co.v1="urn:schemas-microsoft-com:clickonce.v1" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3" xmlns:dsig="http://www.w3.org/2000/09/xmldsig#" xmlns:co.v2="urn:schemas-microsoft-com:clickonce.v2">
<asmv1:assemblyIdentity name="AdvertsingProfitControl.exe" version="1.0.0.1" publicKeyToken="0000000000000000" language="neutral" processorArchitecture="amd64" type="win32" />
<description asmv2:iconFile="Stretched Logo Collection.ico" xmlns="urn:schemas-microsoft-com:asm.v1" />
<application />
<entryPoint>
<assemblyIdentity name="AdvertsingProfitControl" version="1.9.0.0" language="neutral" processorArchitecture="amd64" />
<commandLine file="AdvertsingProfitControl.exe" parameters="" />
</entryPoint>
<trustInfo>
<security>
<applicationRequestMinimum>
<PermissionSet version="1" class="System.Security.NamedPermissionSet" Name="LocalIntranet" Description="Default rights given to applications on the local intranet" Unrestricted="true" ID="Custom" SameSite="site" />
<defaultAssemblyRequest permissionSetReference="Custom" />
</applicationRequestMinimum>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<!-- UAC Manifest Options
If you want to change the Windows User Account Control level replace the
requestedExecutionLevel node with one of the following.
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />
Specifying requestedExecutionLevel element will disable file and registry virtualization.
Remove this element if your application requires this virtualization for backwards
compatibility.
-->
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
</requestedPrivileges>
</security>
</trustInfo>
<dependency>
<dependentOS>
<osVersionInfo>
<os majorVersion="5" minorVersion="1" buildNumber="2600" servicePackMajor="0" />
</osVersionInfo>
</dependentOS>
</dependency>
<dependency>
<dependentAssembly dependencyType="preRequisite" allowDelayedBinding="true">
<assemblyIdentity name="Microsoft.Windows.CommonLanguageRuntime" version="4.0.30319.0" />
</dependentAssembly>
</dependency>
<dependency>
<dependentAssembly dependencyType="install" allowDelayedBinding="true" codebase="AdvertsingProfitControl.exe" size="3642368">
<assemblyIdentity name="AdvertsingProfitControl" version="1.9.0.0" language="neutral" processorArchitecture="amd64" />
<hash>
<dsig:Transforms>
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
</dsig:Transforms>
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
<dsig:DigestValue>+wWYuietw+BCATYFQjU6MraHUChvlqs8LdDZ5zoAEB0=</dsig:DigestValue>
</hash>
</dependentAssembly>
</dependency>
<dependency>
<dependentAssembly dependencyType="install" allowDelayedBinding="true" codebase="HtmlRenderer.dll" size="222208">
<assemblyIdentity name="HtmlRenderer" version="1.5.0.6" language="neutral" processorArchitecture="msil" />
<hash>
<dsig:Transforms>
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
</dsig:Transforms>
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
<dsig:DigestValue>VGr+ZzYUr4vMefSbFien3axjDZd7ylgpjfrMKI12ink=</dsig:DigestValue>
</hash>
</dependentAssembly>
</dependency>
<dependency>
<dependentAssembly dependencyType="install" allowDelayedBinding="true" codebase="HtmlRenderer.WinForms.dll" size="60416">
<assemblyIdentity name="HtmlRenderer.WinForms" version="1.5.0.6" language="neutral" processorArchitecture="msil" />
<hash>
<dsig:Transforms>
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
</dsig:Transforms>
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
<dsig:DigestValue>WF/zxFwKgeKM8FANZnlU0EY/IhL18w1Px1iKE75KJWM=</dsig:DigestValue>
</hash>
</dependentAssembly>
</dependency>
<file name="APCDatabase Template Script.sql" size="5400">
<hash>
<dsig:Transforms>
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
</dsig:Transforms>
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
<dsig:DigestValue>e48EkTyChGHXYJETENSLw7RKQ1LZ5ZDUghEtiv5DmqY=</dsig:DigestValue>
</hash>
</file>
<file name="APCDatabase.accdb" size="864256">
<hash>
<dsig:Transforms>
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
</dsig:Transforms>
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
<dsig:DigestValue>4BSEtKDqq4aQTfxV+PNjxEP3nnJgdxk0ksIfi4xSGI0=</dsig:DigestValue>
</hash>
</file>
<file name="APCTemplate.accdb" size="819200">
<hash>
<dsig:Transforms>
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
</dsig:Transforms>
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
<dsig:DigestValue>HWMXjUaEQtZd0vBm2k4ValXtZwmVzcqV0rERViSzOOc=</dsig:DigestValue>
</hash>
</file>
<file name="Stretched Logo Collection.ico" size="370070">
<hash>
<dsig:Transforms>
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
</dsig:Transforms>
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
<dsig:DigestValue>EhpcVkhatavmpmzYIlqLL5P0WB1QFP8mU66foV/5u+c=</dsig:DigestValue>
</hash>
</file>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- A list of the Windows versions that this application has been tested on and is
is designed to work with. Uncomment the appropriate elements and Windows will
automatically selected the most compatible environment. -->
<!-- Windows Vista -->
<!--<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" />-->
<!-- Windows 7 -->
<!--<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />-->
<!-- Windows 8 -->
<!--<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />-->
<!-- Windows 8.1 -->
<!--<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />-->
<!-- Windows 10 -->
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />
</application>
</compatibility>
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true/PM</dpiAware>
</windowsSettings>
</application>
</asmv1:assembly>