public void SetCustomer(Customer customer, SailsModule module)
        {
            customer.Fullname = txtName.Text;
            switch (ddlGender.SelectedIndex)
            {
            case 1:
                customer.IsMale = true;
                break;

            case 2:
                customer.IsMale = false;
                break;

            default:
                customer.IsMale = null;
                break;
            }
            customer.Passport = txtPassport.Text;
            customer.VisaNo   = txtVisaNo.Text;
            DateTime birthdate;

            if (DateTime.TryParseExact(txtBirthDay.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out birthdate))
            {
                customer.Birthday = birthdate;
            }
            else
            {
                customer.Birthday = DateTime.Now;
            }

            DateTime expired;

            if (DateTime.TryParseExact(txtVisaExpired.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out expired))
            {
                customer.VisaExpired = expired;
            }
            else
            {
                customer.VisaExpired = null;
            }
            customer.IsVietKieu = chkVietKieu.Checked;
            customer.Code       = txtCode.Text;

            if (ddlNationalities.SelectedValue == "-1")
            {
                customer.Nationality = null;
            }
            else
            {
                customer.Nationality = module.NationalityGetById(Convert.ToInt32(ddlNationalities.SelectedValue));
            }

            if (!string.IsNullOrEmpty(txtTotal.Text))
            {
                customer.Total = Convert.ToDouble(txtTotal.Text);
            }

            customer.NguyenQuan = txtNguyenQuan.Text;
        }
コード例 #2
0
 public void BindDataToRptBirdthday(SailsModule module)
 {
     AgencyContactBirthdayList = module.AgencyContactGetByTodayBirdthday();
     if (AgencyContactBirthdayList.Count > 0)
     {
         rptBirthday.DataSource = AgencyContactBirthdayList;
         rptBirthday.DataBind();
     }
 }
コード例 #3
0
        public void SetGroupCruise(string agentLvCode, SailsModule module, int groupId, QQuotation quotation)
        {
            var group = module.GetById <QCruiseGroup>(groupId);

            litGroupName.Text = group.Name;
            AgentLevelCode    = agentLvCode;
            quotationPrice2Day.NewQuotationPriceConfig(module, agentLvCode, 2, group, quotation);
            quotationPrice3Day.NewQuotationPriceConfig(module, agentLvCode, 3, group, quotation);
        }
        public void GetCustomer(Customer customer, SailsModule module)
        {
            if (customer.Nationality != null)
            {
                ddlNationalities.SelectedValue = customer.Nationality.Id.ToString();
            }

            txtName.Text = customer.Fullname;
            if (customer.IsMale.HasValue)
            {
                if (customer.IsMale.Value)
                {
                    ddlGender.SelectedIndex = 1;
                }
                else
                {
                    ddlGender.SelectedIndex = 2;
                }
            }
            else
            {
                ddlGender.SelectedIndex = 0;
            }
            txtPassport.Text = customer.Passport;
            txtVisaNo.Text   = customer.VisaNo;
            if (customer.Birthday.HasValue)
            {
                txtBirthDay.Text = customer.Birthday.Value.ToString("dd/MM/yyyy");
            }
            else
            {
                txtBirthDay.Text = DateTime.Now.ToString("dd/MM/yyyy");
            }

            if (customer.VisaExpired.HasValue)
            {
                txtVisaExpired.Text = customer.VisaExpired.Value.ToString("dd/MM/yyyy");
            }

            chkVietKieu.Checked = customer.IsVietKieu;
            txtCode.Text        = customer.Code;
            txtTotal.Text       = customer.Total.ToString();
            if (!String.IsNullOrEmpty(customer.NguyenQuan))
            {
                txtNguyenQuan.Text = customer.NguyenQuan;
            }
            if (module.ModuleSettings(SailsModule.CUSTOMER_PRICE) == null || Convert.ToBoolean(module.ModuleSettings(SailsModule.CUSTOMER_PRICE)))
            {
                txtTotal.Visible = true;
            }
            else
            {
                txtTotal.Visible = false;
            }

            hiddenId.Value = customer.Id.ToString();
        }
コード例 #5
0
 public void DisplayDataConfig(SailsModule module, Cruise cruise, QCruiseGroup group, string agentLvCode, int trip, QQuotation qQuotation)
 {
     litCruiseName.Text = cruise.Name;
     _module            = module;
     _qQuotation        = qQuotation;
     _trip        = trip;
     _agentLvCode = agentLvCode;
     rptCharterRanger.DataSource = module.GetCruiseCharterPrice(group.Id, cruise, agentLvCode, trip, qQuotation);
     rptCharterRanger.DataBind();
 }
コード例 #6
0
        public void SaveDataConfig(SailsModule module, Cruise cruise, QCruiseGroup group, string agentLvCode, int trip, QQuotation qQuotation)
        {
            litCruiseName.Text = cruise.Name;
            _module            = module;
            _qQuotation        = qQuotation;
            _trip        = trip;
            _agentLvCode = agentLvCode;
            foreach (RepeaterItem item in rptCharterRanger.Items)
            {
                var         charterPrice      = new QCharterPrice();
                HiddenField hidCharterPriceId = item.FindControl("hidCharterPriceId") as HiddenField;

                TextBox  txtValidFrom  = item.FindControl("txtValidFrom") as TextBox;
                TextBox  txtValidTo    = item.FindControl("txtValidTo") as TextBox;
                TextBox  txtPriceUSD   = item.FindControl("txtPriceUSD") as TextBox;
                TextBox  txtPriceVND   = item.FindControl("txtPriceVND") as TextBox;
                CheckBox checkIsDelete = item.FindControl("checkIsDelete") as CheckBox;


                if (hidCharterPriceId != null && (!string.IsNullOrEmpty(hidCharterPriceId.Value) && hidCharterPriceId.Value != "0"))
                {
                    charterPrice = _module.GetById <QCharterPrice>(Convert.ToInt32(hidCharterPriceId.Value));
                }
                if (txtValidFrom != null && !string.IsNullOrEmpty(txtValidFrom.Text))
                {
                    charterPrice.Validfrom = Convert.ToInt32(txtValidFrom.Text);
                }
                if (txtValidTo != null && !string.IsNullOrEmpty(txtValidTo.Text))
                {
                    charterPrice.Validto = Convert.ToInt32(txtValidTo.Text);
                }

                if (txtPriceUSD != null && !string.IsNullOrEmpty(txtPriceUSD.Text))
                {
                    charterPrice.Priceusd = Convert.ToDecimal(txtPriceUSD.Text);
                }
                if (txtPriceVND != null && !string.IsNullOrEmpty(txtPriceVND.Text))
                {
                    charterPrice.Pricevnd = Convert.ToDecimal(txtPriceVND.Text);
                }
                charterPrice.QQuotation     = qQuotation;
                charterPrice.Trip           = trip;
                charterPrice.AgentLevelCode = agentLvCode;
                charterPrice.Cruise         = cruise;
                charterPrice.GroupCruise    = group;
                if (checkIsDelete.Checked)
                {
                    module.Delete(charterPrice);
                }
                else
                {
                    module.SaveOrUpdate(charterPrice);
                }
            }
        }
コード例 #7
0
 public DashBoardBLL()
 {
     BookingRepository       = new BookingRepository();
     CruiseRepository        = new CruiseRepository();
     RoomClassRepository     = new RoomClassRepository();
     RoomTypeRepository      = new RoomTypeRepository();
     SailsModule             = SailsModule.GetInstance();
     ActivityRepository      = new ActivityRepository();
     AgencyRepository        = new AgencyRepository();
     AgencyContactRepository = new AgencyContactRepository();
     CustomerRepository      = new CustomerRepository();
     GoldenDayRepository     = new GoldenDayRepository();
 }
コード例 #8
0
        public virtual double Calculate(SailsModule Module, IList policies, double childPrice, double agencySup, Agency agency)
        {
            // Lấy về kiểu phòng
            RoomClass rclass = RoomClass;
            RoomTypex rtype  = RoomType;

            int adult = Adult;
            int child = Child;

            double price = Calculate(rclass, rtype, adult, child, IsSingle, _book.Trip, _book.Cruise, _book.TripOption, _book.StartDate, Module,
                                     policies, childPrice, agencySup, agency);

            return(price);
        }
コード例 #9
0
        public void NewQuotationPriceConfig(SailsModule module, string agentLvCode, int trip, QCruiseGroup group, QQuotation quotation)
        {
            _module                 = module;
            _trip                   = trip;
            _group                  = group;
            _qQuotation             = quotation;
            _agentLvCode            = agentLvCode;
            hidTrip.Value           = trip.ToString();
            rptRoomPrice.DataSource = module.GetGroupRoomPrice(group.Id, agentLvCode, trip, quotation);
            rptRoomPrice.DataBind();

            // load cruise charter price config
            rptCruise.DataSource = module.CruiseGetAllByGroup(group.Id);
            rptCruise.DataBind();
        }
コード例 #10
0
        public Customer NewCustomer(SailsModule module)
        {
            Customer customer;

            if (CustomerId > 0)
            {
                customer = module.CustomerGetById(CustomerId);
            }
            else
            {
                customer = new Customer();
            }
            SetCustomer(customer, module);
            return(customer);
        }
コード例 #11
0
        public int GetNumberOfRoomAvaiable(Cruise cruise, DateTime date)
        {
            var roomClasses          = RoomClassRepository.RoomClassGetAll();
            var roomTypes            = RoomTypeRepository.RoomTypeGetAll();
            var numberOfRoomAvaiable = 0;

            foreach (RoomClass roomClass in roomClasses)
            {
                foreach (RoomTypex roomType in roomTypes)
                {
                    var numberOfRoomAvailableByRoomClassRoomType = SailsModule.RoomCount(roomClass, roomType, cruise, date, 2, 0);
                    if (numberOfRoomAvailableByRoomClassRoomType > 0)
                    {
                        numberOfRoomAvaiable += numberOfRoomAvailableByRoomClassRoomType;
                    }
                }
            }
            return(numberOfRoomAvaiable);
        }
コード例 #12
0
        public string RoomGetAvaiable(int roomClassId, int roomTypeId, int cruiseId, string startDate, int tripId)
        {
            CoreRepository CoreRepository = HttpContext.Current.Items["CoreRepository"] as CoreRepository;
            int            nodeId         = 1;
            Node           node           = (Node)CoreRepository.GetObjectById(typeof(Node), nodeId);
            int            sectionId      = 15;
            Section        section        = (Section)CoreRepository.GetObjectById(typeof(Section), sectionId);
            SailsModule    module         = (SailsModule)ContainerAccessorUtil.GetContainer().Resolve <ModuleLoader>().GetModuleFromSection(section);
            var            roomClass      = RoomServiceBLL.RoomClassGetById(roomClassId);
            var            roomType       = RoomServiceBLL.RoomTypeGetById(roomTypeId);
            var            cruise         = RoomServiceBLL.CruiseGetById(cruiseId);
            var            trip           = RoomServiceBLL.TripGetById(tripId);

            if (startDate == null)
            {
                return("Start date is required!");
            }
            var startDateDT = DateTime.ParseExact(startDate, "dd/MM/yyyy", CultureInfo.InvariantCulture);

            return(module.RoomCount(roomClass, roomType, cruise, startDateDT, trip.NumberOfDay, trip.HalfDay).ToString());
        }
