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:
2021-01-28 19:58:37 -06:00
parent 665f4784e4
commit 75061c9d51
19 changed files with 904 additions and 2171 deletions
+23 -42
View File
@@ -6,23 +6,22 @@ using System.Linq;
namespace AdvertsingProfitControl
{
internal class RowParsing
class RowParsing
{
public static List<string> AdSpecialGroups = new List<string>();
public string CheckForGroupKeyWord(string cellContents)
{
string[] weekendAdIdentifiers = {"Weekend Ad", "Valentines", "Affiliated Weekend Ad", "Daily Coupons", "New Years Ad", "Christmas", "Mother's Day"};
var keyWord = "NoGroupFound";
var query = from adI in AdSpecialGroups
var query = from adI in weekendAdIdentifiers
where adI.Equals(cellContents, StringComparison.InvariantCultureIgnoreCase)
select adI;
var enumerable = query as string[] ?? query.ToArray();
if (enumerable.ToArray().Length > 0)
if (query.ToArray().Length > 0)
{
//Grab the first object in the array and return it.
keyWord = enumerable.ToArray().First();
keyWord = query.ToArray().First();
}
return keyWord;
@@ -32,26 +31,25 @@ namespace AdvertsingProfitControl
/// </summary>
/// <param name="row">The row from a DataGridView object to be examined.</param>
/// <returns>The row's status, such as HeaderRow or NewRow.</returns>
public RowAttribute GetRowAttribute(DataGridViewRow row)
public string GetRowAttribute(DataGridViewRow row)
{
//IF the supplied row is null, then simply declare it an IncompleteRow.
if (row == null)
{
return RowAttribute.IncompleteRow;
return "IncompleteRow";
}
//IF the supplied row is a new row, by the definition of the DataGridViewRow class, then return NewRow.
if (row.IsNewRow)
{
return RowAttribute.NewRow;
return "NewRow";
}
var rowContents = new List<string>();
var rowAttribute = RowAttribute.MemberRow;
var rowAttribute = "MemberRow";
//Get the contents of the row that's being examined and add then to a List<string> array.
var i = 0;
foreach (DataGridViewCell cell in row.Cells)
{
if (cell.ColumnIndex >= (int) SalesTableColumns.IsHeaderRow) { i++; continue;}
//Strip all whitespace characters from the cell, this includes vertical tabs, newlines, and any number of spaces.
var cellContentsStripped = new string(cell.EditedFormattedValue.ToString().Where(c => !char.IsWhiteSpace(c)).ToArray());
//Now remove all zeros, including any decimal points as these values are meaningless.
@@ -61,10 +59,10 @@ namespace AdvertsingProfitControl
{
rowContents.Add(cell.EditedFormattedValue.ToString());
}
//If the first cell contains nothing, then return as IncompleteRow.
else if (cellContentsStripped == "" && i == (int) SalesTableColumns.AdItem)
//If the first cell contains nothing, than return as IncompleteRow.
else if (cellContentsStripped == "" && i == 0)
{
return RowAttribute.IncompleteRow;
return "IncompleteRow";
}
i++;
}
@@ -73,7 +71,7 @@ namespace AdvertsingProfitControl
//cells with meaningful data in them. Which means that this row can be a header row with member rows under it.
if (rowContents.Count > 1)
{
rowAttribute = RowAttribute.HeaderRow;
rowAttribute = "HeaderRow";
}
else if (rowContents.Count == 1) //Check to see if this row is intended to be for a special ad.
{
@@ -81,31 +79,21 @@ namespace AdvertsingProfitControl
//IF a keyword is found then declare this row an AdSpecialRow.
if (keyWord != "NoGroupFound")
{
return RowAttribute.AdSpecialRow;
return "AdSpecialRow";
}
}
return rowAttribute;
}
public RowAttribute GetRowAttribute(object[] row)
{
var rowAttribute = RowAttribute.MemberRow;
return rowAttribute;
}
public void PaintDataGridViewRowGroups(DataGridView dataGridView, DataGridView companionDataGridView = null, int startIndex = 0,
public void PaintDataGridViewRowGroups(DataGridView dataGridView, int startIndex = 0,
bool stopOnFirstFullGroupFound = false)
{
}
/// <summary>
/// Checks for the presents of a repeat command using the Reg-ex engine.
/// Checks for the presents of a repeat command using the Regex engine.
/// If a repeat command is found it returns the line number the command
/// specifies to repeat.
/// </summary>
@@ -113,25 +101,18 @@ namespace AdvertsingProfitControl
/// <returns>Line number to be repeated, -1 if no command is found.</returns>
public int CheckForRepeatCommand(string rowCommandField)
{
const string repeatCommandPattern = @"^repeat( line)?:? [0-9]"; //Reference sheet: https://msdn.microsoft.com/en-us/library/az24scfc.aspx
var repeatCommandPattern = @"^repeat( line)?:? [0-9]"; //Reference sheet: https://msdn.microsoft.com/en-us/library/az24scfc.aspx
var rgx = new Regex(repeatCommandPattern, RegexOptions.IgnoreCase);
var lineNumber = -1;
if (!rgx.IsMatch(rowCommandField)) return lineNumber;
//Parse the string and retrieve the line number
var numbers = Regex.Split(rowCommandField, @"\D+");
if (rgx.IsMatch(rowCommandField))
{
//Parse the string and retrieve the line number
var numbers = Regex.Split(rowCommandField, @"\D+");
lineNumber = int.Parse(numbers[1]);
lineNumber = int.Parse(numbers[1]);
}
return lineNumber;
}
}
public enum RowAttribute
{
NewRow = 0,
MemberRow = 1,
HeaderRow = 2,
AdSpecialRow = 3,
IncompleteRow = 4
}
}