diff --git a/.gitignore b/.gitignore
index 5779e47..1e2966a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,4 +7,5 @@ AdvertsingProfitControl/obj
DataTableParsingEngine/bin
DataTableParsingEngine/obj
SetupProject/bin
-SetupProject/obj
\ No newline at end of file
+SetupProject/obj
+.vs/
\ No newline at end of file
diff --git a/AdvertsingProfitControl/AdvertsingProfitControl.csproj b/AdvertsingProfitControl/AdvertsingProfitControl.csproj
index 779bfde..0fadd12 100644
--- a/AdvertsingProfitControl/AdvertsingProfitControl.csproj
+++ b/AdvertsingProfitControl/AdvertsingProfitControl.csproj
@@ -174,6 +174,8 @@
FrmReportSettings.cs
+
+
Form
diff --git a/AdvertsingProfitControl/FrmMain.cs b/AdvertsingProfitControl/FrmMain.cs
index 3bfb0fc..e2c6501 100644
--- a/AdvertsingProfitControl/FrmMain.cs
+++ b/AdvertsingProfitControl/FrmMain.cs
@@ -24,6 +24,11 @@ namespace AdvertsingProfitControl
{
InitializeComponent();
debugMainMenu.Visible = isDebug;
+ //var l = new Logger();
+ //Logger.WriteLog(DateTime.Now, "Main Form", "Test Critical", Level.Info);
+ //Logger.WriteLog(DateTime.Now, "Main Form", "Test verbose", Level.Verbose);
+ //Logger.WriteLog(DateTime.Now, "Form Main", "Test Debug Message", Level.Debug);
+ //l.ReadLogFile();
}
private void frmMain_Load(object sender, EventArgs e)
@@ -1120,7 +1125,7 @@ namespace AdvertsingProfitControl
private void testToolStripMenuItem_Click(object sender, EventArgs e)
{
-
+
}
}
}
\ No newline at end of file
diff --git a/AdvertsingProfitControl/GlobalClasses.cs b/AdvertsingProfitControl/GlobalClasses.cs
index 7cc7d2f..fbc2cc9 100644
--- a/AdvertsingProfitControl/GlobalClasses.cs
+++ b/AdvertsingProfitControl/GlobalClasses.cs
@@ -6,17 +6,31 @@ namespace AdvertsingProfitControl
{
internal class GlobalClasses
{
- public static string LogFilePath = @"C:\Users\" + Environment.UserName + @"\AppData\Local\APC\";
+ public static string LogFilePath = Path.GetPathRoot(Environment.SystemDirectory) + @"Users\" + Environment.UserName + @"\AppData\Local\APC\";
+ public GlobalClasses()
+ {
+ //Check to make sure the directory exists and if it doesn't then create it.
+ if (Directory.Exists(Logger.LogFolderPath)) return;
+ try
+ {
+ Directory.CreateDirectory(Logger.LogFolderPath);
+ }
+ catch (IOException e)
+ {
+ MessageBox.Show(e.Message + Environment.NewLine + @"Advertising Profit Control will be forced to exit.", @"Failed to Create Log File Directory", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ ///
+ /// Logs any error related to uncaught thread exceptions.
+ ///
+ ///
+ ///
public static void LogError(object sender, System.Threading.ThreadExceptionEventArgs e)
{
- if (!Directory.Exists(LogFilePath))
- {
- Directory.CreateDirectory(LogFilePath);
- }
using (
var file =
- new StreamWriter(@"C:\Users\" + Environment.UserName + @"\AppData\Local\APC\" + DateTime.Now.ToString("yy-MM-dd") + ".log", true))
+ new StreamWriter(Logger.LogFolderPath + DateTime.Now.ToString("yy-MM-dd") + ".log", true))
{
file.WriteLine(DateTime.Now + ": Unhandled Thread Exception:\n" + e.Exception.Message + Environment.NewLine);
MessageBox.Show(@"An unhandled thread exception has occurred. Advertising Profit Control will be forced to exit.",
@@ -25,29 +39,30 @@ namespace AdvertsingProfitControl
}
}
+ ///
+ /// Logs any unhandled exceptions that fires.
+ ///
+ ///
+ ///
public static void LogError(object sender, UnhandledExceptionEventArgs e)
{
- if (!Directory.Exists(LogFilePath))
- {
- Directory.CreateDirectory(LogFilePath);
- }
- using (var file = new StreamWriter(@"C:\Users\" + Environment.UserName + @"\AppData\Local\APC\" + DateTime.Now.ToString("yy-MM-dd") + ".log", true))
+ using (var file = new StreamWriter(Path.GetPathRoot(Environment.SystemDirectory) + @"Users\" + Environment.UserName + @"\AppData\Local\APC\" + DateTime.Now.ToString("yy-MM-dd") + ".log", true))
{
file.WriteLine(DateTime.Now + ": An unhandled exception occurred. \nException Object: " + e.ExceptionObject + Environment.NewLine);
- MessageBox.Show(@"And unknown error has occurred. Advertising Profit Control will be forced to exit.",
+ MessageBox.Show(@"An unknown error has occurred. Advertising Profit Control will be forced to exit.",
@"Fatal Error");
Application.Exit();
}
}
+ ///
+ /// Used to log anything from information for the user to errors that don't cause a total application failure.
+ ///
+ /// The message to log for future use.
public static void WriteToLog(string message)
{
- if (!Directory.Exists(LogFilePath))
- {
- Directory.CreateDirectory(LogFilePath);
- }
using (
- var file = new StreamWriter(@"C:\Users\" + Environment.UserName + @"\AppData\Local\APC\Information.log", true))
+ var file = new StreamWriter(Path.GetPathRoot(Environment.SystemDirectory) + @"Users\" + Environment.UserName + @"\AppData\Local\APC\Information.log", true))
{
file.WriteLine(message);
}
diff --git a/AdvertsingProfitControl/Log.cs b/AdvertsingProfitControl/Log.cs
new file mode 100644
index 0000000..1e3cad8
--- /dev/null
+++ b/AdvertsingProfitControl/Log.cs
@@ -0,0 +1,22 @@
+using System;
+
+namespace AdvertsingProfitControl
+{
+ public class Log
+ {
+ public DateTime Date { get; set; }
+ public string Source { get; set; }
+ public string Message { get; set; }
+ public Level Level { get; set; }
+ }
+
+ public enum Level
+ {
+ Critical = 0,
+ Error = 1,
+ Warning = 2,
+ Info = 3,
+ Verbose = 4,
+ Debug = 5
+ }
+}
diff --git a/AdvertsingProfitControl/Logger.cs b/AdvertsingProfitControl/Logger.cs
new file mode 100644
index 0000000..7090aba
--- /dev/null
+++ b/AdvertsingProfitControl/Logger.cs
@@ -0,0 +1,104 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Text;
+using System.Xml;
+using System.Xml.Serialization;
+
+namespace AdvertsingProfitControl
+{
+ internal class Logger
+ {
+ public static string LogFolderPath = Path.GetPathRoot(Environment.SystemDirectory) + @"Users\" + Environment.UserName + @"\AppData\Local\APC\";
+
+ ///
+ ///
+ ///
+ /// Date and time of the event.
+ /// The class or form name that generated the message.
+ /// Log message.
+ /// The log's level.
+ /// A Log object to optionally store for later use by the calling code.
+ public static Log WriteLog(DateTime date, string source, string message, Level level)
+ {
+ var log = new Log
+ {
+ Date = date,
+ Level = level,
+ Message = message,
+ Source = source
+ };
+ //Check to see if the message level is a critical (0) error.
+ //If it is not then simply return the Log object to the calling code.
+ if (level == Level.Critical)
+ {
+ //If the message is critical then write it to disk and return the Log object created.
+ using (var file = new StreamWriter(LogFolderPath + DateTime.Now.ToString("yy-MM-dd") + ".log", true))
+ {
+ file.WriteLine(SerializeLog(log));
+ }
+ }
+ else
+ {
+ using (var file = new StreamWriter(LogFolderPath + "information.log", true))
+ {
+ file.WriteLine(SerializeLog(log));
+ }
+ }
+ return log;
+ }
+
+ ///
+ ///
+ ///
+ ///
+ ///
+ public List ReadLogFile(string logFilePath = null)
+ {
+ var logs = new List();
+ //Check to see if a specific log file has been passed in.
+ if (logFilePath == null)
+ {
+ //If no specific log file has been passed then check to see if the
+ //default information log exists.
+ if (!File.Exists(LogFolderPath + "information.log"))
+ {
+ //If it doesn't then return an empty list.
+ return logs;
+ }
+ logFilePath = LogFolderPath + "information.log";
+ }
+
+ var myDeserializer = new XmlSerializer(typeof(List));
+ var myFileStream = new FileStream(logFilePath, FileMode.Open);
+ var stream = new StreamReader(myFileStream, Encoding.UTF8);
+ logs = (List)myDeserializer.Deserialize(stream);
+ myFileStream.Close();
+
+ return logs;
+ }
+
+ private static string SerializeLog(Log log)
+ {
+ var serializer = new XmlSerializer(typeof(Log));
+ string xml;
+
+ using (var sw = new StringWriter())
+ {
+ using (var writer = new XmlTextWriter(sw) {Formatting = Formatting.Indented})
+ {
+ writer.WriteStartElement("Log");
+ writer.WriteElementString("Date", log.Date.ToString("g"));
+ writer.WriteElementString("Level", log.Level.ToString());
+ writer.WriteElementString("Source", log.Source);
+ writer.WriteElementString("Message", log.Message);
+ writer.Close();
+ //serializer.Serialize(writer, log);
+ xml = sw.ToString();
+ }
+ }
+
+ return xml;
+ }
+ }
+}
diff --git a/AdvertsingProfitControl/NewModifyRecord.cs b/AdvertsingProfitControl/NewModifyRecord.cs
index 72b18f0..538825f 100644
--- a/AdvertsingProfitControl/NewModifyRecord.cs
+++ b/AdvertsingProfitControl/NewModifyRecord.cs
@@ -520,11 +520,16 @@ namespace AdvertsingProfitControl
//Paint the rows to identify what group they belong to.
if (dataGridView != inventoryDataGridView)
{
- TableGroupParser.PaintRowGroupsFromIndex(e.RowIndex, dataGridView);
+ //Paint the groups and check if the form should be marked as dirty.
+ if (TableGroupParser.PaintRowGroups(dataGridView, e.RowIndex))
+ {
+ _isFormDirty = true;
+ }
+ //TableGroupParser.PaintRowGroupsFromIndex(e.RowIndex, dataGridView);
}
else
{
- TableGroupParser.PaintInventoryRowGroups(e.RowIndex, inventoryDataGridView, actualSalesDataGridView);
+ //TODO: Update Inventory table parser.
}
//Add in used Ad Items to the list.
if (userInput == string.Empty) return;
@@ -1014,17 +1019,25 @@ namespace AdvertsingProfitControl
return;
}
//Update the color coding of the other tables.
- TableGroupParser.PaintRowGroupsFromIndex(e.RowIndex - 1, projectionsDataGridView);
+ //Paint the groups and check if the form should be marked as dirty.
+ if (TableGroupParser.PaintRowGroups(projectionsDataGridView, e.RowIndex, true))
+ {
+ _isFormDirty = true;
+ }
if (inventoryDataGridView.RowCount > e.RowIndex)
{
inventoryDataGridView.Rows[e.RowIndex].Cells[(int) TableGroupParser.InventoryTableColumns.AdItem].Value = userInput;
}
- TableGroupParser.PaintInventoryRowGroups(e.RowIndex - 1, inventoryDataGridView, actualSalesDataGridView); //TODO:CHANGED .PaintRowGroupsFromIndex(e.RowIndex - 1, inventoryDataGridView);
+ TableGroupParser.PaintInventoryRowGroups(e.RowIndex - 1, inventoryDataGridView, projectionsDataGridView); //TODO:CHANGED .PaintRowGroupsFromIndex(e.RowIndex - 1, inventoryDataGridView);
if (actualSalesDataGridView.RowCount > e.RowIndex)
{
actualSalesDataGridView.Rows[e.RowIndex].Cells[(int) TableGroupParser.SalesTableColumns.AdItem].Value = userInput;
}
- TableGroupParser.PaintRowGroupsFromIndex(e.RowIndex - 1, actualSalesDataGridView);
+ //Paint the groups and check if the form should be marked as dirty.
+ if (TableGroupParser.PaintRowGroups(actualSalesDataGridView, e.RowIndex, true))
+ {
+ _isFormDirty = true;
+ }
}
else
{
@@ -1392,7 +1405,7 @@ namespace AdvertsingProfitControl
projectionsDataGridView.RefreshEdit();
inventoryDataGridView.RefreshEdit();
actualSalesDataGridView.RefreshEdit();
- TableGroupParser.PaintRowGroups(dataGridView);
+ TableGroupParser.PaintRowGroups(dataGridView, 0);
}
#endregion
@@ -1532,17 +1545,25 @@ namespace AdvertsingProfitControl
return;
}
//Update the color coding of the other tables.
- TableGroupParser.PaintRowGroupsFromIndex(e.RowIndex - 1, projectionsDataGridView);
+ //Paint the groups and check if the form should be marked as dirty.
+ if (TableGroupParser.PaintRowGroups(projectionsDataGridView, e.RowIndex, true))
+ {
+ _isFormDirty = true;
+ }
if (inventoryDataGridView.RowCount > e.RowIndex)
{
inventoryDataGridView.Rows[e.RowIndex].Cells[(int)TableGroupParser.InventoryTableColumns.AdItem].Value = userInput;
}
- TableGroupParser.PaintInventoryRowGroups(e.RowIndex - 1, inventoryDataGridView, actualSalesDataGridView); //TODO:CHANGE .PaintRowGroupsFromIndex(e.RowIndex - 1, inventoryDataGridView);
+ TableGroupParser.PaintInventoryRowGroups(e.RowIndex - 1, inventoryDataGridView, projectionsDataGridView); //TODO:CHANGE .PaintRowGroupsFromIndex(e.RowIndex - 1, inventoryDataGridView);
if (actualSalesDataGridView.RowCount > e.RowIndex)
{
actualSalesDataGridView.Rows[e.RowIndex].Cells[(int)TableGroupParser.SalesTableColumns.AdItem].Value = userInput;
}
- TableGroupParser.PaintRowGroupsFromIndex(e.RowIndex - 1, actualSalesDataGridView);
+ //Paint the groups and check if the form should be marked as dirty.
+ if (TableGroupParser.PaintRowGroups(actualSalesDataGridView, e.RowIndex, true))
+ {
+ _isFormDirty = true;
+ }
}
else
{
@@ -1863,7 +1884,7 @@ out double beginningBinCount, out string newBinText))
projectionsDataGridView.RefreshEdit();
inventoryDataGridView.RefreshEdit();
actualSalesDataGridView.RefreshEdit();
- TableGroupParser.PaintInventoryRowGroups(0, inventoryDataGridView, actualSalesDataGridView); //TODO: CHANEG.PaintRowGroups(dataGridView);
+ TableGroupParser.PaintInventoryRowGroups(0, inventoryDataGridView, projectionsDataGridView); //TODO: CHANEG.PaintRowGroups(dataGridView);
}
#endregion
@@ -2079,7 +2100,7 @@ out double beginningBinCount, out string newBinText))
projectionsDataGridView.RefreshEdit();
inventoryDataGridView.RefreshEdit();
actualSalesDataGridView.RefreshEdit();
- TableGroupParser.PaintRowGroups(dataGridView);
+ TableGroupParser.PaintRowGroups(dataGridView, 0);
}
#endregion
@@ -2132,7 +2153,7 @@ out double beginningBinCount, out string newBinText))
Name = name,
HeaderText = TextFormat.AddSpacesToSentence(name, false),
ValueType = typeof(bool),
- Visible = false,
+ //Visible = false,
SortMode = DataGridViewColumnSortMode.NotSortable
};
projectionsDataGridView.Columns.Add(column);
@@ -3282,9 +3303,10 @@ out double beginningBinCount, out string newBinText))
try
{
//Force update all the data tables.
- //TableGroupParser.PaintRowGroupsFromIndex(0, projectionsDataGridView);
- //TableGroupParser.PaintRowGroupsFromIndex(0, inventoryDataGridView);
- //TableGroupParser.PaintRowGroupsFromIndex(0, actualSalesDataGridView);
+ //Paint the groups and check if the form should be marked as dirty.
+ TableGroupParser.PaintRowGroups(projectionsDataGridView, 0, true);
+ TableGroupParser.PaintRowGroups(inventoryDataGridView, 0, true);
+ TableGroupParser.PaintRowGroups(actualSalesDataGridView, 0, true);
using (var scope = new TransactionScope())
{
SaveProjections(date);
diff --git a/AdvertsingProfitControl/Properties/AssemblyInfo.cs b/AdvertsingProfitControl/Properties/AssemblyInfo.cs
index 77a933c..6c6e9ec 100644
--- a/AdvertsingProfitControl/Properties/AssemblyInfo.cs
+++ b/AdvertsingProfitControl/Properties/AssemblyInfo.cs
@@ -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("3.1.2.0")]
-[assembly: AssemblyFileVersion("3.1.2.0")]
+[assembly: AssemblyVersion("3.2.0.0")]
+[assembly: AssemblyFileVersion("3.2.0.0")]
diff --git a/AdvertsingProfitControl/obj/Debug/AdvertsingProfitControl.csproj.FileListAbsolute.txt b/AdvertsingProfitControl/obj/Debug/AdvertsingProfitControl.csproj.FileListAbsolute.txt
index e0b4939..bbf1245 100644
--- a/AdvertsingProfitControl/obj/Debug/AdvertsingProfitControl.csproj.FileListAbsolute.txt
+++ b/AdvertsingProfitControl/obj/Debug/AdvertsingProfitControl.csproj.FileListAbsolute.txt
@@ -1,23 +1,49 @@
-C:\Users\glmcc\Documents\Source Control\AdvertisingProfitControl\AdvertsingProfitControl\obj\Debug\AdvertsingProfitControl.csprojResolveAssemblyReference.cache
-C:\Users\glmcc\Documents\Source Control\AdvertisingProfitControl\AdvertsingProfitControl\obj\Debug\AdvertsingProfitControl.DebugDatabaseConverter.resources
-C:\Users\glmcc\Documents\Source Control\AdvertisingProfitControl\AdvertsingProfitControl\obj\Debug\AdvertsingProfitControl.FrmAddRecord.resources
-C:\Users\glmcc\Documents\Source Control\AdvertisingProfitControl\AdvertsingProfitControl\obj\Debug\AdvertsingProfitControl.FrmMain.resources
-C:\Users\glmcc\Documents\Source Control\AdvertisingProfitControl\AdvertsingProfitControl\obj\Debug\AdvertsingProfitControl.FrmLogConsole.resources
-C:\Users\glmcc\Documents\Source Control\AdvertisingProfitControl\AdvertsingProfitControl\obj\Debug\AdvertsingProfitControl.FrmRegisterAdSpecial.resources
-C:\Users\glmcc\Documents\Source Control\AdvertisingProfitControl\AdvertsingProfitControl\obj\Debug\AdvertsingProfitControl.NewModifyRecord.resources
-C:\Users\glmcc\Documents\Source Control\AdvertisingProfitControl\AdvertsingProfitControl\obj\Debug\AdvertsingProfitControl.Properties.Resources.resources
-C:\Users\glmcc\Documents\Source Control\AdvertisingProfitControl\AdvertsingProfitControl\obj\Debug\AdvertsingProfitControl.csproj.GenerateResource.Cache
-C:\Users\glmcc\Documents\Source Control\AdvertisingProfitControl\AdvertsingProfitControl\bin\Debug\APCDatabase.accdb
-C:\Users\glmcc\Documents\Source Control\AdvertisingProfitControl\AdvertsingProfitControl\bin\Debug\AdvertsingProfitControl.exe.config
-C:\Users\glmcc\Documents\Source Control\AdvertisingProfitControl\AdvertsingProfitControl\bin\Debug\AdvertsingProfitControl.exe
-C:\Users\glmcc\Documents\Source Control\AdvertisingProfitControl\AdvertsingProfitControl\bin\Debug\AdvertsingProfitControl.pdb
-C:\Users\glmcc\Documents\Source Control\AdvertisingProfitControl\AdvertsingProfitControl\bin\Debug\EntityFramework.dll
-C:\Users\glmcc\Documents\Source Control\AdvertisingProfitControl\AdvertsingProfitControl\bin\Debug\EntityFramework.SqlServer.dll
-C:\Users\glmcc\Documents\Source Control\AdvertisingProfitControl\AdvertsingProfitControl\bin\Debug\HtmlRenderer.dll
-C:\Users\glmcc\Documents\Source Control\AdvertisingProfitControl\AdvertsingProfitControl\bin\Debug\HtmlRenderer.WinForms.dll
-C:\Users\glmcc\Documents\Source Control\AdvertisingProfitControl\AdvertsingProfitControl\bin\Debug\EntityFramework.xml
-C:\Users\glmcc\Documents\Source Control\AdvertisingProfitControl\AdvertsingProfitControl\bin\Debug\EntityFramework.SqlServer.xml
-C:\Users\glmcc\Documents\Source Control\AdvertisingProfitControl\AdvertsingProfitControl\bin\Debug\HtmlRenderer.pdb
-C:\Users\glmcc\Documents\Source Control\AdvertisingProfitControl\AdvertsingProfitControl\bin\Debug\HtmlRenderer.WinForms.pdb
-C:\Users\glmcc\Documents\Source Control\AdvertisingProfitControl\AdvertsingProfitControl\obj\Debug\AdvertsingProfitControl.exe
-C:\Users\glmcc\Documents\Source Control\AdvertisingProfitControl\AdvertsingProfitControl\obj\Debug\AdvertsingProfitControl.pdb
+C:\Users\Crypto\Documents\Source Control\AdvertisingProfitControl\AdvertsingProfitControl\bin\Debug\APCDatabase.accdb
+C:\Users\Crypto\Documents\Source Control\AdvertisingProfitControl\AdvertsingProfitControl\bin\Debug\libeay32.dll
+C:\Users\Crypto\Documents\Source Control\AdvertisingProfitControl\AdvertsingProfitControl\bin\Debug\libgcc_s_dw2-1.dll
+C:\Users\Crypto\Documents\Source Control\AdvertisingProfitControl\AdvertsingProfitControl\bin\Debug\mingwm10.dll
+C:\Users\Crypto\Documents\Source Control\AdvertisingProfitControl\AdvertsingProfitControl\bin\Debug\ssleay32.dll
+C:\Users\Crypto\Documents\Source Control\AdvertisingProfitControl\AdvertsingProfitControl\bin\Debug\wkhtmltox0.dll
+C:\Users\Crypto\Documents\Source Control\AdvertisingProfitControl\AdvertsingProfitControl\bin\Debug\AdvertsingProfitControl.exe.config
+C:\Users\Crypto\Documents\Source Control\AdvertisingProfitControl\AdvertsingProfitControl\bin\Debug\AdvertsingProfitControl.exe
+C:\Users\Crypto\Documents\Source Control\AdvertisingProfitControl\AdvertsingProfitControl\bin\Debug\AdvertsingProfitControl.pdb
+C:\Users\Crypto\Documents\Source Control\AdvertisingProfitControl\AdvertsingProfitControl\bin\Debug\AdvertisingProfitControlData.dll
+C:\Users\Crypto\Documents\Source Control\AdvertisingProfitControl\AdvertsingProfitControl\bin\Debug\Common.Logging.Core.dll
+C:\Users\Crypto\Documents\Source Control\AdvertisingProfitControl\AdvertsingProfitControl\bin\Debug\Common.Logging.dll
+C:\Users\Crypto\Documents\Source Control\AdvertisingProfitControl\AdvertsingProfitControl\bin\Debug\DataTableParsingEngine.dll
+C:\Users\Crypto\Documents\Source Control\AdvertisingProfitControl\AdvertsingProfitControl\bin\Debug\EntityFramework.dll
+C:\Users\Crypto\Documents\Source Control\AdvertisingProfitControl\AdvertsingProfitControl\bin\Debug\EntityFramework.SqlServer.dll
+C:\Users\Crypto\Documents\Source Control\AdvertisingProfitControl\AdvertsingProfitControl\bin\Debug\Pechkin.dll
+C:\Users\Crypto\Documents\Source Control\AdvertisingProfitControl\AdvertsingProfitControl\bin\Debug\Spire.License.dll
+C:\Users\Crypto\Documents\Source Control\AdvertisingProfitControl\AdvertsingProfitControl\bin\Debug\Spire.Pdf.dll
+C:\Users\Crypto\Documents\Source Control\AdvertisingProfitControl\AdvertsingProfitControl\bin\Debug\Microsoft.mshtml.dll
+C:\Users\Crypto\Documents\Source Control\AdvertisingProfitControl\AdvertsingProfitControl\bin\Debug\AdvertisingProfitControlData.pdb
+C:\Users\Crypto\Documents\Source Control\AdvertisingProfitControl\AdvertsingProfitControl\bin\Debug\AdvertisingProfitControlData.dll.config
+C:\Users\Crypto\Documents\Source Control\AdvertisingProfitControl\AdvertsingProfitControl\bin\Debug\DataTableParsingEngine.pdb
+C:\Users\Crypto\Documents\Source Control\AdvertisingProfitControl\AdvertsingProfitControl\bin\Debug\DataTableParsingEngine.dll.config
+C:\Users\Crypto\Documents\Source Control\AdvertisingProfitControl\AdvertsingProfitControl\bin\Debug\Common.Logging.pdb
+C:\Users\Crypto\Documents\Source Control\AdvertisingProfitControl\AdvertsingProfitControl\bin\Debug\Common.Logging.xml
+C:\Users\Crypto\Documents\Source Control\AdvertisingProfitControl\AdvertsingProfitControl\bin\Debug\Common.Logging.Core.pdb
+C:\Users\Crypto\Documents\Source Control\AdvertisingProfitControl\AdvertsingProfitControl\bin\Debug\Common.Logging.Core.xml
+C:\Users\Crypto\Documents\Source Control\AdvertisingProfitControl\AdvertsingProfitControl\bin\Debug\EntityFramework.xml
+C:\Users\Crypto\Documents\Source Control\AdvertisingProfitControl\AdvertsingProfitControl\bin\Debug\EntityFramework.SqlServer.xml
+C:\Users\Crypto\Documents\Source Control\AdvertisingProfitControl\AdvertsingProfitControl\bin\Debug\Spire.License.xml
+C:\Users\Crypto\Documents\Source Control\AdvertisingProfitControl\AdvertsingProfitControl\bin\Debug\Spire.Pdf.xml
+C:\Users\Crypto\Documents\Source Control\AdvertisingProfitControl\AdvertsingProfitControl\obj\Debug\AdvertsingProfitControl.csprojResolveAssemblyReference.cache
+C:\Users\Crypto\Documents\Source Control\AdvertisingProfitControl\AdvertsingProfitControl\obj\Debug\AdvertsingProfitControl.AboutBox.resources
+C:\Users\Crypto\Documents\Source Control\AdvertisingProfitControl\AdvertsingProfitControl\obj\Debug\AdvertsingProfitControl.DatabaseRecovery.resources
+C:\Users\Crypto\Documents\Source Control\AdvertisingProfitControl\AdvertsingProfitControl\obj\Debug\AdvertsingProfitControl.FrmAddRecord.resources
+C:\Users\Crypto\Documents\Source Control\AdvertisingProfitControl\AdvertsingProfitControl\obj\Debug\AdvertsingProfitControl.FrmChangeShrink.resources
+C:\Users\Crypto\Documents\Source Control\AdvertisingProfitControl\AdvertsingProfitControl\obj\Debug\AdvertsingProfitControl.FrmLogFileViewer.resources
+C:\Users\Crypto\Documents\Source Control\AdvertisingProfitControl\AdvertsingProfitControl\obj\Debug\AdvertsingProfitControl.FrmLoginForm.resources
+C:\Users\Crypto\Documents\Source Control\AdvertisingProfitControl\AdvertsingProfitControl\obj\Debug\AdvertsingProfitControl.FrmMain.resources
+C:\Users\Crypto\Documents\Source Control\AdvertisingProfitControl\AdvertsingProfitControl\obj\Debug\AdvertsingProfitControl.FrmLogConsole.resources
+C:\Users\Crypto\Documents\Source Control\AdvertisingProfitControl\AdvertsingProfitControl\obj\Debug\AdvertsingProfitControl.FrmManageAdItems.resources
+C:\Users\Crypto\Documents\Source Control\AdvertisingProfitControl\AdvertsingProfitControl\obj\Debug\AdvertsingProfitControl.FrmManageSuppliers.resources
+C:\Users\Crypto\Documents\Source Control\AdvertisingProfitControl\AdvertsingProfitControl\obj\Debug\AdvertsingProfitControl.FrmRegisterAdSpecial.resources
+C:\Users\Crypto\Documents\Source Control\AdvertisingProfitControl\AdvertsingProfitControl\obj\Debug\AdvertsingProfitControl.FrmReportSettings.resources
+C:\Users\Crypto\Documents\Source Control\AdvertisingProfitControl\AdvertsingProfitControl\obj\Debug\AdvertsingProfitControl.NewModifyRecord.resources
+C:\Users\Crypto\Documents\Source Control\AdvertisingProfitControl\AdvertsingProfitControl\obj\Debug\AdvertsingProfitControl.Properties.Resources.resources
+C:\Users\Crypto\Documents\Source Control\AdvertisingProfitControl\AdvertsingProfitControl\obj\Debug\AdvertsingProfitControl.csproj.GenerateResource.Cache
+C:\Users\Crypto\Documents\Source Control\AdvertisingProfitControl\AdvertsingProfitControl\obj\Debug\AdvertsingProfitControl.exe
+C:\Users\Crypto\Documents\Source Control\AdvertisingProfitControl\AdvertsingProfitControl\obj\Debug\AdvertsingProfitControl.pdb
diff --git a/DataTableParsingEngine/Properties/AssemblyInfo.cs b/DataTableParsingEngine/Properties/AssemblyInfo.cs
index 9925f96..52c44a9 100644
--- a/DataTableParsingEngine/Properties/AssemblyInfo.cs
+++ b/DataTableParsingEngine/Properties/AssemblyInfo.cs
@@ -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.1.0.0")]
-[assembly: AssemblyFileVersion("1.1.0.0")]
+[assembly: AssemblyVersion("1.5.0.0")]
+[assembly: AssemblyFileVersion("1.5.0.0")]
diff --git a/DataTableParsingEngine/RowParser.cs b/DataTableParsingEngine/RowParser.cs
index bdb3428..5ab40f2 100644
--- a/DataTableParsingEngine/RowParser.cs
+++ b/DataTableParsingEngine/RowParser.cs
@@ -109,7 +109,8 @@ namespace DataTableParsingEngine
AdSpecialRow = 2,
RepeatedRow = 3,
MemberRow = 4,
- HeaderRow = 5
+ HeaderRow = 5,
+ UnAssigned = 6
}
}
}
diff --git a/DataTableParsingEngine/TableGroupParser.cs b/DataTableParsingEngine/TableGroupParser.cs
index 013bf67..8d80d6b 100644
--- a/DataTableParsingEngine/TableGroupParser.cs
+++ b/DataTableParsingEngine/TableGroupParser.cs
@@ -12,303 +12,225 @@ namespace DataTableParsingEngine
/// fired the row leave even. As opposed to the PaintRowGroups function which spins through all the
/// DataGridView's rows.
///
+ /// The DataGridView to parse.
/// The starting index (the row that fired the RowLeave event)
- /// The DataGridView to parse.
- public static void PaintRowGroupsFromIndex(int startingIndex, DataGridView dataGridView)
+ /// True to force a full scan of all rows beginning at the starting index.
+ public static bool PaintRowGroups(DataGridView table, int startingIndex, bool fullScan = false)
{
- //Underflow protection for the lazy.
- if (startingIndex < 0)
- {
- return;
- }
-
var parser = new RowParser();
- var isHeaderColumn = (int)SalesTableColumns.IsHeaderRow;
- var isMemberColumn = (int)SalesTableColumns.IsMemberRow;
- var isDirtyColumn = (int)SalesTableColumns.IsDirty;
- if (dataGridView.ColumnCount < Enum.GetNames(typeof(SalesTableColumns)).Length)
+ var isHeaderColumn = (int) SalesTableColumns.IsHeaderRow;
+ var isMemberColumn = (int) SalesTableColumns.IsMemberRow;
+ var isDirtyColumn = (int) SalesTableColumns.IsDirty;
+ var updatesOccured = false;
+ if (table.ColumnCount < Enum.GetNames(typeof(SalesTableColumns)).Length)
{
- isHeaderColumn = (int)InventoryTableColumns.IsHeaderRow;
- isMemberColumn = (int)InventoryTableColumns.IsMemberRow;
- isDirtyColumn = (int)InventoryTableColumns.IsDirty;
+ isHeaderColumn = (int) InventoryTableColumns.IsHeaderRow;
+ isMemberColumn = (int) InventoryTableColumns.IsMemberRow;
+ isDirtyColumn = (int) InventoryTableColumns.IsDirty;
}
//Spin through the dataGridView rows starting at the row that fired the event.
- for (var i = startingIndex; i < (dataGridView.RowCount - 1); i++)
+ for (var i = startingIndex; i < (table.RowCount - 1); i++)
{
//Get the status of the current row.
- var rowStatus = parser.GetRowAttribute(dataGridView.Rows[i]);
- //IF the current row is a header row...
- if (rowStatus == RowParser.RowAttribute.HeaderRow)
+ var currentRowAttribute = parser.GetRowAttribute(table.Rows[i]);
+ //Get the previous row's status.
+ var previousRow = RowParser.RowAttribute.UnAssigned;
+ if (i > 0)
{
- //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 == RowParser.RowAttribute.HeaderRow)
+ previousRow = parser.GetRowAttribute(table.Rows[i - 1]);
+ }
+ //Get the next row's attribute.
+ var nextRow = RowParser.RowAttribute.UnAssigned;
+ if ((i + 1) < table.RowCount)
+ {
+ nextRow = parser.GetRowAttribute(table.Rows[i + 1]);
+ }
+ //If current row is a header row...
+ if (currentRowAttribute == RowParser.RowAttribute.HeaderRow)
+ {
+ //...and the current row is index zero or the previous row is a header row
+ //then clear color coding from both.
+ if (previousRow == RowParser.RowAttribute.HeaderRow)
{
- //Clear the current row of its attributes.
- dataGridView.Rows[i].Cells[isHeaderColumn].Value = false;
- dataGridView.Rows[i].Cells[isMemberColumn].Value = false;
- dataGridView.Rows[i].DefaultCellStyle.BackColor = default(Color);
- return;
- }
- //IF the current row is not the first row in the data grid (index zero)...
- if (i > 0)
- {
- //The start by checking the previous row's status.
- rowStatus = parser.GetRowAttribute(dataGridView.Rows[i - 1]);
- //IF the previous row is a header row AND has color coding saying it is a group header, then clear the previous row's color and apply it to this row (i).
- if (rowStatus == RowParser.RowAttribute.HeaderRow && (bool)dataGridView.Rows[i - 1].Cells[isHeaderColumn].EditedFormattedValue)
+ //Check the previous row's attributes to see if it needs to be marked for updating.
+ if ((bool) table.Rows[i - 1].Cells[isHeaderColumn].EditedFormattedValue ||
+ (bool) table.Rows[i - 1].Cells[isMemberColumn].EditedFormattedValue)
{
- //Clear the previous row of its attributes.
- dataGridView.Rows[i - 1].Cells[isHeaderColumn].Value = false;
- dataGridView.Rows[i - 1].Cells[isMemberColumn].Value = false;
- //This condition means the user changed the members of a group, so the old header row needs to be updated in the database.
- dataGridView.Rows[i - 1].Cells[isDirtyColumn].Value = true;
- dataGridView.Rows[i - 1].HeaderCell.Style.BackColor = TableColors.PendingEdit;
- dataGridView.Rows[i - 1].DefaultCellStyle.BackColor = default(Color);
- //Check the next row to see if its a member row before declaring the current row a header row.
- rowStatus = parser.GetRowAttribute(dataGridView.Rows[i + 1]);
- if (rowStatus != RowParser.RowAttribute.MemberRow)
+ //The previous row had some attributes set, so mark the previous row for updating.
+ table.Rows[i - 1].Cells[isDirtyColumn].Value = true;
+ updatesOccured = true;
+ table.Rows[i - 1].HeaderCell.Style.BackColor = TableColors.PendingEdit;
+ table.Rows[i - 1].DefaultCellStyle.BackColor = default(Color);
+ }
+ //Clear the previous row of its attributes.
+ table.Rows[i - 1].Cells[isHeaderColumn].Value = false;
+ table.Rows[i - 1].Cells[isMemberColumn].Value = false;
+ //This condition means the user changed the members of a group, so the old header row needs to be updated in the database.
+ //Check the next row to see if its a member row before declaring the current row a header row.
+ if (nextRow == RowParser.RowAttribute.MemberRow)
+ {
+ if (!(bool)table.Rows[i].Cells[isHeaderColumn].EditedFormattedValue ||
+ (bool) table.Rows[i].Cells[isMemberColumn].EditedFormattedValue)
{
- //Clear the coloring from the current row.
- dataGridView.Rows[i].Cells[isHeaderColumn].Value = true;
- dataGridView.Rows[i].Cells[isMemberColumn].Value = false;
- dataGridView.Rows[i].DefaultCellStyle.BackColor = default(Color);
- return;
+ //The current row had some attributes set, so mark the previous row for updating.
+ table.Rows[i].Cells[isDirtyColumn].Value = true;
+ updatesOccured = true;
+ table.Rows[i].HeaderCell.Style.BackColor = TableColors.PendingEdit;
+ table.Rows[i].DefaultCellStyle.BackColor = default(Color);
}
//Set the current row as a header row.
- dataGridView.Rows[i].Cells[isHeaderColumn].Value = true;
- dataGridView.Rows[i].Cells[isMemberColumn].Value = false;
- dataGridView.Rows[i].DefaultCellStyle.BackColor = TableColors.HeaderRow;
- return;
- }
- //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 == RowParser.RowAttribute.HeaderRow || rowStatus == RowParser.RowAttribute.MemberRow && (i - 1) == 0)
- {
- //Set the current row and check for changes.
- if ((bool)dataGridView.Rows[i - 1].Cells[isMemberColumn].EditedFormattedValue)
+ table.Rows[i].Cells[isHeaderColumn].Value = true;
+ table.Rows[i].Cells[isMemberColumn].Value = false;
+ table.Rows[i].DefaultCellStyle.BackColor = TableColors.HeaderRow;
+ //Mark the next row as a member row.
+ if ((bool) table.Rows[i + 1].Cells[isHeaderColumn].EditedFormattedValue ||
+ !(bool)table.Rows[i + 1].Cells[isMemberColumn].EditedFormattedValue)
{
- dataGridView.Rows[i - 1].Cells[isDirtyColumn].Value = true;
- dataGridView.Rows[i - 1].HeaderCell.Style.BackColor = TableColors.PendingEdit;
+ //The next row had some attributes set, so mark the previous row for updating.
+ table.Rows[i + 1].Cells[isDirtyColumn].Value = true;
+ updatesOccured = true;
+ table.Rows[i + 1].HeaderCell.Style.BackColor = TableColors.PendingEdit;
+ table.Rows[i + 1].DefaultCellStyle.BackColor = default(Color);
}
- //Clear the previous row of its attributes.
- dataGridView.Rows[i - 1].Cells[isHeaderColumn].Value = false;
- dataGridView.Rows[i - 1].Cells[isMemberColumn].Value = false;
- dataGridView.Rows[i - 1].DefaultCellStyle.BackColor = default(Color);
+
+ table.Rows[i + 1].Cells[isHeaderColumn].Value = false;
+ table.Rows[i + 1].Cells[isMemberColumn].Value = true;
+ table.Rows[i + 1].DefaultCellStyle.BackColor = TableColors.MemberRow;
}
- //Then check to see if the next row is a member row
- rowStatus = parser.GetRowAttribute(dataGridView.Rows[i + 1]);
- if (rowStatus == RowParser.RowAttribute.MemberRow)
+ else
{
- //Set the current row and check for changes.
- if (!(bool)dataGridView.Rows[i].Cells[isHeaderColumn].EditedFormattedValue)
+ //If the current row is not a member row then clear the current row of any attributes it may have.
+ if ((bool) table.Rows[i].Cells[isHeaderColumn].EditedFormattedValue ||
+ (bool) table.Rows[i].Cells[isMemberColumn].EditedFormattedValue)
{
- dataGridView.Rows[i].Cells[isDirtyColumn].Value = true;
- dataGridView.Rows[i].HeaderCell.Style.BackColor = TableColors.PendingEdit;
+ //The current row had some attributes set, so mark the previous row for updating.
+ table.Rows[i].Cells[isDirtyColumn].Value = true;
+ updatesOccured = true;
+ table.Rows[i].HeaderCell.Style.BackColor = TableColors.PendingEdit;
+ table.Rows[i].DefaultCellStyle.BackColor = default(Color);
}
- dataGridView.Rows[i].Cells[isHeaderColumn].Value = true;
- dataGridView.Rows[i].Cells[isMemberColumn].Value = false;
- dataGridView.Rows[i].DefaultCellStyle.BackColor = TableColors.HeaderRow;
- //Set the next row as a member row.
- if (!(bool)dataGridView.Rows[i + 1].Cells[isMemberColumn].EditedFormattedValue)
- {
- dataGridView.Rows[i + 1].Cells[isDirtyColumn].Value = true;
- dataGridView.Rows[i + 1].HeaderCell.Style.BackColor = TableColors.PendingEdit;
- }
- dataGridView.Rows[i + 1].Cells[isHeaderColumn].Value = false;
- dataGridView.Rows[i + 1].Cells[isMemberColumn].Value = true;
- dataGridView.Rows[i + 1].DefaultCellStyle.BackColor = TableColors.MemberRow;
- }
- //IF previous row is Incomplete, then call the stable PaintRowGroups function.
- else if (rowStatus == RowParser.RowAttribute.IncompleteRow)
- {
- //PaintRowGroups(dataGridView);
+ //Clear the current row's attributes.
+ table.Rows[i].Cells[isHeaderColumn].Value = false;
+ table.Rows[i].Cells[isMemberColumn].Value = false;
+ table.Rows[i].DefaultCellStyle.BackColor = default(Color);
+ if (!fullScan) return updatesOccured;
}
}
else
{
- //Then check to see if the next row is a member row
- rowStatus = parser.GetRowAttribute(dataGridView.Rows[i + 1]);
- if (rowStatus != RowParser.RowAttribute.MemberRow) continue;
- //Set the current row and check for changes.
- if (!(bool)dataGridView.Rows[i].Cells[isHeaderColumn].EditedFormattedValue)
+ //Else if check to see if the previous row exists.
+ if (previousRow == RowParser.RowAttribute.UnAssigned)
{
- dataGridView.Rows[i].Cells[isDirtyColumn].Value = true;
- dataGridView.Rows[i].HeaderCell.Style.BackColor = TableColors.PendingEdit;
+ //This indicates that there is no previous row, so its safe to assume that
+ //we can simply continue on to the next row.
+ continue;
}
- dataGridView.Rows[i].Cells[isHeaderColumn].Value = true;
- dataGridView.Rows[i].Cells[isMemberColumn].Value = false;
- dataGridView.Rows[i].DefaultCellStyle.BackColor = TableColors.MemberRow;
- //Set the next row as a member row.
- if (!(bool)dataGridView.Rows[i + 1].Cells[isMemberColumn].EditedFormattedValue)
+ if (nextRow == RowParser.RowAttribute.MemberRow)
{
- dataGridView.Rows[i + 1].Cells[isDirtyColumn].Value = true;
- dataGridView.Rows[i + 1].HeaderCell.Style.BackColor = TableColors.PendingEdit;
+ continue;
}
- dataGridView.Rows[i + 1].Cells[isHeaderColumn].Value = false;
- dataGridView.Rows[i + 1].Cells[isMemberColumn].Value = true;
- dataGridView.Rows[i + 1].DefaultCellStyle.BackColor = TableColors.MemberRow;
+ //If the current row is not a member row then clear the current row of any attributes it may have.
+ if ((bool)table.Rows[i].Cells[isHeaderColumn].EditedFormattedValue ||
+ (bool)table.Rows[i].Cells[isMemberColumn].EditedFormattedValue)
+ {
+ //The current row had some attributes set, so mark the previous row for updating.
+ table.Rows[i].Cells[isDirtyColumn].Value = true;
+ updatesOccured = true;
+ table.Rows[i].HeaderCell.Style.BackColor = TableColors.PendingEdit;
+ table.Rows[i].DefaultCellStyle.BackColor = default(Color);
+ }
+ //Clear the current row's attributes.
+ table.Rows[i].Cells[isHeaderColumn].Value = false;
+ table.Rows[i].Cells[isMemberColumn].Value = false;
+ table.Rows[i].DefaultCellStyle.BackColor = default(Color);
+ if(!fullScan) return updatesOccured;
}
}
- else if (rowStatus == RowParser.RowAttribute.MemberRow)
+ if (currentRowAttribute == RowParser.RowAttribute.MemberRow)
{
- if (i > 0)
+ //Check to see if the previous row is a header row.
+ if (previousRow == RowParser.RowAttribute.HeaderRow)
{
- //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 from it and the current row (i).
- if (rowStatus == RowParser.RowAttribute.MemberRow && (i - 1) == 0)
+ //Set the previous row as a header.
+ if (!(bool)table.Rows[i - 1].Cells[isHeaderColumn].EditedFormattedValue ||
+ (bool)table.Rows[i - 1].Cells[isMemberColumn].EditedFormattedValue)
{
- //Clear the previous row of its attributes.
- if ((bool)dataGridView.Rows[i - 1].Cells[isMemberColumn].EditedFormattedValue)
- {
- //And mark it as dirty if those attributes have been set for whatever reason.
- dataGridView.Rows[i - 1].Cells[isDirtyColumn].Value = true;
- dataGridView.Rows[i - 1].HeaderCell.Style.BackColor = TableColors.PendingEdit;
- }
- dataGridView.Rows[i - 1].Cells[isHeaderColumn].Value = false;
- dataGridView.Rows[i - 1].Cells[isMemberColumn].Value = false;
- dataGridView.Rows[i - 1].DefaultCellStyle.BackColor = default(Color);
- //Check for changes in the current row.
- if ((bool)dataGridView.Rows[i].Cells[isMemberColumn].EditedFormattedValue)
- {
- dataGridView.Rows[i].Cells[isDirtyColumn].Value = true;
- dataGridView.Rows[i].HeaderCell.Style.BackColor = TableColors.PendingEdit;
- }
- //Clear the current row of its attributes.
- dataGridView.Rows[i].Cells[isHeaderColumn].Value = false;
- dataGridView.Rows[i].Cells[isMemberColumn].Value = false;
- dataGridView.Rows[i].DefaultCellStyle.BackColor = default(Color);
+ //The current row had some attributes set, so mark the current row for updating.
+ table.Rows[i - 1].Cells[isDirtyColumn].Value = true;
+ updatesOccured = true;
+ table.Rows[i - 1].HeaderCell.Style.BackColor = TableColors.PendingEdit;
+ table.Rows[i - 1].DefaultCellStyle.BackColor = default(Color);
}
- //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 == RowParser.RowAttribute.MemberRow && (bool)dataGridView.Rows[i - 1].Cells[isMemberColumn].EditedFormattedValue)
+ table.Rows[i - 1].Cells[isHeaderColumn].Value = true;
+ table.Rows[i - 1].Cells[isMemberColumn].Value = false;
+ table.Rows[i - 1].DefaultCellStyle.BackColor = TableColors.HeaderRow;
+ //Mark current row as member row.
+ if ((bool)table.Rows[i].Cells[isHeaderColumn].EditedFormattedValue ||
+ !(bool)table.Rows[i].Cells[isMemberColumn].EditedFormattedValue)
{
- //Check for changes in the current row.
- if (!(bool)dataGridView.Rows[i].Cells[isMemberColumn].EditedFormattedValue)
- {
- dataGridView.Rows[i].Cells[isDirtyColumn].Value = true;
- dataGridView.Rows[i].HeaderCell.Style.BackColor = TableColors.PendingEdit;
- }
- //Set the current row as a member row.
- dataGridView.Rows[i].Cells[isHeaderColumn].Value = false;
- dataGridView.Rows[i].Cells[isMemberColumn].Value = true;
- dataGridView.Rows[i].DefaultCellStyle.BackColor = TableColors.MemberRow;
+ //The current row had some attributes set, so mark the current row for updating.
+ table.Rows[i].Cells[isDirtyColumn].Value = true;
+ updatesOccured = true;
+ table.Rows[i].HeaderCell.Style.BackColor = TableColors.PendingEdit;
+ table.Rows[i].DefaultCellStyle.BackColor = default(Color);
}
- //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 == RowParser.RowAttribute.MemberRow || rowStatus == RowParser.RowAttribute.AdSpecialRow)
+ table.Rows[i].Cells[isHeaderColumn].Value = false;
+ table.Rows[i].Cells[isMemberColumn].Value = true;
+ table.Rows[i].DefaultCellStyle.BackColor = TableColors.MemberRow;
+ }
+ else if (previousRow == RowParser.RowAttribute.MemberRow)
+ {
+ //Check to see if the previous row is set as a member row.
+ if ((bool) table.Rows[i - 1].Cells[isMemberColumn].EditedFormattedValue)
{
- //Check for changes in the current row.
- if ((bool)dataGridView.Rows[i].Cells[isMemberColumn].EditedFormattedValue)
+ //Assume that the current row is part of the group.
+ if ((bool) table.Rows[i].Cells[isHeaderColumn].EditedFormattedValue ||
+ !(bool) table.Rows[i].Cells[isMemberColumn].EditedFormattedValue)
{
- dataGridView.Rows[i].Cells[isDirtyColumn].Value = true;
- dataGridView.Rows[i].HeaderCell.Style.BackColor = TableColors.PendingEdit;
+ //The current row had some attributes set, so mark the current row for updating.
+ table.Rows[i].Cells[isDirtyColumn].Value = true;
+ updatesOccured = true;
+ table.Rows[i].HeaderCell.Style.BackColor = TableColors.PendingEdit;
+ table.Rows[i].DefaultCellStyle.BackColor = default(Color);
}
- //Clear the current row of its attributes.
- dataGridView.Rows[i].Cells[isHeaderColumn].Value = false;
- dataGridView.Rows[i].Cells[isMemberColumn].Value = false;
- dataGridView.Rows[i].DefaultCellStyle.BackColor = default(Color);
+ table.Rows[i].Cells[isHeaderColumn].Value = false;
+ table.Rows[i].Cells[isMemberColumn].Value = true;
+ table.Rows[i].DefaultCellStyle.BackColor = TableColors.MemberRow;
}
- //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 == RowParser.RowAttribute.HeaderRow && !(bool)dataGridView.Rows[i - 1].Cells[isHeaderColumn].EditedFormattedValue)
+ else
{
- //Set the previous row as a header row.
- if (!(bool)dataGridView.Rows[i - 1].Cells[isMemberColumn].EditedFormattedValue)
+ if ((bool)table.Rows[i].Cells[isHeaderColumn].EditedFormattedValue ||
+ (bool)table.Rows[i].Cells[isMemberColumn].EditedFormattedValue)
{
- dataGridView.Rows[i - 1].Cells[isDirtyColumn].Value = true;
- dataGridView.Rows[i - 1].HeaderCell.Style.BackColor = TableColors.PendingEdit;
+ //The current row had some attributes set, so mark the current row for updating.
+ table.Rows[i].Cells[isDirtyColumn].Value = true;
+ updatesOccured = true;
+ table.Rows[i].HeaderCell.Style.BackColor = TableColors.PendingEdit;
+ table.Rows[i].DefaultCellStyle.BackColor = default(Color);
}
- dataGridView.Rows[i - 1].Cells[isHeaderColumn].Value = true;
- dataGridView.Rows[i - 1].Cells[isMemberColumn].Value = false;
- dataGridView.Rows[i - 1].DefaultCellStyle.BackColor = TableColors.HeaderRow;
- //This condition means the user created a group so the newly made header row will need to be updated in the database as well.
- dataGridView.Rows[i - 1].Cells[isDirtyColumn].Value = true;
- dataGridView.Rows[i - 1].HeaderCell.Style.BackColor = TableColors.PendingEdit;
- //Check for changes in the current row.
- if (!(bool)dataGridView.Rows[i].Cells[isMemberColumn].EditedFormattedValue)
- {
- dataGridView.Rows[i].Cells[isDirtyColumn].Value = true;
- dataGridView.Rows[i].HeaderCell.Style.BackColor = TableColors.PendingEdit;
- }
- //Set the current row as a member row.
- dataGridView.Rows[i].Cells[isHeaderColumn].Value = false;
- dataGridView.Rows[i].Cells[isMemberColumn].Value = true;
- dataGridView.Rows[i].DefaultCellStyle.BackColor = TableColors.MemberRow;
- }
- else if (rowStatus == RowParser.RowAttribute.HeaderRow)
- {
- //Check for changes in the current row.
- if (!(bool)dataGridView.Rows[i].Cells[isMemberColumn].EditedFormattedValue)
- {
- dataGridView.Rows[i].Cells[isDirtyColumn].Value = true;
- dataGridView.Rows[i].HeaderCell.Style.BackColor = TableColors.PendingEdit;
- }
- //Set the current row as a member row.
- dataGridView.Rows[i].Cells[isHeaderColumn].Value = false;
- dataGridView.Rows[i].Cells[isMemberColumn].Value = true;
- dataGridView.Rows[i].DefaultCellStyle.BackColor = TableColors.MemberRow;
- }
- //IF the previous row is incomplete, then call the stable PaintRowGroups function.
- else if (rowStatus == RowParser.RowAttribute.IncompleteRow)
- {
- //PaintRowGroups(dataGridView);
+ table.Rows[i].Cells[isHeaderColumn].Value = false;
+ table.Rows[i].Cells[isMemberColumn].Value = false;
+ table.Rows[i].DefaultCellStyle.BackColor = default(Color);
}
}
- //ELSE the current row is the first row in the data grid, therefore it can't be a member row so remove all coloring.
else
{
- //Clear the current row of its attributes.
- if (!(bool)dataGridView.Rows[0].Cells[isMemberColumn].EditedFormattedValue)
+ if ((bool)table.Rows[i].Cells[isHeaderColumn].EditedFormattedValue ||
+ (bool)table.Rows[i].Cells[isMemberColumn].EditedFormattedValue)
{
- //If the row thinks that it's a member row then set it to dirty so the changes can be shown.
- dataGridView.Rows[0].Cells[isDirtyColumn].Value = true;
- dataGridView.Rows[0].HeaderCell.Style.BackColor = TableColors.PendingEdit;
+ //The current row had some attributes set, so mark the current row for updating.
+ table.Rows[i].Cells[isDirtyColumn].Value = true;
+ updatesOccured = true;
+ table.Rows[i].HeaderCell.Style.BackColor = TableColors.PendingEdit;
+ table.Rows[i].DefaultCellStyle.BackColor = default(Color);
}
- dataGridView.Rows[0].Cells[isHeaderColumn].Value = false;
- dataGridView.Rows[0].Cells[isMemberColumn].Value = false;
- dataGridView.Rows[0].DefaultCellStyle.BackColor = default(Color);
- }
- }
- else if (rowStatus == RowParser.RowAttribute.AdSpecialRow)
- {
- if (i == 0) return;
- dataGridView.Rows[startingIndex].DefaultCellStyle.BackColor = TableColors.AdSpecial;
- //Get the previous row's attribute.
- rowStatus = parser.GetRowAttribute(dataGridView.Rows[i - 1]);
- if (rowStatus == RowParser.RowAttribute.HeaderRow)
- {
- //Check to see if the previous row sees itself as a header row, if so mark it dirty.
- if ((bool)dataGridView.Rows[i - 1].Cells[isHeaderColumn].EditedFormattedValue)
- {
- dataGridView.Rows[i - 1].Cells[isDirtyColumn].Value = true;
- dataGridView.Rows[i - 1].HeaderCell.Style.BackColor = TableColors.PendingEdit;
- }
- //Clear its color coding.
- dataGridView.Rows[i - 1].Cells[isHeaderColumn].Value = false;
- dataGridView.Rows[i - 1].Cells[isMemberColumn].Value = false;
- dataGridView.Rows[i - 1].DefaultCellStyle.BackColor = default(Color);
- }
- //Next get the status of the next row.
- rowStatus = parser.GetRowAttribute(dataGridView.Rows[i + 1]);
- if (rowStatus == RowParser.RowAttribute.MemberRow)
- {
- //Check to see if the next row thinks it is a member row.
- if (!(bool)dataGridView.Rows[i + 1].Cells[isMemberColumn].EditedFormattedValue)
- {
- dataGridView.Rows[i + 1].Cells[isDirtyColumn].Value = true;
- dataGridView.Rows[i + 1].HeaderCell.Style.BackColor = TableColors.PendingEdit;
- }
- //Clear its color coding.
- dataGridView.Rows[i + 1].Cells[isMemberColumn].Value = false;
- dataGridView.Rows[i + 1].Cells[isHeaderColumn].Value = false;
- dataGridView.Rows[i + 1].DefaultCellStyle.BackColor = default(Color);
+ table.Rows[i].Cells[isHeaderColumn].Value = false;
+ table.Rows[i].Cells[isMemberColumn].Value = false;
}
}
}
- }
-
- public static void PaintRowGroups(DataGridView table)
- {
+ return updatesOccured;
}
public static void PaintInventoryRowGroups(int startingIndex, DataGridView inventoryDataGridView,
@@ -408,11 +330,6 @@ namespace DataTableParsingEngine
inventoryDataGridView.Rows[i + 1].Cells[isMemberColumn].Value = true;
inventoryDataGridView.Rows[i + 1].DefaultCellStyle.BackColor = TableColors.MemberRow;
}
- //IF previous row is Incomplete, then call the stable PaintRowGroups function.
- else if (rowStatus == RowParser.RowAttribute.IncompleteRow)
- {
- //PaintRowGroups(dataGridView);
- }
}
else
{