コード例 #13
0
ファイル: BookingRoom.cs プロジェクト: thieunq92/mysapatravel
        public static double RoomPrice(SailsModule module, RoomClass rclass, RoomTypex rtype, SailsTrip trip, Cruise cruise, TripOption option, DateTime startDate)
        {
            if (trip == null)
            {
                return(0);
            }
            SailsPriceConfig rolePrice = module.SailsPriceConfigGet(rclass, rtype, trip, cruise, option, startDate,
                                                                    BookingType.Double, null);

            if (rolePrice != null)
            {
                return(rolePrice.NetPrice);
            }

            SailsPriceConfig priceConfig = module.SailsPriceConfigGet2(rclass, rtype, trip, cruise, option, startDate, BookingType.Double, null);

            if (priceConfig != null)
            {
                return(priceConfig.NetPrice * MARK_UP);
            }

            return(-1);
        }
コード例 #14
0
        public virtual Dictionary <CostType, double> Calculate(IList costTypes, GetCurrentCostTable costTable, GetCurrentDailyCostTable dailyTable, GetCurrentCruiseExpenseTable getCruiseTable, Cruise activecruise, IList bookings, SailsModule module, bool partnership)
        {
            Cruise = activecruise;

            if (Cruise != null)
            {
                Dictionary <CostType, ExpenseService> serviceMap   = new Dictionary <CostType, ExpenseService>();
                Dictionary <CostType, double>         serviceTotal = new Dictionary <CostType, double>();
                foreach (CostType type in costTypes)
                {
                    serviceMap.Add(type, null);
                    serviceTotal.Add(type, 0);
                }

                foreach (ExpenseService service in Services)
                {
                    if (!serviceMap.ContainsKey(service.Type))
                    {
                        continue;
                    }
                    serviceMap[service.Type] = service;
                    if (service.Type.IsDailyInput)
                    {
                        serviceTotal[service.Type] += service.Cost;
                    }
                }
                int adultHaiPhong = 0;
                int childHaiPhong = 0;

                foreach (Booking booking in bookings)
                {
                    Dictionary <CostType, double> bookingCost = booking.Cost(costTable(Date, booking.Trip, booking.TripOption), costTypes);
                    foreach (CostType type in costTypes)
                    {
                        serviceTotal[type] += bookingCost[type];
                    }

                    adultHaiPhong += booking.Adult;
                    childHaiPhong += booking.Child;
                }

                bool _isRun = bookings.Count > 0;

                if (_isRun)
                {
                    DailyCostTable table = dailyTable(Date);
                    if (table != null)
                    {
                        foreach (DailyCost cost in dailyTable(Date).Costs)
                        {
                            if (serviceTotal.ContainsKey(cost.Type))
                            {
                                serviceTotal[cost.Type] += cost.Cost;
                            }
                        }
                    }
                }

                CruiseExpenseTable cruiseTable = getCruiseTable(Date, Cruise);
                CalculateCruiseExpense(costTypes, serviceTotal, adultHaiPhong, childHaiPhong, cruiseTable);

                foreach (CostType type in costTypes)
                {
                    if (type.IsDailyInput)
                    {
                        continue;
                    }
                    if (serviceMap[type] != null)
                    {
                        if (serviceMap[type].Cost != serviceTotal[type])
                        {
                            serviceMap[type].Cost = serviceTotal[type];
                            module.SaveOrUpdate(serviceMap[type]);
                        }
                    }
                    else
                    {
                        if (type.DefaultAgency == null && partnership)
                        {
                            throw new Exception("You must config default agency for " + type.Name);
                        }
                        ExpenseService service = new ExpenseService();
                        service.Expense  = this;
                        service.Cost     = serviceTotal[type];
                        service.Name     = string.Format("{0:dd/MM/yyyy}- {1}", Date, type.Name);
                        service.Paid     = 0;
                        service.Supplier = type.DefaultAgency;
                        if (service.Supplier != null)
                        {
                            service.Phone = type.DefaultAgency.Phone;
                        }
                        service.Type = type;
                        module.SaveOrUpdate(service);
                    }
                }
                return(serviceTotal);
            }

            Dictionary <CostType, double> total = new Dictionary <CostType, double>();
            IList cruises = module.CruiseGetAll();

            foreach (CostType type in costTypes)
            {
                total.Add(type, 0);
            }

            foreach (Cruise cruise in cruises)
            {
                Expense expense = module.ExpenseGetByDate(cruise, Date);

                IList filtered = new ArrayList();
                foreach (Booking booking in bookings)
                {
                    if (booking.Cruise != null && booking.Cruise.Id == cruise.Id)
                    {
                        filtered.Add(booking);
                    }
                }

                Dictionary <CostType, double> expenses = expense.Calculate(costTypes, costTable, dailyTable,
                                                                           getCruiseTable, cruise, filtered, module,
                                                                           partnership);
                foreach (CostType type in costTypes)
                {
                    total[type] += expenses[type];
                }
            }
            return(total);
        }
コード例 #15
0
        protected IList GetData(out int count, params Order[] orders)
        {
            ICriterion criterion = SailsModule.IncomeCriterion();
            DateTime   from;
            DateTime   to;

            if (string.IsNullOrEmpty(txtFrom.Text) || string.IsNullOrEmpty(txtTo.Text))
            {
                from = DateTime.Today.AddDays(-DateTime.Today.Day + 1);
                to   = from.AddMonths(1).AddDays(-1);
            }
            else
            {
                from = DateTime.ParseExact(txtFrom.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture);
                to   = DateTime.ParseExact(txtTo.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture);
            }
            //if (Request.QueryString["mode"] != "all") // Nếu không phải là mode all thì thêm điều kiện về thời gian
            //{
            txtFrom.Text = from.ToString("dd/MM/yyyy");
            txtTo.Text   = to.ToString("dd/MM/yyyy");
            criterion    = Expression.And(criterion,
                                          Expression.And(Expression.Ge(Booking.STARTDATE, from),
                                                         Expression.Le(Booking.STARTDATE, to)));
            //}
            //else
            //{
            //criterion = Expression.And(criterion, Expression.Not(Expression.Eq("ComPaid", true)));
            ICriterion commissionCriterion = Expression.Or(Expression.Gt("Commission", (double)0), Expression.Gt("CommissionVND", (double)0));

            criterion = Expression.And(criterion, commissionCriterion);
            //}

            if (Request.QueryString["paidon"] != null)
            {
                criterion = Expression.And(criterion, Expression.Ge("PaidDate", DateTime.FromOADate(Convert.ToDouble(Request.QueryString["paidon"]))));
                criterion = Expression.And(criterion, Expression.Lt("PaidDate", DateTime.FromOADate(Convert.ToDouble(Request.QueryString["paidon"])).AddDays(1)));
            }

            ICriterion agencyCrit = SetCriterion(GetAgencies());

            if (agencyCrit != null)
            {
                criterion = Expression.And(criterion, agencyCrit);
            }

            if (UserIdentity.HasPermission(AccessLevel.Administrator) || Module.PermissionCheck("VIEW_ALLBOOKINGRECEIVABLE", UserIdentity))
            {
                // Nếu có quyền xem hết thì mới để ý đến tham số saleid
                if (Request.QueryString["saleid"] != null)
                {
                    int saleid = Convert.ToInt32(Request.QueryString["saleid"]);
                    if (saleid > 0)
                    {
                        criterion = Expression.And(criterion, Expression.Eq("agency.Sale", Module.UserGetById(saleid)));
                    }
                    else
                    {
                        criterion = Expression.And(criterion, Expression.IsNull("agency.Sale"));
                    }
                }
            }
            else
            {
                criterion = Expression.And(criterion, Expression.Eq("agency.Sale", UserIdentity));
            }

            if (Request.QueryString["bookingcode"] != null)
            {
                string code = Request.QueryString["bookingcode"];
                criterion = SailsModule.AddBookingCodeCriterion(criterion, code);
            }

            Order order = Order.Asc(Booking.STARTDATE);

            if (orders.Length > 0)
            {
                order = orders[0];
            }

            return(Module.BookingGetByCriterion(criterion, order, out count, 0, 0, false, UserIdentity));
        }
コード例 #16
0
 public RoomUtil(SailsModule module)
 {
     _module = module;
     _rooms  = new Dictionary <int, IList>();
 }
