Exemple #1
0
        protected void rptPriceTables_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.DataItem is SailsPriceTable)
            {
                SailsPriceTable table       = (SailsPriceTable)e.Item.DataItem;
                Label           labelCruise = e.Item.FindControl("labelCruise") as Label;
                if (labelCruise != null)
                {
                    if (table.Cruise != null)
                    {
                        labelCruise.Text = table.Cruise.Name;
                    }
                }

                Label labelValidFrom = e.Item.FindControl("labelValidFrom") as Label;
                if (labelValidFrom != null)
                {
                    labelValidFrom.Text = table.StartDate.ToString("dd/MM/yyyy");
                }

                Label labelValidTo = e.Item.FindControl("labelValidTo") as Label;
                if (labelValidTo != null)
                {
                    labelValidTo.Text = table.EndDate.ToString("dd/MM/yyyy");
                }

                HyperLink hplEdit = e.Item.FindControl("hplEdit") as HyperLink;
                if (hplEdit != null)
                {
                    hplEdit.NavigateUrl = string.Format("SailsPriceConfig.aspx?NodeId={0}&SectionId={1}&TableId={2}",
                                                        Node.Id, Section.Id, table.Id);
                }
            }
        }
Exemple #2
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            var sailsPriceTable = new SailsPriceTable();

            if (!String.IsNullOrEmpty(Request.QueryString["roleid"]))
            {
                sailsPriceTable.Role = Module.GetObject <Role>(Convert.ToInt32(Request.QueryString["roleid"]));
            }
            else
            {
                sailsPriceTable.Agency = Module.GetObject <Agency>(Convert.ToInt32(Request.QueryString["agentid"]));
            }
            Module.SaveOrUpdate(sailsPriceTable);
            PageRedirect(string.Format("PriceTableConfig.aspx?SectionId={0}&NodeId={1}&tableid={2}", Section.Id, Node.Id, sailsPriceTable.Id));
        }
Exemple #3
0
        public SailsPriceTable GetSailsPriceTableReturnNotNull()
        {
            if (GetAgency() != null && GetStartDate() != null)
            {
                return(GetSailsPriceTableByAgencyAndStartDate());
            }
            var sailsPriceTable = GetSailsPriceTable();

            if (sailsPriceTable == null)
            {
                sailsPriceTable        = new SailsPriceTable();
                sailsPriceTable.Agency = GetAgencyReturnNotNull();
                sailsPriceTable.Role   = GetAgencyReturnNotNull().Role;
            }
            if (GetSailsPriceTableTemplate() != null)
            {
                sailsPriceTable = GetSailsPriceTableTemplate();
            }
            return(sailsPriceTable);
        }
        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);
            }
        }
Exemple #5
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);
            }
        }