protected void RptRoomTypeItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            RoomTypex rtype     = e.Item.DataItem as RoomTypex;
            RoomClass father    = (RoomClass)(((RepeaterItem)e.Item.Parent.Parent).DataItem);
            TextBox   txtSingle = (e.Item.Parent.Parent).FindControl("txtSingle") as TextBox;

            if (rtype != null)
            {
                #region RoomType Id

                using (Label labelRoomTypeId = e.Item.FindControl("labelRoomTypeId") as Label)
                {
                    if (labelRoomTypeId != null)
                    {
                        labelRoomTypeId.Text = rtype.Id.ToString();
                    }
                }

                #endregion

                TextBox textBoxPrice            = (TextBox)e.Item.FindControl("textBoxPrice");
                Label   labelSailsPriceConfigId = (Label)e.Item.FindControl("labelSailsPriceConfigId");

                //Kiểm tra xem có tồn tại room nào mà class và type là rtype và father ko?
                IList room = Module.RoomGetBy_ClassType(ActiveCruise, father, rtype);
                //Nếu có thì hiện giá
                if (room.Count > 0)
                {
                    Domain.SailsPriceConfig priceConfig = Module.SailsPriceConfigGet(Table, rtype, father);
                    //Module.SailsPriceConfigGetBy_RoomType_RoomClass_Trip(_trip,rtype,father,Option);
                    //Nếu có giá thì hiện
                    if (priceConfig != null)
                    {
                        labelSailsPriceConfigId.Text = priceConfig.Id.ToString();
                        textBoxPrice.Text            = priceConfig.NetPrice.ToString("####");
                        if (txtSingle != null)
                        {
                            txtSingle.Text = priceConfig.SpecialPrice.ToString("#,0.#");
                        }
                    }
                }
                //Nếu không tồn tại room thì để N/A
                else
                {
                    textBoxPrice.Enabled = false;
                    textBoxPrice.Text    = "N/A";
                }
            }
        }
        protected void buttonSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                bool isvalid = false;

                #region -- Lấy thông tin bảng giá, độc lập với lưu giá --
                SailsPriceTable table;
                if (_tableId <= 0)
                {
                    table = new SailsPriceTable();
                }
                else
                {
                    table = Table;
                }
                table.StartDate = DateTime.ParseExact(textBoxStartDate.Text, "dd/MM/yyyy",
                                                      CultureInfo.InvariantCulture);
                table.EndDate = DateTime.ParseExact(textBoxEndDate.Text, "dd/MM/yyyy",
                                                    CultureInfo.InvariantCulture);
                table.Trip       = _trip;
                table.TripOption = Option;
                table.Note       = string.Empty;
                table.Agency     = ActiveAgency;
                if (ActiveCruise != null)
                {
                    table.Cruise = ActiveCruise;
                }
                else
                {
                    if (ddlCruises.SelectedIndex > 0)
                    {
                        table.Cruise = Module.CruiseGetById(Convert.ToInt32(ddlCruises.SelectedValue));
                    }
                    else
                    {
                        table.Cruise = null;
                    }
                }

                #endregion

                foreach (RepeaterItem rptClassItem in rptRoomClass.Items)
                {
                    Repeater rptRoomTypeCell  = rptClassItem.FindControl("rptRoomTypeCell") as Repeater;
                    Label    labelRoomClassId = rptClassItem.FindControl("labelRoomClassId") as Label;
                    if (labelRoomClassId != null && labelRoomClassId.Text != string.Empty && rptRoomTypeCell != null)
                    {
                        RoomClass roomClass = Module.RoomClassGetById(Convert.ToInt32(labelRoomClassId.Text));

                        #region -- Kiểm tra tính hợp lệ của bảng giá --

                        foreach (RepeaterItem priceItem in rptRoomTypeCell.Items)
                        {
                            TextBox txtCellPrice = priceItem.FindControl("textBoxPrice") as TextBox;
                            //Kiểm tra xem textboxPrice có enable ko ( không nghĩa là o tồn tại giá kiểu class và type đó)
                            if (txtCellPrice != null && txtCellPrice.Enabled)
                            {
                                double price;
                                //kiểm tra xem price có hợp lệ ko
                                isvalid = double.TryParse(txtCellPrice.Text, out price);
                                if (!isvalid)
                                {
                                    break;
                                }
                            }
                        }

                        #endregion

                        //Nếu bảng giá hợp lệ thì lưu
                        if (isvalid)
                        {
                            Module.SaveOrUpdate(table);

                            TextBox txtSingle = rptClassItem.FindControl("txtSingle") as TextBox;
                            double  single    = 0;
                            if (txtSingle != null && !string.IsNullOrEmpty(txtSingle.Text))
                            {
                                single = Convert.ToDouble(txtSingle.Text);
                            }

                            foreach (RepeaterItem priceItem in rptRoomTypeCell.Items)
                            {
                                Label labelRoomTypeId         = priceItem.FindControl("labelRoomTypeId") as Label;
                                Label labelSailsPriceConfigId =
                                    priceItem.FindControl("labelSailsPriceConfigId") as Label;
                                TextBox   textBoxPrice = priceItem.FindControl("textBoxPrice") as TextBox;
                                RoomTypex roomType     = null;

                                #region Lấy về RoomType tương ứng để chuẩn bị lưu

                                if (labelRoomTypeId != null && labelRoomTypeId.Text != string.Empty)
                                {
                                    if (Convert.ToInt32(labelRoomTypeId.Text) > 0)
                                    {
                                        roomType = Module.RoomTypexGetById(Convert.ToInt32(labelRoomTypeId.Text));
                                    }
                                }

                                #endregion

                                if (textBoxPrice != null && textBoxPrice.Enabled &&
                                    textBoxPrice.Text != string.Empty)
                                {
                                    double price;
                                    //Check giá người dùng nhập vào
                                    if (!double.TryParse(textBoxPrice.Text, out price))
                                    {
                                        isvalid = false;
                                        break;
                                    }
                                    Domain.SailsPriceConfig rPrice;
                                    if (labelSailsPriceConfigId != null &&
                                        !string.IsNullOrEmpty(labelSailsPriceConfigId.Text) &&
                                        Convert.ToInt32(labelSailsPriceConfigId.Text) > 0)
                                    {
                                        //update
                                        rPrice =
                                            Module.SailsPriceConfigGetById(Convert.ToInt32(labelSailsPriceConfigId.Text));
                                    }
                                    else
                                    {
                                        //insert
                                        rPrice            = new Domain.SailsPriceConfig();
                                        rPrice.RoomType   = roomType;
                                        rPrice.RoomClass  = roomClass;
                                        rPrice.TripOption = Option;
                                        rPrice.Trip       = _trip;
                                    }

                                    // Giá single supplement
                                    rPrice.SpecialPrice = single;
                                    rPrice.NetPrice     = price;
                                    rPrice.Table        = table;
                                    Module.SaveOrUpdate(rPrice);
                                }
                            }
                        }
                    }
                }

                PageRedirect(Request.RawUrl);
            }
            catch (Exception ex)
            {
                _logger.Error("Error when buttonSubmit_Click in SailsPriceConfig", ex);
                ShowError(ex.Message);
            }
        }
