public static List <AccountingDept> Search(AccountingDeptParam param, Pagination paging) { var sql = Sql.Builder; if (!param.Term.IsNullOrEmpty()) { sql.Where(string.Format("IDOrder in (Select ID From [dbo].[Order] Where SearchMeta like '%{0}%')", param.Term.RemoveUnicode())); } if (param.OrderType > 0) { sql.Where("Type =@0", param.OrderType); } if (param.Status > 0) { sql.Where("Status = @0", param.Status); } if (!Equals(param.StartDate, null) && !Equals(param.EndDate, null)) { sql.Where("(Created >= @startDate AND Created <= @endDate)", new { startDate = param.StartDate, endDate = param.EndDate }); } else if (!Equals(param.StartDate, null)) { sql.Where("(@startDate <= Created)", new { startDate = param.StartDate }); } else if (!Equals(param.EndDate, null)) { sql.Where("(Created <= @endDate)", new { endDate = param.EndDate }); } return(UseInstance.GetListOrDefault(sql, paging)); }
public ActionResult Index() { var searchParam = new AccountingDeptParam().BindData(DATA); var accountingDepts = AccountingDeptRepository.Search(searchParam, Paging); var idOrders = new long[] { 0 }; idOrders = Equals(accountingDepts, null) ? idOrders : accountingDepts.Select(t => (long)t.IDOrder).ToArray(); var orders = OrderRepository.UseInstance.GetByIdsOrDefault(idOrders); var orderFiles = OrderFileRepository.UseInstance.GetListByFieldsOrDefault(new List <CondParam> { new CondParam { Field = "OrderStatus", Value = (int)OrderStatus.CollectVouchers, CompareType = (int)CompareTypes.Equal, TypeSQL = (int)TypeSQl.Number }, new CondParam { Field = "IDOrder", Value = orders.Select(t => (long)t.ID).ToArray(), CompareType = (int)CompareTypes.In, TypeSQL = (int)TypeSQl.Number, } }); var listStatus = Utils.EnumToDictionary <AccountingDeptStatus>(); SetTitle("Danh sách đơn hàng gửi đến phòng kế toán"); return(GetCustResultOrView(new ViewParam { ViewName = "Index", ViewNameAjax = "AccountingDepts", Data = new AccountingDeptModel { Orders = orders, OrderFiles = orderFiles, AccountingDepts = accountingDepts, ListStatus = listStatus, SearchParam = searchParam, }, })); }