public override TList <PaymentItem> 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.PaymentItem_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 <PaymentItem> rows = new TList <PaymentItem>(); try { try { if (transactionManager != null) { reader = Utility.ExecuteReader(transactionManager, command); } else { reader = Utility.ExecuteReader(database, command); } PaymentItemProviderBaseCore.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 <PaymentItem> 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.PaymentItem_Find_Dynamic", typeof(PaymentItemColumn), 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 <PaymentItem> rows = new TList <PaymentItem>(); IDataReader reader = null; try { if (transactionManager != null) { reader = Utility.ExecuteReader(transactionManager, command); } else { reader = Utility.ExecuteReader(database, command); } PaymentItemProviderBaseCore.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 PaymentItem GetByPaymentItemCode(TransactionManager transactionManager, string paymentItemCode, int start, int pageLength, out int count) { SqlDatabase database = new SqlDatabase(this._connectionString); DbCommand command = StoredProcedureProvider.GetCommandWrapper(database, "dbo.PaymentItem_GetByPaymentItemCode", this._useStoredProcedure); database.AddInParameter(command, "@PaymentItemCode", DbType.AnsiString, paymentItemCode); IDataReader reader = null; TList <PaymentItem> rows = new TList <PaymentItem>(); try { if (transactionManager != null) { reader = Utility.ExecuteReader(transactionManager, command); } else { reader = Utility.ExecuteReader(database, command); } PaymentItemProviderBaseCore.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 <PaymentItem> GetByContractCostCode(TransactionManager transactionManager, string contractCostCode, int start, int pageLength, out int count) { SqlDatabase database = new SqlDatabase(this._connectionString); DbCommand command = StoredProcedureProvider.GetCommandWrapper(database, "dbo.PaymentItem_GetByContractCostCode", this._useStoredProcedure); database.AddInParameter(command, "@ContractCostCode", DbType.AnsiString, contractCostCode); IDataReader reader = null; TList <PaymentItem> rows = new TList <PaymentItem>(); try { if (transactionManager != null) { reader = Utility.ExecuteReader(transactionManager, command); } else { reader = Utility.ExecuteReader(database, command); } PaymentItemProviderBaseCore.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 <PaymentItem> Find(TransactionManager transactionManager, string whereClause, int start, int pageLength, out int count) { count = -1; if (whereClause.IndexOf(";") > -1) { return(new TList <PaymentItem>()); } SqlDatabase database = new SqlDatabase(this._connectionString); DbCommand command = StoredProcedureProvider.GetCommandWrapper(database, "dbo.PaymentItem_Find", this._useStoredProcedure); bool flag = false; if (whereClause.IndexOf(" OR ") > 0) { flag = true; } database.AddInParameter(command, "@SearchUsingOR", DbType.Boolean, flag); database.AddInParameter(command, "@PaymentItemCode", DbType.AnsiString, DBNull.Value); database.AddInParameter(command, "@PaymentCode", DbType.AnsiString, DBNull.Value); database.AddInParameter(command, "@CostCode", DbType.AnsiString, DBNull.Value); database.AddInParameter(command, "@PaymentType", DbType.AnsiString, DBNull.Value); database.AddInParameter(command, "@ItemMoney", DbType.Decimal, DBNull.Value); database.AddInParameter(command, "@Summary", DbType.AnsiString, DBNull.Value); database.AddInParameter(command, "@Remark", DbType.AnsiString, DBNull.Value); database.AddInParameter(command, "@AllocateCode", DbType.AnsiString, DBNull.Value); database.AddInParameter(command, "@OldItemMoney", DbType.Decimal, DBNull.Value); database.AddInParameter(command, "@AlloType", DbType.AnsiString, DBNull.Value); database.AddInParameter(command, "@CostBudgetSetCode", DbType.AnsiString, DBNull.Value); database.AddInParameter(command, "@PBSType", DbType.AnsiString, DBNull.Value); database.AddInParameter(command, "@PBSCode", DbType.AnsiString, DBNull.Value); database.AddInParameter(command, "@Description", DbType.AnsiString, DBNull.Value); database.AddInParameter(command, "@ContractCostCode", DbType.AnsiString, DBNull.Value); database.AddInParameter(command, "@ItemCash", DbType.Decimal, DBNull.Value); database.AddInParameter(command, "@MoneyType", DbType.AnsiString, DBNull.Value); database.AddInParameter(command, "@ExchangeRate", DbType.Decimal, DBNull.Value); database.AddInParameter(command, "@ItemCash0", DbType.Decimal, DBNull.Value); database.AddInParameter(command, "@ItemCash1", DbType.Decimal, DBNull.Value); database.AddInParameter(command, "@ItemCash2", DbType.Decimal, DBNull.Value); database.AddInParameter(command, "@ItemCash3", DbType.Decimal, DBNull.Value); database.AddInParameter(command, "@ItemCash4", DbType.Decimal, DBNull.Value); database.AddInParameter(command, "@ItemCash5", DbType.Decimal, DBNull.Value); database.AddInParameter(command, "@ItemCash6", DbType.Decimal, DBNull.Value); database.AddInParameter(command, "@ItemCash7", DbType.Decimal, DBNull.Value); database.AddInParameter(command, "@ItemCash8", DbType.Decimal, DBNull.Value); database.AddInParameter(command, "@ItemCash9", 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("paymentitemcode ") || text.Trim().StartsWith("paymentitemcode=")) { database.SetParameterValue(command, "@PaymentItemCode", text.Replace("paymentitemcode", "").Trim().TrimStart(trimChars).Trim().Trim(chArray2)); } else if (text.Trim().StartsWith("paymentcode ") || text.Trim().StartsWith("paymentcode=")) { database.SetParameterValue(command, "@PaymentCode", text.Replace("paymentcode", "").Trim().TrimStart(trimChars).Trim().Trim(chArray2)); } else if (text.Trim().StartsWith("costcode ") || text.Trim().StartsWith("costcode=")) { database.SetParameterValue(command, "@CostCode", text.Replace("costcode", "").Trim().TrimStart(trimChars).Trim().Trim(chArray2)); } else if (text.Trim().StartsWith("paymenttype ") || text.Trim().StartsWith("paymenttype=")) { database.SetParameterValue(command, "@PaymentType", text.Replace("paymenttype", "").Trim().TrimStart(trimChars).Trim().Trim(chArray2)); } else if (text.Trim().StartsWith("itemmoney ") || text.Trim().StartsWith("itemmoney=")) { database.SetParameterValue(command, "@ItemMoney", text.Replace("itemmoney", "").Trim().TrimStart(trimChars).Trim().Trim(chArray2)); } else if (text.Trim().StartsWith("summary ") || text.Trim().StartsWith("summary=")) { database.SetParameterValue(command, "@Summary", text.Replace("summary", "").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("allocatecode ") || text.Trim().StartsWith("allocatecode=")) { database.SetParameterValue(command, "@AllocateCode", text.Replace("allocatecode", "").Trim().TrimStart(trimChars).Trim().Trim(chArray2)); } else if (text.Trim().StartsWith("olditemmoney ") || text.Trim().StartsWith("olditemmoney=")) { database.SetParameterValue(command, "@OldItemMoney", text.Replace("olditemmoney", "").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("costbudgetsetcode ") || text.Trim().StartsWith("costbudgetsetcode=")) { database.SetParameterValue(command, "@CostBudgetSetCode", text.Replace("costbudgetsetcode", "").Trim().TrimStart(trimChars).Trim().Trim(chArray2)); } else if (text.Trim().StartsWith("pbstype ") || text.Trim().StartsWith("pbstype=")) { database.SetParameterValue(command, "@PBSType", text.Replace("pbstype", "").Trim().TrimStart(trimChars).Trim().Trim(chArray2)); } else if (text.Trim().StartsWith("pbscode ") || text.Trim().StartsWith("pbscode=")) { database.SetParameterValue(command, "@PBSCode", text.Replace("pbscode", "").Trim().TrimStart(trimChars).Trim().Trim(chArray2)); } else if (text.Trim().StartsWith("description ") || text.Trim().StartsWith("description=")) { database.SetParameterValue(command, "@Description", text.Replace("description", "").Trim().TrimStart(trimChars).Trim().Trim(chArray2)); } else if (text.Trim().StartsWith("contractcostcode ") || text.Trim().StartsWith("contractcostcode=")) { database.SetParameterValue(command, "@ContractCostCode", text.Replace("contractcostcode", "").Trim().TrimStart(trimChars).Trim().Trim(chArray2)); } else if (text.Trim().StartsWith("itemcash ") || text.Trim().StartsWith("itemcash=")) { database.SetParameterValue(command, "@ItemCash", text.Replace("itemcash", "").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("itemcash0 ") || text.Trim().StartsWith("itemcash0=")) { database.SetParameterValue(command, "@ItemCash0", text.Replace("itemcash0", "").Trim().TrimStart(trimChars).Trim().Trim(chArray2)); } else if (text.Trim().StartsWith("itemcash1 ") || text.Trim().StartsWith("itemcash1=")) { database.SetParameterValue(command, "@ItemCash1", text.Replace("itemcash1", "").Trim().TrimStart(trimChars).Trim().Trim(chArray2)); } else if (text.Trim().StartsWith("itemcash2 ") || text.Trim().StartsWith("itemcash2=")) { database.SetParameterValue(command, "@ItemCash2", text.Replace("itemcash2", "").Trim().TrimStart(trimChars).Trim().Trim(chArray2)); } else if (text.Trim().StartsWith("itemcash3 ") || text.Trim().StartsWith("itemcash3=")) { database.SetParameterValue(command, "@ItemCash3", text.Replace("itemcash3", "").Trim().TrimStart(trimChars).Trim().Trim(chArray2)); } else if (text.Trim().StartsWith("itemcash4 ") || text.Trim().StartsWith("itemcash4=")) { database.SetParameterValue(command, "@ItemCash4", text.Replace("itemcash4", "").Trim().TrimStart(trimChars).Trim().Trim(chArray2)); } else if (text.Trim().StartsWith("itemcash5 ") || text.Trim().StartsWith("itemcash5=")) { database.SetParameterValue(command, "@ItemCash5", text.Replace("itemcash5", "").Trim().TrimStart(trimChars).Trim().Trim(chArray2)); } else if (text.Trim().StartsWith("itemcash6 ") || text.Trim().StartsWith("itemcash6=")) { database.SetParameterValue(command, "@ItemCash6", text.Replace("itemcash6", "").Trim().TrimStart(trimChars).Trim().Trim(chArray2)); } else if (text.Trim().StartsWith("itemcash7 ") || text.Trim().StartsWith("itemcash7=")) { database.SetParameterValue(command, "@ItemCash7", text.Replace("itemcash7", "").Trim().TrimStart(trimChars).Trim().Trim(chArray2)); } else if (text.Trim().StartsWith("itemcash8 ") || text.Trim().StartsWith("itemcash8=")) { database.SetParameterValue(command, "@ItemCash8", text.Replace("itemcash8", "").Trim().TrimStart(trimChars).Trim().Trim(chArray2)); } else { if (!text.Trim().StartsWith("itemcash9 ") && !text.Trim().StartsWith("itemcash9=")) { throw new ArgumentException("Unable to use this part of the where clause in this version of Find: " + text); } database.SetParameterValue(command, "@ItemCash9", text.Replace("itemcash9", "").Trim().TrimStart(trimChars).Trim().Trim(chArray2)); } } IDataReader reader = null; TList <PaymentItem> rows = new TList <PaymentItem>(); try { if (transactionManager != null) { reader = Utility.ExecuteReader(transactionManager, command); } else { reader = Utility.ExecuteReader(database, command); } PaymentItemProviderBaseCore.Fill(reader, rows, start, pageLength); if (reader.NextResult() && reader.Read()) { count = reader.GetInt32(0); } } finally { if (reader != null) { reader.Close(); } } return(rows); }