mirror of
https://github.com/stokebob/bnhtrade.git
synced 2026-03-19 14:37:16 +00:00
progress has been made. Beer o'clock
This commit is contained in:
105
src/bnhtrade.Core/Data/Database/Account/Contact.cs
Normal file
105
src/bnhtrade.Core/Data/Database/Account/Contact.cs
Normal file
@@ -0,0 +1,105 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace bnhtrade.Core.Data.Database.Account
|
||||
{
|
||||
internal class Contact : Connection
|
||||
{
|
||||
private bnhtrade.Core.Data.Database.SqlWhereBuilder sqlBuilder;
|
||||
|
||||
public List<int> ContactIdList { get; set; }
|
||||
|
||||
public Contact()
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
public void Init()
|
||||
{
|
||||
sqlBuilder = new SqlWhereBuilder();
|
||||
ContactIdList = new List<int>();
|
||||
}
|
||||
|
||||
public Dictionary<int, Model.Account.Contact> Read()
|
||||
{
|
||||
var returnList = new Dictionary<int, Model.Account.Contact>();
|
||||
sqlBuilder.Init();
|
||||
|
||||
//build sql query
|
||||
string sql = @"
|
||||
SELECT [ContactID]
|
||||
,[ContactName]
|
||||
,[PaypalName]
|
||||
,[PaypalEmail]
|
||||
,[EbayUsername]
|
||||
,[EbayEmail]
|
||||
,[RecordCreated]
|
||||
,[RecordModified]
|
||||
FROM [e2A].[dbo].[tblContact]
|
||||
WHERE 1=1 ";
|
||||
|
||||
// build the where statments
|
||||
if (ContactIdList.Any())
|
||||
{
|
||||
sqlBuilder.In("[ContactID]", ContactIdList, "AND");
|
||||
}
|
||||
|
||||
// append where string to the sql
|
||||
if (sqlBuilder.IsSetSqlWhereString)
|
||||
{
|
||||
sql = sql + sqlBuilder.SqlWhereString;
|
||||
}
|
||||
|
||||
using (SqlConnection conn = new SqlConnection(SqlConnectionString))
|
||||
{
|
||||
conn.Open();
|
||||
|
||||
using (SqlCommand cmd = new SqlCommand(sql, conn))
|
||||
{
|
||||
sqlBuilder.AddParametersToSqlCommand(cmd);
|
||||
|
||||
using (SqlDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
if (reader.HasRows)
|
||||
{
|
||||
while (reader.Read())
|
||||
{
|
||||
int contactId = reader.GetInt32(0);
|
||||
string contactName = null;
|
||||
if (!reader.IsDBNull(1)) { contactName = reader.GetString(1); }
|
||||
string paypalName = null;
|
||||
if (!reader.IsDBNull(2)) { paypalName = reader.GetString(2); }
|
||||
string paypalEmail = null;
|
||||
if (!reader.IsDBNull(3)) { paypalEmail = reader.GetString(3); }
|
||||
string ebayUsername = null;
|
||||
if (!reader.IsDBNull(4)) { ebayUsername = reader.GetString(4); }
|
||||
string ebayEmail = null;
|
||||
if (!reader.IsDBNull(5)) { ebayEmail = reader.GetString(5); }
|
||||
DateTime recordCreated = DateTime.SpecifyKind(reader.GetDateTime(6), DateTimeKind.Utc);
|
||||
DateTime? recordModified = null;
|
||||
if (!reader.IsDBNull(7)) { recordModified = DateTime.SpecifyKind(reader.GetDateTime(7), DateTimeKind.Utc); }
|
||||
|
||||
var contact = new Model.Account.Contact();
|
||||
contact.ContactId = contactId;
|
||||
contact.ContantName = contactName;
|
||||
contact.ContactPaypalName = paypalName;
|
||||
contact.ContactPaypalEmail = paypalEmail;
|
||||
contact.ContactEbayName = ebayUsername;
|
||||
contact.ContactEbayEmail = ebayEmail;
|
||||
contact.Created = recordCreated;
|
||||
contact.Modified = recordModified;
|
||||
|
||||
returnList.Add(contactId, contact);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return returnList;
|
||||
}
|
||||
}
|
||||
}
|
||||
178
src/bnhtrade.Core/Data/Database/Account/PurchaseInvoice.cs
Normal file
178
src/bnhtrade.Core/Data/Database/Account/PurchaseInvoice.cs
Normal file
@@ -0,0 +1,178 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using static System.ComponentModel.Design.ObjectSelectorEditor;
|
||||
|
||||
namespace bnhtrade.Core.Data.Database.Account
|
||||
{
|
||||
internal class PurchaseInvoice : Connection
|
||||
{
|
||||
private bnhtrade.Core.Data.Database.SqlWhereBuilder sqlBuilder;
|
||||
|
||||
public List<int> PurchaseInvoiceIdList { get; set; }
|
||||
|
||||
public PurchaseInvoice()
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
public void Init()
|
||||
{
|
||||
sqlBuilder = new SqlWhereBuilder();
|
||||
PurchaseInvoiceIdList = new List<int>();
|
||||
}
|
||||
|
||||
public Dictionary<int, Model.Account.PurchaseInvoice> Read()
|
||||
{
|
||||
var returnList = new Dictionary<int, Model.Account.PurchaseInvoice>();
|
||||
sqlBuilder.Init();
|
||||
|
||||
//build sql query
|
||||
string sql = @"
|
||||
SELECT tblPurchase.PurchaseID
|
||||
,tblPurchase.PurchaseNumber
|
||||
,tblPurchase.RecordID
|
||||
,tblPurchase.PurchaseDate
|
||||
,tblPurchase.ContactID
|
||||
,tblPurchase.SupplierRef
|
||||
,tblPurchase.PurchaseTotalAmount
|
||||
,tblPurchase.VatInclusiveAmounts
|
||||
,tblPurchase.RecordCreated
|
||||
,tblPurchase.RecordModified
|
||||
,tblPurchase.IsActive
|
||||
,tblAccountCurrency.CurrencyCode
|
||||
,tblPurchaseChannel.PurchaseChannelName
|
||||
,tblPurchaseStatus.PurchaseStatus
|
||||
FROM tblPurchase
|
||||
LEFT OUTER JOIN tblAccountCurrency ON tblPurchase.AccountCurrencyID = tblAccountCurrency.AccountCurrencyID
|
||||
LEFT OUTER JOIN tblPurchaseStatus ON tblPurchase.PurchaseStatusID = tblPurchaseStatus.PurchaseStatusID
|
||||
LEFT OUTER JOIN tblPurchaseChannel ON tblPurchase.PurchaseChannelID = tblPurchaseChannel.PurchaseChannelID
|
||||
WHERE 1 = 1
|
||||
";
|
||||
|
||||
// build the where statments
|
||||
if (PurchaseInvoiceIdList.Any())
|
||||
{
|
||||
sqlBuilder.In("[PurchaseID]", PurchaseInvoiceIdList, "AND");
|
||||
}
|
||||
|
||||
// append where string to the sql
|
||||
if (sqlBuilder.IsSetSqlWhereString)
|
||||
{
|
||||
sql = sql + sqlBuilder.SqlWhereString;
|
||||
}
|
||||
|
||||
// dictionary so we can fill in details afterwards
|
||||
var invoiceContactDict = new Dictionary<int, int>();
|
||||
var purchaseIdList = new List<int>();
|
||||
|
||||
using (SqlConnection conn = new SqlConnection(SqlConnectionString))
|
||||
{
|
||||
conn.Open();
|
||||
|
||||
using (SqlCommand cmd = new SqlCommand(sql, conn))
|
||||
{
|
||||
sqlBuilder.AddParametersToSqlCommand(cmd);
|
||||
|
||||
using (SqlDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
if (reader.HasRows)
|
||||
{
|
||||
while (reader.Read())
|
||||
{
|
||||
|
||||
|
||||
int purchaseID = reader.GetInt32(0);
|
||||
int purchaseNumber = reader.GetInt32(1);
|
||||
int? recordID = null;
|
||||
if (!reader.IsDBNull(2)) { recordID = reader.GetInt32(2); }
|
||||
DateTime purchaseDate = DateTime.SpecifyKind(reader.GetDateTime(3), DateTimeKind.Utc);
|
||||
int? contactID = null;
|
||||
if (!reader.IsDBNull(4)) { contactID = reader.GetInt32(4);}
|
||||
string supplierRef = null;
|
||||
if (!reader.IsDBNull(5)) { supplierRef = reader.GetString(5);}
|
||||
decimal? purchaseTotalAmount = null;
|
||||
if (!reader.IsDBNull(6)) { purchaseTotalAmount = reader.GetDecimal(6);}
|
||||
bool vatInclusiveAmounts = reader.GetBoolean(7);
|
||||
DateTime recordCreated = DateTime.SpecifyKind(reader.GetDateTime(8), DateTimeKind.Utc);
|
||||
DateTime recordModified = DateTime.SpecifyKind(reader.GetDateTime(9), DateTimeKind.Utc);
|
||||
bool isActive = reader.GetBoolean(10);
|
||||
string currencyCode = reader.GetString(11);
|
||||
string purchaseChannelName = reader.GetString(12);
|
||||
string purchaseStatus = null;
|
||||
if (!reader.IsDBNull(13)) { purchaseStatus = reader.GetString(13);}
|
||||
|
||||
var invoice = new Model.Account.PurchaseInvoice();
|
||||
invoice.PurchaseID = purchaseID;
|
||||
invoice.PurchaseNumber = purchaseNumber;
|
||||
invoice.RecordID = recordID;
|
||||
invoice.PurchaseDate = purchaseDate;
|
||||
invoice.SupplierRef = supplierRef;
|
||||
//invoice.PurchaseTotalAmount = purchaseTotalAmount;
|
||||
invoice.VatInclusiveAmounts = vatInclusiveAmounts;
|
||||
invoice.RecordCreated = recordCreated;
|
||||
invoice.RecordModified = recordModified;
|
||||
invoice.IsActive = isActive;
|
||||
invoice.CurrencyCode = currencyCode;
|
||||
invoice.PurchaseChannel = purchaseChannelName;
|
||||
|
||||
// is there contact info that needs to be added?
|
||||
if (contactID != null)
|
||||
{
|
||||
invoiceContactDict.Add(purchaseID, (int)contactID);
|
||||
}
|
||||
|
||||
purchaseIdList.Add(purchaseID);
|
||||
|
||||
returnList.Add(purchaseID, invoice);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// add contact info
|
||||
if (invoiceContactDict.Any())
|
||||
{
|
||||
var readContact = new Data.Database.Account.Contact();
|
||||
readContact.ContactIdList = invoiceContactDict.Values.ToList();
|
||||
var contactDict = readContact.Read();
|
||||
|
||||
if (contactDict.Any())
|
||||
{
|
||||
foreach ( var invoice in returnList)
|
||||
{
|
||||
if (invoiceContactDict.ContainsKey(invoice.Value.PurchaseID))
|
||||
{
|
||||
int contactId = invoiceContactDict[invoice.Value.PurchaseID];
|
||||
invoice.Value.Contact = contactDict[contactId];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// add invoice lines
|
||||
var readLines = new Data.Database.Account.PurchaseInvoiceLine();
|
||||
readLines.InvoiceIdList = purchaseIdList;
|
||||
var lines = readLines.Read();
|
||||
foreach(var invoice in returnList.Values)
|
||||
{
|
||||
foreach(var line in lines.Values)
|
||||
{
|
||||
if (line.PurchaseId == invoice.PurchaseID)
|
||||
{
|
||||
if (invoice.InvoiceLines == null)
|
||||
{
|
||||
invoice.InvoiceLines = new List<Model.Account.PurchaseInvoice.Line>();
|
||||
}
|
||||
invoice.InvoiceLines.Add(line);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return returnList;
|
||||
}
|
||||
}
|
||||
}
|
||||
187
src/bnhtrade.Core/Data/Database/Account/PurchaseInvoiceLine.cs
Normal file
187
src/bnhtrade.Core/Data/Database/Account/PurchaseInvoiceLine.cs
Normal file
@@ -0,0 +1,187 @@
|
||||
using Amazon.Runtime.Internal.Transform;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using static System.ComponentModel.Design.ObjectSelectorEditor;
|
||||
|
||||
namespace bnhtrade.Core.Data.Database.Account
|
||||
{
|
||||
internal class PurchaseInvoiceLine : Connection
|
||||
{
|
||||
private bnhtrade.Core.Data.Database.SqlWhereBuilder sqlBuilder;
|
||||
|
||||
/// <summary>
|
||||
/// Results filter
|
||||
/// </summary>
|
||||
public List<int> InvoiceIdList { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Results filter
|
||||
/// </summary>
|
||||
public List<int> InvoiceLineIdList { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Results filter
|
||||
/// </summary>
|
||||
public List<string> StatusList { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Searches for the specificed phases within the item description. Uses the LIKE AND sql function
|
||||
/// </summary>
|
||||
public List<string> ItemDescription { get; set; }
|
||||
|
||||
public PurchaseInvoiceLine()
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
public void Init()
|
||||
{
|
||||
sqlBuilder = new SqlWhereBuilder();
|
||||
InvoiceIdList = new List<int>();
|
||||
InvoiceLineIdList = new List<int>();
|
||||
StatusList = new List<string>();
|
||||
}
|
||||
|
||||
public Dictionary<int, Model.Account.PurchaseInvoice.Line> Read()
|
||||
{
|
||||
var returnList = new Dictionary<int, Model.Account.PurchaseInvoice.Line>();
|
||||
sqlBuilder.Init();
|
||||
|
||||
//build sql query
|
||||
string sql = @"
|
||||
SELECT tblPurchaseLine.PurchaseLineID
|
||||
,tblPurchaseLine.PurchaseID
|
||||
,tblPurchaseLineStatus.PurchaseLineStatus
|
||||
,tblPurchaseLine.SupplierRef
|
||||
,tblPurchaseLine.CheckedIn
|
||||
,tblPurchaseLine.ItemDescription
|
||||
,tblPurchaseLine.ItemQuantity
|
||||
,tblPurchaseLine.ItemGross
|
||||
,tblPurchaseLine.ItemTax
|
||||
,tblPurchaseLine.ShippingGross
|
||||
,tblPurchaseLine.ShippingTax
|
||||
,tblPurchaseLine.OtherGross
|
||||
,tblPurchaseLine.OtherTax
|
||||
,tblPurchaseLine.AccountTaxCodeID
|
||||
,tblPurchaseLine.Tax_AccountTransactionID
|
||||
,tblPurchaseLine.Net_AccountChartOfID
|
||||
,tblPurchaseLine.Net_AccountTransactionID
|
||||
,tblPurchaseLine.RecordCreated
|
||||
,tblPurchaseLine.RecordModified
|
||||
,tblPurchaseLine.IsActive
|
||||
,tblAccountTaxCode.TaxCode
|
||||
FROM tblPurchaseLine
|
||||
INNER JOIN tblPurchaseLineStatus ON tblPurchaseLine.PurchaseLineStatusID = tblPurchaseLineStatus.PurchaseLineStatusID
|
||||
LEFT OUTER JOIN tblAccountTaxCode ON tblPurchaseLine.AccountTaxCodeID = tblAccountTaxCode.AccountTaxCodeID
|
||||
WHERE 1 = 1 ";
|
||||
|
||||
// build the where statments
|
||||
if (InvoiceIdList.Any())
|
||||
{
|
||||
sqlBuilder.In("PurchaseID", InvoiceLineIdList, "AND");
|
||||
}
|
||||
if (InvoiceLineIdList.Any())
|
||||
{
|
||||
sqlBuilder.In("PurchaseLineID", InvoiceLineIdList, "AND");
|
||||
}
|
||||
if (StatusList.Any())
|
||||
{
|
||||
sqlBuilder.In("PurchaseLineStatus", InvoiceLineIdList, "AND");
|
||||
}
|
||||
if (ItemDescription.Any())
|
||||
{
|
||||
sqlBuilder.LikeAnd("ItemDescription", ItemDescription, "AND");
|
||||
}
|
||||
|
||||
|
||||
// append where string to the sql
|
||||
if (sqlBuilder.IsSetSqlWhereString)
|
||||
{
|
||||
sql = sql + sqlBuilder.SqlWhereString;
|
||||
}
|
||||
|
||||
using (SqlConnection conn = new SqlConnection(SqlConnectionString))
|
||||
{
|
||||
conn.Open();
|
||||
|
||||
using (SqlCommand cmd = new SqlCommand(sql, conn))
|
||||
{
|
||||
sqlBuilder.AddParametersToSqlCommand(cmd);
|
||||
|
||||
using (SqlDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
if (reader.HasRows)
|
||||
{
|
||||
while (reader.Read())
|
||||
{
|
||||
int purchaseLineID = reader.GetInt32(0);
|
||||
int purchaseID = reader.GetInt32(1);
|
||||
string purchaseLineStatus = reader.GetString(2);
|
||||
string supplierRef = null;
|
||||
if (!reader.IsDBNull(3)) { supplierRef = reader.GetString(3); }
|
||||
DateTime? checkedIn = null;
|
||||
if (!reader.IsDBNull(4)) { checkedIn = DateTime.SpecifyKind(reader.GetDateTime(4), DateTimeKind.Utc); }
|
||||
string itemDescription = null;
|
||||
if (!reader.IsDBNull(5)) { itemDescription = reader.GetString(5); }
|
||||
int itemQuantity = reader.GetInt32(6);
|
||||
decimal itemGross = 0;
|
||||
if (!reader.IsDBNull(7)) { itemGross = reader.GetDecimal(7); }
|
||||
decimal itemTax = 0;
|
||||
if (!reader.IsDBNull(8)) { itemTax = reader.GetDecimal(8); }
|
||||
decimal shippingGross = 0;
|
||||
if (!reader.IsDBNull(9)) { shippingGross = reader.GetDecimal(9); }
|
||||
decimal shippingTax = 0;
|
||||
if (!reader.IsDBNull(10)) { shippingTax = reader.GetDecimal(10); }
|
||||
decimal otherGross = 0;
|
||||
if (!reader.IsDBNull(11)) { otherGross = reader.GetDecimal(11); }
|
||||
decimal otherTax = 0;
|
||||
if (!reader.IsDBNull(12)) { otherTax = reader.GetDecimal(12); }
|
||||
int accountTaxCodeID = reader.GetInt32(13);
|
||||
int? tax_AccountTransactionID = null;
|
||||
if (!reader.IsDBNull(14)) { tax_AccountTransactionID = reader.GetInt32(14); }
|
||||
int net_AccountChartOfID = reader.GetInt32(15);
|
||||
int? net_AccountTransactionID = null;
|
||||
if (!reader.IsDBNull(16)) { net_AccountTransactionID = reader.GetInt32(16); }
|
||||
DateTime recordModified;
|
||||
DateTime recordCreated = DateTime.SpecifyKind(reader.GetDateTime(17), DateTimeKind.Utc);
|
||||
if (reader.IsDBNull(18)) { recordModified = recordCreated; }
|
||||
else { recordModified = DateTime.SpecifyKind(reader.GetDateTime(18), DateTimeKind.Utc); }
|
||||
bool isActive = reader.GetBoolean(19);
|
||||
string accountTaxCode = reader.GetString(20);
|
||||
|
||||
var line = new Model.Account.PurchaseInvoice.Line();
|
||||
line.PurchaseLineId = purchaseLineID;
|
||||
line.PurchaseId = purchaseID;
|
||||
line.Status = purchaseLineStatus;
|
||||
line.SupplierRef = supplierRef;
|
||||
line.CheckedIn = checkedIn;
|
||||
line.ItemDescription = itemDescription;
|
||||
line.ItemQuantity = itemQuantity;
|
||||
line.ItemGross = itemGross;
|
||||
line.ItemTax = itemTax;
|
||||
line.ShippingGross = shippingGross;
|
||||
line.ShippingTax = shippingTax;
|
||||
line.OtherGross = otherGross;
|
||||
line.OtherTax = otherTax;
|
||||
line.Tax_AccountTransactionId = tax_AccountTransactionID;
|
||||
line.Net_AccountChartOfId = net_AccountChartOfID;
|
||||
line.Net_AccountTransactionId = net_AccountTransactionID;
|
||||
line.RecordModified = recordModified;
|
||||
line.RecordCreated = recordCreated;
|
||||
line.IsActive = isActive;
|
||||
line.AccountTaxCode = accountTaxCode;
|
||||
|
||||
returnList.Add(purchaseLineID, line);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return returnList;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,13 +5,13 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace bnhtrade.Core.Data.Database.Purchase
|
||||
namespace bnhtrade.Core.Data.Database.Account
|
||||
{
|
||||
public class PurchaseLineStatus : Connection
|
||||
internal class PurchaseInvoiceLineStatus : Connection
|
||||
{
|
||||
public List<Model.Purchase.PurchaseLineStatus> Read()
|
||||
public Dictionary<int, Model.Account.PurchaseInvoiceLineStatus> Read()
|
||||
{
|
||||
var returnList = new List<Model.Purchase.PurchaseLineStatus>();
|
||||
var returnList = new Dictionary<int, Model.Account.PurchaseInvoiceLineStatus>();
|
||||
|
||||
using (SqlConnection conn = new SqlConnection(SqlConnectionString))
|
||||
{
|
||||
@@ -41,8 +41,8 @@ namespace bnhtrade.Core.Data.Database.Purchase
|
||||
string name = reader.GetString(1);
|
||||
int lineSort = reader.GetInt32(2);
|
||||
|
||||
var returnItem = new Model.Purchase.PurchaseLineStatus(id, name,lineSort);
|
||||
returnList.Add( returnItem );
|
||||
var returnItem = new Model.Account.PurchaseInvoiceLineStatus(id, name,lineSort);
|
||||
returnList.Add(id, returnItem );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -64,6 +64,89 @@ namespace bnhtrade.Core.Data.Database
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Append an 'Like' statement (with AND between each like string) and parameter list to the class properties
|
||||
/// </summary>
|
||||
/// <param name="columnReference">Name of the column to used to for the condition statement</param>
|
||||
/// <param name="phraseList">List of phrases to test in condition statement</param>
|
||||
/// <param name="wherePrefix">Optional prefix that gets added to the sql string result</param>
|
||||
public void LikeAnd(string columnReference, List<string> phraseList, string wherePrefix = null)
|
||||
{
|
||||
Like(columnReference, phraseList, true, wherePrefix);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Append an 'Like' statement (with OR between each like string) and parameter list to the class properties
|
||||
/// </summary>
|
||||
/// <param name="columnReference">Name of the column to used to for the condition statement</param>
|
||||
/// <param name="phraseList">List of phrases to test in condition statement</param>
|
||||
/// <param name="wherePrefix">Optional prefix that gets added to the sql string result</param>
|
||||
public void LikeOr(string columnReference, List<string> phraseList, string wherePrefix = null)
|
||||
{
|
||||
Like(columnReference, phraseList, false, wherePrefix);
|
||||
}
|
||||
|
||||
private void Like(string columnReference, List<string> phraseList, bool isAnd, string wherePrefix = null)
|
||||
{
|
||||
if (phraseList == null || !phraseList.Any())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// ensure no values are repeated
|
||||
var distinctList = phraseList.ToList();
|
||||
|
||||
// clean the list
|
||||
for (int i = 0; i < distinctList.Count; i++)
|
||||
{
|
||||
if (string.IsNullOrEmpty(distinctList[i]))
|
||||
{
|
||||
distinctList.RemoveAt(i);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
|
||||
// check again
|
||||
if (distinctList == null || !distinctList.Any())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
string sqlWhere = @"
|
||||
";
|
||||
|
||||
if (wherePrefix != null)
|
||||
{
|
||||
sqlWhere += wherePrefix;
|
||||
}
|
||||
|
||||
|
||||
int listCount = distinctList.Count();
|
||||
for (int i = 0; i < listCount; i++, parameterCount++)
|
||||
{
|
||||
if (i > 0)
|
||||
{
|
||||
if (isAnd)
|
||||
{
|
||||
sqlWhere += " AND ";
|
||||
}
|
||||
else
|
||||
{
|
||||
sqlWhere += " OR ";
|
||||
}
|
||||
}
|
||||
|
||||
sqlWhere += " ( " + columnReference + " LIKE '%' + ";
|
||||
|
||||
string param = "@parameter" + parameterCount;
|
||||
sqlWhere += param;
|
||||
ParameterList.Add(param, distinctList[i]);
|
||||
|
||||
sqlWhere += " + '%' ) ";
|
||||
}
|
||||
SqlWhereString = SqlWhereString + sqlWhere;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Append an 'In' statement and parameter list to the class properties
|
||||
/// </summary>
|
||||
|
||||
16
src/bnhtrade.Core/Logic/Account/PurchaseInvoice.cs
Normal file
16
src/bnhtrade.Core/Logic/Account/PurchaseInvoice.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace bnhtrade.Core.Logic.Account
|
||||
{
|
||||
public class PurchaseInvoice
|
||||
{
|
||||
public List<Model.Account.PurchaseInvoiceLineStatus> ReadLineStatusToList()
|
||||
{
|
||||
return new Data.Database.Account.PurchaseInvoiceLineStatus().Read().Values.ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace bnhtrade.Core.Logic.Purchase
|
||||
{
|
||||
public class PurchaseLineStatus
|
||||
{
|
||||
public List<Model.Purchase.PurchaseLineStatus> ReadAll()
|
||||
{
|
||||
return new Data.Database.Purchase.PurchaseLineStatus().Read();
|
||||
}
|
||||
}
|
||||
}
|
||||
27
src/bnhtrade.Core/Model/Account/Contact.cs
Normal file
27
src/bnhtrade.Core/Model/Account/Contact.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace bnhtrade.Core.Model.Account
|
||||
{
|
||||
public class Contact
|
||||
{
|
||||
public int ContactId { get; set; }
|
||||
|
||||
public string ContantName { get; set; }
|
||||
|
||||
public string ContactEbayName { get; set; }
|
||||
|
||||
public string ContactEbayEmail { get; set; }
|
||||
|
||||
public string ContactPaypalName { get; set; }
|
||||
|
||||
public string ContactPaypalEmail { get; set; }
|
||||
|
||||
public DateTime Created { get; set; }
|
||||
|
||||
public DateTime? Modified { get; set; }
|
||||
}
|
||||
}
|
||||
52
src/bnhtrade.Core/Model/Account/PurchaseInvoice.cs
Normal file
52
src/bnhtrade.Core/Model/Account/PurchaseInvoice.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace bnhtrade.Core.Model.Account
|
||||
{
|
||||
public class PurchaseInvoice
|
||||
{
|
||||
public int PurchaseID { get; set; }
|
||||
public int PurchaseNumber { get; set; }
|
||||
public int? RecordID { get; set; }
|
||||
public DateTime PurchaseDate { get; set; }
|
||||
public Model.Account.Contact Contact { get; set; }
|
||||
public string SupplierRef { get; set; }
|
||||
public string AccountCurrency { get; set; }
|
||||
public string PurchaseChannel { get; set; }
|
||||
public string CurrencyCode { get; set; }
|
||||
public decimal PurchaseTotalAmount { get; set; }
|
||||
public bool VatInclusiveAmounts { get; set; }
|
||||
public DateTime RecordCreated { get; set; }
|
||||
public DateTime RecordModified { get; set; }
|
||||
public bool IsActive { get; set; }
|
||||
|
||||
public List<Model.Account.PurchaseInvoice.Line> InvoiceLines { get; set; }
|
||||
|
||||
public class Line
|
||||
{
|
||||
public int PurchaseLineId { get; set; }
|
||||
public int PurchaseId { get; set; }
|
||||
public string Status { get; set; }
|
||||
public string SupplierRef { get; set; }
|
||||
public DateTime? CheckedIn { get; set; }
|
||||
public string ItemDescription { get; set; }
|
||||
public int ItemQuantity { get; set; }
|
||||
public decimal ItemGross { get; set; }
|
||||
public decimal ItemTax { get; set; }
|
||||
public decimal ShippingGross { get; set; }
|
||||
public decimal ShippingTax { get; set; }
|
||||
public decimal OtherGross { get; set; }
|
||||
public decimal OtherTax { get; set; }
|
||||
public string AccountTaxCode { get; set; }
|
||||
public int? Tax_AccountTransactionId { get; set; }
|
||||
public int Net_AccountChartOfId { get; set; }
|
||||
public int? Net_AccountTransactionId { get; set; }
|
||||
public DateTime RecordCreated { get; set; }
|
||||
public DateTime RecordModified { get; set; }
|
||||
public bool IsActive { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
24
src/bnhtrade.Core/Model/Account/PurchaseInvoiceLineStatus.cs
Normal file
24
src/bnhtrade.Core/Model/Account/PurchaseInvoiceLineStatus.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace bnhtrade.Core.Model.Account
|
||||
{
|
||||
public class PurchaseInvoiceLineStatus
|
||||
{
|
||||
public PurchaseInvoiceLineStatus(int statusId, string statusName, int listSort)
|
||||
{
|
||||
PurchaseLineStatusId = statusId;
|
||||
PurchaseLineStatusName = statusName;
|
||||
ListSort = listSort;
|
||||
}
|
||||
|
||||
public int PurchaseLineStatusId { get; private set; }
|
||||
|
||||
public string PurchaseLineStatusName { get; private set; }
|
||||
|
||||
public int ListSort { get; private set; }
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms.Design;
|
||||
|
||||
namespace bnhtrade.Core.Test.Account
|
||||
{
|
||||
@@ -10,10 +11,21 @@ namespace bnhtrade.Core.Test.Account
|
||||
{
|
||||
public Account()
|
||||
{
|
||||
//var inst = new Data.Database.Account.GetTaxCode(sqlConnectionString);
|
||||
//inst.
|
||||
PurchaseInvoiceLine();
|
||||
}
|
||||
|
||||
//var taxInfo = inst.GetAll();
|
||||
public void PurchaseInvoice()
|
||||
{
|
||||
var read = new Data.Database.Account.PurchaseInvoice();
|
||||
read.PurchaseInvoiceIdList = new List<int> { 14718, 100, 101, 102, 300, 400, 1200, 2734, 6339, 9999 }; // 10 in total
|
||||
var result = read.Read();
|
||||
}
|
||||
|
||||
public void PurchaseInvoiceLine()
|
||||
{
|
||||
var read = new Data.Database.Account.PurchaseInvoiceLine();
|
||||
read.ItemDescription = new List<string> { "xbox", "kill" };
|
||||
var result = read.Read();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,11 @@
|
||||
<StartupObject />
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Data\Database\Inventory\" />
|
||||
<Compile Remove="Data\Database\Inventory\**" />
|
||||
<EmbeddedResource Remove="Data\Database\Inventory\**" />
|
||||
<None Remove="Data\Database\Inventory\**" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Model\Inventory\" />
|
||||
<Folder Include="Model\Product\ProductPricing\" />
|
||||
<Folder Include="Test\Product\" />
|
||||
|
||||
@@ -68,7 +68,6 @@
|
||||
<PackageReference Include="System.Configuration.ConfigurationManager" Version="8.0.0" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>xcopy /E /Y "$(TargetDir)" "C:\Users\Bobbie\Dropbox\Apps\bnhtrade"</PostBuildEvent>
|
||||
<AssemblyTitle>bnhtrade Scheduled Tasks</AssemblyTitle>
|
||||
<Product>bnhtrade Scheduled Tasks</Product>
|
||||
<Copyright>Copyright © 2018</Copyright>
|
||||
|
||||
74
src/bnhtrade.gui/Form1.Designer.cs
generated
74
src/bnhtrade.gui/Form1.Designer.cs
generated
@@ -31,15 +31,15 @@
|
||||
components = new System.ComponentModel.Container();
|
||||
tabControl1 = new TabControl();
|
||||
tabPage1 = new TabPage();
|
||||
tabPage3 = new TabPage();
|
||||
tabPage2 = new TabPage();
|
||||
Receiving = new TabPage();
|
||||
comboBox1 = new ComboBox();
|
||||
purchaseLineStatusBindingSource = new BindingSource(components);
|
||||
dtTmOrderSearch = new DateTimePicker();
|
||||
label1 = new Label();
|
||||
txtbxOrderSearch = new TextBox();
|
||||
tabPage2 = new TabPage();
|
||||
purchaseLineStatusBindingSource = new BindingSource(components);
|
||||
tabControl1.SuspendLayout();
|
||||
tabPage3.SuspendLayout();
|
||||
Receiving.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)purchaseLineStatusBindingSource).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
@@ -47,8 +47,8 @@
|
||||
//
|
||||
tabControl1.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
||||
tabControl1.Controls.Add(tabPage1);
|
||||
tabControl1.Controls.Add(tabPage3);
|
||||
tabControl1.Controls.Add(tabPage2);
|
||||
tabControl1.Controls.Add(Receiving);
|
||||
tabControl1.Location = new Point(12, 12);
|
||||
tabControl1.Name = "tabControl1";
|
||||
tabControl1.SelectedIndex = 0;
|
||||
@@ -66,20 +66,31 @@
|
||||
tabPage1.Text = "Home";
|
||||
tabPage1.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// tabPage3
|
||||
// tabPage2
|
||||
//
|
||||
tabPage3.Controls.Add(comboBox1);
|
||||
tabPage3.Controls.Add(dtTmOrderSearch);
|
||||
tabPage3.Controls.Add(label1);
|
||||
tabPage3.Controls.Add(txtbxOrderSearch);
|
||||
tabPage3.Location = new Point(4, 24);
|
||||
tabPage3.Name = "tabPage3";
|
||||
tabPage3.Padding = new Padding(3);
|
||||
tabPage3.Size = new Size(1002, 505);
|
||||
tabPage3.TabIndex = 2;
|
||||
tabPage3.Text = "Receiving";
|
||||
tabPage3.UseVisualStyleBackColor = true;
|
||||
tabPage3.Click += tabPage3_Click;
|
||||
tabPage2.AccessibleName = "";
|
||||
tabPage2.Location = new Point(4, 24);
|
||||
tabPage2.Name = "tabPage2";
|
||||
tabPage2.Padding = new Padding(3);
|
||||
tabPage2.Size = new Size(1002, 505);
|
||||
tabPage2.TabIndex = 1;
|
||||
tabPage2.Text = "FBA Shipments";
|
||||
tabPage2.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// Receiving
|
||||
//
|
||||
Receiving.Controls.Add(comboBox1);
|
||||
Receiving.Controls.Add(dtTmOrderSearch);
|
||||
Receiving.Controls.Add(label1);
|
||||
Receiving.Controls.Add(txtbxOrderSearch);
|
||||
Receiving.Location = new Point(4, 24);
|
||||
Receiving.Name = "Receiving";
|
||||
Receiving.Padding = new Padding(3);
|
||||
Receiving.Size = new Size(1002, 505);
|
||||
Receiving.TabIndex = 2;
|
||||
Receiving.Text = "Receiving";
|
||||
Receiving.UseVisualStyleBackColor = true;
|
||||
Receiving.Click += tabPage3_Click;
|
||||
//
|
||||
// comboBox1
|
||||
//
|
||||
@@ -93,6 +104,11 @@
|
||||
comboBox1.ValueMember = "PurchaseLineStatusId";
|
||||
comboBox1.SelectedIndexChanged += comboBox1_SelectedIndexChanged;
|
||||
//
|
||||
// purchaseLineStatusBindingSource
|
||||
//
|
||||
purchaseLineStatusBindingSource.DataSource = typeof(Core.Model.Purchase.PurchaseLineStatus);
|
||||
purchaseLineStatusBindingSource.CurrentChanged += purchaseLineStatusBindingSource_CurrentChanged;
|
||||
//
|
||||
// dtTmOrderSearch
|
||||
//
|
||||
dtTmOrderSearch.Location = new Point(356, 46);
|
||||
@@ -116,22 +132,6 @@
|
||||
txtbxOrderSearch.Size = new Size(268, 23);
|
||||
txtbxOrderSearch.TabIndex = 0;
|
||||
//
|
||||
// tabPage2
|
||||
//
|
||||
tabPage2.AccessibleName = "";
|
||||
tabPage2.Location = new Point(4, 24);
|
||||
tabPage2.Name = "tabPage2";
|
||||
tabPage2.Padding = new Padding(3);
|
||||
tabPage2.Size = new Size(1002, 505);
|
||||
tabPage2.TabIndex = 1;
|
||||
tabPage2.Text = "FBA Shipments";
|
||||
tabPage2.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// purchaseLineStatusBindingSource
|
||||
//
|
||||
purchaseLineStatusBindingSource.DataSource = typeof(Core.Model.Purchase.PurchaseLineStatus);
|
||||
purchaseLineStatusBindingSource.CurrentChanged += purchaseLineStatusBindingSource_CurrentChanged;
|
||||
//
|
||||
// Form1
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
@@ -142,8 +142,8 @@
|
||||
Text = "Form1";
|
||||
Load += Form1_Load;
|
||||
tabControl1.ResumeLayout(false);
|
||||
tabPage3.ResumeLayout(false);
|
||||
tabPage3.PerformLayout();
|
||||
Receiving.ResumeLayout(false);
|
||||
Receiving.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)purchaseLineStatusBindingSource).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
@@ -153,7 +153,7 @@
|
||||
private TabControl tabControl1;
|
||||
private TabPage tabPage1;
|
||||
private TabPage tabPage2;
|
||||
private TabPage tabPage3;
|
||||
private TabPage Receiving;
|
||||
private TextBox txtbxOrderSearch;
|
||||
private Label label1;
|
||||
private DateTimePicker dtTmOrderSearch;
|
||||
|
||||
@@ -3,12 +3,11 @@ namespace bnhtrade.gui
|
||||
public partial class Form1 : Form
|
||||
{
|
||||
|
||||
bool loadedTabIndex1 = false;
|
||||
bool initTabReceiving = false;
|
||||
|
||||
public Form1()
|
||||
{
|
||||
InitializeComponent();
|
||||
purchaseLineStatusBindingSource.DataSource = new Core.Logic.Purchase.PurchaseLineStatus().ReadAll();
|
||||
}
|
||||
|
||||
private void Form1_Load(object sender, EventArgs e)
|
||||
@@ -24,13 +23,21 @@ namespace bnhtrade.gui
|
||||
private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
int index = (sender as TabControl).SelectedIndex;
|
||||
string name = tabControl1.SelectedTab.Name;
|
||||
|
||||
if (index == 1)
|
||||
if (name == "Receiving" && initTabReceiving == false)
|
||||
{
|
||||
|
||||
InitialiseTabReceiving();
|
||||
}
|
||||
}
|
||||
|
||||
private void InitialiseTabReceiving()
|
||||
{
|
||||
purchaseLineStatusBindingSource.DataSource = new Core.Logic.Account.PurchaseInvoice().ReadLineStatusToList();
|
||||
initTabReceiving = true;
|
||||
MessageBox.Show("ldsakjfl;s");
|
||||
}
|
||||
|
||||
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
@@ -40,5 +47,6 @@ namespace bnhtrade.gui
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,4 +120,7 @@
|
||||
<metadata name="purchaseLineStatusBindingSource.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="purchaseLineStatusBindingSource.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
</root>
|
||||
Reference in New Issue
Block a user