mirror of
https://github.com/stokebob/bnhtrade.git
synced 2026-03-19 06:27:15 +00:00
reading account journal complete
This commit is contained in:
@@ -11,7 +11,7 @@ namespace bnhtrade.Core.Test.Account
|
||||
{
|
||||
public Account()
|
||||
{
|
||||
PurchaseInvoiceLine();
|
||||
Journal();
|
||||
}
|
||||
|
||||
public void PurchaseInvoice()
|
||||
@@ -27,5 +27,12 @@ namespace bnhtrade.Core.Test.Account
|
||||
read.ItemDescription = new List<string> { "xbox", "kill" };
|
||||
var result = read.Read();
|
||||
}
|
||||
|
||||
public void Journal()
|
||||
{
|
||||
var read = new Data.Database.Account.Journal();
|
||||
read.AccountJournalId = new List<uint> { 123, 300, 324, 5678, 22 };
|
||||
var result = read.Read();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
94
src/bnhtrade.Core/Test/_BoilerPlate/sql_Read.cs
Normal file
94
src/bnhtrade.Core/Test/_BoilerPlate/sql_Read.cs
Normal file
@@ -0,0 +1,94 @@
|
||||
using bnhtrade.Core.Data.Database;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace bnhtrade.Core.Test._BoilerPlate
|
||||
{
|
||||
internal class xxxxxxxYourClassNameHerexxxxxxxx : Connection
|
||||
{
|
||||
private bnhtrade.Core.Data.Database.SqlWhereBuilder sqlBuilder;
|
||||
|
||||
/// <summary>
|
||||
/// Results filter
|
||||
/// </summary>
|
||||
public List<int> ColumnTitle1List { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Searches for the specificed phases within the item description. Uses the LIKE AND sql function
|
||||
/// </summary>
|
||||
public List<string> ColumnTitle2List { get; set; }
|
||||
|
||||
public xxxxxxxYourClassNameHerexxxxxxxx()
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
public void Init()
|
||||
{
|
||||
sqlBuilder = new SqlWhereBuilder();
|
||||
ColumnTitle1List = new List<int>();
|
||||
ColumnTitle2List = new List<string>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns>Dictionary were key is the table primary key</returns>
|
||||
public Dictionary<int, string> Read()
|
||||
{
|
||||
// create the return (emptyP list) here
|
||||
var returnList = new Dictionary<int, string>();
|
||||
sqlBuilder.Init();
|
||||
|
||||
//build sql query
|
||||
string sql = @"
|
||||
SELECT item1, item2, item3
|
||||
FROM tblPurchaseLine
|
||||
WHERE 1 = 1 ";
|
||||
|
||||
// build the where statments
|
||||
if (ColumnTitle1List.Any())
|
||||
{
|
||||
sqlBuilder.In("xxxxxxxxxxxxxxColumnTitle1xxxxxxxxxxxxxxxxxx", ColumnTitle1List, "AND");
|
||||
}
|
||||
if (ColumnTitle2List.Any())
|
||||
{
|
||||
sqlBuilder.In("xxxxxxxxxxxxxxColumnTitle2xxxxxxxxxxxxxxxxxx", ColumnTitle2List, "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())
|
||||
{
|
||||
// read from db and create object
|
||||
// and add to return list
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// all done, return the list here
|
||||
return returnList;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user