-
Notifications
You must be signed in to change notification settings - Fork 9
The DBManager file
Mauro Rogledi edited this page Mar 7, 2018
·
5 revisions
The DBManager is the class used by ERPFramework to find, read and write data to the database. Each dataentry has its own DBManager.
internal class DBManagerCustomer : DBManager
{
public DBManagerCustomer(string name, IDocument document)
: base(name, document)
{ }
protected override string CreateMasterQuery(ref List<SqlABParameter> dParam)
{
var qB = new QueryBuilder();
return qB.SelectAllFrom<CustomerTable>().
Where(CustomerTable.ID).IsEqualTo(dParam[0]).
Query;
}
protected override List<SqlABParameter> CreateMasterParam()
{
var PList = new List<SqlABParameter>();
var sParam1 = new SqlABParameter("@p1", CustomerTable.ID) { Value = CustomerTable.ID.DefaultValue };
PList.Add(sParam1);
return PList;
}
protected override void SetParameters(ERPFramework.Controls.IRadarParameters key, DBCollection collection)
{
collection.Parameter[0].Value = key[0];
}
}
Let's analyze the main methods of this class
-
CreateMasterQuery
Using the QueryBuilder class we create a query that selects a single record in a unique way (in this case through its primary key).
The result of this method will beselect * from APP_Customer where [ID] = @p1
-
CreateMasterParam
With this method we declare a list of all parameters used in our query
In this case a int parameter for ID -
SetParameters
In this method we will go to assign a value to the various parameters
In the next version the value assignment will be by name