Marked as 'AdvertsingProfitControl' but located in a 'projects' folder. Added a new 'Add Record' form with a completely neww interface. This is the start of the final look of the the form that'd allow the user to add, update and remove records.
This commit is contained in:
@@ -6,15 +6,15 @@ using System.Linq;
|
||||
|
||||
namespace AdvertsingProfitControl
|
||||
{
|
||||
class RowParsing
|
||||
internal 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 weekendAdIdentifiers
|
||||
var query = from adI in _adSpecialGroups
|
||||
where adI.Equals(cellContents, StringComparison.InvariantCultureIgnoreCase)
|
||||
select adI;
|
||||
|
||||
@@ -31,21 +31,21 @@ 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 string GetRowAttribute(DataGridViewRow row)
|
||||
public RowAttribute GetRowAttribute(DataGridViewRow row)
|
||||
{
|
||||
//IF the supplied row is null, then simply declare it an IncompleteRow.
|
||||
if (row == null)
|
||||
{
|
||||
return "IncompleteRow";
|
||||
return RowAttribute.IncompleteRow;
|
||||
}
|
||||
//IF the supplied row is a new row, by the definition of the DataGridViewRow class, then return NewRow.
|
||||
if (row.IsNewRow)
|
||||
{
|
||||
return "NewRow";
|
||||
return RowAttribute.NewRow;
|
||||
}
|
||||
|
||||
var rowContents = new List<string>();
|
||||
var rowAttribute = "MemberRow";
|
||||
var rowAttribute = 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)
|
||||
@@ -59,10 +59,10 @@ namespace AdvertsingProfitControl
|
||||
{
|
||||
rowContents.Add(cell.EditedFormattedValue.ToString());
|
||||
}
|
||||
//If the first cell contains nothing, than return as IncompleteRow.
|
||||
//If the first cell contains nothing, then return as IncompleteRow.
|
||||
else if (cellContentsStripped == "" && i == 0)
|
||||
{
|
||||
return "IncompleteRow";
|
||||
return RowAttribute.IncompleteRow;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
@@ -71,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 = "HeaderRow";
|
||||
rowAttribute = RowAttribute.HeaderRow;
|
||||
}
|
||||
else if (rowContents.Count == 1) //Check to see if this row is intended to be for a special ad.
|
||||
{
|
||||
@@ -79,21 +79,31 @@ namespace AdvertsingProfitControl
|
||||
//IF a keyword is found then declare this row an AdSpecialRow.
|
||||
if (keyWord != "NoGroupFound")
|
||||
{
|
||||
return "AdSpecialRow";
|
||||
return RowAttribute.AdSpecialRow;
|
||||
}
|
||||
}
|
||||
|
||||
return rowAttribute;
|
||||
}
|
||||
|
||||
public void PaintDataGridViewRowGroups(DataGridView dataGridView, int startIndex = 0,
|
||||
public RowAttribute GetRowAttribute(object[] row)
|
||||
{
|
||||
var rowAttribute = RowAttribute.MemberRow;
|
||||
|
||||
|
||||
|
||||
return rowAttribute;
|
||||
}
|
||||
|
||||
public void PaintDataGridViewRowGroups(DataGridView dataGridView, DataGridView companionDataGridView = null, int startIndex = 0,
|
||||
bool stopOnFirstFullGroupFound = false)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks for the presents of a repeat command using the Regex engine.
|
||||
/// Checks for the presents of a repeat command using the Reg-ex engine.
|
||||
/// If a repeat command is found it returns the line number the command
|
||||
/// specifies to repeat.
|
||||
/// </summary>
|
||||
@@ -101,18 +111,25 @@ namespace AdvertsingProfitControl
|
||||
/// <returns>Line number to be repeated, -1 if no command is found.</returns>
|
||||
public int CheckForRepeatCommand(string rowCommandField)
|
||||
{
|
||||
var repeatCommandPattern = @"^repeat( line)?:? [0-9]"; //Reference sheet: https://msdn.microsoft.com/en-us/library/az24scfc.aspx
|
||||
const string 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))
|
||||
{
|
||||
//Parse the string and retrieve the line number
|
||||
var numbers = Regex.Split(rowCommandField, @"\D+");
|
||||
if (!rgx.IsMatch(rowCommandField)) return lineNumber;
|
||||
//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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user