public IEnumerable <R_Expense> GetExpenses() { IEnumerable <R_Expense> results = null; var sql = PetaPoco.Sql.Builder .Select("*") .From("R_Expense") .Where("IsDeleted = 0") ; results = R_Expense.Query(sql); return(results); }
public IEnumerable <R_Expense> GetExpenseListAdvancedSearch( int?nucleoId , string name , string description , int?responsiblePersonId , int?executerPersonId , int?documentId , int?partnerId , System.DateTime?invoiceDateFrom , System.DateTime?invoiceDateTo , double?amount ) { IEnumerable <R_Expense> results = null; var sql = PetaPoco.Sql.Builder .Select("*") .From("R_Expense") .Where("IsDeleted = 0" + (nucleoId != null ? " and NucleoId like '%" + nucleoId + "%'" : "") + (name != null ? " and Name like '%" + name + "%'" : "") + (description != null ? " and Description like '%" + description + "%'" : "") + (responsiblePersonId != null ? " and ResponsiblePersonId like '%" + responsiblePersonId + "%'" : "") + (executerPersonId != null ? " and ExecuterPersonId like '%" + executerPersonId + "%'" : "") + (documentId != null ? " and DocumentId like '%" + documentId + "%'" : "") + (partnerId != null ? " and PartnerId like '%" + partnerId + "%'" : "") + (invoiceDateFrom != null ? " and InvoiceDate >= '" + invoiceDateFrom.Value.ToShortDateString() + "'" : "") + (invoiceDateTo != null ? " and InvoiceDate <= '" + invoiceDateTo.Value.ToShortDateString() + "'" : "") + (amount != null ? " and Amount like '%" + amount + "%'" : "") ) ; results = R_Expense.Query(sql); return(results); }