コード例 #17
0
        /// <summary>
        /// Dùng cho sự kiện data bound của một danh sách booking room
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <param name="module"></param>
        /// <param name="customPrice"></param>
        /// <param name="policies"></param>
        /// <param name="page"></param>
        /// <param name="roomTypes"></param>
        public static void rptRoomList_itemDataBound(object sender, RepeaterItemEventArgs e, SailsModule module, bool customPrice, IList policies, SailsAdminBasePage page, ListItemCollection roomTypes)
        {
            if (e.Item.ItemType != ListItemType.Header)
            {
                BookingRoom item = e.Item.DataItem as BookingRoom;
                if (item != null)
                {
                    #region -- Thông tin thường --

                    Label lblRoomName = (Label)e.Item.FindControl("lblRoomName");
                    if (item.Room != null)
                    {
                        Label label_RoomId = (Label)e.Item.FindControl("label_RoomId");
                        label_RoomId.Text = item.Room.Id.ToString();
                        if (item.Room != null)
                        {
                            lblRoomName.Text = string.Format("{2}: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{0} {1}",
                                                             item.RoomClass.Name, item.RoomType.Name,
                                                             item.Room.Name);
                        }
                        else
                        {
                            lblRoomName.Text = string.Format("{0} {1}",
                                                             item.RoomClass.Name, item.RoomType.Name);
                        }
                    }
                    else
                    {
                        lblRoomName.Text = string.Format("Room {2}: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{0} {1}",
                                                         item.RoomClass.Name, item.RoomType.Name,
                                                         e.Item.ItemIndex + 1);
                    }

                    HiddenField hiddenRoomClassId = (HiddenField)e.Item.FindControl("hiddenRoomClassId");
                    HiddenField hiddenRoomTypeId  = (HiddenField)e.Item.FindControl("hiddenRoomTypeId");

                    hiddenRoomClassId.Value = item.RoomClass.Id.ToString();
                    hiddenRoomTypeId.Value  = item.RoomType.Id.ToString();

                    if (item.Booked == 1 && item.RoomType.Id == SailsModule.TWIN)
                    {
                        e.Item.FindControl("trCustomer2").Visible = false;
                        e.Item.FindControl("trExtra").Visible     = false;
                    }

                    CheckBox    checkBoxAddChild = (CheckBox)e.Item.FindControl("checkBoxAddChild");
                    HtmlControl trChild          = (HtmlControl)e.Item.FindControl("trChild");
                    HtmlControl trChildServices  = (HtmlControl)e.Item.FindControl("trChildServices");

                    string scriptChild = string.Format(@"toggleVisible('{0}');toggleVisible('{1}');",
                                                       trChild.ClientID, trChildServices.ClientID);
                    checkBoxAddChild.Attributes.Add("onclick", scriptChild);

                    CheckBox    checkBoxAddBaby = (CheckBox)e.Item.FindControl("checkBoxAddBaby");
                    HtmlControl trBaby          = (HtmlControl)e.Item.FindControl("trBaby");
                    HtmlControl trBabyServices  = (HtmlControl)e.Item.FindControl("trBabyServices");
                    string      scriptBaby      = string.Format(@"toggleVisible('{0}');toggleVisible('{1}');", trBaby.ClientID,
                                                                trBabyServices.ClientID);
                    checkBoxAddBaby.Attributes.Add("onclick", scriptBaby);

                    CheckBox    checkBoxSingle      = (CheckBox)e.Item.FindControl("checkBoxSingle");
                    HtmlControl trCustomer2         = (HtmlControl)e.Item.FindControl("trCustomer2");
                    HtmlControl trCustomer2Services = (HtmlControl)e.Item.FindControl("trCustomer2Services");
                    string      scriptCustomer      = string.Format(@"toggleVisible('{0}');toggleVisible('{1}');",
                                                                    trCustomer2.ClientID, trCustomer2Services.ClientID);
                    checkBoxSingle.Attributes.Add("onclick", scriptCustomer);

                    #endregion

                    #region -- (back-end) --

                    bool isSecond = false;
                    // Load customer info đã có

                    #region -- customer info --

                    foreach (Customer customer in item.Customers)
                    {
                        if (customer.Type == CustomerType.Adult)
                        {
                            if (!isSecond)
                            {
                                CustomerInfoInput customer1   = e.Item.FindControl("customer1") as CustomerInfoInput;
                                Repeater          rptService1 = e.Item.FindControl("rptServices1") as Repeater;
                                if (customer1 != null && rptService1 != null)
                                {
                                    customer1.GetCustomer(customer, module);
                                    if (page.DetailService)
                                    {
                                        CustomerServiceRepeaterHandler handler =
                                            new CustomerServiceRepeaterHandler(customer, module);
                                        rptService1.DataSource     = module.CustomerServices;
                                        rptService1.ItemDataBound += handler.ItemDataBound;
                                        rptService1.DataBind();
                                    }
                                    else
                                    {
                                        rptService1.Visible = false;
                                    }
                                    isSecond = true;
                                }
                            }
                            else
                            {
                                CustomerInfoInput customer2   = e.Item.FindControl("customer2") as CustomerInfoInput;
                                Repeater          rptService2 = e.Item.FindControl("rptServices2") as Repeater;
                                if (customer2 != null && rptService2 != null)
                                {
                                    customer2.GetCustomer(customer, module);
                                    if (page.DetailService)
                                    {
                                        CustomerServiceRepeaterHandler handler =
                                            new CustomerServiceRepeaterHandler(customer, module);
                                        rptService2.DataSource     = module.CustomerServices;
                                        rptService2.ItemDataBound += handler.ItemDataBound;
                                        rptService2.DataBind();
                                    }
                                    else
                                    {
                                        rptService2.Visible = false;
                                    }
                                }
                            }
                        }


                        if (customer.Type == CustomerType.Children)
                        {
                            CustomerInfoInput customerChild =
                                e.Item.FindControl("customerChild") as CustomerInfoInput;
                            Repeater rptServicesChild = e.Item.FindControl("rptServicesChild") as Repeater;
                            if (customerChild != null && rptServicesChild != null)
                            {
                                customerChild.GetCustomer(customer, module);
                                if (page.DetailService)
                                {
                                    CustomerServiceRepeaterHandler handler = new CustomerServiceRepeaterHandler(
                                        customer, module);
                                    rptServicesChild.DataSource     = module.CustomerServices;
                                    rptServicesChild.ItemDataBound += handler.ItemDataBound;
                                    rptServicesChild.DataBind();
                                }
                                else
                                {
                                    rptServicesChild.Visible = false;
                                }
                            }
                        }

                        if (customer.Type == CustomerType.Baby)
                        {
                            CustomerInfoInput customerBaby    = e.Item.FindControl("customerBaby") as CustomerInfoInput;
                            Repeater          rptServicesBaby = e.Item.FindControl("rptServicesBaby") as Repeater;
                            if (customerBaby != null && rptServicesBaby != null)
                            {
                                customerBaby.GetCustomer(customer, module);
                                if (page.DetailService)
                                {
                                    CustomerServiceRepeaterHandler handler = new CustomerServiceRepeaterHandler(
                                        customer, module);
                                    rptServicesBaby.DataSource     = module.CustomerServices;
                                    rptServicesBaby.ItemDataBound += handler.ItemDataBound;
                                    rptServicesBaby.DataBind();
                                }
                                else
                                {
                                    rptServicesBaby.Visible = false;
                                }
                            }
                        }
                    }

                    #endregion

                    #region -- Check box và visible --

                    if (item.VirtualAdult == 1)
                    {
                        e.Item.FindControl("trCustomer2").Visible  = false;
                        e.Item.FindControl("rptServices2").Visible = false;
                    }

                    if (item.HasChild)
                    {
                        trChild.Attributes.CssStyle["display"]         = "";
                        trChildServices.Attributes.CssStyle["display"] = "";
                        checkBoxAddChild.Checked = true;
                    }
                    else
                    {
                        Repeater rptServicesChild = e.Item.FindControl("rptServicesChild") as Repeater;
                        if (rptServicesChild != null)
                        {
                            rptServicesChild.DataSource = module.CustomerServices;
                            rptServicesChild.DataBind();
                        }
                    }

                    if (item.HasBaby)
                    {
                        trBaby.Attributes.CssStyle["display"]         = "";
                        trBabyServices.Attributes.CssStyle["display"] = "";
                        checkBoxAddBaby.Checked = true;
                    }
                    else
                    {
                        Repeater rptServicesBaby = e.Item.FindControl("rptServicesBaby") as Repeater;
                        if (rptServicesBaby != null)
                        {
                            rptServicesBaby.DataSource = module.CustomerServices;
                            rptServicesBaby.DataBind();
                        }
                    }

                    if (item.IsSingle)
                    {
                        trCustomer2.Attributes.CssStyle["display"]         = "none";
                        trCustomer2Services.Attributes.CssStyle["display"] = "none";
                        checkBoxSingle.Checked = true;
                    }

                    #endregion

                    // Load room available

                    #region -- available --

                    DropDownList ddlRooms = e.Item.FindControl("ddlRooms") as DropDownList;
                    if (ddlRooms != null)
                    {
                        // Danh sách phòng được chọn bao gồm: toàn bộ các phòng chưa được chọn và phòng trong book hiện tại
                        IList datasouce = module.RoomGetAvailable(item.Book.Cruise, item, (item.Book.EndDate - item.Book.StartDate).Days,
                                                                  item.Book);
                        Room room = new Room("", false, null, null);
                        datasouce.Insert(0, room);
                        ddlRooms.DataSource     = datasouce;
                        ddlRooms.DataTextField  = Room.NAME;
                        ddlRooms.DataValueField = "Id";
                        ddlRooms.DataBind();

                        if (item.Room != null)
                        {
                            ListItem listItem = ddlRooms.Items.FindByValue(item.Room.Id.ToString());
                            if (listItem != null)
                            {
                                listItem.Selected = true;
                            }
                        }
                    }

                    #endregion

                    #region -- room price --

                    if (customPrice)
                    {
                        TextBox txtPrice = e.Item.FindControl("txtPrice") as TextBox;
                        if (txtPrice != null)
                        {
                            if (item.Total <= 0)
                            {
                                if (module.ModuleSettings(SailsModule.CUSTOMER_PRICE) == null || Convert.ToBoolean(module.ModuleSettings(SailsModule.CUSTOMER_PRICE)))
                                {
                                    txtPrice.Visible = false;
                                }
                                else
                                {
                                    txtPrice.Visible = true;
                                }
                                item.Total = item.Calculate(module, policies, page.ChildPrice, page.AgencySupplement, null);
                            }
                            txtPrice.Text = item.Total.ToString("0.#");
                        }
                    }
                    else
                    {
                        PlaceHolder plhRoomPrice = e.Item.FindControl("plhRoomPrice") as PlaceHolder;
                        if (plhRoomPrice != null)
                        {
                            plhRoomPrice.Visible = false;
                        }
                    }

                    #endregion

                    DropDownList ddlRoomTypes = e.Item.FindControl("ddlRoomTypes") as DropDownList;
                    if (ddlRoomTypes != null)
                    {
                        if (item.VirtualAdult == 2)
                        {
                            ddlRoomTypes.DataSource     = roomTypes; //module.RoomTypexGetAll();
                            ddlRoomTypes.DataValueField = "Value";
                            ddlRoomTypes.DataTextField  = "Text";
                            ddlRoomTypes.DataBind();

                            ListItem listitem =
                                ddlRoomTypes.Items.FindByValue(string.Format("{0}|{1}", item.RoomClass.Id,
                                                                             item.RoomType.Id));

                            if (listitem != null)
                            {
                                listitem.Selected = true;
                            }
                            else
                            {
                                ddlRoomTypes.Items.Add(new ListItem(item.RoomClass.Name + " " + item.RoomType.Name,
                                                                    string.Format("{0}|{1}", item.RoomClass.Id,
                                                                                  item.RoomType.Id)));
                                ddlRoomTypes.SelectedValue = string.Format("{0}|{1}", item.RoomClass.Id,
                                                                           item.RoomType.Id);
                            }
                        }
                        else
                        {
                            ddlRoomTypes.Visible = false;
                            e.Item.FindControl("labelRoomTypes").Visible = false;
                        }
                    }

                    #endregion
                }
            }
        }