Пример #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Title = Resources.titleSailsPriceConfig;
            if (TripId <= 0)
            {
                panelContent.Visible = false;
                ShowError(Resources.stringAccessDenied);
                return;
            }
            _trip = Module.TripGetById(TripId);

            int option = 0;

            if (Request.QueryString["option"] != null)
            {
                option = Convert.ToInt32(Request.QueryString["option"]);
            }
            if (option == 0)
            {
                option = 1;
            }
            if (ActiveAgency != null)
            {
                titleSailsPriceConfig.Text = string.Format("Price config for {0}, option {1} on {2} of {3}", _trip.Name, option, ActiveCruise.Name, ActiveAgency.Name);
            }
            else
            {
                titleSailsPriceConfig.Text = string.Format("Price config for {0}, option {1} on {2}", _trip.Name, option, ActiveCruise.Name);
            }

            if (!IsPostBack)
            {
                //if (ActiveCruise != null)
                //{
                //    ddlCruises.Visible = false;
                //}
                //else
                //{
                //    ddlCruises.DataSource = Module.CruiseGetAll();
                //    ddlCruises.DataTextField = "Name";
                //    ddlCruises.DataValueField = "Id";
                //    ddlCruises.DataBind ();
                //    ddlCruises.Items.Insert(0, "-- Choose cruise --");
                //}

                //rptPriceTables.DataSource = Module.PriceTableGetAll(_trip, Option, ActiveCruise, ActiveAgency);
                //rptPriceTables.DataBind();
            }
            int count;

            rptValidFrom.DataSource       = Module.SailsPriceConfigGetAllBySailsTripAndOption(_trip, Option, pgValidFrom.PageSize, pgValidFrom.CurrentPageIndex, out count);
            pgValidFrom.AllowCustomPaging = true;
            pgValidFrom.VirtualItemCount  = count;
            rptValidFrom.DataBind();

            rptCommission.DataSource = Module.AgencyLevelGetAll();
            rptCommission.DataBind();

            Domain.SailsPriceConfig priceConfig = Module.SailsPriceConfigGet(_trip, ValidFrom.Date);
            txtPriceAdultUSD.Text = priceConfig.PriceAdultUSD.ToString("#,0.#");
            txtPriceAdultVND.Text = priceConfig.PriceAdultVND.ToString("#,0.#");
            txtPriceChildUSD.Text = priceConfig.PriceChildUSD.ToString("#,0.#");
            txtPriceChildVND.Text = priceConfig.PriceChildVND.ToString("#,0.#");
            txtPriceBabyUSD.Text  = priceConfig.PriceBabyUSD.ToString("#,0.#");
            txtPriceBabyVND.Text  = priceConfig.PriceBabyVND.ToString("#,0.#");

            textBoxStartDate.Text = ValidFrom.ToString("dd/MM/yyyy");
        }
