예제 #1
0
파일: Bunk.aspx.cs 프로젝트: 842549829/Pool
        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();
            }
        }
예제 #2
0
 private void Refresh()
 {
     ChinaPay.B3B.Service.Foundation.Domain.Bunk bunk = FoundationService.QueryBunkNew(new Guid(Request.QueryString["Id"].ToString()));
     ddlAirline.SelectedValue = bunk.AirlineCode.Value;
     txtHBStartDate.Text      = bunk.FlightBeginDate.ToString("yyyy-MM-dd");
     if (bunk.FlightEndDate != null)
     {
         txtHBStopDate.Text = Convert.ToDateTime(bunk.FlightEndDate).ToString("yyyy-MM-dd");
     }
     txtCpStartDate.Text       = bunk.ETDZDate.ToString("yyyy-MM-dd");
     txtRefundRegulation.Text  = bunk.RefundRegulation;
     txtChangeRegulation.Text  = bunk.ChangeRegulation;
     txtEndorseRegulation.Text = bunk.EndorseRegulation;
     txtRemarks.Text           = bunk.Remarks;
     radseatlist.SelectedIndex = bunk.Valid == true ? 0 : 1;
     txtCwCode.Text            = bunk.Code.Value;
     //舱位类型
     if (bunk is EconomicBunk)//经济舱位
     {
         radiolist.SelectedValue = ((int)BunkType.Economic).ToString();
         EconomicBunk economicBunk = bunk as EconomicBunk;
         this.ddlDepartCity.SelectedValue = economicBunk.DepartureCode.Value;
         this.ddlArriveCity.SelectedValue = economicBunk.ArrivalCode.Value;
         this.txtDiscount.Text            = (economicBunk.Discount * 100).ToString();
         this.txtCwCode.Text = economicBunk.Code.Value;
         if (economicBunk.Extended.Count() > 0)
         {
             UpdateData(economicBunk.Extended);
         }
     }
     else if (bunk is FirstBusinessBunk)
     {
         radiolist.SelectedValue = ((int)BunkType.FirstOrBusiness).ToString();
         FirstBusinessBunk firstBusinessBunk = bunk as FirstBusinessBunk;
         this.ddlDepartCity.SelectedValue = firstBusinessBunk.DepartureCode.Value;
         this.ddlArriveCity.SelectedValue = firstBusinessBunk.ArrivalCode.Value;
         setDropDownListSelectItemByText(this.ddltdType, firstBusinessBunk.Description);
         this.txtCwCode.Text   = firstBusinessBunk.Code.Value;
         this.txtDiscount.Text = (firstBusinessBunk.Discount * 100).ToString();
         if (firstBusinessBunk.Extended.Count() > 0)
         {
             UpdateData(firstBusinessBunk.Extended);
         }
     }
     else if (bunk is PromotionBunk)
     {
         radiolist.SelectedValue = ((int)BunkType.Promotion).ToString();
         PromotionBunk promotionBunk = bunk as PromotionBunk;
         setDropDownListSelectItemByText(this.ddlTJType, promotionBunk.Description);
         this.txtCwCode.Text = promotionBunk.Code.Value;
         if (promotionBunk.Extended.Count() > 0)
         {
             int           index = 0;
             StringBuilder str   = new StringBuilder();
             foreach (string cal in promotionBunk.Extended)
             {
                 str.Append("(tr class='tr')(th height='23')扩展:(/th)(td colspan='3')(input type='text' class='input2' id='txtCodeExtend" + index + "'  value='" + cal + "' /)(/tr)");
                 index++;
             }
             hiddindex.Value = index.ToString();
             hiddtr.Value    = str.ToString();
         }
     }
     else if (bunk is ProductionBunk)
     {
         radiolist.SelectedValue = ((int)BunkType.Production).ToString();
     }
     else if (bunk is TransferBunk)
     {
         radiolist.SelectedValue = ((int)BunkType.Transfer).ToString();
     }
     else if (bunk is FreeBunk)
     {
         radiolist.SelectedValue = ((int)BunkType.Free).ToString();
         FreeBunk promotionBunk = bunk as FreeBunk;
         setDropDownListSelectItemByText(this.dropMpType, promotionBunk.Description);
     }
     else if (bunk is TeamBunk)
     {
         radiolist.SelectedValue = ((int)BunkType.Team).ToString();
     }
     ddlAirline.Enabled    = false;
     ddlDepartCity.Enabled = false;
     ddlArriveCity.Enabled = false;
     txtCwCode.Enabled     = false;
     radiolist.Enabled     = false;
 }