コード例 #18
0
        public void SaveQuotationPriceConfig(SailsModule module, string agentLvCode, int trip, int groupId, QQuotation quotation)
        {
            QCruiseGroup group = module.GetById <QCruiseGroup>(groupId);

            // save room price
            foreach (RepeaterItem item in rptRoomPrice.Items)
            {
                var         roomPrice         = new QGroupRomPrice();
                HiddenField hidRoomPriceId    = item.FindControl("hidRoomPriceId") as HiddenField;
                TextBox     txtRoomType       = item.FindControl("txtRoomType") as TextBox;
                TextBox     txtPriceDoubleUsd = item.FindControl("txtPriceDoubleUsd") as TextBox;
                TextBox     txtPriceDoubleVnd = item.FindControl("txtPriceDoubleVnd") as TextBox;
                TextBox     txtPriceTwinUsd   = item.FindControl("txtPriceTwinUsd") as TextBox;
                TextBox     txtPriceTwinVnd   = item.FindControl("txtPriceTwinVnd") as TextBox;
                TextBox     txtPriceExtraUsd  = item.FindControl("txtPriceExtraUsd") as TextBox;
                TextBox     txtPriceExtraVnd  = item.FindControl("txtPriceExtraVnd") as TextBox;
                TextBox     txtPriceChildUsd  = item.FindControl("txtPriceChildUsd") as TextBox;
                TextBox     txtPriceChildVnd  = item.FindControl("txtPriceChildVnd") as TextBox;
                CheckBox    checkIsDelete     = item.FindControl("checkIsDelete") as CheckBox;


                if (!string.IsNullOrEmpty(hidRoomPriceId.Value) && hidRoomPriceId.Value != "0")
                {
                    roomPrice = module.GetById <QGroupRomPrice>(Convert.ToInt32(hidRoomPriceId.Value));
                }
                if (!string.IsNullOrEmpty(txtRoomType.Text))
                {
                    roomPrice.RoomType = txtRoomType.Text;
                }
                if (!string.IsNullOrEmpty(txtPriceDoubleUsd.Text))
                {
                    roomPrice.PriceDoubleUsd = Convert.ToDecimal(txtPriceDoubleUsd.Text);
                }
                if (!string.IsNullOrEmpty(txtPriceDoubleVnd.Text))
                {
                    roomPrice.PriceDoubleVnd = Convert.ToDecimal(txtPriceDoubleVnd.Text);
                }
                if (!string.IsNullOrEmpty(txtPriceTwinUsd.Text))
                {
                    roomPrice.PriceTwinUsd = Convert.ToDecimal(txtPriceTwinUsd.Text);
                }
                if (!string.IsNullOrEmpty(txtPriceTwinVnd.Text))
                {
                    roomPrice.PriceTwinVnd = Convert.ToDecimal(txtPriceTwinVnd.Text);
                }

                if (!string.IsNullOrEmpty(txtPriceExtraUsd.Text))
                {
                    roomPrice.PriceExtraUsd = Convert.ToDecimal(txtPriceExtraUsd.Text);
                }
                if (!string.IsNullOrEmpty(txtPriceExtraVnd.Text))
                {
                    roomPrice.PriceExtraVnd = Convert.ToDecimal(txtPriceExtraVnd.Text);
                }
                if (!string.IsNullOrEmpty(txtPriceChildUsd.Text))
                {
                    roomPrice.PriceChildUsd = Convert.ToDecimal(txtPriceChildUsd.Text);
                }
                if (!string.IsNullOrEmpty(txtPriceChildVnd.Text))
                {
                    roomPrice.PriceChildVnd = Convert.ToDecimal(txtPriceChildVnd.Text);
                }
                roomPrice.GroupCruise    = group;
                roomPrice.AgentLevelCode = agentLvCode;
                roomPrice.QQuotation     = quotation;
                roomPrice.Trip           = trip;
                if (checkIsDelete.Checked)
                {
                    module.Delete(roomPrice);
                }
                else
                {
                    module.SaveOrUpdate(roomPrice);
                }
            }
            //save charter range

            foreach (RepeaterItem cruiseItem in rptCruise.Items)
            {
                var hidCruise   = cruiseItem.FindControl("hidCruise") as HiddenField;
                var cruiseprice = cruiseItem.FindControl("cruiseprice") as CruiseCharterConfigPrice;
                if (cruiseprice != null)
                {
                    if (hidCruise != null && !string.IsNullOrWhiteSpace(hidCruise.Value))
                    {
                        var cruise = module.GetById <Cruise>(Convert.ToInt32(hidCruise.Value));
                        cruiseprice.SaveDataConfig(module, cruise, group, agentLvCode, trip, quotation);
                    }
                }
            }
        }
コード例 #19
0
        public virtual double Calculate(SailsModule Module, Agency agency, double childPrice, double agencySup, bool customPrice, double roomTotal)
        {
            Role applyRole;

            if (agency != null && agency.Role != null)
            {
                applyRole = agency.Role;
            }
            else
            {
                applyRole = Module.RoleGetById(4);
            }
            double total = roomTotal;

            #region -- Lấy danh sách chính sách giá --
            Role role;
            if (Agency != null && Agency.Role != null)
            {
                role = Agency.Role;
            }
            else
            {
                role = applyRole;
            }
            IList _policies = Module.AgencyPolicyGetByRole(role);
            #endregion

            #region -- Giá dịch vụ --

            IList services      = Module.ExtraOptionGetBooking();
            IList servicePrices = Module.ServicePriceGetByBooking(this);

            foreach (ExtraOption extra in services)
            {
                double child = Child;

                double unitPrice = -1;
                // Với mỗi dịch vụ ưu tiên lấy giá nhập trước
                foreach (BookingServicePrice price in servicePrices)
                {
                    if (price.ExtraOption == extra)
                    {
                        unitPrice = price.UnitPrice;
                    }
                }

                if (unitPrice < 0)
                {
                    unitPrice = Module.ApplyPriceFor(extra.Price, _policies);
                }

                if (extra.IsIncluded)
                {
                    // Nếu dịch vụ đã include thì xem xem có không check không để trừ
                    if (!_extraServices.Contains(extra))
                    {
                        total -= unitPrice * (Adult + child * childPrice / 100);
                    }
                }
                else
                {
                    // Nếu là dịch vụ chưa include thì xem có có không để cộng
                    if (_extraServices.Contains(extra))
                    {
                        total += unitPrice * (Adult + child * childPrice / 100);
                    }
                }
            }

            //TODO: Cần phải check cả dịch vụ dành cho từng khách nữa

            #endregion

            return(total);
        }
コード例 #20
0
        protected int GetData(out IList list, bool loadService)
        {
            Cruise cruise = null;

            if (Request.QueryString["code"] != null)
            {
                ICriterion crit = Expression.Eq("Deleted", false);
                crit = SailsModule.AddBookingCodeCriterion(crit, Request.QueryString["code"]);

                var temp = Module.GetObject <Booking>(crit, 2, 0);
                if (temp.Count > 1)
                {
                    ShowErrors("Please input booking code correctly");
                    list = new ArrayList();
                    return(0);
                }
                else if (temp.Count == 0)
                {
                    ShowErrors("No booking with the code you provided");
                    list = new ArrayList();
                    return(0);
                }
                else
                {
                    cruise = temp[0].Cruise;
                    _date  = temp[0].StartDate;
                }
            }

            if (cruise == null)
            {
                if (Request.QueryString["cruiseid"] != null)
                {
                    cruise = Module.CruiseGetById(Convert.ToInt32(Request.QueryString["cruiseid"]));
                }

                if (string.IsNullOrEmpty(txtDate.Text))
                {
                    _date = DateTime.Today;
                }
                else
                {
                    _date = DateTime.ParseExact(txtDate.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture);
                }
            }

            ICriterion criterion = Module.LockCrit();

            criterion = Expression.And(criterion, Expression.Not(Expression.Eq("IsTransferred", true)));

            if (cruise != null)
            {
                criterion = Expression.And(criterion, Expression.Eq("Cruise", cruise));
            }

            criterion = Module.AddDateExpression(criterion, _date);

            int count;

            list = Module.BookingGetByCriterion(criterion, null, out count, 0, 0);
            List <Booking> bookings = new List <Booking>();

            foreach (Booking booking in list)
            {
                bookings.Add(booking);
            }

            list = bookings.OrderBy(o => o.Trip.Id).ToList <Booking>();

            if (loadService)
            {
                LoadService(_date);
            }
            return(count);
        }
コード例 #21
0
 public ExpenseCalculator(SailsModule module, bool IsPartnershipManager)
 {
     _module            = module;
     PartnershipManager = IsPartnershipManager;
 }
コード例 #22
0
        protected IList GetData(out int count)
        {
            ICriterion criterion = SailsModule.IncomeCriterion();

            if (String.IsNullOrEmpty(Request.QueryString["ps"]))
            {
                criterion = Expression.And(criterion, Expression.Eq("DriverCollected", false));
            }

            criterion = Expression.And(criterion, Expression.Or(Expression.Gt("DriverCollect", 0d), Expression.Gt("DriverCollectVND", 0d)));
            DateTime from;
            DateTime to;

            if (string.IsNullOrEmpty(txtFrom.Text) || string.IsNullOrEmpty(txtTo.Text))
            {
                from = DateTime.Today.AddDays(-DateTime.Today.Day + 1);
                to   = from.AddMonths(1).AddDays(-1);
            }
            else
            {
                from = DateTime.ParseExact(txtFrom.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture);
                to   = DateTime.ParseExact(txtTo.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture);
            }

            if (Request.QueryString["mode"] != "all") // Nếu không phải là mode all thì thêm điều kiện về thời gian
            {
                txtFrom.Text = from.ToString("dd/MM/yyyy");
                txtTo.Text   = to.ToString("dd/MM/yyyy");
                criterion    = Expression.And(criterion,
                                              Expression.And(Expression.Ge(Booking.STARTDATE, from),
                                                             Expression.Le(Booking.STARTDATE, to)));
            }
            else
            {
                criterion = Expression.And(criterion, Expression.Eq("IsPaid", false));
            }

            if (Request.QueryString["paidon"] != null)
            {
                criterion = Expression.And(criterion, Expression.Ge("PaidDate", DateTime.FromOADate(Convert.ToDouble(Request.QueryString["paidon"]))));
                criterion = Expression.And(criterion, Expression.Lt("PaidDate", DateTime.FromOADate(Convert.ToDouble(Request.QueryString["paidon"])).AddDays(1)));
            }

            ICriterion agencyCrit = SetCriterion(GetAgencies());

            if (agencyCrit != null)
            {
                criterion = Expression.And(criterion, agencyCrit);
            }

            if (UserIdentity.HasPermission(AccessLevel.Administrator) || Module.PermissionCheck("VIEW_ALLBOOKINGGUIDECOLLECT", UserIdentity))
            {
                // Nếu có quyền xem hết thì mới để ý đến tham số saleid
                if (Request.QueryString["saleid"] != null)
                {
                    int saleid = Convert.ToInt32(Request.QueryString["saleid"]);
                    if (saleid > 0)
                    {
                        criterion = Expression.And(criterion, Expression.Eq("agency.Sale", Module.UserGetById(saleid)));
                    }
                    else
                    {
                        criterion = Expression.And(criterion, Expression.IsNull("agency.Sale"));
                    }
                }
            }
            else
            {
                criterion = Expression.And(criterion, Expression.Eq("agency.Sale", UserIdentity));
            }

            if (Request.QueryString["bookingcode"] != null)
            {
                string code = Request.QueryString["bookingcode"];
                criterion = SailsModule.AddBookingCodeCriterion(criterion, code);
            }

            bool tripped = false;

            if (Request.QueryString["tripid"] != null)
            {
                criterion = Expression.And(criterion,
                                           Expression.Eq("Trip.Id", Convert.ToInt32(Request.QueryString["tripid"])));
                tripped = true;
            }

            if (Request.QueryString["orgid"] != null)
            {
                criterion = Expression.And(criterion,
                                           Expression.Eq("trip.Organization", Module.OrganizationGetById(Convert.ToInt32(Request.QueryString["orgid"]))));
                tripped = true;
            }

            if (Request.QueryString["ps"] != null)
            {
                switch (Request.QueryString["ps"])
                {
                case "notpaid":
                    criterion = Expression.And(criterion, Expression.Eq("DriverCollected", false));
                    break;

                case "paid":
                    criterion = Expression.And(criterion, Expression.Eq("DriverCollected", true));
                    break;
                }
            }

            var bookings          = Module.BookingGetByCriterion(criterion, Order.Asc(Booking.STARTDATE), out count, 0, 0, tripped, UserIdentity);
            var bookingFilterList = new List <Booking>();

            if (Request.QueryString["drivername"] != null)
            {
                foreach (Booking booking in bookings)
                {
                    var            sailDate = Module.ExpenseGetByDate(booking.Trip, booking.StartDate);
                    ExpenseService driver   = null;
                    foreach (ExpenseService service in sailDate.Services)
                    {
                        if (service.Type.Name.ToUpper() == "TRANSPORT" && service.Group == booking.Group)
                        {
                            driver = service;
                            if (driver != null && driver.Supplier != null)
                            {
                                if (driver.Name.Contains(Request.QueryString["drivername"]))
                                {
                                    bookingFilterList.Add(booking);
                                }
                            }
                        }
                    }
                }
                bookings = bookingFilterList;
            }

            var bookingDriverFilterList = new List <Booking>();

            if (Request.QueryString["supplierid"] != null)
            {
                var agencyId = Convert.ToInt32(Request.QueryString["supplierid"]);
                foreach (Booking booking in bookings)
                {
                    var            sailDate = Module.ExpenseGetByDate(booking.Trip, booking.StartDate);
                    ExpenseService driver   = null;
                    foreach (ExpenseService service in sailDate.Services)
                    {
                        if (service.Type.Name.ToUpper() == "TRANSPORT" && service.Group == booking.Group)
                        {
                            driver = service;
                            if (driver != null && driver.Supplier != null)
                            {
                                if (driver.Supplier.Id == agencyId)
                                {
                                    bookingDriverFilterList.Add(booking);
                                }
                            }
                        }
                    }
                }
                bookings = bookingDriverFilterList;
            }

            return(bookings);
        }
