Ejemplo n.º 1
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            //舱位类型
            var      bunkType        = (BunkType)int.Parse(this.radiolist.SelectedValue);
            string   AirlineCode     = this.ddlAirline.SelectedValue;                //航空公司代码
            DateTime FlightBeginDate = Convert.ToDateTime(this.txtHBStartDate.Text); //航班开始日期
            string   FlightEndDate   = string.Empty;

            if (!string.IsNullOrEmpty(this.txtHBStopDate.Text))
            {
                FlightEndDate = this.txtHBStopDate.Text;                              //航班截止时间
            }
            DateTime ETDZDate = Convert.ToDateTime(this.txtCpStartDate.Text);         //出票时间
            string   Code     = this.txtCwCode.Text.Trim();                           //代码
            bool     Valid    = this.radseatlist.SelectedValue == "T" ? true : false; //状态
            //折扣
            decimal Discount = 0;

            if (bunkType == BunkType.Economic || bunkType == BunkType.FirstOrBusiness)
            {
                Discount = Convert.ToDecimal(this.txtDiscount.Text.Trim()) / 100;
            }
            //描述
            string Description = string.Empty;

            if (bunkType == BunkType.FirstOrBusiness)
            {
                Description = this.ddltdType.SelectedItem.Text;
            }
            if (bunkType == BunkType.Promotion)
            {
                Description = this.ddlTJType.SelectedItem.Text;
            }
            if (bunkType == BunkType.Free)
            {
                Description = dropMpType.SelectedItem.Text;
            }
            //子舱位
            string strSeatName = seatName.Value;
            //创建舱位
            BunkView bunkView = null;

            try
            {
                //验证
                ExistsValidate();
                switch (bunkType)
                {
                case BunkType.Economic:    //经济舱位
                    var econmicBunkVie = new EconomicBunkView()
                    {
                        Discount = Discount
                    };
                    if (this.ddlDepartCity.SelectedValue != "0")
                    {
                        econmicBunkVie.Departure = this.ddlDepartCity.SelectedValue;
                    }
                    if (this.ddlArriveCity.SelectedValue != "0")
                    {
                        econmicBunkVie.Arrival = this.ddlArriveCity.SelectedValue;
                    }
                    if (!string.IsNullOrEmpty(strSeatName))
                    {
                        string[] strseatlist = strSeatName.Split('|');
                        for (int i = 0; i < strseatlist.Length; i++)
                        {
                            ExtendedWithDiscountBunkView ewbv = new ExtendedWithDiscountBunkView();
                            ewbv.Code     = strseatlist[i].Split(',')[0];
                            ewbv.Discount = decimal.Parse(strseatlist[i].Split(',')[1]) / 100;
                            econmicBunkVie.AddExtended(ewbv);
                        }
                    }
                    bunkView = econmicBunkVie;
                    break;

                case BunkType.FirstOrBusiness:    //头等公务舱
                    var firstBusinessBunkView = new FirstBusinessBunkView()
                    {
                        Description = Description,
                        Discount    = Discount
                    };
                    if (this.ddlDepartCity.SelectedValue != "0")
                    {
                        firstBusinessBunkView.Departure = this.ddlDepartCity.SelectedValue;
                    }
                    if (this.ddlArriveCity.SelectedValue != "0")
                    {
                        firstBusinessBunkView.Arrival = this.ddlArriveCity.SelectedValue;
                    }
                    if (!string.IsNullOrEmpty(strSeatName))
                    {
                        string[] strseatlist = strSeatName.Split('|');

                        for (int i = 0; i < strseatlist.Length; i++)
                        {
                            ExtendedWithDiscountBunkView ewbv = new ExtendedWithDiscountBunkView();
                            ewbv.Code     = strseatlist[i].Split(',')[0];
                            ewbv.Discount = decimal.Parse(strseatlist[i].Split(',')[1]) / 100;
                            firstBusinessBunkView.AddExtended(ewbv);
                        }
                    }
                    bunkView = firstBusinessBunkView;
                    break;

                case BunkType.Promotion:    //特价舱位
                    var promotionBunkView = new PromotionBunkView()
                    {
                        Description = Description
                    };
                    string strSeatTJ = this.seatTJ.Value;
                    if (!string.IsNullOrEmpty(strSeatTJ))
                    {
                        string[] strseatlist = strSeatName.Split('|');
                        for (int i = 0; i < strseatlist.Length; i++)
                        {
                            promotionBunkView.AddExtended(strseatlist[i].Split(',')[0]);
                        }
                    }
                    bunkView = promotionBunkView;
                    break;

                case BunkType.Production:    //往返产品舱
                    bunkView = new ProductionBunkView();
                    break;

                case BunkType.Transfer:    //中转联程舱
                    bunkView = new TransferBunkView();
                    break;

                case BunkType.Free:    //免票
                    bunkView = new FreeBunkView()
                    {
                        Description = Description
                    };
                    break;

                case BunkType.Team:    //团队
                    bunkView = new TeamBunkView();
                    break;
                }
                bunkView.Airline           = AirlineCode;
                bunkView.Code              = Code;
                bunkView.RefundRegulation  = txtRefundRegulation.Text.Trim();
                bunkView.ChangeRegulation  = txtChangeRegulation.Text.Trim();
                bunkView.EndorseRegulation = txtEndorseRegulation.Text.Trim();
                bunkView.Remarks           = txtRemarks.Text.Trim();
                bunkView.ETDZDate          = ETDZDate;
                bunkView.Valid             = Valid;
                if (!string.IsNullOrEmpty(FlightEndDate))
                {
                    bunkView.FlightEndDate = Convert.ToDateTime(FlightEndDate);
                }
                bunkView.FlightBeginDate = FlightBeginDate;
                for (int i = 0; i < chklVoyageType.Items.Count; i++)
                {
                    if (chklVoyageType.Items[i].Selected)
                    {
                        bunkView.VoyageType |= (VoyageTypeValue)(int.Parse(chklVoyageType.Items[i].Value));
                    }
                }
                for (int i = 0; i < chklTravelType.Items.Count; i++)
                {
                    if (chklTravelType.Items[i].Selected)
                    {
                        bunkView.TravelType |= (TravelTypeValue)(int.Parse(chklTravelType.Items[i].Value));
                    }
                }
                for (int i = 0; i < chklPassengerType.Items.Count; i++)
                {
                    if (chklPassengerType.Items[i].Selected)
                    {
                        bunkView.PassengerType |= (PassengerTypeValue)(int.Parse(chklPassengerType.Items[i].Value));
                    }
                }
                //添加
                if (Request.QueryString["action"] != null && Request.QueryString["action"].ToString() == "add")
                {
                    try
                    {
                        FoundationService.AddBunk(bunkView, CurrentUser.UserName);
                        RegisterScript("alert('添加成功!'); window.location.href='Bunk.aspx';");
                    }
                    catch (Exception ex)
                    {
                        ShowExceptionMessage(ex, "添加");
                    }
                }
                else//修改
                {
                    try
                    {
                        FoundationService.UpdateBunk(new Guid(Request.QueryString["Id"].ToString()), bunkView, CurrentUser.UserName);
                        RegisterScript("alert('修改成功!'); window.location.href='Bunk.aspx?Search=Back';");
                    }
                    catch (Exception ex)
                    {
                        ShowExceptionMessage(ex, "修改");
                    }
                }
            }
            catch (Exception exw)
            {
                ShowExceptionMessage(exw, "操作");
            }
        }
