/// <summary> /// Returns rows from the DataSource that meet the parameter conditions. /// </summary> /// <param name="transactionManager"><see cref="TransactionManager"/> object</param> /// <param name="parameters">A collection of <see cref="SqlFilterParameter"/> objects.</param> /// <param name="orderBy">Specifies the sort criteria for the rows in the DataSource (Name ASC; BirthDay DESC, Name ASC);</param> /// <param name="start">Row number at which to start reading.</param> /// <param name="pageLength">Number of rows to return.</param> /// <param name="count">out. The number of rows that match this query.</param> /// <returns>Returns a typed collection of LibraryManagement.Domain.Staff objects.</returns> public override TList <Staff> Find(TransactionManager transactionManager, IFilterParameterCollection parameters, string orderBy, int start, int pageLength, out int count) { SqlFilterParameterCollection filter = null; if (parameters == null) { filter = new SqlFilterParameterCollection(); } else { filter = parameters.GetParameters(); } SqlDatabase database = new SqlDatabase(this._connectionString); DbCommand commandWrapper = StoredProcedureProvider.GetCommandWrapper(database, "dbo.tblStaff_Find_Dynamic", typeof(StaffColumn), filter, orderBy, start, pageLength); SqlFilterParameter param; for (int i = 0; i < filter.Count; i++) { param = filter[i]; database.AddInParameter(commandWrapper, param.Name, param.DbType, param.GetValue()); } TList <Staff> rows = new TList <Staff>(); IDataReader reader = null; try { //Provider Data Requesting Command Event OnDataRequesting(new CommandEventArgs(commandWrapper, "Find", rows)); if (transactionManager != null) { reader = Utility.ExecuteReader(transactionManager, commandWrapper); } else { reader = Utility.ExecuteReader(database, commandWrapper); } Fill(reader, rows, 0, int.MaxValue); count = rows.Count; if (reader.NextResult()) { if (reader.Read()) { count = reader.GetInt32(0); } } //Provider Data Requested Command Event OnDataRequested(new CommandEventArgs(commandWrapper, "Find", rows)); } finally { if (reader != null) { reader.Close(); } commandWrapper = null; } return(rows); }
} //end getall #endregion #region GetPaged Methods /// <summary> /// Gets a page of rows from the DataSource. /// </summary> /// <param name="start">Row number at which to start reading.</param> /// <param name="pageLength">Number of rows to return.</param> /// <param name="count">Number of rows in the DataSource.</param> /// <param name="whereClause">Specifies the condition for the rows returned by a query (Name='John Doe', Name='John Doe' AND Id='1', Name='John Doe' OR Id='1').</param> /// <param name="orderBy">Specifies the sort criteria for the rows in the DataSource (Name ASC; BirthDay DESC, Name ASC);</param> /// <param name="transactionManager"><see cref="TransactionManager"/> object</param> /// <remarks></remarks> /// <returns>Returns a typed collection of LibraryManagement.Domain.Staff objects.</returns> public override TList <Staff> GetPaged(TransactionManager transactionManager, string whereClause, string orderBy, int start, int pageLength, out int count) { SqlDatabase database = new SqlDatabase(this._connectionString); DbCommand commandWrapper = StoredProcedureProvider.GetCommandWrapper(database, "dbo.tblStaff_GetPaged", _useStoredProcedure); if (commandWrapper.CommandType == CommandType.Text && commandWrapper.CommandText != null) { commandWrapper.CommandText = commandWrapper.CommandText.Replace(SqlUtil.PAGE_INDEX, string.Concat(SqlUtil.PAGE_INDEX, Guid.NewGuid().ToString("N").Substring(0, 8))); } database.AddInParameter(commandWrapper, "@WhereClause", DbType.String, whereClause); database.AddInParameter(commandWrapper, "@OrderBy", DbType.String, orderBy); database.AddInParameter(commandWrapper, "@PageIndex", DbType.Int32, start); database.AddInParameter(commandWrapper, "@PageSize", DbType.Int32, pageLength); IDataReader reader = null; //Create Collection TList <Staff> rows = new TList <Staff>(); try { //Provider Data Requesting Command Event OnDataRequesting(new CommandEventArgs(commandWrapper, "GetPaged", rows)); if (transactionManager != null) { reader = Utility.ExecuteReader(transactionManager, commandWrapper); } else { reader = Utility.ExecuteReader(database, commandWrapper); } Fill(reader, rows, 0, int.MaxValue); count = rows.Count; if (reader.NextResult()) { if (reader.Read()) { count = reader.GetInt32(0); } } //Provider Data Requested Command Event OnDataRequested(new CommandEventArgs(commandWrapper, "GetPaged", rows)); } catch (Exception) { throw; } finally { if (reader != null) { reader.Close(); } commandWrapper = null; } return(rows); }
/// <summary> /// Gets rows from the datasource based on the PK_tblUser index. /// </summary> /// <param name="transactionManager"><see cref="TransactionManager"/> object</param> /// <param name="_id"></param> /// <param name="start">Row number at which to start reading.</param> /// <param name="pageLength">Number of rows to return.</param> /// <param name="count">out parameter to get total records for query.</param> /// <returns>Returns an instance of the <see cref="LibraryManagement.Domain.User"/> class.</returns> /// <remarks></remarks> /// <exception cref="System.Exception">The command could not be executed.</exception> /// <exception cref="System.Data.DataException">The <paramref name="transactionManager"/> is not open.</exception> /// <exception cref="System.Data.Common.DbException">The command could not be executed.</exception> public override LibraryManagement.Domain.User GetById(TransactionManager transactionManager, System.Int32 _id, int start, int pageLength, out int count) { SqlDatabase database = new SqlDatabase(this._connectionString); DbCommand commandWrapper = StoredProcedureProvider.GetCommandWrapper(database, "dbo.tblUser_GetById", _useStoredProcedure); database.AddInParameter(commandWrapper, "@Id", DbType.Int32, _id); IDataReader reader = null; TList <User> tmp = new TList <User>(); try { //Provider Data Requesting Command Event OnDataRequesting(new CommandEventArgs(commandWrapper, "GetById", tmp)); if (transactionManager != null) { reader = Utility.ExecuteReader(transactionManager, commandWrapper); } else { reader = Utility.ExecuteReader(database, commandWrapper); } //Create collection and fill Fill(reader, tmp, start, pageLength); count = -1; if (reader.NextResult()) { if (reader.Read()) { count = reader.GetInt32(0); } } //Provider Data Requested Command Event OnDataRequested(new CommandEventArgs(commandWrapper, "GetById", tmp)); } finally { if (reader != null) { reader.Close(); } commandWrapper = null; } if (tmp.Count == 1) { return(tmp[0]); } else if (tmp.Count == 0) { return(null); } else { throw new DataException("Cannot find the unique instance of the class."); } //return rows; }
} //end Delete #endregion #region Find Functions #region Parsed Find Methods /// <summary> /// Returns rows meeting the whereClause condition from the DataSource. /// </summary> /// <param name="transactionManager"><see cref="TransactionManager"/> object</param> /// <param name="whereClause">Specifies the condition for the rows returned by a query (Name='John Doe', Name='John Doe' AND Id='1', Name='John Doe' OR Id='1').</param> /// <param name="start">Row number at which to start reading.</param> /// <param name="pageLength">Number of rows to return.</param> /// <param name="count">out. The number of rows that match this query.</param> /// <remarks>Operators must be capitalized (OR, AND).</remarks> /// <returns>Returns a typed collection of LibraryManagement.Domain.Staff objects.</returns> public override TList <Staff> Find(TransactionManager transactionManager, string whereClause, int start, int pageLength, out int count) { count = -1; if (whereClause.IndexOf(";") > -1) { return(new TList <Staff>()); } SqlDatabase database = new SqlDatabase(this._connectionString); DbCommand commandWrapper = StoredProcedureProvider.GetCommandWrapper(database, "dbo.tblStaff_Find", _useStoredProcedure); bool searchUsingOR = false; if (whereClause.IndexOf(" OR ") > 0) // did they want to do "a=b OR c=d OR..."? { searchUsingOR = true; } database.AddInParameter(commandWrapper, "@SearchUsingOR", DbType.Boolean, searchUsingOR); database.AddInParameter(commandWrapper, "@Id", DbType.StringFixedLength, DBNull.Value); database.AddInParameter(commandWrapper, "@Name", DbType.String, DBNull.Value); database.AddInParameter(commandWrapper, "@Depart", DbType.StringFixedLength, DBNull.Value); database.AddInParameter(commandWrapper, "@OpenDate", DbType.DateTime, DBNull.Value); database.AddInParameter(commandWrapper, "@SalaryLevel", DbType.Decimal, DBNull.Value); database.AddInParameter(commandWrapper, "@Address", DbType.String, DBNull.Value); database.AddInParameter(commandWrapper, "@Phone", DbType.StringFixedLength, DBNull.Value); database.AddInParameter(commandWrapper, "@PersonId", DbType.StringFixedLength, DBNull.Value); database.AddInParameter(commandWrapper, "@PersonIddate", DbType.DateTime, DBNull.Value); database.AddInParameter(commandWrapper, "@Location", DbType.String, DBNull.Value); database.AddInParameter(commandWrapper, "@ContactPerson", DbType.String, DBNull.Value); database.AddInParameter(commandWrapper, "@Remark", DbType.String, DBNull.Value); database.AddInParameter(commandWrapper, "@Labelsprn", DbType.StringFixedLength, DBNull.Value); database.AddInParameter(commandWrapper, "@Status", DbType.Int32, DBNull.Value); // replace all instances of 'AND' and 'OR' because we already set searchUsingOR whereClause = whereClause.Replace(" AND ", "|").Replace(" OR ", "|"); string[] clauses = whereClause.ToLower().Split('|'); // Here's what's going on below: Find a field, then to get the value we // drop the field name from the front, trim spaces, drop the '=' sign, // trim more spaces, and drop any outer single quotes. // Now handles the case when two fields start off the same way - like "Friendly='Yes' AND Friend='john'" char[] equalSign = { '=' }; char[] singleQuote = { '\'' }; foreach (string clause in clauses) { if (clause.Trim().StartsWith("id ") || clause.Trim().StartsWith("id=")) { database.SetParameterValue(commandWrapper, "@Id", clause.Trim().Remove(0, 2).Trim().TrimStart(equalSign).Trim().Trim(singleQuote)); continue; } if (clause.Trim().StartsWith("name ") || clause.Trim().StartsWith("name=")) { database.SetParameterValue(commandWrapper, "@Name", clause.Trim().Remove(0, 4).Trim().TrimStart(equalSign).Trim().Trim(singleQuote)); continue; } if (clause.Trim().StartsWith("depart ") || clause.Trim().StartsWith("depart=")) { database.SetParameterValue(commandWrapper, "@Depart", clause.Trim().Remove(0, 6).Trim().TrimStart(equalSign).Trim().Trim(singleQuote)); continue; } if (clause.Trim().StartsWith("open_date ") || clause.Trim().StartsWith("open_date=")) { database.SetParameterValue(commandWrapper, "@OpenDate", clause.Trim().Remove(0, 9).Trim().TrimStart(equalSign).Trim().Trim(singleQuote)); continue; } if (clause.Trim().StartsWith("salarylevel ") || clause.Trim().StartsWith("salarylevel=")) { database.SetParameterValue(commandWrapper, "@SalaryLevel", clause.Trim().Remove(0, 11).Trim().TrimStart(equalSign).Trim().Trim(singleQuote)); continue; } if (clause.Trim().StartsWith("address ") || clause.Trim().StartsWith("address=")) { database.SetParameterValue(commandWrapper, "@Address", clause.Trim().Remove(0, 7).Trim().TrimStart(equalSign).Trim().Trim(singleQuote)); continue; } if (clause.Trim().StartsWith("phone ") || clause.Trim().StartsWith("phone=")) { database.SetParameterValue(commandWrapper, "@Phone", clause.Trim().Remove(0, 5).Trim().TrimStart(equalSign).Trim().Trim(singleQuote)); continue; } if (clause.Trim().StartsWith("personid ") || clause.Trim().StartsWith("personid=")) { database.SetParameterValue(commandWrapper, "@PersonId", clause.Trim().Remove(0, 8).Trim().TrimStart(equalSign).Trim().Trim(singleQuote)); continue; } if (clause.Trim().StartsWith("personiddate ") || clause.Trim().StartsWith("personiddate=")) { database.SetParameterValue(commandWrapper, "@PersonIddate", clause.Trim().Remove(0, 12).Trim().TrimStart(equalSign).Trim().Trim(singleQuote)); continue; } if (clause.Trim().StartsWith("location ") || clause.Trim().StartsWith("location=")) { database.SetParameterValue(commandWrapper, "@Location", clause.Trim().Remove(0, 8).Trim().TrimStart(equalSign).Trim().Trim(singleQuote)); continue; } if (clause.Trim().StartsWith("contactperson ") || clause.Trim().StartsWith("contactperson=")) { database.SetParameterValue(commandWrapper, "@ContactPerson", clause.Trim().Remove(0, 13).Trim().TrimStart(equalSign).Trim().Trim(singleQuote)); continue; } if (clause.Trim().StartsWith("remark ") || clause.Trim().StartsWith("remark=")) { database.SetParameterValue(commandWrapper, "@Remark", clause.Trim().Remove(0, 6).Trim().TrimStart(equalSign).Trim().Trim(singleQuote)); continue; } if (clause.Trim().StartsWith("labelsprn ") || clause.Trim().StartsWith("labelsprn=")) { database.SetParameterValue(commandWrapper, "@Labelsprn", clause.Trim().Remove(0, 9).Trim().TrimStart(equalSign).Trim().Trim(singleQuote)); continue; } if (clause.Trim().StartsWith("status ") || clause.Trim().StartsWith("status=")) { database.SetParameterValue(commandWrapper, "@Status", clause.Trim().Remove(0, 6).Trim().TrimStart(equalSign).Trim().Trim(singleQuote)); continue; } throw new ArgumentException("Unable to use this part of the where clause in this version of Find: " + clause); } IDataReader reader = null; //Create Collection TList <Staff> rows = new TList <Staff>(); try { //Provider Data Requesting Command Event OnDataRequesting(new CommandEventArgs(commandWrapper, "Find", rows)); if (transactionManager != null) { reader = Utility.ExecuteReader(transactionManager, commandWrapper); } else { reader = Utility.ExecuteReader(database, commandWrapper); } Fill(reader, rows, start, pageLength); if (reader.NextResult()) { if (reader.Read()) { count = reader.GetInt32(0); } } //Provider Data Requested Command Event OnDataRequested(new CommandEventArgs(commandWrapper, "Find", rows)); } finally { if (reader != null) { reader.Close(); } commandWrapper = null; } return(rows); }
} //end Delete #endregion #region Find Functions #region Parsed Find Methods /// <summary> /// Returns rows meeting the whereClause condition from the DataSource. /// </summary> /// <param name="transactionManager"><see cref="TransactionManager"/> object</param> /// <param name="whereClause">Specifies the condition for the rows returned by a query (Name='John Doe', Name='John Doe' AND Id='1', Name='John Doe' OR Id='1').</param> /// <param name="start">Row number at which to start reading.</param> /// <param name="pageLength">Number of rows to return.</param> /// <param name="count">out. The number of rows that match this query.</param> /// <remarks>Operators must be capitalized (OR, AND).</remarks> /// <returns>Returns a typed collection of LibraryManagement.Domain.StockInfo objects.</returns> public override TList <StockInfo> Find(TransactionManager transactionManager, string whereClause, int start, int pageLength, out int count) { count = -1; if (whereClause.IndexOf(";") > -1) { return(new TList <StockInfo>()); } SqlDatabase database = new SqlDatabase(this._connectionString); DbCommand commandWrapper = StoredProcedureProvider.GetCommandWrapper(database, "dbo.tblStockInfo_Find", _useStoredProcedure); bool searchUsingOR = false; if (whereClause.IndexOf(" OR ") > 0) // did they want to do "a=b OR c=d OR..."? { searchUsingOR = true; } database.AddInParameter(commandWrapper, "@SearchUsingOR", DbType.Boolean, searchUsingOR); database.AddInParameter(commandWrapper, "@Id", DbType.AnsiStringFixedLength, DBNull.Value); database.AddInParameter(commandWrapper, "@GoodsId", DbType.AnsiStringFixedLength, DBNull.Value); database.AddInParameter(commandWrapper, "@OpenDate", DbType.DateTime, DBNull.Value); database.AddInParameter(commandWrapper, "@LastDate", DbType.DateTime, DBNull.Value); database.AddInParameter(commandWrapper, "@MinusDate", DbType.DateTime, DBNull.Value); database.AddInParameter(commandWrapper, "@StktakeDt", DbType.DateTime, DBNull.Value); database.AddInParameter(commandWrapper, "@StktakeTm", DbType.StringFixedLength, DBNull.Value); database.AddInParameter(commandWrapper, "@BeginQty", DbType.Decimal, DBNull.Value); database.AddInParameter(commandWrapper, "@ExpQty", DbType.Decimal, DBNull.Value); database.AddInParameter(commandWrapper, "@ImpQty", DbType.Decimal, DBNull.Value); database.AddInParameter(commandWrapper, "@BeginAmt", DbType.Decimal, DBNull.Value); database.AddInParameter(commandWrapper, "@ExpAmt", DbType.Decimal, DBNull.Value); database.AddInParameter(commandWrapper, "@ImpAmt", DbType.Decimal, DBNull.Value); database.AddInParameter(commandWrapper, "@Averimppr", DbType.Decimal, DBNull.Value); // replace all instances of 'AND' and 'OR' because we already set searchUsingOR whereClause = whereClause.Replace(" AND ", "|").Replace(" OR ", "|"); string[] clauses = whereClause.ToLower().Split('|'); // Here's what's going on below: Find a field, then to get the value we // drop the field name from the front, trim spaces, drop the '=' sign, // trim more spaces, and drop any outer single quotes. // Now handles the case when two fields start off the same way - like "Friendly='Yes' AND Friend='john'" char[] equalSign = { '=' }; char[] singleQuote = { '\'' }; foreach (string clause in clauses) { if (clause.Trim().StartsWith("id ") || clause.Trim().StartsWith("id=")) { database.SetParameterValue(commandWrapper, "@Id", clause.Trim().Remove(0, 2).Trim().TrimStart(equalSign).Trim().Trim(singleQuote)); continue; } if (clause.Trim().StartsWith("goods_id ") || clause.Trim().StartsWith("goods_id=")) { database.SetParameterValue(commandWrapper, "@GoodsId", clause.Trim().Remove(0, 8).Trim().TrimStart(equalSign).Trim().Trim(singleQuote)); continue; } if (clause.Trim().StartsWith("open_date ") || clause.Trim().StartsWith("open_date=")) { database.SetParameterValue(commandWrapper, "@OpenDate", clause.Trim().Remove(0, 9).Trim().TrimStart(equalSign).Trim().Trim(singleQuote)); continue; } if (clause.Trim().StartsWith("last_date ") || clause.Trim().StartsWith("last_date=")) { database.SetParameterValue(commandWrapper, "@LastDate", clause.Trim().Remove(0, 9).Trim().TrimStart(equalSign).Trim().Trim(singleQuote)); continue; } if (clause.Trim().StartsWith("minus_date ") || clause.Trim().StartsWith("minus_date=")) { database.SetParameterValue(commandWrapper, "@MinusDate", clause.Trim().Remove(0, 10).Trim().TrimStart(equalSign).Trim().Trim(singleQuote)); continue; } if (clause.Trim().StartsWith("stktake_dt ") || clause.Trim().StartsWith("stktake_dt=")) { database.SetParameterValue(commandWrapper, "@StktakeDt", clause.Trim().Remove(0, 10).Trim().TrimStart(equalSign).Trim().Trim(singleQuote)); continue; } if (clause.Trim().StartsWith("stktake_tm ") || clause.Trim().StartsWith("stktake_tm=")) { database.SetParameterValue(commandWrapper, "@StktakeTm", clause.Trim().Remove(0, 10).Trim().TrimStart(equalSign).Trim().Trim(singleQuote)); continue; } if (clause.Trim().StartsWith("begin_qty ") || clause.Trim().StartsWith("begin_qty=")) { database.SetParameterValue(commandWrapper, "@BeginQty", clause.Trim().Remove(0, 9).Trim().TrimStart(equalSign).Trim().Trim(singleQuote)); continue; } if (clause.Trim().StartsWith("exp_qty ") || clause.Trim().StartsWith("exp_qty=")) { database.SetParameterValue(commandWrapper, "@ExpQty", clause.Trim().Remove(0, 7).Trim().TrimStart(equalSign).Trim().Trim(singleQuote)); continue; } if (clause.Trim().StartsWith("imp_qty ") || clause.Trim().StartsWith("imp_qty=")) { database.SetParameterValue(commandWrapper, "@ImpQty", clause.Trim().Remove(0, 7).Trim().TrimStart(equalSign).Trim().Trim(singleQuote)); continue; } if (clause.Trim().StartsWith("begin_amt ") || clause.Trim().StartsWith("begin_amt=")) { database.SetParameterValue(commandWrapper, "@BeginAmt", clause.Trim().Remove(0, 9).Trim().TrimStart(equalSign).Trim().Trim(singleQuote)); continue; } if (clause.Trim().StartsWith("exp_amt ") || clause.Trim().StartsWith("exp_amt=")) { database.SetParameterValue(commandWrapper, "@ExpAmt", clause.Trim().Remove(0, 7).Trim().TrimStart(equalSign).Trim().Trim(singleQuote)); continue; } if (clause.Trim().StartsWith("imp_amt ") || clause.Trim().StartsWith("imp_amt=")) { database.SetParameterValue(commandWrapper, "@ImpAmt", clause.Trim().Remove(0, 7).Trim().TrimStart(equalSign).Trim().Trim(singleQuote)); continue; } if (clause.Trim().StartsWith("averimppr ") || clause.Trim().StartsWith("averimppr=")) { database.SetParameterValue(commandWrapper, "@Averimppr", clause.Trim().Remove(0, 9).Trim().TrimStart(equalSign).Trim().Trim(singleQuote)); continue; } throw new ArgumentException("Unable to use this part of the where clause in this version of Find: " + clause); } IDataReader reader = null; //Create Collection TList <StockInfo> rows = new TList <StockInfo>(); try { //Provider Data Requesting Command Event OnDataRequesting(new CommandEventArgs(commandWrapper, "Find", rows)); if (transactionManager != null) { reader = Utility.ExecuteReader(transactionManager, commandWrapper); } else { reader = Utility.ExecuteReader(database, commandWrapper); } Fill(reader, rows, start, pageLength); if (reader.NextResult()) { if (reader.Read()) { count = reader.GetInt32(0); } } //Provider Data Requested Command Event OnDataRequested(new CommandEventArgs(commandWrapper, "Find", rows)); } finally { if (reader != null) { reader.Close(); } commandWrapper = null; } return(rows); }
} //end Delete #endregion #region Find Functions #region Parsed Find Methods /// <summary> /// Returns rows meeting the whereClause condition from the DataSource. /// </summary> /// <param name="transactionManager"><see cref="TransactionManager"/> object</param> /// <param name="whereClause">Specifies the condition for the rows returned by a query (Name='John Doe', Name='John Doe' AND Id='1', Name='John Doe' OR Id='1').</param> /// <param name="start">Row number at which to start reading.</param> /// <param name="pageLength">Number of rows to return.</param> /// <param name="count">out. The number of rows that match this query.</param> /// <remarks>Operators must be capitalized (OR, AND).</remarks> /// <returns>Returns a typed collection of LibraryManagement.Domain.AtrCode objects.</returns> public override TList <AtrCode> Find(TransactionManager transactionManager, string whereClause, int start, int pageLength, out int count) { count = -1; if (whereClause.IndexOf(";") > -1) { return(new TList <AtrCode>()); } SqlDatabase database = new SqlDatabase(this._connectionString); DbCommand commandWrapper = StoredProcedureProvider.GetCommandWrapper(database, "dbo.tblAtrCode_Find", _useStoredProcedure); bool searchUsingOR = false; if (whereClause.IndexOf(" OR ") > 0) // did they want to do "a=b OR c=d OR..."? { searchUsingOR = true; } database.AddInParameter(commandWrapper, "@SearchUsingOR", DbType.Boolean, searchUsingOR); database.AddInParameter(commandWrapper, "@TransCode", DbType.String, DBNull.Value); database.AddInParameter(commandWrapper, "@TransName", DbType.String, DBNull.Value); database.AddInParameter(commandWrapper, "@Status", DbType.Boolean, DBNull.Value); database.AddInParameter(commandWrapper, "@DbAccid", DbType.String, DBNull.Value); database.AddInParameter(commandWrapper, "@CrAccid", DbType.String, DBNull.Value); database.AddInParameter(commandWrapper, "@Accid1", DbType.String, DBNull.Value); database.AddInParameter(commandWrapper, "@Accid2", DbType.String, DBNull.Value); database.AddInParameter(commandWrapper, "@Accid3", DbType.String, DBNull.Value); database.AddInParameter(commandWrapper, "@Pcommand", DbType.String, DBNull.Value); database.AddInParameter(commandWrapper, "@Form", DbType.String, DBNull.Value); database.AddInParameter(commandWrapper, "@Voucher", DbType.String, DBNull.Value); database.AddInParameter(commandWrapper, "@Fvoucher", DbType.String, DBNull.Value); database.AddInParameter(commandWrapper, "@Nov", DbType.Decimal, DBNull.Value); database.AddInParameter(commandWrapper, "@TrType", DbType.String, DBNull.Value); // replace all instances of 'AND' and 'OR' because we already set searchUsingOR whereClause = whereClause.Replace(" AND ", "|").Replace(" OR ", "|"); string[] clauses = whereClause.ToLower().Split('|'); // Here's what's going on below: Find a field, then to get the value we // drop the field name from the front, trim spaces, drop the '=' sign, // trim more spaces, and drop any outer single quotes. // Now handles the case when two fields start off the same way - like "Friendly='Yes' AND Friend='john'" char[] equalSign = { '=' }; char[] singleQuote = { '\'' }; foreach (string clause in clauses) { if (clause.Trim().StartsWith("trans_code ") || clause.Trim().StartsWith("trans_code=")) { database.SetParameterValue(commandWrapper, "@TransCode", clause.Trim().Remove(0, 10).Trim().TrimStart(equalSign).Trim().Trim(singleQuote)); continue; } if (clause.Trim().StartsWith("trans_name ") || clause.Trim().StartsWith("trans_name=")) { database.SetParameterValue(commandWrapper, "@TransName", clause.Trim().Remove(0, 10).Trim().TrimStart(equalSign).Trim().Trim(singleQuote)); continue; } if (clause.Trim().StartsWith("status ") || clause.Trim().StartsWith("status=")) { database.SetParameterValue(commandWrapper, "@Status", clause.Trim().Remove(0, 6).Trim().TrimStart(equalSign).Trim().Trim(singleQuote)); continue; } if (clause.Trim().StartsWith("db_accid ") || clause.Trim().StartsWith("db_accid=")) { database.SetParameterValue(commandWrapper, "@DbAccid", clause.Trim().Remove(0, 8).Trim().TrimStart(equalSign).Trim().Trim(singleQuote)); continue; } if (clause.Trim().StartsWith("cr_accid ") || clause.Trim().StartsWith("cr_accid=")) { database.SetParameterValue(commandWrapper, "@CrAccid", clause.Trim().Remove(0, 8).Trim().TrimStart(equalSign).Trim().Trim(singleQuote)); continue; } if (clause.Trim().StartsWith("accid1 ") || clause.Trim().StartsWith("accid1=")) { database.SetParameterValue(commandWrapper, "@Accid1", clause.Trim().Remove(0, 6).Trim().TrimStart(equalSign).Trim().Trim(singleQuote)); continue; } if (clause.Trim().StartsWith("accid2 ") || clause.Trim().StartsWith("accid2=")) { database.SetParameterValue(commandWrapper, "@Accid2", clause.Trim().Remove(0, 6).Trim().TrimStart(equalSign).Trim().Trim(singleQuote)); continue; } if (clause.Trim().StartsWith("accid3 ") || clause.Trim().StartsWith("accid3=")) { database.SetParameterValue(commandWrapper, "@Accid3", clause.Trim().Remove(0, 6).Trim().TrimStart(equalSign).Trim().Trim(singleQuote)); continue; } if (clause.Trim().StartsWith("pcommand ") || clause.Trim().StartsWith("pcommand=")) { database.SetParameterValue(commandWrapper, "@Pcommand", clause.Trim().Remove(0, 8).Trim().TrimStart(equalSign).Trim().Trim(singleQuote)); continue; } if (clause.Trim().StartsWith("form ") || clause.Trim().StartsWith("form=")) { database.SetParameterValue(commandWrapper, "@Form", clause.Trim().Remove(0, 4).Trim().TrimStart(equalSign).Trim().Trim(singleQuote)); continue; } if (clause.Trim().StartsWith("voucher ") || clause.Trim().StartsWith("voucher=")) { database.SetParameterValue(commandWrapper, "@Voucher", clause.Trim().Remove(0, 7).Trim().TrimStart(equalSign).Trim().Trim(singleQuote)); continue; } if (clause.Trim().StartsWith("fvoucher ") || clause.Trim().StartsWith("fvoucher=")) { database.SetParameterValue(commandWrapper, "@Fvoucher", clause.Trim().Remove(0, 8).Trim().TrimStart(equalSign).Trim().Trim(singleQuote)); continue; } if (clause.Trim().StartsWith("nov ") || clause.Trim().StartsWith("nov=")) { database.SetParameterValue(commandWrapper, "@Nov", clause.Trim().Remove(0, 3).Trim().TrimStart(equalSign).Trim().Trim(singleQuote)); continue; } if (clause.Trim().StartsWith("tr_type ") || clause.Trim().StartsWith("tr_type=")) { database.SetParameterValue(commandWrapper, "@TrType", clause.Trim().Remove(0, 7).Trim().TrimStart(equalSign).Trim().Trim(singleQuote)); continue; } throw new ArgumentException("Unable to use this part of the where clause in this version of Find: " + clause); } IDataReader reader = null; //Create Collection TList <AtrCode> rows = new TList <AtrCode>(); try { //Provider Data Requesting Command Event OnDataRequesting(new CommandEventArgs(commandWrapper, "Find", rows)); if (transactionManager != null) { reader = Utility.ExecuteReader(transactionManager, commandWrapper); } else { reader = Utility.ExecuteReader(database, commandWrapper); } Fill(reader, rows, start, pageLength); if (reader.NextResult()) { if (reader.Read()) { count = reader.GetInt32(0); } } //Provider Data Requested Command Event OnDataRequested(new CommandEventArgs(commandWrapper, "Find", rows)); } finally { if (reader != null) { reader.Close(); } commandWrapper = null; } return(rows); }
} //end Delete #endregion #region Find Functions #region Parsed Find Methods /// <summary> /// Returns rows meeting the whereClause condition from the DataSource. /// </summary> /// <param name="transactionManager"><see cref="TransactionManager"/> object</param> /// <param name="whereClause">Specifies the condition for the rows returned by a query (Name='John Doe', Name='John Doe' AND Id='1', Name='John Doe' OR Id='1').</param> /// <param name="start">Row number at which to start reading.</param> /// <param name="pageLength">Number of rows to return.</param> /// <param name="count">out. The number of rows that match this query.</param> /// <remarks>Operators must be capitalized (OR, AND).</remarks> /// <returns>Returns a typed collection of LibraryManagement.Domain.OnOrder objects.</returns> public override TList <OnOrder> Find(TransactionManager transactionManager, string whereClause, int start, int pageLength, out int count) { count = -1; if (whereClause.IndexOf(";") > -1) { return(new TList <OnOrder>()); } SqlDatabase database = new SqlDatabase(this._connectionString); DbCommand commandWrapper = StoredProcedureProvider.GetCommandWrapper(database, "dbo.tblOn_order_Find", _useStoredProcedure); bool searchUsingOR = false; if (whereClause.IndexOf(" OR ") > 0) // did they want to do "a=b OR c=d OR..."? { searchUsingOR = true; } database.AddInParameter(commandWrapper, "@SearchUsingOR", DbType.Boolean, searchUsingOR); database.AddInParameter(commandWrapper, "@TranDate", DbType.DateTime, DBNull.Value); database.AddInParameter(commandWrapper, "@TranTime", DbType.AnsiStringFixedLength, DBNull.Value); database.AddInParameter(commandWrapper, "@DeliverDt", DbType.DateTime, DBNull.Value); database.AddInParameter(commandWrapper, "@TransNum", DbType.AnsiStringFixedLength, DBNull.Value); database.AddInParameter(commandWrapper, "@TransCode", DbType.AnsiStringFixedLength, DBNull.Value); database.AddInParameter(commandWrapper, "@ExpId", DbType.AnsiStringFixedLength, DBNull.Value); database.AddInParameter(commandWrapper, "@GoodsId", DbType.AnsiStringFixedLength, DBNull.Value); database.AddInParameter(commandWrapper, "@Qty", DbType.Decimal, DBNull.Value); database.AddInParameter(commandWrapper, "@UnitSymb", DbType.AnsiStringFixedLength, DBNull.Value); database.AddInParameter(commandWrapper, "@Price", DbType.Decimal, DBNull.Value); database.AddInParameter(commandWrapper, "@MercType", DbType.AnsiStringFixedLength, DBNull.Value); database.AddInParameter(commandWrapper, "@UserId", DbType.Decimal, DBNull.Value); database.AddInParameter(commandWrapper, "@Remark", DbType.String, DBNull.Value); database.AddInParameter(commandWrapper, "@Recnum", DbType.Decimal, DBNull.Value); database.AddInParameter(commandWrapper, "@Status", DbType.Boolean, DBNull.Value); database.AddInParameter(commandWrapper, "@EndQty", DbType.Decimal, DBNull.Value); // replace all instances of 'AND' and 'OR' because we already set searchUsingOR whereClause = whereClause.Replace(" AND ", "|").Replace(" OR ", "|"); string[] clauses = whereClause.ToLower().Split('|'); // Here's what's going on below: Find a field, then to get the value we // drop the field name from the front, trim spaces, drop the '=' sign, // trim more spaces, and drop any outer single quotes. // Now handles the case when two fields start off the same way - like "Friendly='Yes' AND Friend='john'" char[] equalSign = { '=' }; char[] singleQuote = { '\'' }; foreach (string clause in clauses) { if (clause.Trim().StartsWith("tran_date ") || clause.Trim().StartsWith("tran_date=")) { database.SetParameterValue(commandWrapper, "@TranDate", clause.Trim().Remove(0, 9).Trim().TrimStart(equalSign).Trim().Trim(singleQuote)); continue; } if (clause.Trim().StartsWith("tran_time ") || clause.Trim().StartsWith("tran_time=")) { database.SetParameterValue(commandWrapper, "@TranTime", clause.Trim().Remove(0, 9).Trim().TrimStart(equalSign).Trim().Trim(singleQuote)); continue; } if (clause.Trim().StartsWith("deliver_dt ") || clause.Trim().StartsWith("deliver_dt=")) { database.SetParameterValue(commandWrapper, "@DeliverDt", clause.Trim().Remove(0, 10).Trim().TrimStart(equalSign).Trim().Trim(singleQuote)); continue; } if (clause.Trim().StartsWith("trans_num ") || clause.Trim().StartsWith("trans_num=")) { database.SetParameterValue(commandWrapper, "@TransNum", clause.Trim().Remove(0, 9).Trim().TrimStart(equalSign).Trim().Trim(singleQuote)); continue; } if (clause.Trim().StartsWith("trans_code ") || clause.Trim().StartsWith("trans_code=")) { database.SetParameterValue(commandWrapper, "@TransCode", clause.Trim().Remove(0, 10).Trim().TrimStart(equalSign).Trim().Trim(singleQuote)); continue; } if (clause.Trim().StartsWith("exp_id ") || clause.Trim().StartsWith("exp_id=")) { database.SetParameterValue(commandWrapper, "@ExpId", clause.Trim().Remove(0, 6).Trim().TrimStart(equalSign).Trim().Trim(singleQuote)); continue; } if (clause.Trim().StartsWith("goods_id ") || clause.Trim().StartsWith("goods_id=")) { database.SetParameterValue(commandWrapper, "@GoodsId", clause.Trim().Remove(0, 8).Trim().TrimStart(equalSign).Trim().Trim(singleQuote)); continue; } if (clause.Trim().StartsWith("qty ") || clause.Trim().StartsWith("qty=")) { database.SetParameterValue(commandWrapper, "@Qty", clause.Trim().Remove(0, 3).Trim().TrimStart(equalSign).Trim().Trim(singleQuote)); continue; } if (clause.Trim().StartsWith("unit_symb ") || clause.Trim().StartsWith("unit_symb=")) { database.SetParameterValue(commandWrapper, "@UnitSymb", clause.Trim().Remove(0, 9).Trim().TrimStart(equalSign).Trim().Trim(singleQuote)); continue; } if (clause.Trim().StartsWith("price ") || clause.Trim().StartsWith("price=")) { database.SetParameterValue(commandWrapper, "@Price", clause.Trim().Remove(0, 5).Trim().TrimStart(equalSign).Trim().Trim(singleQuote)); continue; } if (clause.Trim().StartsWith("merc_type ") || clause.Trim().StartsWith("merc_type=")) { database.SetParameterValue(commandWrapper, "@MercType", clause.Trim().Remove(0, 9).Trim().TrimStart(equalSign).Trim().Trim(singleQuote)); continue; } if (clause.Trim().StartsWith("user_id ") || clause.Trim().StartsWith("user_id=")) { database.SetParameterValue(commandWrapper, "@UserId", clause.Trim().Remove(0, 7).Trim().TrimStart(equalSign).Trim().Trim(singleQuote)); continue; } if (clause.Trim().StartsWith("remark ") || clause.Trim().StartsWith("remark=")) { database.SetParameterValue(commandWrapper, "@Remark", clause.Trim().Remove(0, 6).Trim().TrimStart(equalSign).Trim().Trim(singleQuote)); continue; } if (clause.Trim().StartsWith("recnum ") || clause.Trim().StartsWith("recnum=")) { database.SetParameterValue(commandWrapper, "@Recnum", clause.Trim().Remove(0, 6).Trim().TrimStart(equalSign).Trim().Trim(singleQuote)); continue; } if (clause.Trim().StartsWith("status ") || clause.Trim().StartsWith("status=")) { database.SetParameterValue(commandWrapper, "@Status", clause.Trim().Remove(0, 6).Trim().TrimStart(equalSign).Trim().Trim(singleQuote)); continue; } if (clause.Trim().StartsWith("end_qty ") || clause.Trim().StartsWith("end_qty=")) { database.SetParameterValue(commandWrapper, "@EndQty", clause.Trim().Remove(0, 7).Trim().TrimStart(equalSign).Trim().Trim(singleQuote)); continue; } throw new ArgumentException("Unable to use this part of the where clause in this version of Find: " + clause); } IDataReader reader = null; //Create Collection TList <OnOrder> rows = new TList <OnOrder>(); try { //Provider Data Requesting Command Event OnDataRequesting(new CommandEventArgs(commandWrapper, "Find", rows)); if (transactionManager != null) { reader = Utility.ExecuteReader(transactionManager, commandWrapper); } else { reader = Utility.ExecuteReader(database, commandWrapper); } Fill(reader, rows, start, pageLength); if (reader.NextResult()) { if (reader.Read()) { count = reader.GetInt32(0); } } //Provider Data Requested Command Event OnDataRequested(new CommandEventArgs(commandWrapper, "Find", rows)); } finally { if (reader != null) { reader.Close(); } commandWrapper = null; } return(rows); }
} //end Delete #endregion #region Find Functions #region Parsed Find Methods /// <summary> /// Returns rows meeting the whereClause condition from the DataSource. /// </summary> /// <param name="transactionManager"><see cref="TransactionManager"/> object</param> /// <param name="whereClause">Specifies the condition for the rows returned by a query (Name='John Doe', Name='John Doe' AND Id='1', Name='John Doe' OR Id='1').</param> /// <param name="start">Row number at which to start reading.</param> /// <param name="pageLength">Number of rows to return.</param> /// <param name="count">out. The number of rows that match this query.</param> /// <remarks>Operators must be capitalized (OR, AND).</remarks> /// <returns>Returns a typed collection of LibraryManagement.Domain.Menus objects.</returns> public override TList <Menus> Find(TransactionManager transactionManager, string whereClause, int start, int pageLength, out int count) { count = -1; if (whereClause.IndexOf(";") > -1) { return(new TList <Menus>()); } SqlDatabase database = new SqlDatabase(this._connectionString); DbCommand commandWrapper = StoredProcedureProvider.GetCommandWrapper(database, "dbo.tblMenus_Find", _useStoredProcedure); bool searchUsingOR = false; if (whereClause.IndexOf(" OR ") > 0) // did they want to do "a=b OR c=d OR..."? { searchUsingOR = true; } database.AddInParameter(commandWrapper, "@SearchUsingOR", DbType.Boolean, searchUsingOR); database.AddInParameter(commandWrapper, "@Id", DbType.Int32, DBNull.Value); database.AddInParameter(commandWrapper, "@Subitem", DbType.Int32, DBNull.Value); database.AddInParameter(commandWrapper, "@Parent", DbType.Int32, DBNull.Value); database.AddInParameter(commandWrapper, "@Menukey", DbType.StringFixedLength, DBNull.Value); database.AddInParameter(commandWrapper, "@Prompt", DbType.String, DBNull.Value); database.AddInParameter(commandWrapper, "@Type", DbType.StringFixedLength, DBNull.Value); database.AddInParameter(commandWrapper, "@Procerdue", DbType.StringFixedLength, DBNull.Value); database.AddInParameter(commandWrapper, "@Imageidx", DbType.Int32, DBNull.Value); database.AddInParameter(commandWrapper, "@Password", DbType.Boolean, DBNull.Value); database.AddInParameter(commandWrapper, "@Basicright", DbType.Int32, DBNull.Value); database.AddInParameter(commandWrapper, "@Depcode", DbType.StringFixedLength, DBNull.Value); database.AddInParameter(commandWrapper, "@Skip", DbType.Boolean, DBNull.Value); // replace all instances of 'AND' and 'OR' because we already set searchUsingOR whereClause = whereClause.Replace(" AND ", "|").Replace(" OR ", "|"); string[] clauses = whereClause.ToLower().Split('|'); // Here's what's going on below: Find a field, then to get the value we // drop the field name from the front, trim spaces, drop the '=' sign, // trim more spaces, and drop any outer single quotes. // Now handles the case when two fields start off the same way - like "Friendly='Yes' AND Friend='john'" char[] equalSign = { '=' }; char[] singleQuote = { '\'' }; foreach (string clause in clauses) { if (clause.Trim().StartsWith("id ") || clause.Trim().StartsWith("id=")) { database.SetParameterValue(commandWrapper, "@Id", clause.Trim().Remove(0, 2).Trim().TrimStart(equalSign).Trim().Trim(singleQuote)); continue; } if (clause.Trim().StartsWith("subitem ") || clause.Trim().StartsWith("subitem=")) { database.SetParameterValue(commandWrapper, "@Subitem", clause.Trim().Remove(0, 7).Trim().TrimStart(equalSign).Trim().Trim(singleQuote)); continue; } if (clause.Trim().StartsWith("parent ") || clause.Trim().StartsWith("parent=")) { database.SetParameterValue(commandWrapper, "@Parent", clause.Trim().Remove(0, 6).Trim().TrimStart(equalSign).Trim().Trim(singleQuote)); continue; } if (clause.Trim().StartsWith("menukey ") || clause.Trim().StartsWith("menukey=")) { database.SetParameterValue(commandWrapper, "@Menukey", clause.Trim().Remove(0, 7).Trim().TrimStart(equalSign).Trim().Trim(singleQuote)); continue; } if (clause.Trim().StartsWith("prompt ") || clause.Trim().StartsWith("prompt=")) { database.SetParameterValue(commandWrapper, "@Prompt", clause.Trim().Remove(0, 6).Trim().TrimStart(equalSign).Trim().Trim(singleQuote)); continue; } if (clause.Trim().StartsWith("type ") || clause.Trim().StartsWith("type=")) { database.SetParameterValue(commandWrapper, "@Type", clause.Trim().Remove(0, 4).Trim().TrimStart(equalSign).Trim().Trim(singleQuote)); continue; } if (clause.Trim().StartsWith("procerdue ") || clause.Trim().StartsWith("procerdue=")) { database.SetParameterValue(commandWrapper, "@Procerdue", clause.Trim().Remove(0, 9).Trim().TrimStart(equalSign).Trim().Trim(singleQuote)); continue; } if (clause.Trim().StartsWith("imageidx ") || clause.Trim().StartsWith("imageidx=")) { database.SetParameterValue(commandWrapper, "@Imageidx", clause.Trim().Remove(0, 8).Trim().TrimStart(equalSign).Trim().Trim(singleQuote)); continue; } if (clause.Trim().StartsWith("password ") || clause.Trim().StartsWith("password="******"@Password", clause.Trim().Remove(0, 8).Trim().TrimStart(equalSign).Trim().Trim(singleQuote)); continue; } if (clause.Trim().StartsWith("basicright ") || clause.Trim().StartsWith("basicright=")) { database.SetParameterValue(commandWrapper, "@Basicright", clause.Trim().Remove(0, 10).Trim().TrimStart(equalSign).Trim().Trim(singleQuote)); continue; } if (clause.Trim().StartsWith("depcode ") || clause.Trim().StartsWith("depcode=")) { database.SetParameterValue(commandWrapper, "@Depcode", clause.Trim().Remove(0, 7).Trim().TrimStart(equalSign).Trim().Trim(singleQuote)); continue; } if (clause.Trim().StartsWith("skip ") || clause.Trim().StartsWith("skip=")) { database.SetParameterValue(commandWrapper, "@Skip", clause.Trim().Remove(0, 4).Trim().TrimStart(equalSign).Trim().Trim(singleQuote)); continue; } throw new ArgumentException("Unable to use this part of the where clause in this version of Find: " + clause); } IDataReader reader = null; //Create Collection TList <Menus> rows = new TList <Menus>(); try { //Provider Data Requesting Command Event OnDataRequesting(new CommandEventArgs(commandWrapper, "Find", rows)); if (transactionManager != null) { reader = Utility.ExecuteReader(transactionManager, commandWrapper); } else { reader = Utility.ExecuteReader(database, commandWrapper); } Fill(reader, rows, start, pageLength); if (reader.NextResult()) { if (reader.Read()) { count = reader.GetInt32(0); } } //Provider Data Requested Command Event OnDataRequested(new CommandEventArgs(commandWrapper, "Find", rows)); } finally { if (reader != null) { reader.Close(); } commandWrapper = null; } return(rows); }
}//end Delete #endregion #region Find Functions #region Parsed Find Methods /// <summary> /// Returns rows meeting the whereClause condition from the DataSource. /// </summary> /// <param name="transactionManager"><see cref="TransactionManager"/> object</param> /// <param name="whereClause">Specifies the condition for the rows returned by a query (Name='John Doe', Name='John Doe' AND Id='1', Name='John Doe' OR Id='1').</param> /// <param name="start">Row number at which to start reading.</param> /// <param name="pageLength">Number of rows to return.</param> /// <param name="count">out. The number of rows that match this query.</param> /// <remarks>Operators must be capitalized (OR, AND).</remarks> /// <returns>Returns a typed collection of LibraryManagement.Domain.PaymentOrder objects.</returns> public override TList<PaymentOrder> Find(TransactionManager transactionManager, string whereClause, int start, int pageLength, out int count) { count = -1; if (whereClause.IndexOf(";") > -1) return new TList<PaymentOrder>(); SqlDatabase database = new SqlDatabase(this._connectionString); DbCommand commandWrapper = StoredProcedureProvider.GetCommandWrapper(database, "dbo.tblPaymentOrder_Find", _useStoredProcedure); bool searchUsingOR = false; if (whereClause.IndexOf(" OR ") > 0) // did they want to do "a=b OR c=d OR..."? searchUsingOR = true; database.AddInParameter(commandWrapper, "@SearchUsingOR", DbType.Boolean, searchUsingOR); database.AddInParameter(commandWrapper, "@TransNum", DbType.StringFixedLength, DBNull.Value); database.AddInParameter(commandWrapper, "@Payer", DbType.String, DBNull.Value); database.AddInParameter(commandWrapper, "@PayerAcc", DbType.String, DBNull.Value); database.AddInParameter(commandWrapper, "@PayerBank", DbType.String, DBNull.Value); database.AddInParameter(commandWrapper, "@PayerBranch", DbType.String, DBNull.Value); database.AddInParameter(commandWrapper, "@Benef", DbType.String, DBNull.Value); database.AddInParameter(commandWrapper, "@BenefAcc", DbType.String, DBNull.Value); database.AddInParameter(commandWrapper, "@BenefBank", DbType.String, DBNull.Value); database.AddInParameter(commandWrapper, "@BenefBranch", DbType.String, DBNull.Value); database.AddInParameter(commandWrapper, "@Amount", DbType.Decimal, DBNull.Value); // replace all instances of 'AND' and 'OR' because we already set searchUsingOR whereClause = whereClause.Replace(" AND ", "|").Replace(" OR ", "|") ; string[] clauses = whereClause.ToLower().Split('|'); // Here's what's going on below: Find a field, then to get the value we // drop the field name from the front, trim spaces, drop the '=' sign, // trim more spaces, and drop any outer single quotes. // Now handles the case when two fields start off the same way - like "Friendly='Yes' AND Friend='john'" char[] equalSign = {'='}; char[] singleQuote = {'\''}; foreach (string clause in clauses) { if (clause.Trim().StartsWith("trans_num ") || clause.Trim().StartsWith("trans_num=")) { database.SetParameterValue(commandWrapper, "@TransNum", clause.Trim().Remove(0,9).Trim().TrimStart(equalSign).Trim().Trim(singleQuote)); continue; } if (clause.Trim().StartsWith("payer ") || clause.Trim().StartsWith("payer=")) { database.SetParameterValue(commandWrapper, "@Payer", clause.Trim().Remove(0,5).Trim().TrimStart(equalSign).Trim().Trim(singleQuote)); continue; } if (clause.Trim().StartsWith("payer_acc ") || clause.Trim().StartsWith("payer_acc=")) { database.SetParameterValue(commandWrapper, "@PayerAcc", clause.Trim().Remove(0,9).Trim().TrimStart(equalSign).Trim().Trim(singleQuote)); continue; } if (clause.Trim().StartsWith("payer_bank ") || clause.Trim().StartsWith("payer_bank=")) { database.SetParameterValue(commandWrapper, "@PayerBank", clause.Trim().Remove(0,10).Trim().TrimStart(equalSign).Trim().Trim(singleQuote)); continue; } if (clause.Trim().StartsWith("payer_branch ") || clause.Trim().StartsWith("payer_branch=")) { database.SetParameterValue(commandWrapper, "@PayerBranch", clause.Trim().Remove(0,12).Trim().TrimStart(equalSign).Trim().Trim(singleQuote)); continue; } if (clause.Trim().StartsWith("benef ") || clause.Trim().StartsWith("benef=")) { database.SetParameterValue(commandWrapper, "@Benef", clause.Trim().Remove(0,5).Trim().TrimStart(equalSign).Trim().Trim(singleQuote)); continue; } if (clause.Trim().StartsWith("benef_acc ") || clause.Trim().StartsWith("benef_acc=")) { database.SetParameterValue(commandWrapper, "@BenefAcc", clause.Trim().Remove(0,9).Trim().TrimStart(equalSign).Trim().Trim(singleQuote)); continue; } if (clause.Trim().StartsWith("benef_bank ") || clause.Trim().StartsWith("benef_bank=")) { database.SetParameterValue(commandWrapper, "@BenefBank", clause.Trim().Remove(0,10).Trim().TrimStart(equalSign).Trim().Trim(singleQuote)); continue; } if (clause.Trim().StartsWith("benef_branch ") || clause.Trim().StartsWith("benef_branch=")) { database.SetParameterValue(commandWrapper, "@BenefBranch", clause.Trim().Remove(0,12).Trim().TrimStart(equalSign).Trim().Trim(singleQuote)); continue; } if (clause.Trim().StartsWith("amount ") || clause.Trim().StartsWith("amount=")) { database.SetParameterValue(commandWrapper, "@Amount", clause.Trim().Remove(0,6).Trim().TrimStart(equalSign).Trim().Trim(singleQuote)); continue; } throw new ArgumentException("Unable to use this part of the where clause in this version of Find: " + clause); } IDataReader reader = null; //Create Collection TList<PaymentOrder> rows = new TList<PaymentOrder>(); try { //Provider Data Requesting Command Event OnDataRequesting(new CommandEventArgs(commandWrapper, "Find", rows)); if (transactionManager != null) { reader = Utility.ExecuteReader(transactionManager, commandWrapper); } else { reader = Utility.ExecuteReader(database, commandWrapper); } Fill(reader, rows, start, pageLength); if(reader.NextResult()) { if(reader.Read()) { count = reader.GetInt32(0); } } //Provider Data Requested Command Event OnDataRequested(new CommandEventArgs(commandWrapper, "Find", rows)); } finally { if (reader != null) reader.Close(); commandWrapper = null; } return rows; }