Esempio n. 1
0
        protected virtual void GetDataSource()
        {
            // Điều kiện bắt buộc: chưa xóa và đang pending
            //ICriterion criterion = Expression.Eq(Booking.DELETED, false);
            //criterion = Expression.And(criterion, Expression.Eq(Booking.STATUS, StatusType.Pending));
            var criterion = Expression.And(Expression.Eq("Status", StatusType.Pending),
                                           Expression.Ge("Deadline", DateTime.Now));

            criterion = Expression.And(criterion, Expression.Eq("Deleted", false));

            int count;

            // Điều kiện từ query string
            if (Request.QueryString["UserId"] != null)
            {
                User user = Module.UserGetById(Convert.ToInt32(Request.QueryString["UserId"]));
                criterion = Expression.And(criterion, Expression.Eq("CreatedBy", user));

                // và mình là sale in charge
                criterion = Expression.And(criterion, Expression.Eq("agency.Sale", UserIdentity));
            }
            else // nếu không có user thì lấy create by me OR sale in charge
            {
                if (Request.QueryString["mode"] != "all")
                {
                    criterion = Expression.And(criterion,
                                               Expression.Or(Expression.Eq("CreatedBy", UserIdentity),
                                                             Expression.Eq("agency.Sale", UserIdentity)));
                }
            }

            if (Request.QueryString["TripId"] != null)
            {
                SailsTrip trip = Module.TripGetById(Convert.ToInt32(Request.QueryString["TripId"]));
                criterion = Expression.And(criterion, Expression.Eq("Trip", trip));
            }

            if (Request.QueryString["Date"] != null)
            {
                DateTime date = DateTime.FromOADate(Convert.ToDouble(Request.QueryString["date"]));
                criterion = Expression.And(criterion, Expression.Eq("StartDate", date.Date));
            }

            Order order = RepeaterOrder.GetOrderFromQueryString(Request.QueryString);

            if (order == null)
            {
                order = Order.Asc("Deadline");
            }

            rptBookingList.DataSource = Module.BookingGetByCriterion(criterion, order, out count, pagerOrders.PageSize,
                                                                     pagerOrders.CurrentPageIndex);
            pagerOrders.VirtualItemCount = count;
        }
Esempio n. 2
0
        protected virtual void GetDataSource()
        {
            // Điều kiện bắt buộc: chưa xóa và đang pending
            ICriterion criterion = Expression.Eq(Booking.DELETED, false);

            criterion = Expression.And(criterion, Expression.Eq(Booking.STATUS, StatusType.Pending));
            int count;

            // Điều kiện từ query string
            if (Request.QueryString["UserId"] != null)
            {
                User user = Module.UserGetById(Convert.ToInt32(Request.QueryString["UserId"]));
                criterion = Expression.And(criterion, Expression.Eq(Booking.PARTNERID, user));
            }

            if (Request.QueryString["TripId"] != null)
            {
                SailsTrip trip = Module.TripGetById(Convert.ToInt32(Request.QueryString["TripId"]));
                criterion = Expression.And(criterion, Expression.Eq(Booking.TRIP, trip));
            }

            if (Request.QueryString["Date"] != null)
            {
                DateTime date = DateTime.FromOADate(Convert.ToDouble(Request.QueryString["date"]));
                criterion = Expression.And(criterion, Expression.Eq(Booking.STARTDATE, date.Date));
            }

            Order order = RepeaterOrder.GetOrderFromQueryString(Request.QueryString);

            if (order == null)
            {
                order = Order.Desc(Booking.CREATEDDATE);
            }
            rptBookingList.DataSource = Module.BookingGetByCriterion(criterion, order, out count, pagerOrders.PageSize,
                                                                     pagerOrders.CurrentPageIndex);
            pagerOrders.VirtualItemCount = count;
        }
Esempio n. 3
0
        public IList TourSearchByQueryString(NameValueCollection queryString)
        {
            ICriterion criterion = Expression.Eq("Deleted", false);

            criterion = Expression.And(criterion,
                                       Expression.Or(Expression.IsNull(Tour.PACKAGESTATUS),
                                                     Expression.Not(Expression.Eq(Tour.PACKAGESTATUS,
                                                                                  PackageStatus.PartPackage))));
            if (!string.IsNullOrEmpty(queryString["Name"]))
            {
                criterion = Expression.And(criterion, Expression.Like("Name", queryString["Name"], MatchMode.Anywhere));
            }


            #region -- Location --

            Location start = null;
            if (!string.IsNullOrEmpty(queryString["StartId"]) && Convert.ToInt32(queryString["StartId"]) > 0)
            {
                start = LocationGetById(Convert.ToInt32(queryString["StartId"]));
            }

            Location end = null;
            if (!string.IsNullOrEmpty(queryString["EndId"]) && Convert.ToInt32(queryString["EndId"]) > 0)
            {
                end = LocationGetById(Convert.ToInt32(queryString["EndId"]));
            }

            if (start != null)
            {
                switch (start.Level)
                {
                case 3:
                    criterion = Expression.And(criterion, Expression.Eq("CountryStart", start));
                    break;

                case 4:
                    criterion = Expression.And(criterion, Expression.Eq("RegionStart", start));
                    break;

                case 5:
                    criterion = Expression.And(criterion, Expression.Eq("CityStart", start));
                    break;

                default:     //Chưa sử lý nếu Level>5. Để mặc định load ra Location
                    criterion = Expression.And(criterion, Expression.Eq("StartFrom", start));
                    break;
                }
            }

            if (end != null)
            {
                switch (end.Level)
                {
                case 3:
                    criterion = Expression.And(criterion, Expression.Eq("CountryEnd", end));
                    break;

                case 4:
                    criterion = Expression.And(criterion, Expression.Eq("RegionEnd", end));
                    break;

                case 5:
                    criterion = Expression.And(criterion, Expression.Eq("CityEnd", end));
                    break;

                default:     //Chưa sử lý nếu Level>5. Để mặc định load ra Location
                    criterion = Expression.And(criterion, Expression.Eq("EndIn", end));
                    break;
                }
            }

            #endregion

            if (!string.IsNullOrEmpty(queryString["Type"]))
            {
                TourType type = TourTypeGetById(Convert.ToInt32(queryString["Type"]));
                criterion = Expression.And(criterion, Expression.Eq("TourType", type));
            }

            if (!string.IsNullOrEmpty(queryString["TimeLt"]))
            {
                criterion = Expression.And(criterion, Expression.Lt("NumberOfDay", Convert.ToInt32(queryString["TimeLt"])));
            }

            if (!string.IsNullOrEmpty(queryString["TimeGt"]))
            {
                criterion = Expression.And(criterion, Expression.Gt("NumberOfDay", Convert.ToInt32(queryString["TimeGt"])));
            }

            if (!string.IsNullOrEmpty(queryString["LengthLt"]))
            {
                criterion = Expression.And(criterion, Expression.Lt("LengthTrip", Convert.ToInt32(queryString["LengthLt"])));
            }

            if (!string.IsNullOrEmpty(queryString["LengthGt"]))
            {
                criterion = Expression.And(criterion, Expression.Gt("LengthTrip", Convert.ToInt32(queryString["LengthGt"])));
            }

            Order order = RepeaterOrder.GetOrderFromQueryString(queryString);

            if (!string.IsNullOrEmpty(queryString["Region"]))
            {
                TourRegion region = TourRegionGetById(Convert.ToInt32(queryString["Region"]));
                return(_tourDao.TourSearch(criterion, order, region, 0));
            }

            return(_tourDao.TourSearch(criterion, order, 0));
        }