コード例 #23
0
        protected void rptBookingList_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            Dictionary <SailsTrip, double> incomes = new Dictionary <SailsTrip, double>(AllTrips.Count);
            double total = 0;

            foreach (SailsTrip trip in AllTrips)
            {
                incomes.Add(trip, 0);
            }

            if (e.Item.DataItem is DateTime)
            {
                DateTime  date    = (DateTime)e.Item.DataItem;
                HyperLink hplDate = (HyperLink)e.Item.FindControl("hplDate");
                if (hplDate != null)
                {
                    hplDate.Text        = date.ToString("dd/MM/yyyy");
                    hplDate.NavigateUrl = string.Format("BookingReport.aspx?NodeId={0}&SectionId={1}&Date={2}", Node.Id,
                                                        Section.Id, date.ToOADate());
                }

                #region -- Counting --
                int count;
                // Khi tính income thì chỉ tính theo khách đã check-in
                ICriterion criterion = Expression.And(Expression.Eq(Booking.STARTDATE, date),
                                                      SailsModule.IncomeCriterion());
                // Bỏ deleted và cả transfer
                criterion = Expression.And(Expression.Eq("Deleted", false), criterion);
                criterion = Expression.And(Expression.Eq("IsTransferred", false), criterion);

                if (ActiveCruise != null)
                {
                    criterion = Expression.And(Expression.Eq("Cruise", ActiveCruise), criterion);
                }

                IList bookings =
                    Module.BookingGetByCriterion(criterion, null, out count, 0, 0, false, UserIdentity);
                int pax = 0;

                foreach (Booking booking in bookings)
                {
                    if (booking.Status == StatusType.Approved)
                    {
                        // Số khách trong cả book, bao gồm cả trẻ em và trẻ sơ sinh
                        int inBook = 0;
                        inBook += booking.Adult;
                        foreach (BookingRoom room in booking.BookingRooms)
                        {
                            if (room.HasChild)
                            {
                                inBook++;
                            }
                            if (room.HasBaby)
                            {
                                inBook++;
                            }
                        }
                        pax += inBook;
                    }
                    _total += booking.Value;
                    total  += booking.Value;
                    incomes[booking.Trip]  += booking.Value;
                    _incomes[booking.Trip] += booking.Value;
                }
                _pax += pax;
                Literal litTotalPax = (Literal)e.Item.FindControl("litTotalPax");
                Literal litTotal    = (Literal)e.Item.FindControl("litTotal");
                litTotalPax.Text = pax.ToString();
                litTotal.Text    = (total).ToString("#,0");

                #endregion

                _currentIncomes = incomes;
                Repeater rptTrip = (Repeater)e.Item.FindControl("rptTrip");
                rptTrip.DataSource = AllTrips;
                rptTrip.DataBind();

                if (ActiveCruise != null)
                {
                    BarRevenue bar    = Module.BarRevenueGetByDate(ActiveCruise, date);
                    Literal    litBar = e.Item.FindControl("litBar") as Literal;
                    if (litBar != null)
                    {
                        litBar.Text = bar.Revenue.ToString("0");
                        _bar       += bar.Revenue;
                    }
                }
                else
                {
                    double  bar    = Module.SumBarByDate(date);
                    Literal litBar = e.Item.FindControl("litBar") as Literal;
                    if (litBar != null)
                    {
                        litBar.Text = bar.ToString("0");
                        _bar       += bar;
                    }
                }
            }
            else if (e.Item.ItemType == ListItemType.Footer)
            {
                Literal  litTotalPax = (Literal)e.Item.FindControl("litTotalPax");
                Literal  litTotal    = (Literal)e.Item.FindControl("litTotal");
                Repeater rptTrip     = (Repeater)e.Item.FindControl("rptTrip");
                rptTrip.DataSource = AllTrips;
                rptTrip.DataBind();
                litTotalPax.Text = _pax.ToString();
                litTotal.Text    = _total.ToString("#,0");

                Literal litBar = e.Item.FindControl("litBar") as Literal;
                if (litBar != null)
                {
                    litBar.Text = _bar.ToString("0");
                }
            }
            else if (e.Item.ItemType == ListItemType.Header)
            {
                Repeater rptTrip = (Repeater)e.Item.FindControl("rptTrip");
                rptTrip.DataSource = AllTrips;
                rptTrip.DataBind();
            }
        }
コード例 #24
0
        public virtual Dictionary <CostType, double> Calculate(IList costTypes, GetCurrentCostTable costTable, GetCurrentDailyCostTable dailyTable, GetCurrentCruiseExpenseTable getCruiseTable, Cruise activecruise, IList bookings, SailsModule module, bool partnership)
        {
            Cruise = activecruise;
            // Nếu là chi phí từng tàu, tính chi phí cho tàu đó
            // Nếu là chi phí tổng, tính chi phí từng tàu rồi sau đó cộng lại

            #region -- Chi phí cho một tàu --
            if (Cruise != null)
            {
                // Dựng bảng dịch vụ trắng
                Dictionary <CostType, ExpenseService> serviceMap   = new Dictionary <CostType, ExpenseService>();
                Dictionary <CostType, double>         serviceTotal = new Dictionary <CostType, double>();
                foreach (CostType type in costTypes)
                {
                    serviceMap.Add(type, null);
                    serviceTotal.Add(type, 0);
                }

                #region -- Tạo bảng giá trắng và lấy giá nhập thủ công theo thuyến --
                // Kiểm tra xem đã có giá các dịch vụ nào
                foreach (ExpenseService service in Services)
                {
                    // Nếu không thuộc diện tính chi phí cho ngày (không nằm trong danh sách chi phí)
                    if (!serviceMap.ContainsKey(service.Type))
                    {
                        continue;
                    }

                    serviceMap[service.Type] = service;

                    // Nếu là giá nhập thủ công thì cộng luôn
                    if (service.Type.IsDailyInput)
                    {
                        serviceTotal[service.Type] += service.Cost;
                    }
                }
                #endregion

                int adultHaiPhong = 0;
                int childHaiPhong = 0;

                // Tính giá từng dịch vụ với từng booking (chi phí theo số khách )
                #region -- Dịch vụ theo booking (chi phí theo số khách) --
                foreach (Booking booking in bookings)
                {
                    Dictionary <CostType, double> bookingCost = booking.Cost(costTable(Date, booking.Trip, booking.TripOption), costTypes);

                    // Sau khi có bảng giá từng booking thì cộng vào tổng
                    foreach (CostType type in costTypes)
                    {
                        serviceTotal[type] += bookingCost[type];
                    }

                    // Đồng thời tính số người để tính giá thuê tàu Hải Phong luôn
                    adultHaiPhong += booking.Adult;
                    childHaiPhong += booking.Child;
                }
                #endregion

                #region -- Chi phí theo chuyến --
                bool _isRun = bookings.Count > 0; // Nếu có booking thì tính chi phí theo chuyến (tàu có chạy)

                if (_isRun)
                {
                    DailyCostTable table = dailyTable(Date);
                    if (table != null)
                    {
                        foreach (DailyCost cost in dailyTable(Date).Costs)
                        {
                            if (serviceTotal.ContainsKey(cost.Type))
                            {
                                serviceTotal[cost.Type] += cost.Cost; // Luôn cộng luôn chi phí vào tổng
                            }
                        }
                    }
                }

                #endregion

                #region -- Giá tàu Hải Phong --

                // Chỉ tính giá tàu Hải Phong nếu đây là bảng chi phí cho một tàu
                CruiseExpenseTable cruiseTable = getCruiseTable(Date, Cruise);
                CalculateCruiseExpense(costTypes, serviceTotal, adultHaiPhong, childHaiPhong, cruiseTable);

                #endregion

                #region -- Trước khi trả về kết quả, kiểm tra cơ sở dữ liệu --
                foreach (CostType type in costTypes)
                {
                    // Bỏ qua dịch vụ theo ngày vì đã lưu theo từng dịch vụ riêng rẽ
                    if (type.IsDailyInput)
                    {
                        continue;
                    }
                    if (serviceMap[type] != null)
                    {
                        // Nếu giá dịch vụ trong CSDL không bằng thực tính
                        if (serviceMap[type].Cost != serviceTotal[type])
                        {
                            serviceMap[type].Cost = serviceTotal[type];
                            module.SaveOrUpdate(serviceMap[type]);
                        }
                        // Ngược lại thì bỏ qua
                    }
                    else
                    {
                        // Nếu chưa có thì cập nhật mới
                        if (type.DefaultAgency == null && partnership)
                        {
                            throw new Exception("You must config default agency for " + type.Name);
                        }
                        ExpenseService service = new ExpenseService();
                        service.Expense  = this;
                        service.Cost     = serviceTotal[type];
                        service.Name     = string.Format("{0:dd/MM/yyyy}- {1}", Date, type.Name);
                        service.Paid     = 0;
                        service.Supplier = type.DefaultAgency;
                        if (service.Supplier != null)
                        {
                            service.Phone = type.DefaultAgency.Phone;
                        }
                        service.Type = type;
                        module.SaveOrUpdate(service);
                    }
                }
                #endregion
                return(serviceTotal);
            }
            #endregion

            #region -- Chi phí cho tất cả các tàu --
            Dictionary <CostType, double> total = new Dictionary <CostType, double>();
            #region -- Lấy về chi phí cho từng tàu nếu là chi phí tổng --

            //Chi phí cho từng tàu
            //Dictionary<int, SailExpense> expenseCruise = new Dictionary<int, SailExpense>();
            IList cruises = module.CruiseGetAll();

            #region -- Tạo bảng giá trắng --
            foreach (CostType type in costTypes)
            {
                total.Add(type, 0);
            }
            #endregion

            foreach (Cruise cruise in cruises)
            {
                SailExpense expense = module.ExpenseGetByDate(cruise, Date);

                IList filtered = new ArrayList();
                foreach (Booking booking in bookings)
                {
                    if (booking.Cruise != null && booking.Cruise.Id == cruise.Id)
                    {
                        filtered.Add(booking);
                    }
                }

                Dictionary <CostType, double> expenses = expense.Calculate(costTypes, costTable, dailyTable,
                                                                           getCruiseTable, cruise, filtered, module,
                                                                           partnership);
                foreach (CostType type in costTypes)
                {
                    total[type] += expenses[type];
                }
            }

            #endregion

            return(total);

            #endregion
        }
