コード例 #1
0
ファイル: Bunk.aspx.cs プロジェクト: 842549829/Pool
        /// <summary>
        /// 类型转化
        /// </summary>
        /// <param name="bunk">Bunk类型</param>
        /// <returns>NewBunks</returns>
        private ListBunkView GetListBunk(Service.Foundation.Domain.Bunk bunk)
        {
            var result = new ListBunkView();

            result.Id = bunk.Id.ToString();
            result.FlightBeginDate = bunk.FlightBeginDate.ToString("yyyy-MM-dd");
            if (bunk.FlightEndDate != null)
            {
                result.FlightEndDate = bunk.FlightEndDate.Value.ToString("yyyy-MM-dd");
            }
            result.ETDZDate = bunk.ETDZDate.ToString("yyyy-MM-dd");
            result.BunkType = bunk.Type.GetDescription();
            result.BunkCode = bunk.Code.Value;
            var voyageType = (Enum.GetValues(typeof(VoyageTypeValue)) as VoyageTypeValue[]).Select(item => new KeyValuePair <int, string>((int)item, item.GetDescription()));

            result.VoyageType = string.Join("<Br/>",
                                            voyageType.Where(q => (VoyageTypeValue)q.Key == (bunk.VoyageType & (VoyageTypeValue)q.Key)).Select(item => item.Value));
            var extendBunks = string.Empty;

            if (bunk is GeneralBunk)
            {
                extendBunks = (bunk as GeneralBunk).Extended.Join(",", item => item.Code.Value);
            }
            else if (bunk is PromotionBunk)
            {
                extendBunks = (bunk as PromotionBunk).Extended.Join(",");
            }
            if (extendBunks.Length > 0)
            {
                result.BunkCode += "," + extendBunks;
            }
            result.Valid       = bunk.Valid;
            result.AirlineCode = bunk.AirlineCode.Value;
            if (bunk is GeneralBunk)
            {
                var generalBunk = bunk as GeneralBunk;
                result.DepartAriport = generalBunk.DepartureCode.IsNullOrEmpty() ? "所有" : generalBunk.DepartureCode.Value;
                result.ArriveAriport = generalBunk.ArrivalCode.IsNullOrEmpty() ? "所有" : generalBunk.ArrivalCode.Value;
            }
            else
            {
                result.DepartAriport = "所有";
                result.ArriveAriport = "所有";
            }
            return(result);
        }
コード例 #2
0
ファイル: Bunk.aspx.cs プロジェクト: 842549829/Pool
 bool existsInExtendedBunk(Service.Foundation.Domain.Bunk bunk, string bunkCode)
 {
     if (bunk is GeneralBunk)
     {
         var generalBunk = bunk as GeneralBunk;
         return(generalBunk.Extended.Any(item => item.Code.Value == bunkCode));
     }
     else if (bunk is PromotionBunk)
     {
         var promotionBunk = bunk as PromotionBunk;
         return(promotionBunk.Extended.Any(item => item == bunkCode));
     }
     else
     {
         return(false);
     }
 }