Пример #4
0
        //protected void rptRoomClass_ItemDataBound(object sender, RepeaterItemEventArgs e)
        //{
        //    {
        //        RoomClass roomClass = (RoomClass)e.Item.DataItem;

        //        #region -- Header --

        //        // Đối với header, thêm danh sách roomType thông thường
        //        using (Repeater rpt = e.Item.FindControl("rptRoomTypeHeader") as Repeater)
        //        {
        //            if (rpt != null)
        //            {
        //                rpt.DataSource = Module.RoomTypexGetAll();
        //                rpt.DataBind();
        //            }
        //        }

        //        #endregion

        //        #region -- Item --

        //        #region RoomClass Id

        //        using (Label labelRoomClassId = e.Item.FindControl("labelRoomClassId") as Label)
        //        {
        //            if (labelRoomClassId != null)
        //            {
        //                labelRoomClassId.Text = roomClass.Id.ToString();
        //            }
        //        }

        //        #endregion

        //        //Đối với từng dòng
        //        using (Repeater rpt = e.Item.FindControl("rptRoomTypeCell") as Repeater)
        //        {
        //            if (rpt != null)
        //            {
        //                // Gán sự kiện ItemDataBound (vì control trong Repeater không tự nhận hàm này)
        //                rpt.ItemDataBound += RptRoomTypeItemDataBound;

        //                IList roomTypeList = Module.RoomTypexGetAll();

        //                rpt.DataSource = roomTypeList;
        //                rpt.DataBind();
        //            }
        //        }

        //        #endregion
        //    }
        //}

        //protected void RptRoomTypeItemDataBound(object sender, RepeaterItemEventArgs e)
        //{
        //    RoomTypex rtype = e.Item.DataItem as RoomTypex;
        //    RoomClass father = (RoomClass)(((RepeaterItem)e.Item.Parent.Parent).DataItem);
        //    TextBox txtSingle = (e.Item.Parent.Parent).FindControl("txtSingle") as TextBox;
        //    if (rtype != null)
        //    {
        //        #region RoomType Id

        //        using (Label labelRoomTypeId = e.Item.FindControl("labelRoomTypeId") as Label)
        //        {
        //            if (labelRoomTypeId != null)
        //            {
        //                labelRoomTypeId.Text = rtype.Id.ToString();
        //            }
        //        }

        //        #endregion

        //        TextBox textBoxPrice = (TextBox)e.Item.FindControl("textBoxPrice");
        //        TextBox txtPriceVND = (TextBox)e.Item.FindControl("txtPriceVND");
        //        Label labelSailsPriceConfigId = (Label)e.Item.FindControl("labelSailsPriceConfigId");

        //        //Kiểm tra xem có tồn tại room nào mà class và type là rtype và father ko?
        //        IList room = Module.RoomGetBy_ClassType(ActiveCruise, father, rtype);
        //        //Nếu có thì hiện giá
        //        if (room.Count > 0)
        //        {
        //            Domain.SailsPriceConfig priceConfig = Module.SailsPriceConfigGet(Table, rtype, father);
        //            //Module.SailsPriceConfigGetBy_RoomType_RoomClass_Trip(_trip,rtype,father,Option);
        //            //Nếu có giá thì hiện
        //            if (priceConfig != null)
        //            {
        //                labelSailsPriceConfigId.Text = priceConfig.Id.ToString();


        //                if (txtSingle != null)
        //                {
        //                    txtSingle.Text = priceConfig.SpecialPrice.ToString("#,0.#");
        //                }
        //            }
        //        }
        //        //Nếu không tồn tại room thì để N/A
        //        else
        //        {
        //            textBoxPrice.Enabled = false;
        //            textBoxPrice.Text = "N/A";
        //            txtPriceVND.Enabled = false;
        //            txtPriceVND.Text = "N/A";
        //        }
        //    }
        //}

        protected void buttonSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                bool isvalid = false;

                #region -- Lấy thông tin bảng giá, độc lập với lưu giá --
                SailsPriceTable table;
                if (_tableId <= 0)
                {
                    table = new SailsPriceTable();
                }
                else
                {
                    table = Table;
                }
                //table.StartDate = DateTime.ParseExact(textBoxStartDate.Text, "dd/MM/yyyy",
                //                                      CultureInfo.InvariantCulture);
                //table.EndDate = DateTime.ParseExact(textBoxEndDate.Text, "dd/MM/yyyy",
                //                                      CultureInfo.InvariantCulture);
                table.Trip       = _trip;
                table.TripOption = Option;
                table.Note       = string.Empty;
                table.Agency     = ActiveAgency;
                if (ActiveCruise != null)
                {
                    table.Cruise = ActiveCruise;
                }
                else
                {
                    //if (ddlCruises.SelectedIndex > 0)
                    //{
                    //    table.Cruise = Module.CruiseGetById(Convert.ToInt32(ddlCruises.SelectedValue));
                    //}
                    //else
                    //{
                    //    table.Cruise = null;
                    //}
                }

                #endregion

                //foreach (RepeaterItem rptClassItem in rptRoomClass.Items)
                //{
                //    Repeater rptRoomTypeCell = rptClassItem.FindControl("rptRoomTypeCell") as Repeater;
                //    Label labelRoomClassId = rptClassItem.FindControl("labelRoomClassId") as Label;
                //    if (labelRoomClassId != null && labelRoomClassId.Text != string.Empty && rptRoomTypeCell != null)
                //    {
                //        RoomClass roomClass = Module.RoomClassGetById(Convert.ToInt32(labelRoomClassId.Text));

                //        #region -- Kiểm tra tính hợp lệ của bảng giá --

                //        foreach (RepeaterItem priceItem in rptRoomTypeCell.Items)
                //        {
                //            TextBox txtCellPrice = priceItem.FindControl("textBoxPrice") as TextBox;
                //            //Kiểm tra xem textboxPrice có enable ko ( không nghĩa là o tồn tại giá kiểu class và type đó)
                //            if (txtCellPrice != null && txtCellPrice.Enabled)
                //            {
                //                double price;
                //                //kiểm tra xem price có hợp lệ ko
                //                isvalid = double.TryParse(txtCellPrice.Text, out price);
                //                if (!isvalid) break;
                //            }
                //        }

                //        #endregion

                //        //Nếu bảng giá hợp lệ thì lưu
                //        if (isvalid)
                //        {
                //            Module.SaveOrUpdate(table);

                //            TextBox txtSingle = rptClassItem.FindControl("txtSingle") as TextBox;
                //            double single = 0;
                //            if (txtSingle != null && !string.IsNullOrEmpty(txtSingle.Text))
                //            {
                //                single = Convert.ToDouble(txtSingle.Text);
                //            }

                //            foreach (RepeaterItem priceItem in rptRoomTypeCell.Items)
                //            {
                //                Label labelRoomTypeId = priceItem.FindControl("labelRoomTypeId") as Label;
                //                Label labelSailsPriceConfigId =
                //                    priceItem.FindControl("labelSailsPriceConfigId") as Label;
                //                TextBox textBoxPrice = priceItem.FindControl("textBoxPrice") as TextBox;
                //                TextBox txtPriceVND = priceItem.FindControl("txtPriceVND") as TextBox;
                //                RoomTypex roomType = null;

                //                #region Lấy về RoomType tương ứng để chuẩn bị lưu

                //                if (labelRoomTypeId != null && labelRoomTypeId.Text != string.Empty)
                //                {
                //                    if (Convert.ToInt32(labelRoomTypeId.Text) > 0)
                //                    {
                //                        roomType = Module.RoomTypexGetById(Convert.ToInt32(labelRoomTypeId.Text));
                //                    }
                //                }

                //                #endregion

                //                if ((textBoxPrice != null && textBoxPrice.Enabled) && (txtPriceVND != null && txtPriceVND.Enabled))
                //                {
                //                    double price;
                //                    double priceVND;

                //                    double.TryParse(textBoxPrice.Text, out price);
                //                    double.TryParse(txtPriceVND.Text, out priceVND);

                //                    Domain.SailsPriceConfig rPrice;
                //                    if (labelSailsPriceConfigId != null &&
                //                        !string.IsNullOrEmpty(labelSailsPriceConfigId.Text) &&
                //                        Convert.ToInt32(labelSailsPriceConfigId.Text) > 0)
                //                    {
                //                        //update
                //                        rPrice =
                //                            Module.SailsPriceConfigGetById(Convert.ToInt32(labelSailsPriceConfigId.Text));
                //                    }
                //                    else
                //                    {
                //                        //insert
                //                        rPrice = new Domain.SailsPriceConfig();
                //                        rPrice.RoomType = roomType;
                //                        rPrice.RoomClass = roomClass;
                //                        rPrice.TripOption = Option;
                //                        rPrice.Trip = _trip;
                //                    }

                //                    // Giá single supplement
                //                    rPrice.SpecialPrice = single;
                //                    rPrice.NetPrice = price;
                //                    rPrice.NetPriceVND = priceVND;
                //                    rPrice.Table = table;
                //                    Module.SaveOrUpdate(rPrice);
                //                }
                //            }
                //        }
                //    }
                //}
                Domain.SailsPriceConfig sailsPriceConfig = Module.SailsPriceConfigGetBySailsTripAndOption(_trip, Option, ValidFrom.Date);
                sailsPriceConfig.PriceAdultUSD = String.IsNullOrEmpty(hidPriceAdultUSD.Value) ? 0.0 : Convert.ToDouble(hidPriceAdultUSD.Value);
                sailsPriceConfig.PriceAdultVND = String.IsNullOrEmpty(hidPriceAdultVND.Value) ? 0.0 : Convert.ToDouble(hidPriceAdultVND.Value);
                sailsPriceConfig.PriceChildUSD = String.IsNullOrEmpty(hidPriceChildUSD.Value) ? 0.0 : Convert.ToDouble(hidPriceChildUSD.Value);
                sailsPriceConfig.PriceChildVND = String.IsNullOrEmpty(hidPriceChildVND.Value) ? 0.0 : Convert.ToDouble(hidPriceChildVND.Value);
                sailsPriceConfig.PriceBabyUSD  = String.IsNullOrEmpty(hidPriceBabyUSD.Value) ? 0.0 : Convert.ToDouble(hidPriceBabyUSD.Value);
                sailsPriceConfig.PriceBabyVND  = String.IsNullOrEmpty(hidPriceBabyVND.Value) ? 0.0 : Convert.ToDouble(hidPriceBabyVND.Value);
                sailsPriceConfig.Trip          = _trip;
                sailsPriceConfig.TripOption    = Option;
                sailsPriceConfig.ValidFrom     = ValidFrom;
                Module.SaveOrUpdate(sailsPriceConfig);

                foreach (RepeaterItem item in rptCommission.Items)
                {
                    AgencyCommission agencyCommission;
                    var agencyCommissionIdLabel = item.FindControl("AgencyCommissionId") as Label;

                    if (agencyCommissionIdLabel.Text != "0")
                    {
                        agencyCommission = Module.AgencyCommissionGetById(Convert.ToInt32(agencyCommissionIdLabel.Text));
                    }
                    else
                    {
                        agencyCommission = new AgencyCommission();
                    }

                    var hidAdultCommissionUSD = item.FindControl("hidAdultCommissionUSD") as HiddenField;
                    agencyCommission.CommissionAdultUSD = String.IsNullOrEmpty(Request.Params[hidAdultCommissionUSD.UniqueID]) ? 0.0 : Convert.ToDouble(Request.Params[hidAdultCommissionUSD.UniqueID]);

                    var hidAdultCommissionVND = item.FindControl("hidAdultCommissionVND") as HiddenField;
                    agencyCommission.CommissionAdultVND = String.IsNullOrEmpty(Request.Params[hidAdultCommissionVND.UniqueID]) ? 0.0 : Convert.ToDouble(Request.Params[hidAdultCommissionVND.UniqueID]);

                    var hidChildCommissionUSD = item.FindControl("hidChildCommissionUSD") as HiddenField;
                    agencyCommission.CommissionChildUSD = String.IsNullOrEmpty(Request.Params[hidChildCommissionUSD.UniqueID]) ? 0.0 : Convert.ToDouble(Request.Params[hidChildCommissionUSD.UniqueID]);

                    var hidChildCommissionVND = item.FindControl("hidChildCommissionVND") as HiddenField;
                    agencyCommission.CommissionChildVND = String.IsNullOrEmpty(Request.Params[hidChildCommissionVND.UniqueID]) ? 0.0 : Convert.ToDouble(Request.Params[hidChildCommissionVND.UniqueID]);

                    var hidBabyCommissionUSD = item.FindControl("hidBabyCommissionUSD") as HiddenField;
                    agencyCommission.CommissionBabyUSD = String.IsNullOrEmpty(Request.Params[hidBabyCommissionUSD.UniqueID]) ? 0.0 : Convert.ToDouble(Request.Params[hidBabyCommissionUSD.UniqueID]);

                    var hidBabyCommissionVND = item.FindControl("hidBabyCommissionVND") as HiddenField;
                    agencyCommission.CommissionBabyVND = String.IsNullOrEmpty(Request.Params[hidBabyCommissionVND.UniqueID]) ? 0.0 : Convert.ToDouble(Request.Params[hidBabyCommissionVND.UniqueID]);

                    agencyCommission.ValidFrom = ValidFrom;

                    agencyCommission.SailsTrip = _trip;

                    var         agencyLevelIdLabel = item.FindControl("AgencyLevelId") as Label;
                    AgencyLevel agencyLevel        = Module.AgencyLevelGetById(Convert.ToInt32(agencyLevelIdLabel.Text));
                    agencyCommission.AgencyLevel = agencyLevel;

                    Module.SaveOrUpdate(agencyCommission);
                }
                Response.Redirect(Request.RawUrl);
            }
            catch (Exception ex)
            {
                _logger.Error("Error when buttonSubmit_Click in SailsPriceConfig", ex);
                ShowError(ex.Message);
            }
        }