コード例 #25
0
        public string CheckRoom(string sd, string ti, string SectionId, string NodeId)
        {
            CoreRepository CoreRepository = HttpContext.Current.Items["CoreRepository"] as CoreRepository;
            int            nodeId         = Int32.Parse(NodeId);
            Node           node           = (Node)CoreRepository.GetObjectById(typeof(Node), nodeId);
            int            sectionId      = Int32.Parse(SectionId);
            Section        section        = (Section)CoreRepository.GetObjectById(typeof(Section), sectionId);
            SailsModule    module         = (SailsModule)ContainerAccessorUtil.GetContainer().Resolve <ModuleLoader>().GetModuleFromSection(section);

            DateTime?startDate = null;

            try
            {
                startDate = DateTime.ParseExact(sd, "dd/MM/yyyy", CultureInfo.InvariantCulture);
            }
            catch { }

            var tripId = -1;

            try
            {
                tripId = Convert.ToInt32(ti);
            }
            catch { }

            var trip          = AddSeriesBookingsBLL.TripGetById(tripId);
            var listRoomClass = AddSeriesBookingsBLL.RoomClassGetAll();
            var listRoomType  = AddSeriesBookingsBLL.RoomTypeGetAll();
            var listCruise    = AddSeriesBookingsBLL.CruiseGetAllByTrip(trip);

            var listCheckRoomResultDTO = new List <CheckRoomResultDTO>();

            foreach (var cruise in listCruise)
            {
                var checkRoomResultDTO = new CheckRoomResultDTO();
                checkRoomResultDTO.Cruise = new CheckRoomResultDTO.CruiseDTO()
                {
                    Id   = cruise.Id,
                    Name = cruise.Name
                };

                int    total  = 0;
                string detail = "";
                foreach (var roomClass in listRoomClass)
                {
                    foreach (var roomType in listRoomType)
                    {
                        if (trip == null)
                        {
                            break;
                        }

                        if (!startDate.HasValue)
                        {
                            break;
                        }

                        int avail = module.RoomCount(roomClass, roomType, cruise, startDate.Value, trip.NumberOfDay, trip.HalfDay);

                        if (avail > 0)
                        {
                            total  += avail;
                            detail += string.Format("{0} {2} {1} ", avail, roomType.Name, roomClass.Name);
                        }
                    }
                }
                checkRoomResultDTO.NoOfRoomAvaiable = total;
                checkRoomResultDTO.DetailRooms      = detail;
                listCheckRoomResultDTO.Add(checkRoomResultDTO);
            }
            Dispose();
            return(JsonConvert.SerializeObject(listCheckRoomResultDTO));
        }
コード例 #26
0
        public string GetAvaiableRoom(string ci, string sd, string ti, string SectionId, string NodeId)
        {
            CoreRepository CoreRepository = HttpContext.Current.Items["CoreRepository"] as CoreRepository;
            int            nodeId         = Int32.Parse(NodeId);
            Node           node           = (Node)CoreRepository.GetObjectById(typeof(Node), nodeId);
            int            sectionId      = Int32.Parse(SectionId);
            Section        section        = (Section)CoreRepository.GetObjectById(typeof(Section), sectionId);
            SailsModule    module         = (SailsModule)ContainerAccessorUtil.GetContainer().Resolve <ModuleLoader>().GetModuleFromSection(section);

            DateTime?startDate = null;

            try
            {
                startDate = DateTime.ParseExact(sd, "dd/MM/yyyy", CultureInfo.InvariantCulture);
            }
            catch { }

            var tripId = -1;

            try
            {
                tripId = Convert.ToInt32(ti);
            }
            catch { }
            var trip = AddSeriesBookingsBLL.TripGetById(tripId);

            var cruiseId = -1;

            try
            {
                cruiseId = Convert.ToInt32(ci);
            }
            catch { }
            var cruise = AddSeriesBookingsBLL.CruiseGetById(cruiseId);

            var listRoomClass = AddSeriesBookingsBLL.RoomClassGetAll();
            var listRoomType  = AddSeriesBookingsBLL.RoomTypeGetAll();

            var listAvaiableRoomDTO = new List <AvaiableRoomDTO>();

            foreach (var roomClass in listRoomClass)
            {
                foreach (var roomType in listRoomType)
                {
                    if (trip == null)
                    {
                        break;
                    }

                    if (!startDate.HasValue)
                    {
                        break;
                    }

                    var roomCount = module.RoomCount(roomClass, roomType, cruise, startDate.Value, trip.NumberOfDay, true,
                                                     trip.HalfDay);


                    var avaiableRoomDTO = new AvaiableRoomDTO();
                    if (roomCount > -1)
                    {
                        avaiableRoomDTO.KindOfRoom = roomClass.Name + " " + roomType.Name;
                        avaiableRoomDTO.RoomClass  = new AvaiableRoomDTO.RoomClassDTO()
                        {
                            Id   = roomClass.Id,
                            Name = roomClass.Name
                        };

                        avaiableRoomDTO.RoomType = new AvaiableRoomDTO.RoomTypeDTO()
                        {
                            Id   = roomType.Id,
                            Name = roomType.Name,
                        };

                        var NoOfAdult = roomCount;
                        avaiableRoomDTO.NoOfAdult = NoOfAdult;

                        var NoOfChild = roomCount;
                        avaiableRoomDTO.NoOfChild = NoOfChild;

                        var NoOfBaby = roomCount;
                        avaiableRoomDTO.NoOfBaby = NoOfBaby;

                        listAvaiableRoomDTO.Add(avaiableRoomDTO);
                    }
                }
            }
            Dispose();
            return(JsonConvert.SerializeObject(listAvaiableRoomDTO));
        }
