- Code: Select all
public int ValidCount(JiwaFinancials.Jiwa.JiwaApplication.Manager Manager, string Cat1, string Cat2, string Cat3)
{
//System.Diagnostics.Debugger.Launch();
string Sql = null;
SqlDataReader SQLReader = null;
SqlParameter SQLParam = null;
int result = 0;
try
{
var db = Manager.Database;
Sql = @" SELECT coalesce(count(*), 0) as ValidCount
FROM vAttk_ValidCategoryCombos
where Category1 = @Category1 and Category2 = @Category2 and Category3 = @Category3 ";
using (SqlCommand SQLCmd = new SqlCommand(Sql, db.SQLConnection, db.SQLTransaction))
{
SQLCmd.CommandTimeout = Manager.Database.DefaultCommandTimeout;
SQLParam = new SqlParameter("@Category1", System.Data.SqlDbType.Char);
SQLParam.Value = Cat1;
SQLCmd.Parameters.Add(SQLParam);
SQLParam = new SqlParameter("@Category2", System.Data.SqlDbType.Char);
SQLParam.Value = Cat2;
SQLCmd.Parameters.Add(SQLParam);
SQLParam = new SqlParameter("@Category3", System.Data.SqlDbType.Char);
SQLParam.Value = Cat3;
SQLCmd.Parameters.Add(SQLParam);
SQLReader = SQLCmd.ExecuteReader();
while (SQLReader.Read() == true)
{
result = int.Parse( db.Sanitise(SQLReader, "ValidCount").ToString());
}
SQLReader.Close();
}
}
catch(Exception ex )
{
System.Windows.Forms.MessageBox.Show(ex.Message);
result = 0;
}
finally
{
if ((SQLReader != null))
{
SQLReader.Close();
}
}
return result;
}
Alternately something in ORMLite which is the ORM available through ServiceStack which Jiwa uses for the Rest API would be something like this, you just need to make sure the references for the ServiceStack DLLs are included in assembly references, the classes for all the tables and views are defined in JiwaFinancials.Jiwa.JiwaServiceModel, an example is below
- Code: Select all
private List<JiwaFinancials.Jiwa.JiwaServiceModel.Tables.IN_WarehouseSOH> GetWareHouseSOH(JiwaFinancials.Jiwa.JiwaApplication.Manager manager, string InventoryID)
{
var dbFactory = new OrmLiteConnectionFactory(manager.Database.ConnectionString, ServiceStack.OrmLite.SqlServer2012Dialect.Provider);
using (var db = dbFactory.Open())
{
return db.Select<JiwaFinancials.Jiwa.JiwaServiceModel.Tables.IN_WarehouseSOH>(wsoh => wsoh.InventoryID == InventoryID && wsoh.QuantityLeft > 0);
}
}




