protected void Page_Load(object sender, EventArgs e) { Redirect(); Initialize(); this.Master.Title = "Booking by date"; Page.DataBind(); if (!IsPostBack) { txtDate.Text = Date.ToString("dd/MM/yyyy"); rptBookingList.DataSource = bookings.OrderBy(x => x.Trip.Id).ToList(); rptBookingList.DataBind(); rptTrips.DataSource = trips; rptTrips.DataBind(); _services = new ArrayList(); foreach (CostType type in DailyCost) { if (type.IsSupplier) { _services.Add(type); } } var listShadowBooking = BookingReportBLL.ShadowBookingGetByDate(Date); var listShadowBookingNeeding = new List <Booking>(); foreach (Booking booking in listShadowBooking) { var histories = BookingReportBLL.BookingHistoryGetAllByBooking(booking).OrderBy(x => x.Date).AsEnumerable(); for (int ii = histories.Count() - 1; ii >= 0; ii--) { if (((BookingHistory)(histories.ElementAt(ii))).StartDate == Date || ((BookingHistory)(histories.ElementAt(ii))).Status == StatusType.Cancelled) { var bh = (BookingHistory)(histories.ElementAt(ii)); if (booking.BookingRooms.Count >= 6) { if (bh.Date > Date.AddDays(-45)) { listShadowBookingNeeding.Add(booking); } } else { if (bh.Date > Date.AddDays(-7)) { listShadowBookingNeeding.Add(booking); } } break; } } } rptShadows.DataSource = listShadowBookingNeeding; rptShadows.DataBind(); } }
private void ProvisionalRegisterCalypsoCruise() { var bookings = BookingReportBLL.BookingGetAllStartInDate(Date, Cruise); var customers = bookings.SelectMany(x => x.BookingRooms.SelectMany(y => y.Customers)); MemoryStream mem = new MemoryStream(); using (var excelPackage = new ExcelPackage(new FileInfo(Server.MapPath("/Modules/Sails/Admin/ExportTemplates/ProvisionalRegisterTemplate_Calypso.xlsx")))) { var sheet = excelPackage.Workbook.Worksheets["ProvisionalRegister"]; sheet.Name = "PR-Calypso-" + Date.ToString("dd_MM_yyyy"); int startRow = 2; int currentRow = startRow; int templateRow = startRow; currentRow++; sheet.InsertRow(currentRow, customers.Count() - 1, templateRow); currentRow--; for (int i = 0; i < customers.Count(); i++) { var customer = customers.ElementAt(i) as Customer; sheet.Cells[currentRow, 1].Value = i + 1; sheet.Cells[currentRow, 2].Value = customer.Fullname.ToUpper(); sheet.Cells[currentRow, 3].Value = customer.Birthday.HasValue ? customer.Birthday.Value.Year.ToString() : ""; sheet.Cells[currentRow, 4].Value = customer.IsMale.HasValue ? (customer.IsMale.Value ? "Nam" : "Nữ") : ""; sheet.Cells[currentRow, 5].Value = customer.Passport; if (customer.Nationality != null) { if (customer.Nationality.Name.ToLower() != "Khong ro") { sheet.Cells[currentRow, 6].Value = customer.Nationality.NaNameViet; } else { sheet.Cells[currentRow, 6].Value = ""; } } currentRow++; } excelPackage.SaveAs(mem); } Response.Clear(); Response.ContentEncoding = System.Text.Encoding.UTF8; Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; var fileName = ""; if (Cruise != null) { fileName = string.Format("\"ProvisionalRegister - {0} - {1}.xlsx\"", Date.ToString("dd_MM_yyyy"), Cruise.Name.Replace(" ", "_")); } Response.AppendHeader("content-disposition", "attachment; filename=" + fileName); mem.Position = 0; byte[] buffer = mem.ToArray(); Response.BinaryWrite(buffer); Response.End(); }
protected void btnUnlockDate_Click(object sender, EventArgs e) { var lockingExpense = LockingExpense; if (lockingExpense == null) { Response.Redirect(Request.RawUrl); } BookingReportBLL.LockingExpenseDelete(lockingExpense); ShowSuccess("Unlocked date successfully"); Response.Redirect(Request.RawUrl); }
protected void btnLockDate_Click(object sender, EventArgs e) { var lockingExpense = LockingExpense; if (lockingExpense == null) { lockingExpense = new LockingExpense(); } lockingExpense.Date = Date; BookingReportBLL.LockingExpenseSaveOrUpdate(lockingExpense); ShowSuccess("Locked date successfully"); Response.Redirect(Request.RawUrl); }
public new void Dispose() { if (bookingReportBLL != null) { bookingReportBLL.Dispose(); bookingReportBLL = null; } if (userBLL != null) { userBLL.Dispose(); userBLL = null; } }
protected void Page_Unload(object sender, EventArgs e) { if (bookingReportBLL != null) { bookingReportBLL.Dispose(); bookingReportBLL = null; } if (userBLL != null) { userBLL.Dispose(); userBLL = null; } if (permissionBLL != null) { permissionBLL.Dispose(); permissionBLL = null; } }
public string GetAgencyNotes(Agency agency) { var roles = CurrentUser.Roles; var note = ""; foreach (Role role in roles) { var agencyNoteses = BookingReportBLL.AgencyNotesGetAllByAgencyAndRole(agency, role); note += string.Join("<br/>", agencyNoteses.Select(an => an.Note)); if (role.Name == "Administrator") { agencyNoteses = BookingReportBLL.AgencyNotesGetAllByAgency(agency); note = string.Join("<br/>", agencyNoteses.Select(an => an.Note)); break; } } return(note); }
protected void rptCruises_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.DataItem is Cruise) { var cruise = (Cruise)e.Item.DataItem; HyperLink hplCruises = e.Item.FindControl("hplCruises") as HyperLink; hplCruises.CssClass = "btn btn-default"; if (hplCruises != null) { if (cruise.Id.ToString() == Request.QueryString["cruiseid"]) { hplCruises.CssClass = "btn btn-default active"; } DateTime date = DateTime.ParseExact(txtDate.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture); var numberOfRoom = BookingReportBLL.BookingRoomGetRowCountByCriterion(cruise, Date); var numberOfPax = BookingReportBLL.CustomerGetRowCountByCriterion(cruise, Date); hplCruises.Text = string.Format("{0} ({1} pax/{2} cabins)", cruise.Name, numberOfPax.ToString(), numberOfRoom.ToString()); hplCruises.Attributes.Add("data-pax", numberOfPax.ToString()); hplCruises.NavigateUrl = string.Format( "BookingReport.aspx?NodeId={0}&SectionId={1}&Date={2}&cruiseid={3}", Node.Id, Section.Id, date.ToString("dd/MM/yyyy"), cruise.Id); } } else { HyperLink hplCruises = e.Item.FindControl("hplCruises") as HyperLink; if (hplCruises != null) { if (Request.QueryString["cruiseid"] == null) { hplCruises.CssClass = "btn btn-default active"; } DateTime date = DateTime.ParseExact(txtDate.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture); hplCruises.NavigateUrl = string.Format( "BookingReport.aspx?NodeId={0}&SectionId={1}&Date={2}", Node.Id, Section.Id, date.ToString("dd/MM/yyyy")); } } }
private void ProvisionalRegisterOtherCruise() { DateTime startDate = DateTime.ParseExact(txtDate.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture); int cruiseId = -1; try { cruiseId = Convert.ToInt32(Request.QueryString["cruiseid"]); } catch (Exception) { } var bookingStatus = (int)StatusType.Approved; var bookings = BookingReportBLL.BookingReportBLL_BookingSearchBy(startDate, cruiseId, bookingStatus); var bookings2Days = new List <Booking>(); var bookings3Days = new List <Booking>(); foreach (var booking in bookings) { if (booking.Trip.NumberOfDay == 2) { bookings2Days.Add(booking); } if (booking.Trip.NumberOfDay == 3) { bookings3Days.Add(booking); } } var VietNamCustomerOfBookings2Days = new List <Customer>(); var ForeignCustomerOfBookings2Days = new List <Customer>(); var VietNamCustomerOfBookings3Days = new List <Customer>(); var ForeignCustomerOfBookings3Days = new List <Customer>(); ProvisalRegisterSortCustomer(bookings2Days, ref VietNamCustomerOfBookings2Days, ref ForeignCustomerOfBookings2Days); ProvisalRegisterSortCustomer(bookings3Days, ref VietNamCustomerOfBookings3Days, ref ForeignCustomerOfBookings3Days); var excelFile = new ExcelFile(); excelFile.LoadXls(Server.MapPath("/Modules/Sails/Admin/ExportTemplates/DangKyTamTruTemplate.xls")); var sheetVietNam2Days = excelFile.Worksheets[0]; var sheetVietNam3Days = excelFile.Worksheets[1]; var sheetNuocNgoai2Days = excelFile.Worksheets[2]; var sheetNuocNgoai3Days = excelFile.Worksheets[3]; var stt = 1; ExportFillProvisalRegister(VietNamCustomerOfBookings2Days, sheetVietNam2Days, ref stt); ExportFillProvisalRegister(VietNamCustomerOfBookings3Days, sheetVietNam3Days, ref stt); ExportFillProvisalRegister(ForeignCustomerOfBookings2Days, sheetNuocNgoai2Days, ref stt); ExportFillProvisalRegister(ForeignCustomerOfBookings3Days, sheetNuocNgoai3Days, ref stt); Response.Clear(); Response.Buffer = true; Response.ContentType = "application/vnd.ms-excel"; var cruise = bookingReportBLL.CruiseGetById(cruiseId); if (cruise != null) { Response.AppendHeader("content-disposition", "attachment; filename=" + string.Format("Form_tam_tru_{0}_{1}.xls", startDate.ToString("dd/MM/yyyy"), cruise.GetModifiedCruiseName().Replace(" ", "_"))); } if (cruise == null) { return; } MemoryStream m = new MemoryStream(); excelFile.SaveXls(m); Response.OutputStream.Write(m.GetBuffer(), 0, m.GetBuffer().Length); Response.OutputStream.Flush(); Response.OutputStream.Close(); m.Close(); Response.End(); }
public IEnumerable <BookingRoom> BookingRoomGetAllByBooking(Booking booking) { return(BookingReportBLL.BookingRoomGetAllByBooking(booking)); }