コード例 #27
0
        public static void Export(IList list, int count, IList expenseList, DateTime _date, string bookingFormat, HttpResponse Response, string templatePath, SailsTrip trip, SailsAdminBasePage page)
        {
            SailsModule module = page.Module;
            // Bắt đầu thao tác export

            ExcelFile excelFile = new ExcelFile();

            excelFile.LoadXls(templatePath);

            // Số lệnh điều tua = số lượng group
            int numberOfGroup = -1;

            foreach (Booking booking in list)
            {
                if (booking.Group > numberOfGroup)
                {
                    numberOfGroup = booking.Group;
                }
            }

            foreach (ExpenseService service in expenseList)
            {
                if (service.Group > numberOfGroup)
                {
                    numberOfGroup = service.Group;
                }
            }

            if (numberOfGroup <= 0)
            {
                numberOfGroup = 1; // Tối thiểu là 1 group
            }

            #region -- sheet 0: Lệnh điều tour --
            for (int ii = 0; ii <= numberOfGroup; ii++)
            {
                // Mở sheet 0
                ExcelWorksheet originSheet = excelFile.Worksheets[0];

                int numberOfBooking = 0;
                foreach (Booking booking in list)
                {
                    if (booking.Group == ii)
                    {
                        numberOfBooking++;
                    }
                }

                if (numberOfBooking == 0 && ii == 0)
                {
                    continue;
                }

                ExcelWorksheet sheet = excelFile.Worksheets.AddCopy("LenhDieuTour" + ii, originSheet);

                #region -- Thông tin chung --

                if (expenseList != null)
                {
                    // Các thông tin chèn thêm
                    foreach (ExpenseService service in expenseList)
                    {
                        if (service.Group != ii)
                        {
                            continue;
                        }

                        switch (service.Type.Id)
                        {
                        case SailsModule.GUIDE_COST:
                            if (service.Type.IsCustomType || service.Supplier == null)
                            {
                                if (string.IsNullOrEmpty(service.Name) && service.Supplier != null)
                                {
                                    sheet.Cells["C3"].Value = service.Supplier.Name;
                                }
                                else
                                {
                                    sheet.Cells["C3"].Value = service.Name;
                                }
                                if (string.IsNullOrEmpty(service.Name) && service.Supplier != null)
                                {
                                    sheet.Cells["F3"].Value = service.Supplier.Phone;
                                }
                                else
                                {
                                    sheet.Cells["F3"].Value = service.Phone;
                                }
                            }
                            else
                            {
                                sheet.Cells["C3"].Value = service.Supplier.Name;
                                sheet.Cells["f3"].Value = service.Supplier.Phone;
                            }
                            break;

                        case SailsModule.TRANSPORT:
                            if (service.Type.IsCustomType || service.Supplier == null)
                            {
                                if (string.IsNullOrEmpty(service.Name) && service.Supplier != null)
                                {
                                    sheet.Cells["C4"].Value = service.Supplier.Name;
                                }
                                else
                                {
                                    sheet.Cells["C4"].Value = service.Name;
                                }
                                if (string.IsNullOrEmpty(service.Name) && service.Supplier != null)
                                {
                                    sheet.Cells["F4"].Value = service.Supplier.Phone;
                                }
                                else
                                {
                                    sheet.Cells["F4"].Value = service.Phone;
                                }
                            }
                            else
                            {
                                sheet.Cells["C4"].Value = service.Supplier.Name;
                                sheet.Cells["f4"].Value = service.Supplier.Phone;
                            }
                            break;

                        case SailsModule.HOTEL:
                            if (service.Supplier != null)
                            {
                                sheet.Cells["C7"].Value = service.Supplier.Name;
                            }
                            else
                            {
                                sheet.Cells["C7"].Value = service.Name;
                            }
                            break;
                        }
                    }
                }

                sheet.Cells["D1"].Value = _date;

                // Tính tổng pax
                int adult = 0;
                int child = 0;
                int baby  = 0;

                int pAdult = 0;
                int pChild = 0;
                int pBaby  = 0;

                foreach (Booking booking in list)
                {
                    if (booking.StartDate == _date && booking.Group == ii)
                    {
                        adult += booking.Adult;
                        child += booking.Child;
                        baby  += booking.Baby;
                    }
                    else if (booking.Group == ii)
                    {
                        pAdult += booking.Adult;
                        pChild += booking.Child;
                        pBaby  += booking.Baby;
                    }
                }

                int pax = adult + child + pAdult + pChild;

                sheet.Cells["C5"].Value  = page.UserIdentity.FullName;
                sheet.Cells["C6"].Value  = pax;
                sheet.Cells["C12"].Value = adult;
                sheet.Cells["D12"].Value = child;
                sheet.Cells["E12"].Value = baby;

                sheet.Cells["C18"].Value = pAdult;
                sheet.Cells["D18"].Value = pChild;
                sheet.Cells["E18"].Value = pBaby;

                #endregion

                #region -- Sao chép các dòng --

                // Sao chép dòng đầu theo số lượng booking
                // Dòng đầu tiên là dòng 11
                const int firstrow = 10;

                // Đếm số book trong ngày
                int curr = 0;
                foreach (Booking booking in list)
                {
                    if (booking.StartDate == _date && booking.Group == ii)
                    {
                        curr += 1;
                    }
                }

                sheet.Rows[16].InsertCopy(count - curr - 1, sheet.Rows[firstrow]);
                if (curr > 0)
                {
                    sheet.Rows[firstrow].InsertCopy(curr - 1, sheet.Rows[firstrow]);
                }
                int firstProw = 16 + curr;

                #endregion

                #region -- Thông tin từng booking --

                // Ghi vào file excel theo từng dòng
                int crow  = firstrow;
                int cProw = firstProw - 1;
                foreach (Booking booking in list)
                {
                    if (booking.Group != ii)
                    {
                        continue;
                    }
                    sheet.Cells["D2"].Value = string.Format("{0}{1:ddMMyy}-{2:00}", booking.Trip.TripCode, booking.StartDate, booking.Group);
                    int current;
                    int index;
                    if (booking.StartDate != _date)
                    {
                        // Dòng previous hiện tại
                        current = cProw;
                        // Index = cột previous hiện tại - previous đầu tiên
                        index = cProw - firstProw + 2;
                        cProw++;
                    }
                    else
                    {
                        current = crow;
                        index   = crow - firstrow + 1;
                        crow++;
                    }
                    sheet.Cells[current, 0].Value = index; // Cột index
                    string name = booking.CustomerName.Replace("<br/>", "\n");
                    if (name.Length > 0)
                    {
                        name = name.Remove(name.Length - 1);
                    }
                    sheet.Cells[current, 1].Value = name;                   // Cột name
                    sheet.Cells[current, 2].Value = booking.Adult;          // Cột adult
                    sheet.Cells[current, 3].Value = booking.Child;          // Cột child
                    sheet.Cells[current, 4].Value = booking.Baby;           // Cột baby
                    sheet.Cells[current, 5].Value = booking.Trip.TripCode;  // Cột trip code
                    sheet.Cells[current, 6].Value = booking.PickupAddress;  // Cột pickup address
                    sheet.Cells[current, 7].Value = booking.SpecialRequest; // Cột special request

                    sheet.Cells[current, 9].Style.Borders.SetBorders(MultipleBorders.Outside, System.Drawing.Color.Black, LineStyle.Thin);

                    if (booking.Agency != null)
                    {
                        sheet.Cells[current, 8].Value = booking.Agency.Name; // Cột agency

                        if (!string.IsNullOrEmpty(booking.AgencyCode))
                        {
                            sheet.Cells[current, 9].Value = booking.AgencyCode;
                            // Chỉ hiển thị nếu có agency (cột TA COde)
                        }
                        else
                        {
                            if (booking.CustomBookingId > 0)
                            {
                                sheet.Cells[current, 9].Value = string.Format(bookingFormat, booking.CustomBookingId);
                            }
                            else
                            {
                                sheet.Cells[current, 9].Value = string.Format(bookingFormat, booking.Id);
                            }
                        }
                    }
                    else
                    {
                        sheet.Cells[current, 8].Value = SailsModule.NOAGENCY; // Hiển thị oriental nếu ko có agency

                        if (booking.CustomBookingId > 0)
                        {
                            sheet.Cells[current, 9].Value = string.Format(bookingFormat, booking.CustomBookingId);
                        }
                        else
                        {
                            sheet.Cells[current, 9].Value = string.Format(bookingFormat, booking.Id);
                        }
                    }

                    if (booking.PickupTime != null)
                    {
                        sheet.Cells[current, 10].Value = booking.PickupTime.Value.ToString("HH:mm");
                    }

                    if (booking.SeeoffTime != null)
                    {
                        sheet.Cells[current, 11].Value = booking.SeeoffTime.Value.ToString("HH:mm");
                    }

                    if (trip.Name.ToLower() != "airport transfer")
                    {
                        sheet.Columns[11].Delete();
                    }

                    if (trip.Name.ToLower() != "airport transfer")
                    {
                        sheet.Columns[10].Delete();
                    }
                }


                #endregion

                // Mở sheet 1
                originSheet = excelFile.Worksheets[1];
                ExcelWorksheet budget = excelFile.Worksheets.AddCopy("Budget" + ii, originSheet);

                budget.Cells["C3"].Value = sheet.Cells["C3"].Value;
                budget.Cells["C4"].Value = sheet.Cells["C4"].Value;
                budget.Cells["A1"].Value = sheet.Cells["D1"].Value;
                budget.Cells["C5"].Value = page.UserIdentity.FullName;
                budget.Cells["C6"].Value = sheet.Cells["C6"].Value;

                budget.Cells["A1"].Value = string.Format("{0}{1:ddMMyyyy}", trip.TripCode, _date);

                // Các chi phí xuất ra bao gồm chi phí theo ngày và chi phí theo khách
                ExpenseCalculator calculator = new ExpenseCalculator(module, true);
                SailExpense       expense    = module.ExpenseGetByDate(trip, _date);
                IList             expenses   = module.ExpenseServiceGet(trip, _date, _date, null, null, null, null, false, null, 0, "");


                CostingTable cost      = calculator.GetCurrentTable(_date, trip, TripOption.Option1);
                IList        costTypes = new ArrayList();
                foreach (KeyValuePair <CostType, double> entry in module.CostTypeGetAutoDailyBase())
                {
                    costTypes.Add(entry.Key);
                }
                Dictionary <CostType, Costing> unitPrices = cost.GetCostMap(costTypes);


                const int first = 8;
                curr = first;

                foreach (ExpenseService entry in expenses)
                {
                    if (entry.Group != ii)
                    {
                        continue;
                    }

                    if (entry.Type.IsPayNow)
                    {
                        if (entry.Type.IsDailyInput)// Nếu là chi phí nhập tay
                        {
                            if (entry.Cost == 0)
                            {
                                continue;
                            }
                            budget.Rows[curr].InsertCopy(1, budget.Rows[curr]);
                            budget.Cells[curr, 0].Value = curr - first + 1;
                            budget.Cells[curr, 1].Value = _date;
                            if (entry.Type.Name.ToLower().Contains("others"))
                            {
                                budget.Cells[curr, 2].Value = entry.Name;
                            }
                            else
                            {
                                budget.Cells[curr, 2].Value = entry.Type.Name;
                            }
                            budget.Cells[curr, 3].Value = entry.Cost; // chi phí dành cho cả đoàn
                            budget.Cells[curr, 4].Value = entry.Cost;
                            curr++;
                        }
                        else if (!entry.Type.IsMonthly && !entry.Type.IsYearly)
                        {
                            double value = unitPrices[entry.Type].Adult * adult;

                            if (value > 0)
                            {
                                budget.Rows[curr].InsertCopy(1, budget.Rows[curr]);
                                budget.Cells[curr, 0].Value = curr - first + 1;
                                budget.Cells[curr, 1].Value = _date;
                                budget.Cells[curr, 2].Value = entry.Type.Name + " (adult)";
                                budget.Cells[curr, 3].Value = unitPrices[entry.Type].Adult; // giá adult
                                budget.Cells[curr, 4].Value = value;
                                curr++;
                            }

                            value = unitPrices[entry.Type].Child * child;

                            if (value > 0)
                            {
                                budget.Rows[curr].InsertCopy(1, budget.Rows[curr]);
                                budget.Cells[curr, 0].Value = curr - first + 1;
                                budget.Cells[curr, 1].Value = _date;
                                budget.Cells[curr, 2].Value = entry.Type.Name + " (child)";
                                budget.Cells[curr, 3].Value = unitPrices[entry.Type].Child; // giá adult
                                budget.Cells[curr, 4].Value = value;
                                curr++;
                            }

                            value = unitPrices[entry.Type].Baby * baby;

                            if (value > 0)
                            {
                                budget.Rows[curr].InsertCopy(1, budget.Rows[curr]);
                                budget.Cells[curr, 0].Value = curr - first + 1;
                                budget.Cells[curr, 1].Value = _date;
                                budget.Cells[curr, 2].Value = entry.Type.Name + " (baby)";
                                budget.Cells[curr, 3].Value = unitPrices[entry.Type].Baby; // giá adult
                                budget.Cells[curr, 4].Value = value;
                                curr++;
                            }
                        }
                    }
                }
            }

            #endregion

            #region -- sheet 1:
            //if (excelFile.Worksheets.Count == 1)
            //{
            //    goto end;
            //}
            //ExcelWorksheet budget = excelFile.Worksheets[1];
            #endregion

end:
            #region -- Trả dữ liệu về cho người dùng --

            Response.Clear();
            Response.Buffer      = true;
            Response.ContentType = "application/vnd.ms-excel";
            Response.AppendHeader("content-disposition",
                                  "attachment; filename=" + string.Format("Lenhdieutour{0:dd_MMM}.xls", _date));

            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();

            #endregion
        }