예제 #3
0
        internal static Bunk CreateBunk(BunkView bunkView)
        {
            if (null == bunkView)
            {
                throw new ArgumentNullException("bunkView");
            }
            bunkView.Validate();
            Bunk bunk = null;

            if (bunkView is GeneralBunkView)
            {
                if (bunkView is FirstBusinessBunkView)
                {
                    bunk = new FirstBusinessBunk {
                        Description = StringUtility.Trim(((FirstBusinessBunkView)bunkView).Description)
                    };
                }
                else
                {
                    bunk = new EconomicBunk();
                }
                var generalBunkView = bunkView as GeneralBunkView;
                var generalBunk     = bunk as GeneralBunk;
                generalBunk.DepartureCode = StringUtility.Trim(generalBunkView.Departure) ?? string.Empty;
                generalBunk.ArrivalCode   = StringUtility.Trim(generalBunkView.Arrival) ?? string.Empty;
                generalBunk.Discount      = generalBunkView.Discount;
                foreach (var item in generalBunkView.Extended)
                {
                    generalBunk.AddExtended(new ExtendedWithDiscountBunk(StringUtility.Trim(item.Code), item.Discount));
                }
            }
            else if (bunkView is PromotionBunkView)
            {
                var promotionBunkView = bunkView as PromotionBunkView;
                bunk = new PromotionBunk {
                    Description = StringUtility.Trim(promotionBunkView.Description)
                };
                var promotionBunk = bunk as PromotionBunk;
                foreach (var item in promotionBunkView.Extended)
                {
                    promotionBunk.AddExtended(StringUtility.Trim(item));
                }
            }
            else if (bunkView is ProductionBunkView)
            {
                bunk = new ProductionBunk();
            }
            else if (bunkView is TransferBunkView)
            {
                bunk = new TransferBunk();
            }
            else if (bunkView is FreeBunkView)
            {
                bunk = new FreeBunk {
                    Description = StringUtility.Trim((bunkView as FreeBunkView).Description)
                };
            }
            else if (bunkView is TeamBunkView)
            {
                bunk = new TeamBunk();
            }
            else
            {
                throw new NotSupportedException("未知舱位类型");
            }
            bunk.AirlineCode     = StringUtility.Trim(bunkView.Airline);
            bunk.Code            = StringUtility.Trim(bunkView.Code);
            bunk.ETDZDate        = bunkView.ETDZDate;
            bunk.FlightBeginDate = bunkView.FlightBeginDate;
            bunk.FlightEndDate   = bunkView.FlightEndDate;
            //bunk.EI = StringUtility.Trim(bunkView.EI);
            bunk.RefundRegulation  = StringUtility.Trim(bunkView.RefundRegulation);
            bunk.ChangeRegulation  = StringUtility.Trim(bunkView.ChangeRegulation);
            bunk.EndorseRegulation = StringUtility.Trim(bunkView.EndorseRegulation);
            bunk.Remarks           = StringUtility.Trim(bunkView.Remarks);
            bunk.Valid             = bunkView.Valid;
            bunk.ModifyTime        = DateTime.Now;
            bunk.VoyageType        = bunkView.VoyageType;
            bunk.TravelType        = bunkView.TravelType;
            bunk.PassengerType     = bunkView.PassengerType;
            return(bunk);
        }