Marked as 'AdvertsingProfitControl No Print' by its folder name. Updated the 'Mordify Record' form. I believe the 'No Print' was related to creating a PDF version of the Advertising Profit Control sheet. The next version after this was most likely to have the code for that.
This commit is contained in:
@@ -35,9 +35,6 @@ namespace AdvertsingProfitControl
|
||||
public FrmAddRecord()
|
||||
{
|
||||
InitializeComponent();
|
||||
//Set the maximum and minimum sizes for the form.
|
||||
MaximumSize = new Size(1200, 650);
|
||||
MinimumSize = new Size(1000, 550);
|
||||
}
|
||||
|
||||
private void frmAddRecord_Load(object sender, EventArgs e)
|
||||
@@ -53,7 +50,7 @@ namespace AdvertsingProfitControl
|
||||
_AdSpecialList = databaseReader.RetrieveAdSpecialList(databaseTracker.DatabaseConnectionString);
|
||||
//Event handlers for the Projections DataGridView
|
||||
projectionsDataGridView.CellValidating += OnCellValidating;
|
||||
//projectionsDataGridView.RowEnter += DetectAndDisplayIncompleteRows;
|
||||
projectionsDataGridView.RowEnter += DetectAndDisplayIncompleteRows;
|
||||
projectionsDataGridView.RowLeave += OnRowLeave;
|
||||
projectionsDataGridView.RowsAdded += DisplayRowNumbers;
|
||||
projectionsDataGridView.RowsRemoved += OnRowRemoved;
|
||||
@@ -62,14 +59,14 @@ namespace AdvertsingProfitControl
|
||||
projectionsDataGridView.RowValidating += UpdateInventoryActualSalesDataGridView;
|
||||
|
||||
//Event handlers for the Inventory / Actual Sales DataGridView
|
||||
actualSalesDataGridView.CellValidating += OnCellValidating; //
|
||||
actualSalesDataGridView.CellValidating += OnCellValidating;
|
||||
actualSalesDataGridView.RowEnter += DetectAndDisplayIncompleteRows;
|
||||
actualSalesDataGridView.RowLeave += OnRowLeave; //
|
||||
actualSalesDataGridView.RowsAdded += DisplayRowNumbers;//
|
||||
actualSalesDataGridView.RowsRemoved += OnRowRemoved;//
|
||||
actualSalesDataGridView.UserDeletingRow += OnRowRemoving; //
|
||||
actualSalesDataGridView.EditingControlShowing += DisplayAutoCompleteOnEditingControlShowing; //
|
||||
actualSalesDataGridView.RowValidating += UpdateProjectionsDataGridView;//
|
||||
actualSalesDataGridView.RowLeave += OnRowLeave;
|
||||
actualSalesDataGridView.RowsAdded += DisplayRowNumbers;
|
||||
actualSalesDataGridView.RowsRemoved += OnRowRemoved;
|
||||
actualSalesDataGridView.UserDeletingRow += OnRowRemoving;
|
||||
actualSalesDataGridView.EditingControlShowing += DisplayAutoCompleteOnEditingControlShowing;
|
||||
actualSalesDataGridView.RowValidating += UpdateProjectionsDataGridView;
|
||||
|
||||
//Event handlers for the Suppliers DataGridView
|
||||
suppliersDataGridView.CellValidating += SupplierOnCellValidating;
|
||||
@@ -85,15 +82,14 @@ namespace AdvertsingProfitControl
|
||||
//Begin DataGridView event handlers
|
||||
/// <summary>
|
||||
/// Event Used: Leave
|
||||
/// Attempts to parse the date entered when the user leaves the DateMaskedTextbox.
|
||||
/// Clears the date if it is invalid, otherwise formats it and places it in the textbox.
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void OnWeekEndingDateMaskedTextBoxLeave(object sender, EventArgs e)
|
||||
{
|
||||
string input = weekEndingDateMaskedTextBox.Text;
|
||||
input = input.Replace(" ", ""); //The forwardslashes "/" in the masked textbox are sent programmically as spaces.
|
||||
input = input.Replace(" ", "");
|
||||
DateTime processedDate;
|
||||
if (!DateTime.TryParse(input, out processedDate))
|
||||
{
|
||||
@@ -108,7 +104,7 @@ namespace AdvertsingProfitControl
|
||||
|
||||
/// <summary>
|
||||
/// Event Used: CellValidating
|
||||
/// Performs formatting and validation based on what column the cell is in.
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
@@ -152,7 +148,7 @@ namespace AdvertsingProfitControl
|
||||
}
|
||||
}
|
||||
//Make an ugly check for the Inventory / Actual Sales table, and perform logic on the inventory columns to allow 'Bin(s) [0-9]'.
|
||||
if (dataGridView.Name == "inventoryActualSalesDataGridView" && e.ColumnIndex > 0 && e.ColumnIndex < 6 || dataGridView.Name == "projectionsDataGridView" && e.ColumnIndex == 1)
|
||||
if (dataGridView.Name == "inventoryActualSalesDataGridView" && e.ColumnIndex > 0 && e.ColumnIndex < 6)
|
||||
{
|
||||
var invenotryStringCheck = new Regex(@"^[0-9] \bbin(s){0,1}\b", RegexOptions.IgnoreCase);
|
||||
|
||||
@@ -169,7 +165,7 @@ namespace AdvertsingProfitControl
|
||||
}
|
||||
|
||||
//Check to see if whether or not the current cell is not in the first column and not empty.
|
||||
if (e.ColumnIndex != 0 && !string.IsNullOrEmpty(dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].EditedFormattedValue.ToString()))
|
||||
if (e.ColumnIndex != 0 && !String.IsNullOrEmpty(dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].EditedFormattedValue.ToString()))
|
||||
{
|
||||
//IF so, try to parse the contents to a Double and apply number formatting to the contents.
|
||||
//Check for the cost column to see if there are any strings formatted like such:
|
||||
@@ -567,7 +563,7 @@ namespace AdvertsingProfitControl
|
||||
{
|
||||
customAutoComplete.Add(item);
|
||||
}
|
||||
autoText.KeyDown += AutoText_KeyPress;
|
||||
autoText.KeyPress += AutoText_KeyPress;
|
||||
_CustomAdItemCollection = customAutoComplete; //Make a temporary copy of the list for use with the TextBox event handler.
|
||||
autoText.AutoCompleteMode = AutoCompleteMode.Suggest;
|
||||
autoText.AutoCompleteSource = AutoCompleteSource.CustomSource;
|
||||
@@ -579,29 +575,20 @@ namespace AdvertsingProfitControl
|
||||
}
|
||||
}//End DisplayAutoCompleteOnEditingControlShowing
|
||||
|
||||
private void AutoText_KeyPress(object sender, KeyEventArgs e)
|
||||
private void AutoText_KeyPress(object sender, KeyPressEventArgs e)
|
||||
{
|
||||
var textBox = (TextBox)sender;
|
||||
var textBox = (TextBox) sender;
|
||||
errorReportingLabel.Text = "";
|
||||
|
||||
if (e.Modifiers == Keys.Shift && e.KeyCode == Keys.Up)
|
||||
if (e.KeyChar == ':' && textBox.Text.Length == 0)
|
||||
{
|
||||
if (_gAdSpecialIndex == -1)
|
||||
{
|
||||
textBox.AutoCompleteCustomSource = _AdSpecialList;
|
||||
errorReportingLabel.Text = "Auto complete mode changed to Ad Special.";
|
||||
}
|
||||
else
|
||||
{
|
||||
errorReportingLabel.Text = "An Ad Special row already exists, auto complete mode\n can not be changed.";
|
||||
}
|
||||
textBox.AutoCompleteCustomSource = _AdSpecialList;
|
||||
errorReportingLabel.Text = "Auto complete mode changed to Ad Special.";
|
||||
}
|
||||
else if (e.Modifiers == Keys.Shift && e.KeyCode == Keys.Down)
|
||||
else if (e.KeyChar == ';' && textBox.Text.Length == 0)
|
||||
{
|
||||
textBox.AutoCompleteCustomSource = _CustomAdItemCollection;
|
||||
errorReportingLabel.Text = "Auto complete mode changed to Ad Items.";
|
||||
errorReportingLabel.Text = "Auto complete mode changed to Ad Items only.";
|
||||
}
|
||||
e.Handled = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -652,7 +639,7 @@ namespace AdvertsingProfitControl
|
||||
}
|
||||
_gLastAdItemEntered = projectionsDataGridView.Rows[e.RowIndex].Cells[0].EditedFormattedValue.ToString();
|
||||
//IF the current row is either a MemberRow OR an AdSpecialRow then only add the item in the first cell, place holder values are not needed.
|
||||
if (parser.GetRowAttribute(projectionsDataGridView.Rows[e.RowIndex]) == RowAttribute.MemberRow || parser.GetRowAttribute(projectionsDataGridView.Rows[e.RowIndex]) == RowAttribute.AdSpecialRow)
|
||||
if (parser.GetRowAttribute(projectionsDataGridView.Rows[e.RowIndex]) == "MemberRow" || parser.GetRowAttribute(projectionsDataGridView.Rows[e.RowIndex]) == "AdSpecialRow")
|
||||
{
|
||||
rowContents[0] = projectionsDataGridView.Rows[e.RowIndex].Cells[0].EditedFormattedValue.ToString();
|
||||
actualSalesDataGridView.Rows.Add(rowContents);
|
||||
@@ -726,7 +713,7 @@ namespace AdvertsingProfitControl
|
||||
if (actualSalesDataGridView.Rows[e.RowIndex].Cells[0].EditedFormattedValue.ToString() != "")
|
||||
{
|
||||
var parser = new RowParsing();
|
||||
object[] rowContents = new object[11];
|
||||
var rowContents = new string[11];
|
||||
//Check to make sure the user didn't simply leave a row that already exists.
|
||||
if (projectionsDataGridView.Rows[e.RowIndex].Cells[0].EditedFormattedValue.ToString() == actualSalesDataGridView.Rows[e.RowIndex].Cells[0].EditedFormattedValue.ToString())
|
||||
{
|
||||
@@ -755,7 +742,7 @@ namespace AdvertsingProfitControl
|
||||
}
|
||||
_gLastAdItemEntered = actualSalesDataGridView.Rows[e.RowIndex].Cells[0].EditedFormattedValue.ToString();
|
||||
//IF the current row is either a MemberRow OR an AdSpecialRow then only ad the item in the first cell, place holder values are not needed.
|
||||
if (parser.GetRowAttribute(actualSalesDataGridView.Rows[e.RowIndex]) == RowAttribute.MemberRow || parser.GetRowAttribute(actualSalesDataGridView.Rows[e.RowIndex]) == RowAttribute.AdSpecialRow)
|
||||
if (parser.GetRowAttribute(actualSalesDataGridView.Rows[e.RowIndex]) == "MemberRow" || parser.GetRowAttribute(actualSalesDataGridView.Rows[e.RowIndex]) == "AdSpecialRow")
|
||||
{
|
||||
rowContents[0] = actualSalesDataGridView.Rows[e.RowIndex].Cells[0].EditedFormattedValue.ToString();
|
||||
projectionsDataGridView.Rows.Add(rowContents);
|
||||
@@ -936,13 +923,13 @@ namespace AdvertsingProfitControl
|
||||
//Get the status of the current row.
|
||||
var rowStatus = parser.GetRowAttribute(dataGridView.Rows[i]);
|
||||
//IF the current row is a header row...
|
||||
if (rowStatus == RowAttribute.HeaderRow)
|
||||
if (rowStatus == "HeaderRow")
|
||||
{
|
||||
_gLastRowHeaderIndex = i;
|
||||
//Then check to see if the next row is a row header.
|
||||
rowStatus = parser.GetRowAttribute(dataGridView.Rows[i + 1]);
|
||||
//IF so, color code this row as White, since it is not a true group header.
|
||||
if (rowStatus != RowAttribute.HeaderRow)
|
||||
if (rowStatus != "HeaderRow")
|
||||
{
|
||||
dataGridView.Rows[i].DefaultCellStyle.BackColor = Color.White;
|
||||
}
|
||||
@@ -952,53 +939,53 @@ namespace AdvertsingProfitControl
|
||||
//The start by checking the previous row's status.
|
||||
rowStatus = parser.GetRowAttribute(dataGridView.Rows[i - 1]);
|
||||
//IF the previous row is a header row OR if the previous row is index zero AND a member row, clear its coloring.
|
||||
if (rowStatus == RowAttribute.HeaderRow || rowStatus == RowAttribute.MemberRow && (i - 1) == 0)
|
||||
if (rowStatus == "HeaderRow" || rowStatus == "MemberRow" && (i - 1) == 0)
|
||||
{
|
||||
dataGridView.Rows[i - 1].DefaultCellStyle.BackColor = Color.White;
|
||||
}
|
||||
//IF the previous row is a header row AND has color coding saying it is a group header, then clear its color and apply it to this row (i).
|
||||
else if (rowStatus == RowAttribute.HeaderRow && dataGridView.Rows[i - 1].DefaultCellStyle.BackColor == Color.LightGray)
|
||||
else if (rowStatus == "HeaderRow" && dataGridView.Rows[i - 1].DefaultCellStyle.BackColor == Color.LightGray)
|
||||
{
|
||||
dataGridView.Rows[i - 1].DefaultCellStyle.BackColor = Color.White;
|
||||
dataGridView.Rows[i].DefaultCellStyle.BackColor = Color.LightGray;
|
||||
}
|
||||
//IF previous row is Incomplete, then call the stable PaintRowGroups function.
|
||||
else if (rowStatus == RowAttribute.IncompleteRow)
|
||||
else if (rowStatus == "IncompleteRow")
|
||||
{
|
||||
PaintRowGroups(dataGridView);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (rowStatus == RowAttribute.MemberRow)
|
||||
else if (rowStatus == "MemberRow")
|
||||
{
|
||||
if (i > 0)
|
||||
{
|
||||
//Check the previous row.
|
||||
rowStatus = parser.GetRowAttribute(dataGridView.Rows[i - 1]);
|
||||
//IF the previous row is a member row AND is the first row in the data grid, then remove the coloring for it and the current row (i).
|
||||
if (rowStatus == RowAttribute.MemberRow && (i - 1) == 0)
|
||||
if (rowStatus == "MemberRow" && (i - 1) == 0)
|
||||
{
|
||||
dataGridView.Rows[i - 1].DefaultCellStyle.BackColor = Color.White;
|
||||
dataGridView.Rows[i].DefaultCellStyle.BackColor = Color.White;
|
||||
}
|
||||
//IF the previous row is a member row AND it also has color coding suggesting that it is a member of a group, then add the current row (i) as well.
|
||||
else if (rowStatus == RowAttribute.MemberRow && dataGridView.Rows[i - 1].DefaultCellStyle.BackColor == Color.LightBlue)
|
||||
else if (rowStatus == "MemberRow" && dataGridView.Rows[i - 1].DefaultCellStyle.BackColor == Color.LightBlue)
|
||||
{
|
||||
dataGridView.Rows[i].DefaultCellStyle.BackColor = Color.LightBlue;
|
||||
}
|
||||
//IF the previous row is simply a member row with no coloring at all, then remove the coloring from the current row (i).
|
||||
else if (rowStatus == RowAttribute.MemberRow || rowStatus == RowAttribute.AdSpecialRow)
|
||||
else if (rowStatus == "MemberRow" || rowStatus == "AdSpecialRow")
|
||||
{
|
||||
dataGridView.Rows[i].DefaultCellStyle.BackColor = Color.White;
|
||||
}
|
||||
//IF the previous row is a header row, then color it as a group header and color the current row as a member of said group.
|
||||
else if (rowStatus == RowAttribute.HeaderRow)
|
||||
else if (rowStatus == "HeaderRow")
|
||||
{
|
||||
dataGridView.Rows[i - 1].DefaultCellStyle.BackColor = Color.LightGray;
|
||||
dataGridView.Rows[i].DefaultCellStyle.BackColor = Color.LightBlue;
|
||||
}
|
||||
//IF the previous row is incomplete, then call the stable PaintRowGroups function.
|
||||
else if (rowStatus == RowAttribute.IncompleteRow)
|
||||
else if (rowStatus == "IncompleteRow")
|
||||
{
|
||||
PaintRowGroups(dataGridView);
|
||||
}
|
||||
@@ -1026,7 +1013,7 @@ namespace AdvertsingProfitControl
|
||||
//Get the current row's status.
|
||||
var rowType = parser.GetRowAttribute(row);
|
||||
//If the current row is not a group header, the first row in the grid, or a new row and in fact a member row...
|
||||
if (i != 0 && rowType == RowAttribute.MemberRow && !row.IsNewRow && rowType != RowAttribute.IncompleteRow)
|
||||
if (i != 0 && rowType == "MemberRow" && !row.IsNewRow && rowType != "IncompleteRow")
|
||||
{
|
||||
//Remove all coloring on the current row.
|
||||
dataGridView.Rows[i].DefaultCellStyle.BackColor = Color.White;
|
||||
@@ -1036,14 +1023,13 @@ namespace AdvertsingProfitControl
|
||||
{
|
||||
//Check to see if the previous row is a header row by subtracting the number of rows that are (incomplete + 1) from the total number of rows (i).
|
||||
//Adding one (1) to the incomplete count allows for checking the row right before the first incomplete row found so far to see if it's a header row.
|
||||
if (parser.GetRowAttribute(dataGridView.Rows[i - (1 + incompleteRowsFound)]) == RowAttribute.HeaderRow)
|
||||
if (parser.GetRowAttribute(dataGridView.Rows[i - (1 + incompleteRowsFound)]) == "HeaderRow")
|
||||
{
|
||||
row.DefaultCellStyle.BackColor = Color.LightBlue; //Group member
|
||||
dataGridView.Rows[lastHeaderIndex].DefaultCellStyle.BackColor = Color.LightGray; //Group header
|
||||
groupCount++;
|
||||
|
||||
statusReport +=
|
||||
$"\nGroup {groupCount} created with the header row {(i - incompleteRowsFound)} and the following row members: {(i + 1)} ";
|
||||
statusReport += string.Format("\nGroup {0} created with the header row {1} and the following row members: {2} ", groupCount, (i - incompleteRowsFound).ToString(), (i + 1).ToString());
|
||||
}
|
||||
//Else if a header row was not found from the previous operation but a header row is set, then its safe to assume that this row can be a member.
|
||||
else if (lastHeaderIndex >= 0)
|
||||
@@ -1059,22 +1045,21 @@ namespace AdvertsingProfitControl
|
||||
}
|
||||
}
|
||||
//If the current row is a potential group header AND the next row is as well remove the coloring from the current row, no need for checks.
|
||||
else if (rowType == RowAttribute.HeaderRow && parser.GetRowAttribute(dataGridView.Rows[i + 1]) == RowAttribute.HeaderRow)
|
||||
else if (rowType == "HeaderRow" && parser.GetRowAttribute(dataGridView.Rows[i + 1]) == "HeaderRow")
|
||||
{
|
||||
dataGridView.Rows[i].DefaultCellStyle.BackColor = Color.White;
|
||||
}
|
||||
//Check to see if this row is the first row, a header index row, AND the next row is a MemberRow.
|
||||
else if (rowType == RowAttribute.HeaderRow && parser.GetRowAttribute(dataGridView.Rows[i + 1]) == RowAttribute.MemberRow && i == 0)
|
||||
else if (rowType == "HeaderRow" && parser.GetRowAttribute(dataGridView.Rows[i + 1]) == "MemberRow" && i == 0)
|
||||
{
|
||||
//IF so, set the last header index, and color code of this row along with the next row which is a MemberRow.
|
||||
lastHeaderIndex = 0;
|
||||
dataGridView.Rows[0].DefaultCellStyle.BackColor = Color.LightGray;
|
||||
dataGridView.Rows[i + 1].DefaultCellStyle.BackColor = Color.LightBlue;
|
||||
statusReport +=
|
||||
$"Group {groupCount} created with the header row 1 and the following row member(s): {(i + 2)}";
|
||||
statusReport += string.Format("Group {0} created with the header row 1 and the following row member(s): {1}", groupCount, (i + 2).ToString());
|
||||
}
|
||||
//Check to see if this row is a group header.
|
||||
else if (rowType == RowAttribute.HeaderRow)
|
||||
else if (rowType == "HeaderRow")
|
||||
{
|
||||
//If so, reset the incomplete rows found count, set the lastHeaderIndex to this row's index (i) and change it's color to white.
|
||||
incompleteRowsFound = 0;
|
||||
@@ -1082,12 +1067,12 @@ namespace AdvertsingProfitControl
|
||||
dataGridView.Rows[i].DefaultCellStyle.BackColor = Color.White;
|
||||
}
|
||||
//If the current row is the first row in the grid AND is not a group header then remove all color from it, since its not allowed to be a header or a member.
|
||||
else if (i == 0 && rowType == RowAttribute.MemberRow)
|
||||
else if (i == 0 && rowType == "MemberRow")
|
||||
{
|
||||
dataGridView.Rows[i].DefaultCellStyle.BackColor = Color.White;
|
||||
}
|
||||
//Mark an incomplete row to determine whether or not we found one and remove any coloring it may have, incomplete rows are not allowed to be members or headers.
|
||||
if (rowType == RowAttribute.IncompleteRow)
|
||||
if (rowType == "IncompleteRow")
|
||||
{
|
||||
incompleteRowsFound++;
|
||||
dataGridView.Rows[i].DefaultCellStyle.BackColor = Color.White;
|
||||
@@ -1281,7 +1266,7 @@ namespace AdvertsingProfitControl
|
||||
//Get the current row's attribute.
|
||||
var currentRowAttribute = parser.GetRowAttribute(row);
|
||||
//IF the current row is invalid then skip it.
|
||||
if (currentRowAttribute == RowAttribute.IncompleteRow || currentRowAttribute == RowAttribute.MemberRow && rowIndexNumber == 0)
|
||||
if (currentRowAttribute == "IncompleteRow" || currentRowAttribute == "MemberRow" && rowIndexNumber == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -1301,12 +1286,12 @@ namespace AdvertsingProfitControl
|
||||
//BEGIN row attribute check.
|
||||
//Do an in-depth check to determine if the row should be marked with a "Header Row" group tag.
|
||||
//Only rows that have members will be explicitly marked as such.
|
||||
if (currentRowAttribute == RowAttribute.HeaderRow)
|
||||
if (currentRowAttribute == "HeaderRow")
|
||||
{
|
||||
if ((rowIndexNumber + 1) <= projectionsDataGridView.Rows.Count)
|
||||
{
|
||||
//Check to see if the next row is a Member Row.
|
||||
if ((parser.GetRowAttribute(projectionsDataGridView.Rows[rowIndexNumber + 1])) == RowAttribute.MemberRow)
|
||||
if ((parser.GetRowAttribute(projectionsDataGridView.Rows[rowIndexNumber + 1])) == "MemberRow")
|
||||
{
|
||||
//Set the current row's attribute to HeaderRow in the database.
|
||||
parameters[16] = "1";
|
||||
@@ -1321,7 +1306,7 @@ namespace AdvertsingProfitControl
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (currentRowAttribute == RowAttribute.MemberRow && lastHeaderRowNumber != -1)
|
||||
else if (currentRowAttribute == "MemberRow" && lastHeaderRowNumber != -1)
|
||||
{
|
||||
//ELSE IF this row is a member, then mark it as such.
|
||||
parameters[16] = "2";
|
||||
|
||||
Reference in New Issue
Block a user