Пример #5
0
        public void Save()
        {
            foreach (RepeaterItem rptClassItem in rptRoomClass.Items)
            {
                Repeater rptRoomTypeCell  = rptClassItem.FindControl("rptRoomTypeCell") as Repeater;
                Label    labelRoomClassId = rptClassItem.FindControl("labelRoomClassId") as Label;
                if (labelRoomClassId != null && labelRoomClassId.Text != string.Empty && rptRoomTypeCell != null)
                {
                    RoomClass roomClass = Module.RoomClassGetById(Convert.ToInt32(labelRoomClassId.Text));

                    #region -- Kiểm tra tính hợp lệ của bảng giá --

                    foreach (RepeaterItem priceItem in rptRoomTypeCell.Items)
                    {
                        TextBox txtCellPrice = priceItem.FindControl("textBoxPrice") as TextBox;
                        //Kiểm tra xem textboxPrice có enable ko ( không nghĩa là o tồn tại giá kiểu class và type đó)
                        if (txtCellPrice != null && txtCellPrice.Enabled)
                        {
                            double price;
                            //kiểm tra xem price có hợp lệ ko
                            _isValid = double.TryParse(txtCellPrice.Text, out price);
                            if (!_isValid)
                            {
                                break;
                            }
                        }
                    }

                    #endregion

                    //Nếu bảng giá hợp lệ thì lưu
                    if (_isValid)
                    {
                        //Module.SaveOrUpdate(Table);

                        TextBox txtSingle    = rptClassItem.FindControl("txtSingle") as TextBox;
                        TextBox txtSingleVND = rptClassItem.FindControl("txtSingleVND") as TextBox;
                        double  single       = 0;
                        double  singleVND    = 0;
                        if (txtSingle != null && !string.IsNullOrEmpty(txtSingle.Text))
                        {
                            single = Convert.ToDouble(txtSingle.Text);
                        }

                        if (txtSingleVND != null && !string.IsNullOrEmpty(txtSingleVND.Text))
                        {
                            singleVND = Convert.ToDouble(txtSingleVND.Text);
                        }

                        foreach (RepeaterItem priceItem in rptRoomTypeCell.Items)
                        {
                            Label labelRoomTypeId         = priceItem.FindControl("labelRoomTypeId") as Label;
                            Label labelSailsPriceConfigId =
                                priceItem.FindControl("labelSailsPriceConfigId") as Label;
                            TextBox   textBoxPrice    = priceItem.FindControl("textBoxPrice") as TextBox;
                            TextBox   textBoxPriceVND = priceItem.FindControl("textBoxPriceVND") as TextBox;
                            RoomTypex roomType        = null;

                            #region Lấy về RoomType tương ứng để chuẩn bị lưu

                            if (labelRoomTypeId != null && labelRoomTypeId.Text != string.Empty)
                            {
                                if (Convert.ToInt32(labelRoomTypeId.Text) > 0)
                                {
                                    roomType = Module.RoomTypexGetById(Convert.ToInt32(labelRoomTypeId.Text));
                                }
                            }

                            #endregion

                            if (textBoxPrice != null && textBoxPrice.Enabled &&
                                textBoxPrice.Text != string.Empty && textBoxPriceVND != null && textBoxPriceVND.Enabled &&
                                textBoxPriceVND.Text != string.Empty)
                            {
                                double price;
                                double priceVND;
                                //Check giá người dùng nhập vào
                                if (!double.TryParse(textBoxPrice.Text, out price))
                                {
                                    _isValid = false;
                                    break;
                                }

                                if (!double.TryParse(textBoxPriceVND.Text, out priceVND))
                                {
                                    _isValid = false;
                                    break;
                                }
                                Domain.SailsPriceConfig rPrice;
                                if (SailsPriceTableTemplate != null)
                                {
                                    rPrice                 = new SailsPriceConfig();
                                    rPrice.RoomType        = roomType;
                                    rPrice.RoomClass       = roomClass;
                                    rPrice.TripOption      = Option;
                                    rPrice.Trip            = Trip;
                                    rPrice.SpecialPrice    = single;
                                    rPrice.SpecialPriceVND = singleVND;
                                    rPrice.NetPrice        = price;
                                    rPrice.NetPriceVND     = priceVND;
                                    rPrice.Table           = SailsPriceTable;
                                    rPrice.Trip            = Trip;
                                    rPrice.TripOption      = Option;
                                    rPrice.Cruise          = ActiveCruise;
                                    Module.SaveOrUpdate(rPrice);
                                }
                                else
                                {
                                    if (labelSailsPriceConfigId != null &&
                                        !string.IsNullOrEmpty(labelSailsPriceConfigId.Text) &&
                                        Convert.ToInt32(labelSailsPriceConfigId.Text) > 0)
                                    {
                                        //update
                                        rPrice =
                                            Module.SailsPriceConfigGetById(Convert.ToInt32(labelSailsPriceConfigId.Text));
                                    }
                                    else
                                    {
                                        //insert
                                        rPrice            = new Domain.SailsPriceConfig();
                                        rPrice.RoomType   = roomType;
                                        rPrice.RoomClass  = roomClass;
                                        rPrice.TripOption = Option;
                                        rPrice.Trip       = Trip;
                                    }
                                    rPrice.SpecialPrice    = single;
                                    rPrice.SpecialPriceVND = singleVND;
                                    rPrice.NetPrice        = price;
                                    rPrice.NetPriceVND     = priceVND;
                                    rPrice.Table           = SailsPriceTable;
                                    rPrice.Trip            = Trip;
                                    rPrice.TripOption      = Option;
                                    rPrice.Cruise          = ActiveCruise;
                                    Module.SaveOrUpdate(rPrice);
                                }
                            }
                        }
                    }
                }
            }
        }