Updated the main form with a slightly new look. Finished all the code for the main for to pull in all the data from the database and perform calculations on it. Currently can only load the most recent date. Added detection for holidays in the weekly and taxable lists.
This commit is contained in:
@@ -42,10 +42,10 @@ namespace AdvertsingProfitControl
|
||||
/// </summary>
|
||||
/// <param name="connectionString">The connection string for the database.</param>
|
||||
/// <returns>The ID number as a string.</returns>
|
||||
public string RetrieveMostRecentDateId(string connectionString)
|
||||
public int RetrieveMostRecentDateId(string connectionString)
|
||||
{
|
||||
var dateId = "0";
|
||||
var oleDbCommand = new OleDbCommand()
|
||||
int dateId = 0;
|
||||
var oleDbCommand = new OleDbCommand
|
||||
{
|
||||
CommandText = "SELECT WeekEnding.ID FROM WeekEnding WHERE WeekEnding.EndOfWeekDate = (SELECT MAX(WeekEnding.EndOfWeekDate) FROM WeekEnding)"
|
||||
};
|
||||
@@ -61,7 +61,7 @@ namespace AdvertsingProfitControl
|
||||
{
|
||||
while (reader != null && reader.Read())
|
||||
{
|
||||
dateId = reader[0].ToString();
|
||||
dateId = int.Parse(reader[0].ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -70,6 +70,34 @@ namespace AdvertsingProfitControl
|
||||
return dateId;
|
||||
}
|
||||
|
||||
public DateTime RetrieveMostRecentDate(string connectionString)
|
||||
{
|
||||
var date = new DateTime();
|
||||
var oleDbCommand = new OleDbCommand
|
||||
{
|
||||
CommandText = "SELECT WeekEnding.EndOfWeekDate FROM WeekEnding WHERE WeekEnding.EndOfWeekDate = (SELECT MAX(WeekEnding.EndOfWeekDate) FROM WeekEnding)"
|
||||
};
|
||||
var connection = new OleDbConnection(connectionString);
|
||||
oleDbCommand.Connection = connection;
|
||||
|
||||
using (connection)
|
||||
{
|
||||
using (oleDbCommand)
|
||||
{
|
||||
connection.Open();
|
||||
using (var reader = oleDbCommand.ExecuteReader())
|
||||
{
|
||||
while (reader != null && reader.Read())
|
||||
{
|
||||
date = DateTime.Parse(reader[0].ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return date;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the date ID of the date string that is passed.
|
||||
/// Preferred format is short date (1/20/2017).
|
||||
@@ -106,7 +134,7 @@ namespace AdvertsingProfitControl
|
||||
return dateId;
|
||||
}
|
||||
|
||||
public string RetrieveDateStringById(string dateId, string connectionString)
|
||||
public string RetrieveDateStringById(int dateId, string connectionString)
|
||||
{
|
||||
string dateString = "";
|
||||
var oleDbCommand = new OleDbCommand()
|
||||
@@ -222,7 +250,7 @@ namespace AdvertsingProfitControl
|
||||
|
||||
public DateTime RetrieveMostRecentDateString(string connectionString)
|
||||
{
|
||||
DateTime dateTimeObject = new DateTime();
|
||||
var dateTimeObject = new DateTime();
|
||||
var oleDbCommand = new OleDbCommand()
|
||||
{
|
||||
CommandText = "SELECT WeekEnding.EndOfWeekDate FROM WeekEnding WHERE WeekEnding.EndOfWeekDate = (SELECT MAX(WeekEnding.EndOfWeekDate) FROM WeekEnding)"
|
||||
@@ -370,7 +398,7 @@ namespace AdvertsingProfitControl
|
||||
return id;
|
||||
}
|
||||
|
||||
public List<string> RetrieveUsedAdItemListByDateId(string dateId, string connectionString)
|
||||
public List<string> RetrieveUsedAdItemListByDateId(int dateId, string connectionString)
|
||||
{
|
||||
var adItemList = new List<string>();
|
||||
var oleDbCommand = new OleDbCommand
|
||||
@@ -444,35 +472,6 @@ namespace AdvertsingProfitControl
|
||||
|
||||
#region Comment Functions
|
||||
|
||||
public string RetrieveComments(string dateId, string connectionString)
|
||||
{
|
||||
var comments = "";
|
||||
var oleDbCommand = new OleDbCommand()
|
||||
{
|
||||
CommandText = "SELECT Comment.Comment FROM Comment WHERE Comment.FK_DateID = ?"
|
||||
};
|
||||
oleDbCommand.Parameters.AddWithValue("DateID", dateId);
|
||||
var connection = new OleDbConnection(connectionString);
|
||||
oleDbCommand.Connection = connection;
|
||||
|
||||
using (connection)
|
||||
{
|
||||
using (oleDbCommand)
|
||||
{
|
||||
connection.Open();
|
||||
using(var reader = oleDbCommand.ExecuteReader())
|
||||
{
|
||||
while(reader != null && reader.Read())
|
||||
{
|
||||
comments = reader[0].ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return comments;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Created for the new modify record form, returns the ID of the comment being grabbed.
|
||||
/// </summary>
|
||||
@@ -715,7 +714,7 @@ namespace AdvertsingProfitControl
|
||||
|
||||
#region Table Return Functions
|
||||
|
||||
public DataTable ReturnApcTableForReport(string dateId, string connectionString)
|
||||
public DataTable ReturnApcTableForReport(int dateId, string connectionString)
|
||||
{
|
||||
var dataTable = new DataTable();
|
||||
var oleDbCommand = new OleDbCommand()
|
||||
@@ -741,7 +740,7 @@ namespace AdvertsingProfitControl
|
||||
return dataTable;
|
||||
}
|
||||
|
||||
public DataTable ReturnProjectionsTable(string dateId, string connectionString)
|
||||
public DataTable ReturnProjectionsTable(int dateId, string connectionString)
|
||||
{
|
||||
var dataTable = new DataTable();
|
||||
var oleDbCommand = new OleDbCommand()
|
||||
@@ -766,7 +765,7 @@ namespace AdvertsingProfitControl
|
||||
return dataTable;
|
||||
}
|
||||
|
||||
public DataTable ReturnActualSales(string dateId, string connectionString)
|
||||
public DataTable ReturnActualSales(int dateId, string connectionString)
|
||||
{
|
||||
var dataTable = new DataTable();
|
||||
var oleDbCommand = new OleDbCommand()
|
||||
@@ -791,7 +790,7 @@ namespace AdvertsingProfitControl
|
||||
return dataTable;
|
||||
}
|
||||
|
||||
public DataTable ReturnInventoryTable(string dateId, string connectionString)
|
||||
public DataTable ReturnInventoryTable(int dateId, string connectionString)
|
||||
{
|
||||
var dataTable = new DataTable();
|
||||
var oleDbCommand = new OleDbCommand()
|
||||
@@ -817,7 +816,7 @@ namespace AdvertsingProfitControl
|
||||
}
|
||||
|
||||
|
||||
public DataTable ReturnInvoiceTable(string dateId, string connectionString)
|
||||
public DataTable ReturnInvoiceTable(int dateId, string connectionString)
|
||||
{
|
||||
var dataTable = new DataTable();
|
||||
var oleDbCommand = new OleDbCommand()
|
||||
@@ -842,7 +841,7 @@ namespace AdvertsingProfitControl
|
||||
return dataTable;
|
||||
}
|
||||
|
||||
public DataTable ReturnWeeklySalesFromDateId(string dateId, string connectionString)
|
||||
public DataTable ReturnWeeklySalesFromDateId(int dateId, string connectionString)
|
||||
{
|
||||
var dataTable = new DataTable();
|
||||
var oleDbCommand = new OleDbCommand()
|
||||
@@ -867,7 +866,7 @@ namespace AdvertsingProfitControl
|
||||
return dataTable;
|
||||
}
|
||||
|
||||
public DataTable ReturnTaxableFromDateId(string dateId, string connectionString)
|
||||
public DataTable ReturnTaxableFromDateId(int dateId, string connectionString)
|
||||
{
|
||||
var dataTable = new DataTable();
|
||||
var oleDbCommand = new OleDbCommand
|
||||
@@ -948,7 +947,7 @@ namespace AdvertsingProfitControl
|
||||
|
||||
#region Supplier And Invoices Functions
|
||||
|
||||
public string RetrieveSupplierNameById(string supplierId, string connectionString)
|
||||
public string RetrieveSupplierNameById(int supplierId, string connectionString)
|
||||
{
|
||||
var supplierName = "";
|
||||
var oleDbCommand = new OleDbCommand()
|
||||
|
||||
Reference in New Issue
Block a user