protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { txtDate.Text = Date.HasValue ? Date.Value.ToString("dd/MM/yyyy") : DateTime.Now.Date.ToString("dd/MM/yyyy"); rptRoute.DataSource = TransferRequestByDateBLL.RouteGetAll().Where(x => x.Way == "To").Future().ToList(); rptRoute.DataBind(); rptBusType.DataSource = TransferRequestByDateBLL.BusTypeGetAll().Future().ToList(); rptBusType.DataBind(); if (LockingTransfer == null) { btnLockDate.Visible = true; btnUnlockDate.Visible = false; } else { btnUnlockDate.Visible = true; btnLockDate.Visible = false; } rptRouteByWay.DataSource = TransferRequestByDateBLL.RouteGetAllById(Route.Id).Future().ToList(); rptRouteByWay.DataBind(); } }
public string TransferRequestDTOGetByCriterion(string d, string bti, string ri) { DateTime?date = null; try { date = DateTime.ParseExact(d, "dd/MM/yyyy", CultureInfo.InvariantCulture); } catch { } var busTypeId = -1; try { busTypeId = Int32.Parse(bti); } catch { } var listBusType = TransferRequestByDateBLL.BusTypeGetAllById(busTypeId).Future().ToList(); var routeId = -1; try { routeId = Int32.Parse(ri); } catch { } var listRoute = TransferRequestByDateBLL.RouteGetAllById(routeId).Future().ToList(); var listRouteDTO = new List <RouteDTO>(); foreach (var route in listRoute) { var listBusTypeDTO = new List <BusTypeDTO>(); var routeDTO = new RouteDTO() { Id = route.Id, Name = route.Name, Way = route.Way, }; foreach (var busType in listBusType) { var busTypeDTO = new BusTypeDTO() { Id = busType.Id, Name = busType.Name, HaveBookingNoGroup = BusTypeCheckBookingHaveNoGroup(busType, route, date), HaveNoBooking = false, }; var listBusByDateDTO = new List <BusByDateDTO>(); var listBusByDate = TransferRequestByDateBLL.BusByDateGetAllByCriterion(date, busType, route, route.Way) .OrderBy(y => y.Group).Asc.Future().ToList(); listBusByDate.ForEach(busByDate => { var listBookingBusByDate = TransferRequestByDateBLL.BookingBusByDateGetAllByCriterion(busByDate).Future().ToList(); var listBooking = listBookingBusByDate.Select(x => x.Booking).Distinct().ToList(); int?supplierId = null; if (busByDate.Supplier != null) { supplierId = busByDate.Supplier.Id; } var busByDateDTO = new BusByDateDTO() { Id = busByDate.Id, Group = busByDate.Group, Driver_Name = busByDate.Driver_Name, Driver_Phone = busByDate.Driver_Phone, Adult = listBooking.Select(x => x.Adult).Sum(), Child = listBooking.Select(x => x.Child).Sum(), Baby = listBooking.Select(x => x.Baby).Sum(), SupplierId = supplierId, RouteName = busByDate.Route != null ? busByDate.Route.Name : "", BusTypeName = busByDate.BusType != null ? busByDate.BusType.Name : "", }; foreach (var busByDateGuide in busByDate.BusByDatesGuides) { var guide = busByDateGuide.Guide; GuideDTO guideDTO = null; if (guide != null && guide.Id > 0) { guideDTO = new GuideDTO() { Id = guide.Id, Name = guide.Name, Phone = guide.Phone, }; } var busByDateGuideDTO = new BusByDateGuideDTO() { BusByDateDTO = busByDateDTO, GuideDTO = guideDTO }; busByDateDTO.BusByDatesGuidesDTO.Add(busByDateGuideDTO); } listBusByDateDTO.Add(busByDateDTO); }); busTypeDTO.ListBusByDateDTO = listBusByDateDTO; listBusTypeDTO.Add(busTypeDTO); } routeDTO.ListBusTypeDTO = listBusTypeDTO; listRouteDTO.Add(routeDTO); } var transferRequestDTO = new TransferRequestDTO(); transferRequestDTO.ListRouteDTO = listRouteDTO; Dispose(); return(JsonConvert.SerializeObject(transferRequestDTO)); }