Discussions relating to plugin development, and the Jiwa API.
by SBarnes » Thu Jun 08, 2023 10:26 am
I have the following code to get the back order value for a debtor when processing a sales order but to get it to work I have had to declare a class DBBOValue is there any way of avoiding declaring the class?
- Code: Select all
public decimal GetBackOrderValue( JiwaFinancials.Jiwa.JiwaSales.SalesOrder.SalesOrder salesorder)
{
decimal result = 0;
try
{
JiwaFinancials.Jiwa.JiwaApplication.Manager manager = salesorder.Manager;
var dbFactory = new OrmLiteConnectionFactory(manager.Database.ConnectionString, ServiceStack.OrmLite.SqlServer2012Dialect.Provider);
using (var db = dbFactory.Open())
{
string debtorID = salesorder.Debtor.DebtorID;
var qry = db.From<JiwaFinancials.Jiwa.JiwaServiceModel.Tables.IN_OnBackOrder>()
.Where<JiwaFinancials.Jiwa.JiwaServiceModel.Tables.IN_OnBackOrder>((b) => b.DebtorID == debtorID)
.Select<JiwaFinancials.Jiwa.JiwaServiceModel.Tables.IN_OnBackOrder>((b) => new {BOValue = Sql.Sum("EstBOValue")} );
string sql = qry.SelectExpression + Environment.NewLine + qry.FromExpression + Environment.NewLine + qry.WhereExpression;
var qryresult = db.Single<DBBOValue>(qry);
result = qryresult.BOValue;
db.Close();
}
}
catch (Exception ex)
{
result = 0;
}
return result;
}
public class DBBOValue
{ public decimal BOValue {get;set;}
}
Regards
Stuart Barnes
-
SBarnes
- Shihan
-
- Posts: 1620
- Joined: Fri Aug 15, 2008 3:27 pm
- Topics Solved: 175
Return to Technical and or Programming
Who is online
Users browsing this forum: No registered users and 18 guests