public override TList <PayoutItem> GetPaged(TransactionManager transactionManager, string whereClause, string orderBy, int start, int pageLength, out int count) { SqlDatabase database = new SqlDatabase(this._connectionString); DbCommand command = StoredProcedureProvider.GetCommandWrapper(database, "dbo.PayoutItem_GetPaged", this._useStoredProcedure); database.AddInParameter(command, "@WhereClause", DbType.String, whereClause); database.AddInParameter(command, "@OrderBy", DbType.String, orderBy); database.AddInParameter(command, "@PageIndex", DbType.Int32, start); database.AddInParameter(command, "@PageSize", DbType.Int32, pageLength); IDataReader reader = null; TList <PayoutItem> rows = new TList <PayoutItem>(); try { try { if (transactionManager != null) { reader = Utility.ExecuteReader(transactionManager, command); } else { reader = Utility.ExecuteReader(database, command); } PayoutItemProviderBaseCore.Fill(reader, rows, 0, 0x7fffffff); count = rows.Count; if (reader.NextResult() && reader.Read()) { count = reader.GetInt32(0); } return(rows); } catch (Exception) { throw; } } finally { if (reader != null) { reader.Close(); } } return(rows); }
public override TList <PayoutItem> Find(TransactionManager transactionManager, SqlFilterParameterCollection parameters, string orderBy, int start, int pageLength, out int count) { SqlDatabase database = new SqlDatabase(this._connectionString); DbCommand command = StoredProcedureProvider.GetCommandWrapper(database, "dbo.PayoutItem_Find_Dynamic", typeof(PayoutItemColumn), parameters, orderBy, start, pageLength); if (parameters != null) { for (int i = 0; i < parameters.Count; i++) { SqlFilterParameter parameter = parameters[i]; database.AddInParameter(command, parameter.Name, parameter.DbType, parameter.Value); } } TList <PayoutItem> rows = new TList <PayoutItem>(); IDataReader reader = null; try { if (transactionManager != null) { reader = Utility.ExecuteReader(transactionManager, command); } else { reader = Utility.ExecuteReader(database, command); } PayoutItemProviderBaseCore.Fill(reader, rows, 0, 0x7fffffff); count = rows.Count; if (!reader.NextResult()) { return(rows); } if (reader.Read()) { count = reader.GetInt32(0); } } finally { if (reader != null) { reader.Close(); } } return(rows); }
public override PayoutItem GetByPayoutItemCode(TransactionManager transactionManager, string payoutItemCode, int start, int pageLength, out int count) { SqlDatabase database = new SqlDatabase(this._connectionString); DbCommand command = StoredProcedureProvider.GetCommandWrapper(database, "dbo.PayoutItem_GetByPayoutItemCode", this._useStoredProcedure); database.AddInParameter(command, "@PayoutItemCode", DbType.AnsiString, payoutItemCode); IDataReader reader = null; TList <PayoutItem> rows = new TList <PayoutItem>(); try { if (transactionManager != null) { reader = Utility.ExecuteReader(transactionManager, command); } else { reader = Utility.ExecuteReader(database, command); } PayoutItemProviderBaseCore.Fill(reader, rows, start, pageLength); count = -1; if (reader.NextResult() && reader.Read()) { count = reader.GetInt32(0); } } finally { if (reader != null) { reader.Close(); } } if (rows.Count == 1) { return(rows[0]); } if (rows.Count != 0) { throw new DataException("Cannot find the unique instance of the class."); } return(null); }
public override TList <PayoutItem> GetAll(TransactionManager transactionManager, int start, int pageLength, out int count) { SqlDatabase database = new SqlDatabase(this._connectionString); DbCommand dbCommand = StoredProcedureProvider.GetCommandWrapper(database, "dbo.PayoutItem_Get_List", this._useStoredProcedure); IDataReader reader = null; TList <PayoutItem> rows = new TList <PayoutItem>(); try { if (transactionManager != null) { reader = Utility.ExecuteReader(transactionManager, dbCommand); } else { reader = Utility.ExecuteReader(database, dbCommand); } PayoutItemProviderBaseCore.Fill(reader, rows, start, pageLength); count = -1; if (!reader.NextResult()) { return(rows); } if (reader.Read()) { count = reader.GetInt32(0); } } finally { if (reader != null) { reader.Close(); } } return(rows); }
public override TList <PayoutItem> Find(TransactionManager transactionManager, string whereClause, int start, int pageLength, out int count) { count = -1; if (whereClause.IndexOf(";") > -1) { return(new TList <PayoutItem>()); } SqlDatabase database = new SqlDatabase(this._connectionString); DbCommand command = StoredProcedureProvider.GetCommandWrapper(database, "dbo.PayoutItem_Find", this._useStoredProcedure); bool flag = false; if (whereClause.IndexOf(" OR ") > 0) { flag = true; } database.AddInParameter(command, "@SearchUsingOR", DbType.Boolean, flag); database.AddInParameter(command, "@PayoutItemCode", DbType.AnsiString, DBNull.Value); database.AddInParameter(command, "@PayoutCode", DbType.AnsiString, DBNull.Value); database.AddInParameter(command, "@PaymentItemCode", DbType.AnsiString, DBNull.Value); database.AddInParameter(command, "@PayoutMoney", DbType.Decimal, DBNull.Value); database.AddInParameter(command, "@SubjectCode", DbType.AnsiString, DBNull.Value); database.AddInParameter(command, "@Remark", DbType.AnsiString, DBNull.Value); database.AddInParameter(command, "@AlloType", DbType.AnsiString, DBNull.Value); database.AddInParameter(command, "@IsManualAlloc", DbType.Int32, DBNull.Value); database.AddInParameter(command, "@PayoutCash", DbType.Decimal, DBNull.Value); database.AddInParameter(command, "@MoneyType", DbType.AnsiString, DBNull.Value); database.AddInParameter(command, "@ExchangeRate", DbType.Decimal, DBNull.Value); database.AddInParameter(command, "@PayoutMoneyType", DbType.AnsiString, DBNull.Value); database.AddInParameter(command, "@PayoutExchangeRate", DbType.Decimal, DBNull.Value); whereClause = whereClause.Replace(" AND ", "|").Replace(" OR ", "|"); string[] textArray = whereClause.ToLower().Split(new char[] { '|' }); char[] trimChars = new char[] { '=' }; char[] chArray2 = new char[] { '\'' }; foreach (string text in textArray) { if (text.Trim().StartsWith("payoutitemcode ") || text.Trim().StartsWith("payoutitemcode=")) { database.SetParameterValue(command, "@PayoutItemCode", text.Replace("payoutitemcode", "").Trim().TrimStart(trimChars).Trim().Trim(chArray2)); } else if (text.Trim().StartsWith("payoutcode ") || text.Trim().StartsWith("payoutcode=")) { database.SetParameterValue(command, "@PayoutCode", text.Replace("payoutcode", "").Trim().TrimStart(trimChars).Trim().Trim(chArray2)); } else if (text.Trim().StartsWith("paymentitemcode ") || text.Trim().StartsWith("paymentitemcode=")) { database.SetParameterValue(command, "@PaymentItemCode", text.Replace("paymentitemcode", "").Trim().TrimStart(trimChars).Trim().Trim(chArray2)); } else if (text.Trim().StartsWith("payoutmoney ") || text.Trim().StartsWith("payoutmoney=")) { database.SetParameterValue(command, "@PayoutMoney", text.Replace("payoutmoney", "").Trim().TrimStart(trimChars).Trim().Trim(chArray2)); } else if (text.Trim().StartsWith("subjectcode ") || text.Trim().StartsWith("subjectcode=")) { database.SetParameterValue(command, "@SubjectCode", text.Replace("subjectcode", "").Trim().TrimStart(trimChars).Trim().Trim(chArray2)); } else if (text.Trim().StartsWith("remark ") || text.Trim().StartsWith("remark=")) { database.SetParameterValue(command, "@Remark", text.Replace("remark", "").Trim().TrimStart(trimChars).Trim().Trim(chArray2)); } else if (text.Trim().StartsWith("allotype ") || text.Trim().StartsWith("allotype=")) { database.SetParameterValue(command, "@AlloType", text.Replace("allotype", "").Trim().TrimStart(trimChars).Trim().Trim(chArray2)); } else if (text.Trim().StartsWith("ismanualalloc ") || text.Trim().StartsWith("ismanualalloc=")) { database.SetParameterValue(command, "@IsManualAlloc", text.Replace("ismanualalloc", "").Trim().TrimStart(trimChars).Trim().Trim(chArray2)); } else if (text.Trim().StartsWith("payoutcash ") || text.Trim().StartsWith("payoutcash=")) { database.SetParameterValue(command, "@PayoutCash", text.Replace("payoutcash", "").Trim().TrimStart(trimChars).Trim().Trim(chArray2)); } else if (text.Trim().StartsWith("moneytype ") || text.Trim().StartsWith("moneytype=")) { database.SetParameterValue(command, "@MoneyType", text.Replace("moneytype", "").Trim().TrimStart(trimChars).Trim().Trim(chArray2)); } else if (text.Trim().StartsWith("exchangerate ") || text.Trim().StartsWith("exchangerate=")) { database.SetParameterValue(command, "@ExchangeRate", text.Replace("exchangerate", "").Trim().TrimStart(trimChars).Trim().Trim(chArray2)); } else if (text.Trim().StartsWith("payoutmoneytype ") || text.Trim().StartsWith("payoutmoneytype=")) { database.SetParameterValue(command, "@PayoutMoneyType", text.Replace("payoutmoneytype", "").Trim().TrimStart(trimChars).Trim().Trim(chArray2)); } else { if (!text.Trim().StartsWith("payoutexchangerate ") && !text.Trim().StartsWith("payoutexchangerate=")) { throw new ArgumentException("Unable to use this part of the where clause in this version of Find: " + text); } database.SetParameterValue(command, "@PayoutExchangeRate", text.Replace("payoutexchangerate", "").Trim().TrimStart(trimChars).Trim().Trim(chArray2)); } } IDataReader reader = null; TList <PayoutItem> rows = new TList <PayoutItem>(); try { if (transactionManager != null) { reader = Utility.ExecuteReader(transactionManager, command); } else { reader = Utility.ExecuteReader(database, command); } PayoutItemProviderBaseCore.Fill(reader, rows, start, pageLength); if (reader.NextResult() && reader.Read()) { count = reader.GetInt32(0); } } finally { if (reader != null) { reader.Close(); } } return(rows); }