private CheckFilterModel ComposeSearch() { var model = new CheckFilterModel(); if (!string.IsNullOrWhiteSpace(DetailTextbox.Text)) { model.CheckDetail = DetailTextbox.Text.Trim(); } if (!AllDateRB.Checked) { if (DateRangeRB.Checked) { model.DateType = DateSearchType.DateRange; model.DateFrom = DateFromPicker.Value; model.DateTo = DateToPicker.Value; } } else { model.DateType = DateSearchType.All; } model.Issuer = Type; return(model); }
public SortableBindingList <CheckDisplayModel> FetchCheckWithSearch(CheckFilterModel filter) { try { var query = CreateQuery(filter); var result = from a in query select new CheckDisplayModel { Id = a.Id, Voucher = a.PaymentDetail.FirstOrDefault() != null? a.PaymentDetail.FirstOrDefault().VoucherNumber : "-", CheckNumber = a.CheckNumber, Bank = a.Bank, Branch = a.Branch, Amount = a.Amount.Value, CheckDate = a.CheckDate.Value, ClearingDate = a.ClearingDate.Value, IsDeleted = a.IsDeleted.Value, }; SortableBindingList <CheckDisplayModel> c = new SortableBindingList <CheckDisplayModel>(result); return(c); } catch (Exception ex) { throw ex; } }
private void LoadChecks(CheckFilterModel filter) { var checks = this.checkController.FetchCheckWithSearch(filter); checkDisplayModelBindingSource.DataSource = checks; var totalSChecks = checks.Sum(a => a.Amount); TotalReceivedTextbox.Text = totalSChecks.ToString("Php #,##0.00"); }
private IQueryable <Check> CreateQuery(CheckFilterModel filter) { var items = from i in db.Check where i.IsDeleted == false select i; if (filter != null) { if (!string.IsNullOrEmpty(filter.CheckDetail)) { items = items.Where(a => a.CheckNumber.Contains(filter.CheckDetail) || a.Bank.Contains(filter.CheckDetail) || a.Branch.Contains(filter.CheckDetail)); } if (filter.DateType != DateSearchType.All) { DateTime dateFrom = filter.DateFrom.Date; DateTime dateTo = filter.DateTo.AddDays(1).Date; items = items.Where(a => a.ClearingDate >= dateFrom && a.ClearingDate < dateTo); } if (filter.Issuer != IssuerType.All) { if (filter.Issuer == IssuerType.Customer) { items = items.Where(a => a.PaymentDetail.Any(b => b.SalesPayments.Any())); } else if (filter.Issuer == IssuerType.Us) { items = items.Where(a => a.PaymentDetail.Any(b => b.PurchasePayments.Any())); } } } else { //Default Sort items = items.OrderBy(a => a.PaymentDetail.FirstOrDefault().VoucherNumber) .ThenBy(a => a.CheckNumber) .ThenBy(a => a.Bank); } return(items); }
private void SearchButton_Click(object sender, EventArgs e) { CheckFilterModel filter = ComposeSearch(); LoadChecks(filter); }
public void RefreshView() { CheckFilterModel filter = ComposeSearch(); LoadChecks(filter); }