Ejemplo n.º 1
0
 public ActionResult GetParentLocations(LocationLevel?level)
 {
     if (level != null && level != LocationLevel.Factory)
     {
         using (LocationServiceClient client = new LocationServiceClient())
         {
             LocationLevel parentLevel = LocationLevel.Factory;
             if (level == LocationLevel.Area)
             {
                 parentLevel = LocationLevel.Room;
             }
             PagingConfig cfg = new PagingConfig()
             {
                 IsPaging = false,
                 Where    = string.Format("Level='{0}'", Convert.ToInt32(parentLevel))
             };
             MethodReturnResult <IList <Location> > result = client.Get(ref cfg);
             if (result.Code <= 0)
             {
                 if (Request.IsAjaxRequest())
                 {
                     return(Json(result.Data, JsonRequestBehavior.AllowGet));
                 }
                 else
                 {
                     return(View(""));
                 }
             }
         }
     }
     return(Json(new List <Location>(), JsonRequestBehavior.AllowGet));
 }
Ejemplo n.º 2
0
        private void SetParentLocationNameViewData(string viewDataName, LocationLevel level)
        {
            SetViewData();
            if (level != LocationLevel.Factory)
            {
                using (LocationServiceClient client = new LocationServiceClient())
                {
                    LocationLevel parentLevel = LocationLevel.Factory;
                    if (level == LocationLevel.Area)
                    {
                        parentLevel = LocationLevel.Room;
                    }

                    PagingConfig cfg = new PagingConfig()
                    {
                        IsPaging = false,
                        Where    = string.Format("Level='{0}'", Convert.ToInt32(parentLevel))
                    };

                    MethodReturnResult <IList <Location> > resultParentLocation = client.Get(ref cfg);
                    if (resultParentLocation.Code <= 0)
                    {
                        IEnumerable <SelectListItem> lst = from item in resultParentLocation.Data
                                                           select new SelectListItem()
                        {
                            Text  = item.Key,
                            Value = item.Key
                        };
                        ViewData[viewDataName] = lst;
                    }
                }
            }
        }
Ejemplo n.º 3
0
 protected void btnSave_Click(object sender, EventArgs e)
 {
     if (Request.QueryString["action"] != null)
     {
         string        locationCode  = string.Empty;
         LocationLevel locationLevel = LocationLevel.City;
         if (this.ddlCounty.SelectedValue != "0")
         {
             locationCode  = this.ddlCounty.SelectedValue;
             locationLevel = LocationLevel.County;
         }
         else
         {
             locationCode = this.ddlCity.SelectedValue;
         }
         AirportView airportView = new AirportView()
         {
             Code          = this.txtAirportCode.Text.Trim(),
             Name          = this.txtAirportName.Text.Trim(),
             ShortName     = this.txtAirportShortName.Text.Trim(),
             Valid         = this.ddlAirportStatus.SelectedValue == "T" ? true : false,
             LocationCode  = locationCode,
             LocationLevel = locationLevel,
             IsMain        = this.rdoOK.Checked == true ? true : false
         };
         if (Request.QueryString["action"].ToString() == "add")
         {
             try
             {
                 FoundationService.AddAirport(airportView, CurrentUser.UserName);
                 RegisterScript("alert('添加成功!'); window.location.href='Airport.aspx'");
             } catch (Exception ex) {
                 ShowExceptionMessage(ex, "添加");
             }
         }
         else
         {
             try
             {
                 FoundationService.UpdateAirport(airportView, CurrentUser.UserName);
                 RegisterScript("alert('修改成功!'); window.location.href='Airport.aspx?Search=Back'");
             } catch (Exception ex) {
                 ShowExceptionMessage(ex, "修改");
             }
         }
     }
 }
Ejemplo n.º 4
0
        public IEnumerable <SelectListItem> GetLocations(LocationLevel level)
        {
            using (LocationServiceClient client = new LocationServiceClient())
            {
                PagingConfig cfg = new PagingConfig()
                {
                    IsPaging = false,
                    Where    = string.Format("Level='{0}'", Convert.ToInt32(level))
                };

                MethodReturnResult <IList <Location> > result = client.Get(ref cfg);
                if (result.Code <= 0)
                {
                    IEnumerable <SelectListItem> lst = from item in result.Data
                                                       select new SelectListItem()
                    {
                        Text  = item.Key,
                        Value = item.Key
                    };
                    return(lst);
                }
            }
            return(new List <SelectListItem>());
        }