コード例 #3
0
        /// <summary>
        /// 列表绑定
        /// </summary>
        private void DataBindArea()
        {
            //舱位类型
            System.Reflection.FieldInfo[] classType = typeof(BunkType).GetFields();
            foreach (var item in classType)
            {
                if (!item.IsSpecialName)                                    //反射出第一个Field为特殊Field
                {
                    BunkType obj   = (BunkType)item.GetRawConstantValue();  //对应的文章
                    string   text  = obj.GetDescription();
                    string   value = item.GetRawConstantValue().ToString(); //对应的值
                    radiolist.Items.Add(new ListItem(text, value));
                }
            }
            this.radiolist.Items[0].Selected = true;
            //航空公司
            foreach (var item in FoundationService.Airlines)
            {
                this.ddlAirline.Items.Add(new ListItem(item.Code.Value + "-" + item.ShortName, item.Code.Value));
            }
            this.ddlAirline.Items.Insert(0, new ListItem("-请选择-", "0"));
            //到达机场 出发机场

            foreach (var item in FoundationService.Airports)
            {
                string name = item.Code.Value + "-" + item.ShortName;
                this.ddlDepartCity.Items.Add(new ListItem(name, item.Code.Value));
                this.ddlArriveCity.Items.Add(new ListItem(name, item.Code.Value));
            }
            this.ddlDepartCity.Items.Insert(0, new ListItem("-所有-", "0"));
            this.ddlArriveCity.Items.Insert(0, new ListItem("-所有-", "0"));

            //头等/公务舱描述
            this.ddltdType.Items.Clear();
            this.ddltdType.DataSource     = SystemDictionaryService.Query(SystemDictionaryType.FirstOrBusinessBunkDescription);
            this.ddltdType.DataTextField  = "Name";
            this.ddltdType.DataValueField = "Id";
            this.ddltdType.DataBind();
            this.ddltdType.Items.Insert(0, new ListItem("-请选择-", "0"));

            //特价舱描述
            this.ddlTJType.Items.Clear();
            this.ddlTJType.DataSource     = SystemDictionaryService.Query(SystemDictionaryType.PromotionBunkDescription);
            this.ddlTJType.DataTextField  = "Name";
            this.ddlTJType.DataValueField = "Id";
            this.ddlTJType.DataBind();
            this.ddlTJType.Items.Insert(0, new ListItem("-请选择-", "0"));

            //免票描述
            dropMpType.Items.Clear();
            dropMpType.DataSource     = SystemDictionaryService.Query(SystemDictionaryType.FreeDescription);
            dropMpType.DataTextField  = "Name";
            dropMpType.DataValueField = "Id";
            dropMpType.DataBind();
            dropMpType.Items.Insert(0, new ListItem("-请选择-", "0"));
            Service.Foundation.Domain.Bunk bunk = string.IsNullOrEmpty(Request.QueryString["Id"]) ? null : FoundationService.QueryBunkNew(new Guid(Request.QueryString["Id"]));
            //适用行程
            var voyageTypes = (Enum.GetValues(typeof(VoyageTypeValue)) as VoyageTypeValue[]).Select(item => new KeyValuePair <int, string>((int)item, item.GetDescription()));

            foreach (var item in voyageTypes)
            {
                var listIetm = new ListItem();
                if (bunk != null && (bunk.VoyageType & (VoyageTypeValue)item.Key) == (VoyageTypeValue)item.Key)
                {
                    listIetm.Selected = true;
                }
                listIetm.Value = item.Key.ToString();
                listIetm.Text  = item.Value;
                chklVoyageType.Items.Add(listIetm);
            }
            //旅行类型
            var travelTypes = (Enum.GetValues(typeof(TravelTypeValue)) as TravelTypeValue[]).Select(item => new KeyValuePair <int, string>((int)item, item.GetDescription()));

            foreach (var item in travelTypes)
            {
                var listItem = new ListItem();
                if (bunk != null && (bunk.TravelType & (TravelTypeValue)item.Key) == (TravelTypeValue)item.Key)
                {
                    listItem.Selected = true;
                }
                listItem.Value = item.Key.ToString();
                listItem.Text  = item.Value;
                chklTravelType.Items.Add(listItem);
            }
            //旅客类型
            var passengerTypes = (Enum.GetValues(typeof(PassengerTypeValue)) as PassengerTypeValue[]).Select(item => new KeyValuePair <int, string>((int)item, item.GetDescription()));

            foreach (var item in passengerTypes)
            {
                var listItem = new ListItem();
                if (bunk != null && (bunk.PassengerType & (PassengerTypeValue)item.Key) == (PassengerTypeValue)item.Key)
                {
                    listItem.Selected = true;
                }
                listItem.Text  = item.Value;
                listItem.Value = item.Key.ToString();
                chklPassengerType.Items.Add(listItem);
            }
        }