Exemple #1
0
 protected void rptRoomTypes_ItemDataBound(object sender, RepeaterItemEventArgs e)
 {
     if (e.Item.DataItem is RoomTypex)
     {
         RoomTypex type        = (RoomTypex)e.Item.DataItem;
         Literal   litRoomName = (Literal)e.Item.FindControl("litRoomName");
         litRoomName.Text = _currentClass.Name + " " + type.Name;
         //TODO: CRUISE INFO
         SailsPriceConfig config = Module.SailsPriceConfigGet(_currentClass, type, _trip, null, TripOption.Option1,
                                                              DateTime.Today, BookingType.Double, null);
         Literal litPrice = (Literal)e.Item.FindControl("litPrice");
         //litPrice.Text = Module.ApplyPriceFor(config.NetPrice,CurrentPolicies).ToString("$#,0");
     }
 }
Exemple #2
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);
                                }
                            }
                        }
                    }
                }
            }
        }