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:
@@ -8,6 +8,34 @@ namespace AdvertsingProfitControl
|
||||
{
|
||||
internal class DatabaseReader
|
||||
{
|
||||
public string GetDatabaseVersion(string connectionString)
|
||||
{
|
||||
var versionNumber = "0.0.0.0";
|
||||
var oleDbCommand = new OleDbCommand()
|
||||
{
|
||||
CommandText = "SELECT VersionNumber FROM Version"
|
||||
};
|
||||
var connection = new OleDbConnection(connectionString);
|
||||
oleDbCommand.Connection = connection;
|
||||
|
||||
using (connection)
|
||||
{
|
||||
using (oleDbCommand)
|
||||
{
|
||||
connection.Open();
|
||||
using (var reader = oleDbCommand.ExecuteReader())
|
||||
{
|
||||
while (reader != null && reader.Read())
|
||||
{
|
||||
versionNumber = reader[0].ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return versionNumber;
|
||||
}
|
||||
|
||||
#region Date Functions
|
||||
/// <summary>
|
||||
/// Retrieves the most recent date's ID from the database.
|
||||
@@ -253,7 +281,7 @@ namespace AdvertsingProfitControl
|
||||
public List<string> RetrieveUsedAdItemListByDateId(string dateId, string connectionString)
|
||||
{
|
||||
var adItemList = new List<string>();
|
||||
var oleDbCommand = new OleDbCommand()
|
||||
var oleDbCommand = new OleDbCommand
|
||||
{
|
||||
CommandText = "SELECT AdItem.AdItem, APC.RowAttribute, APC.FK_GroupID FROM (APC INNER JOIN AdItem ON APC.FK_AdItemID = AdItem.ID) WHERE FK_DateID = ? ORDER BY RowPosition ASC"
|
||||
};
|
||||
@@ -269,7 +297,7 @@ namespace AdvertsingProfitControl
|
||||
{
|
||||
while (reader != null && reader.Read())
|
||||
{
|
||||
if (reader["FK_GroupID"].ToString() != "" && (int) reader["FK_GroupID"] >= 3)
|
||||
if (reader["FK_GroupID"].ToString() != "" && int.Parse(reader["FK_GroupID"].ToString()) >= 3)
|
||||
{
|
||||
adItemList.Add(reader[0] + ":2");
|
||||
}
|
||||
@@ -284,7 +312,42 @@ namespace AdvertsingProfitControl
|
||||
}
|
||||
|
||||
return adItemList;
|
||||
}
|
||||
|
||||
public List<string> RetrieveAdItemListByLetter(string connectionString, string letterFilter = "All")
|
||||
{
|
||||
var adItemsList = new List<string>();
|
||||
var oleDbCommand = new OleDbCommand();
|
||||
if(letterFilter == "All")
|
||||
{
|
||||
oleDbCommand.CommandText = "SELECT AdItem FROM AdItem ORDER BY AdItem ASC";
|
||||
}
|
||||
else
|
||||
{
|
||||
oleDbCommand.CommandText = "SELECT AdItem FROM AdItem WHERE LEFT(AdItem, 1) = ? ORDER BY AdItem ASC";
|
||||
oleDbCommand.Parameters.AddWithValue("Filter", letterFilter);
|
||||
}
|
||||
var connection = new OleDbConnection(connectionString);
|
||||
oleDbCommand.Connection = connection;
|
||||
|
||||
using (connection)
|
||||
{
|
||||
using (oleDbCommand)
|
||||
{
|
||||
connection.Open();
|
||||
using (var reader = oleDbCommand.ExecuteReader())
|
||||
{
|
||||
while (reader != null && reader.Read())
|
||||
{
|
||||
adItemsList.Add((reader[0].ToString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return adItemsList;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Comment Functions
|
||||
@@ -320,7 +383,7 @@ namespace AdvertsingProfitControl
|
||||
|
||||
#endregion
|
||||
|
||||
#region Group ID Functions
|
||||
#region Ad Special Functions
|
||||
|
||||
public string RetrieveGroupIdByString(string groupName, string connectionString)
|
||||
{
|
||||
@@ -524,6 +587,32 @@ namespace AdvertsingProfitControl
|
||||
|
||||
#region Table Return Functions
|
||||
|
||||
public DataTable ReturnApcTableForReport(string dateId, string connectionString)
|
||||
{
|
||||
var dataTable = new DataTable();
|
||||
var oleDbCommand = new OleDbCommand()
|
||||
{
|
||||
CommandText = "SELECT AdItem.AdItem, APC.ProjectionSold, APC.ProjectionSalePrice, APC.ProjectionTotalSales, APC.ProjectionCost, APC.ProjectionProfitReturn, APC.ProjectionTotalProfitReturn, APC.BeginingInventory, APC.Received, APC.TotalInventory, APC.EndingInventory, APC.ActualSold, APC.ActualSalePrice, APC.ActualTotalSales, APC.ActualCost, APC.ActualProfitReturn, APC.ActualTotalProfitReturn, RowAttribute, FK_GroupID FROM (AdItem INNER JOIN APC ON AdItem.ID = APC.FK_AdItemID) WHERE FK_DateID = ? ORDER BY RowPosition ASC"
|
||||
};
|
||||
oleDbCommand.Parameters.AddWithValue("DateID", dateId);
|
||||
var connection = new OleDbConnection(connectionString);
|
||||
oleDbCommand.Connection = connection;
|
||||
|
||||
using (connection)
|
||||
{
|
||||
using (oleDbCommand)
|
||||
{
|
||||
connection.Open();
|
||||
using (var dataAdapter = new OleDbDataAdapter(oleDbCommand))
|
||||
{
|
||||
dataAdapter.Fill(dataTable);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return dataTable;
|
||||
}
|
||||
|
||||
public DataTable ReturnProjectionsTable(string dateId, string connectionString)
|
||||
{
|
||||
var dataTable = new DataTable();
|
||||
@@ -605,7 +694,7 @@ namespace AdvertsingProfitControl
|
||||
var dataTable = new DataTable();
|
||||
var oleDbCommand = new OleDbCommand()
|
||||
{
|
||||
CommandText = "SELECT Supplier.SupplierName, InvoiceNumber, Invoice.InvoiceDate, Invoice.InvoiceNetAmountAtCost, Invoice.InvoiceNetAmount, Invoice.InvoiceNote FROM (Supplier INNER JOIN Invoice ON Supplier.ID = Invoice.FK_Supplier) WHERE FK_DateID = ?"
|
||||
CommandText = "SELECT Supplier.SupplierName, Invoice.InvoiceNumber, Invoice.InvoiceDate, Invoice.InvoiceNetAmountAtCost, Invoice.InvoiceNetAmount, Invoice.InvoiceNote FROM (Supplier INNER JOIN Invoice ON Supplier.ID = Invoice.FK_Supplier) WHERE FK_DateID = ?"
|
||||
};
|
||||
oleDbCommand.Parameters.AddWithValue("DateID", dateId);
|
||||
var connection = new OleDbConnection(connectionString);
|
||||
|
||||
Reference in New Issue
Block a user