コード例 #28
0
        public virtual double Calculate(SailsModule Module, Agency agency, double childPrice, double agencySup, bool customPrice, bool singleService)
        {
            Role applyRole;

            if (agency != null && agency.Role != null)
            {
                applyRole = agency.Role;
            }
            else
            {
                applyRole = Module.RoleGetById(4);
            }
            double total = 0;

            Role role;

            if (Agency != null && Agency.Role != null)
            {
                role = Agency.Role;
            }
            else
            {
                role = applyRole;
            }
            IList _policies = Module.AgencyPolicyGetByRole(role);

            #region -- Giá dịch vụ --

            IList services      = Module.ExtraOptionGetBooking();
            IList servicePrices = Module.ServicePriceGetByBooking(this);

            foreach (ExtraOption extra in services)
            {
                double child     = Child;
                double unitPrice = -1;
                foreach (BookingServicePrice price in servicePrices)
                {
                    if (price.ExtraOption == extra)
                    {
                        unitPrice = price.UnitPrice;
                    }
                }
                if (unitPrice < 0)
                {
                    unitPrice = Module.ApplyPriceFor(extra.Price, _policies);
                }

                if (extra.IsIncluded)
                {
                    // Nếu dịch vụ đã include thì xem xem có không check không để trừ
                    if (!_extraServices.Contains(extra))
                    {
                        total -= unitPrice * (Adult + child * childPrice / 100);
                    }
                }
                else
                {
                    // Nếu là dịch vụ chưa include thì xem có có không để cộng
                    if (_extraServices.Contains(extra))
                    {
                        total += unitPrice * (Adult + child * childPrice / 100);
                    }
                }
            }

            //TODO: Cần phải check cả dịch vụ dành cho từng khách nữa

            ////foreach (ExtraOption extra in _extraServices)
            ////{
            ////    if (services.Contains(extra))
            ////    {
            ////        total += Module.ApplyPriceFor(extra.Price, _policies)*Adult;
            ////    }
            ////}
            #endregion

            #region -- giá phòng --
            // Tính giá theo từng phòng
            IList cServices = Module.ExtraOptionGetCustomer();
            foreach (BookingRoom broom in _bookosBookingRooms)
            {
                if (customPrice)
                {
                    double tempTotal = 0;
                    foreach (Customer customer in broom.RealCustomers)
                    {
                        tempTotal += customer.Total;
                    }
                    if (tempTotal > 0)
                    {
                        total += tempTotal;
                    }
                    else
                    {
                        total += broom.Total;
                    }
                }
                else
                {
                    total += broom.Calculate(Module, _policies, childPrice, agencySup, Agency);
                }

                if (singleService)
                {
                    // Ngoài giá phòng còn có thể có dịch vụ cá nhân
                    foreach (Customer customer in broom.RealCustomers)
                    {
                        // Baby không tính dịch vụ
                        if (customer.Type == CustomerType.Baby)
                        {
                            continue;
                        }

                        foreach (ExtraOption service in cServices)
                        {
                            CustomerService customerService = Module.CustomerServiceGetByCustomerAndService(customer,
                                                                                                            service);
                            if (customerService != null)
                            {
                                double rate = 1;
                                //if (customer.IsChild)
                                //{
                                //    rate = childPrice / 100;
                                //}

                                double unitPrice = -1;
                                foreach (BookingServicePrice price in servicePrices)
                                {
                                    if (price.ExtraOption == service)
                                    {
                                        unitPrice = price.UnitPrice;
                                    }
                                }
                                if (unitPrice < 0)
                                {
                                    unitPrice = Module.ApplyPriceFor(service.Price, _policies);
                                }

                                if (service.IsIncluded && customerService.IsExcluded)
                                {
                                    // Nếu dịch vụ có included mà lại bị excluded thì trừ
                                    total -= unitPrice * rate;
                                }

                                if (!service.IsIncluded && !customerService.IsExcluded)
                                {
                                    // Nếu dịch vụ không included mà lại có thì cộng
                                    total += unitPrice * rate;
                                }
                            }
                        }
                    }
                }
            }

            #endregion

            return(total);
        }
コード例 #29
0
        /// <summary>
        /// Tính giá cho một loại phòng
        /// </summary>
        /// <returns></returns>
        public static double Calculate(RoomClass rclass, RoomTypex rtype, int adult, int child, bool isSingle, SailsTrip trip, Cruise cruise, TripOption option, DateTime startDate, SailsModule Module, IList policies, double childPrice, double agencySup, Agency agency)
        {
            // Lấy về bảng giá áp dụng cho thời điểm xuất phát
            if (trip == null)
            {
                return(0);
            }
            SailsPriceConfig priceConfig = Module.SailsPriceConfigGet(rclass, rtype, trip, cruise, option, startDate,
                                                                      BookingType.Double, agency);

            if (priceConfig == null)
            {
                throw new PriceException(string.Format("There isn't any price for {0} {1} room in trip {2} on {3}", rclass.Name, rtype.Name, trip.Name, startDate));
            }
            #region -- Giá phòng --
            double price;
            // Biến để lưu giá trị single supplement nếu là booking single
            double singlesup = 0;
            if (isSingle)
            {
                if (agencySup > 0)
                {
                    singlesup = agencySup;
                }
                else
                {
                    singlesup = priceConfig.SpecialPrice; //Module.ApplyPriceFor(priceConfig.SpecialPrice, policies);
                }
            }

            // Tính giá phòng theo người lớn

            // Đơn giá của phòng (đã áp dụng chính sách)
            double unitPrice;
            if (priceConfig.Table.Agency == null)
            {
                //unitPrice = Module.ApplyPriceFor(priceConfig.NetPrice, policies);
            }
            else
            {
                //unitPrice = priceConfig.NetPrice;
            }
            if (rtype.IsShared)
            {
                // Giá phòng twin phòng đơn giá x số lượng người lớn / 2 + đơn giá x tỉ lệ dành cho child x số child / 2
                // (Thực ra adult = 1/2, child =0/1)
                //price = unitPrice * adult / 2 + unitPrice * child * childPrice / 100 / 2;
                // Cộng thêm singlesup (nếu không phải single thì là + 0)
                //price += singlesup;
            }
            else
            {
                // Giá phòng double phòng đơn giá x số lượng người lớn / 2 + đơn giá x tỉ lệ dành cho child x số child / 2
                //price = unitPrice * adult / 2 + unitPrice * child * childPrice / 100 / 2;
                // Cộng thêm singlesup (nếu không phải single thì là + 0)
                //price += singlesup;
            }
            #endregion

            //return price;

            return(0.0);
        }
コード例 #30
0
        public void CheckPermisson(SailsModule module, User user)
        {
            IList permissions     = module.PermissionsGetByUserRole(user);
            IList userPermissions = module.PermissionsGetByUser(user);

            foreach (string str in userPermissions)
            {
                if (!permissions.Contains(str))
                {
                    permissions.Add(str);
                }
            }

            if (user.HasPermission(AccessLevel.Administrator))
            {
                return;
            }

            tabSetting.Visible = false;

            #region -- Booking --
            _panelVisible = false;
            SetVisible(pAddBooking, permissions.Contains(Permission.FORM_ADDBOOKING));
            SetVisible(pBookingList, permissions.Contains(Permission.FORM_BOOKINGLIST));
            SetVisible(pOrders, permissions.Contains(Permission.FORM_ORDERREPORT));
            SetVisible(pBookingDate, permissions.Contains(Permission.FORM_BOOKINGREPORT));
            SetVisible(pRevenueChanged, permissions.Contains(Permission.FORM_TRACKINGREPORT));
            SetVisible(pBookingReport, permissions.Contains(Permission.FORM_BOOKINGREPORTRERIOD));
            SetVisible(pAddSerialBookings, permissions.Contains(Permission.FORM_ADDBOOKING));
            tabBooking.Visible = _panelVisible;
            #endregion

            #region -- Report --
            _panelVisible = false;
            SetVisible(pIncomeReport, permissions.Contains(Permission.FORM_INCOMEREPORT));
            SetVisible(pReceivable, permissions.Contains(Permission.FORM_PAYMENTREPORT));
            SetVisible(pExpenseReport, permissions.Contains(Permission.FORM_EXPENSEREPORT));
            SetVisible(pPayable, permissions.Contains(Permission.FORM_PAYABLELIST));
            SetVisible(pBalance, permissions.Contains(Permission.FORM_BALANCEREPORT));
            SetVisible(pSummary, permissions.Contains(Permission.FORM_RECEIVABLETOTAL));
            tabReports.Visible = _panelVisible;
            #endregion

            #region -- Agency --
            _panelVisible = false;
            SetVisible(pAgencyEdit, permissions.Contains(Permission.FORM_AGENCYEDIT));
            SetVisible(pAgencyList, permissions.Contains(Permission.FORM_AGENCYLIST));
            SetVisible(pAgencyPolicies, permissions.Contains(Permission.FORM_AGENTLIST));
            tabConfiguration.Visible = _panelVisible;
            #endregion

            #region -- Cruise & trip --
            _panelVisible = false;
            SetVisible(pTripEdit, permissions.Contains(Permission.FORM_SAILSTRIPEDIT));
            SetVisible(pTripList, permissions.Contains(Permission.FORM_SAILSTRIPLIST));
            SetVisible(pCruiseEdit, permissions.Contains(Permission.FORM_CRUISESEDIT));
            SetVisible(pCruiseList, permissions.Contains(Permission.FORM_CRUISESLIST));
            tabTrips.Visible = _panelVisible;
            #endregion

            #region -- Room manager --
            _panelVisible = false;
            SetVisible(pRoomClass, permissions.Contains(Permission.FORM_ROOMCLASSEDIT));
            SetVisible(pRoomType, permissions.Contains(Permission.FORM_ROOMTYPEXEDIT));
            SetVisible(pRoomEdit, permissions.Contains(Permission.FORM_ROOMEDIT));
            SetVisible(pRoomList, permissions.Contains(Permission.FORM_ROOMLIST));
            tabRoom.Visible = _panelVisible;
            #endregion

            #region -- Cost --
            _panelVisible = false;
            SetVisible(pExtraService, permissions.Contains(Permission.FORM_EXTRAOPTIONEDIT));
            SetVisible(pCostingConfig, permissions.Contains(Permission.FORM_COSTING));
            //SetVisible(pDailyAutoCost, permissions.Contains(Permission.FORM_));
            SetVisible(pDailyManualCost, permissions.Contains(Permission.FORM_BOOKINGREPORT));
            SetVisible(pHaiPhong, permissions.Contains(Permission.FORM_CRUISECONFIG));
            SetVisible(pExpensePeriod, permissions.Contains(Permission.FORM_EXPENSEPERIOD));
            SetVisible(pCostTypes, permissions.Contains(Permission.FORM_COSTTYPES));
            SetVisible(pUSDRate, permissions.Contains(Permission.FORM_EXCHANGERATE));
            tabCost.Visible = _panelVisible;
            #endregion
        }