public override TList <ContractMaterial> 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.ContractMaterial_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 <ContractMaterial> rows = new TList <ContractMaterial>(); try { try { if (transactionManager != null) { reader = Utility.ExecuteReader(transactionManager, command); } else { reader = Utility.ExecuteReader(database, command); } ContractMaterialProviderBaseCore.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 <ContractMaterial> 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.ContractMaterial_Find_Dynamic", typeof(ContractMaterialColumn), 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 <ContractMaterial> rows = new TList <ContractMaterial>(); IDataReader reader = null; try { if (transactionManager != null) { reader = Utility.ExecuteReader(transactionManager, command); } else { reader = Utility.ExecuteReader(database, command); } ContractMaterialProviderBaseCore.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 ContractMaterial GetByContractMaterialCode(TransactionManager transactionManager, string contractMaterialCode, int start, int pageLength, out int count) { SqlDatabase database = new SqlDatabase(this._connectionString); DbCommand command = StoredProcedureProvider.GetCommandWrapper(database, "dbo.ContractMaterial_GetByContractMaterialCode", this._useStoredProcedure); database.AddInParameter(command, "@ContractMaterialCode", DbType.AnsiString, contractMaterialCode); IDataReader reader = null; TList <ContractMaterial> rows = new TList <ContractMaterial>(); try { if (transactionManager != null) { reader = Utility.ExecuteReader(transactionManager, command); } else { reader = Utility.ExecuteReader(database, command); } ContractMaterialProviderBaseCore.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 <ContractMaterial> GetByMaterialCode(TransactionManager transactionManager, int?materialCode, int start, int pageLength, out int count) { SqlDatabase database = new SqlDatabase(this._connectionString); DbCommand command = StoredProcedureProvider.GetCommandWrapper(database, "dbo.ContractMaterial_GetByMaterialCode", this._useStoredProcedure); database.AddInParameter(command, "@MaterialCode", DbType.Int32, materialCode); IDataReader reader = null; TList <ContractMaterial> rows = new TList <ContractMaterial>(); try { if (transactionManager != null) { reader = Utility.ExecuteReader(transactionManager, command); } else { reader = Utility.ExecuteReader(database, command); } ContractMaterialProviderBaseCore.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 <ContractMaterial> Find(TransactionManager transactionManager, string whereClause, int start, int pageLength, out int count) { count = -1; if (whereClause.IndexOf(";") > -1) { return(new TList <ContractMaterial>()); } SqlDatabase database = new SqlDatabase(this._connectionString); DbCommand command = StoredProcedureProvider.GetCommandWrapper(database, "dbo.ContractMaterial_Find", this._useStoredProcedure); bool flag = false; if (whereClause.IndexOf(" OR ") > 0) { flag = true; } database.AddInParameter(command, "@SearchUsingOR", DbType.Boolean, flag); database.AddInParameter(command, "@ContractMaterialCode", DbType.AnsiString, DBNull.Value); database.AddInParameter(command, "@ContractCode", DbType.AnsiString, DBNull.Value); database.AddInParameter(command, "@MaterialCode", DbType.Int32, DBNull.Value); database.AddInParameter(command, "@Qty", DbType.Decimal, DBNull.Value); database.AddInParameter(command, "@Price", DbType.Decimal, DBNull.Value); database.AddInParameter(command, "@Money", 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("contractmaterialcode ") || text.Trim().StartsWith("contractmaterialcode=")) { database.SetParameterValue(command, "@ContractMaterialCode", text.Replace("contractmaterialcode", "").Trim().TrimStart(trimChars).Trim().Trim(chArray2)); } else if (text.Trim().StartsWith("contractcode ") || text.Trim().StartsWith("contractcode=")) { database.SetParameterValue(command, "@ContractCode", text.Replace("contractcode", "").Trim().TrimStart(trimChars).Trim().Trim(chArray2)); } else if (text.Trim().StartsWith("materialcode ") || text.Trim().StartsWith("materialcode=")) { database.SetParameterValue(command, "@MaterialCode", text.Replace("materialcode", "").Trim().TrimStart(trimChars).Trim().Trim(chArray2)); } else if (text.Trim().StartsWith("qty ") || text.Trim().StartsWith("qty=")) { database.SetParameterValue(command, "@Qty", text.Replace("qty", "").Trim().TrimStart(trimChars).Trim().Trim(chArray2)); } else if (text.Trim().StartsWith("price ") || text.Trim().StartsWith("price=")) { database.SetParameterValue(command, "@Price", text.Replace("price", "").Trim().TrimStart(trimChars).Trim().Trim(chArray2)); } else { if (!text.Trim().StartsWith("money ") && !text.Trim().StartsWith("money=")) { throw new ArgumentException("Unable to use this part of the where clause in this version of Find: " + text); } database.SetParameterValue(command, "@Money", text.Replace("money", "").Trim().TrimStart(trimChars).Trim().Trim(chArray2)); } } IDataReader reader = null; TList <ContractMaterial> rows = new TList <ContractMaterial>(); try { if (transactionManager != null) { reader = Utility.ExecuteReader(transactionManager, command); } else { reader = Utility.ExecuteReader(database, command); } ContractMaterialProviderBaseCore.Fill(reader, rows, start, pageLength); if (reader.NextResult() && reader.Read()) { count = reader.GetInt32(0); } } finally { if (reader != null) { reader.Close(); } } return(rows); }