Ejemplo n.º 2
0
        protected void gvDiscount_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "opdate")
            {
                string code = e.CommandArgument.ToString();
                ChinaPay.B3B.Service.Foundation.Domain.Bunk bunk = FoundationService.QueryBunkNew(new Guid(code));
                if (bunk == null)
                {
                    return;
                }
                BunkView bunkView = null;
                switch (bunk.Type)
                {
                case BunkType.Economic:
                    EconomicBunk economicBunk     = bunk as EconomicBunk;
                    var          economicBunkView = new EconomicBunkView()
                    {
                        Arrival   = economicBunk.ArrivalCode.Value,
                        Departure = economicBunk.DepartureCode.Value,
                        Discount  = economicBunk.Discount
                    };
                    foreach (var item in economicBunk.Extended)
                    {
                        economicBunkView.AddExtended(new ExtendedWithDiscountBunkView {
                            Code = item.Code.Value, Discount = item.Discount
                        });
                    }
                    bunkView = economicBunkView;
                    break;

                case BunkType.FirstOrBusiness:
                    FirstBusinessBunk firstBusinessBunk = bunk as FirstBusinessBunk;
                    var firstBusinessBunkView           = new FirstBusinessBunkView()
                    {
                        Arrival     = firstBusinessBunk.ArrivalCode.Value,
                        Departure   = firstBusinessBunk.DepartureCode.Value,
                        Description = firstBusinessBunk.Description,
                        Discount    = firstBusinessBunk.Discount
                    };
                    foreach (var item in firstBusinessBunk.Extended)
                    {
                        firstBusinessBunkView.AddExtended(new ExtendedWithDiscountBunkView {
                            Code = item.Code.Value, Discount = item.Discount
                        });
                    }
                    bunkView = firstBusinessBunkView;
                    break;

                case BunkType.Promotion:
                    PromotionBunk promotionBunk     = bunk as PromotionBunk;
                    var           promotionBunkView = new PromotionBunkView()
                    {
                        Description = promotionBunk.Description
                    };
                    foreach (var item in promotionBunk.Extended)
                    {
                        promotionBunkView.AddExtended(item);
                    }
                    bunkView = promotionBunkView;
                    break;

                case BunkType.Production:
                    bunkView = new ProductionBunkView();
                    break;

                case BunkType.Transfer:
                    bunkView = new TransferBunkView();
                    break;

                case BunkType.Free:
                    FreeBunk freeBunk = bunk as FreeBunk;
                    bunkView = new FreeBunkView()
                    {
                        Description = freeBunk.Description
                    };
                    break;

                case BunkType.Team:
                    bunkView = new TeamBunkView();
                    break;

                default:
                    throw new Exception("舱位不存在");
                }
                bunkView.Code              = bunk.Code.Value;
                bunkView.RefundRegulation  = bunk.RefundRegulation;
                bunkView.ChangeRegulation  = bunk.ChangeRegulation;
                bunkView.EndorseRegulation = bunk.EndorseRegulation;
                bunkView.VoyageType        = bunk.VoyageType;
                bunkView.PassengerType     = bunk.PassengerType;
                bunkView.TravelType        = bunk.TravelType;
                bunkView.Remarks           = bunk.Remarks;
                bunkView.FlightBeginDate   = bunk.FlightBeginDate;
                bunkView.FlightEndDate     = bunk.FlightEndDate;
                bunkView.ETDZDate          = bunk.ETDZDate;
                bunkView.Airline           = bunk.AirlineCode.Value;
                bunkView.Valid             = !bunk.Valid;
                try
                {
                    FoundationService.UpdateBunk(new Guid(code), bunkView, CurrentUser.UserName);
                    if (bunk.Valid)
                    {
                        RegisterScript("alert('禁用成功!'); window.location.href='Bunk.aspx?Search=Back';");
                    }
                    else
                    {
                        RegisterScript("alert('启用成功!'); window.location.href='Bunk.aspx?Search=Back';");
                    }
                }
                catch (Exception ex)
                {
                    ShowExceptionMessage(ex, bunk.Valid ? "禁用" : "启用");
                    return;
                }
                refresh();
            }
        }