Exemplo n.º 1
0
        public static List<SelectListItem> GetAnpaiUserData()
        {    List<SelectListItem> selectListItems = new List<SelectListItem>();
            Account account = AccountModel.GetCurrentAccount();
            if (account != null)
            {
                Langben.App.ServiceReference1.SysRolesClient client = new Langben.App.ServiceReference1.SysRolesClient();

                var queryData = client.GetPersonByBiaoShi("logo");
                client.Close();


                //遍历Department的集合
                foreach (var it in queryData)
                {
                    SelectListItem selectListItem = new SelectListItem
                    {
                        Text = it.MyTexts,
                        Value = it.MyValues
                    };
                    selectListItems.Add(selectListItem);
                }
            }
            return selectListItems;

        }
        public List<SelectListItem> GetAvailableThemes(string aliasId = null)
        {
            List<SelectListItem> layouts = new List<SelectListItem>();

            string pathToViews = GetPathToViews(aliasId);
            if(Directory.Exists(pathToViews))
            {
                var directoryInfo = new DirectoryInfo(pathToViews);
                var folders = directoryInfo.GetDirectories();
                foreach (DirectoryInfo f in folders)
                {
                    SelectListItem layout = new SelectListItem
                    {
                        Text = f.Name,
                        Value = f.Name
                    };
                    layouts.Add(layout);
                }
            }
            
            layouts.Add(new SelectListItem
            {
                Text = "default",
                Value = ""
            });
           
            return layouts;

        }
 public static string ListItemToOption(SelectListItem item)
 {
     TagBuilder builder = new TagBuilder("option")
                          {
                              InnerHtml = HttpUtility.HtmlEncode(item.Text)
                          };
     if(item.Value != null)
     {
         builder.Attributes["value"] = item.Value;
     }
     if(item.Selected)
     {
         builder.Attributes["selected"] = "selected";
     }
     return builder.ToString(TagRenderMode.Normal);
 }
        public ActionResult GetProductBrandByCategoryId(string CategoryId)
        {
            List<SelectListItem> items = new List<SelectListItem>();
            var service = new ProductConsultService();
            var listCategories = service.QueryProductBrandByCategoryId(Convert.ToInt32(CategoryId));
            if (listCategories == null) return Json(null,JsonRequestBehavior.AllowGet);
            foreach (var productCategory in listCategories)
            {
                var item = new SelectListItem()
                               {
                                   Text = productCategory.BrandName,
                                   Value = productCategory.ID.ToString()
                               };
                items.Add(item);
            }

            return Json(items, JsonRequestBehavior.AllowGet);
        }
Exemplo n.º 5
0
		/// <summary>
		/// Selectable role list for Mvc.
		/// </summary>
		/// <returns></returns>
		public static IEnumerable<SelectListItem> SelectableRoleList()
		{
			foreach (var role in RoleHelper.MutableRoles)
			{
				var listItem = new SelectListItem()
				{
					Text = role,
					Value = role
				};

				yield return listItem;
			}

			var defaultOption = new SelectListItem()
			{
				Selected = true,
				Text = "Change User Role",
				Value = ""
			};

			yield return defaultOption;
		}
Exemplo n.º 6
0
		/// <remarks>
		///     Not used directly in HtmlHelper. Exposed for use in DefaultDisplayTemplates.
		/// </remarks>
		public static TagBuilder GenerateOption(SelectListItem item, string text)
		{
			var tagBuilder = new TagBuilder("option");
			tagBuilder.InnerHtml.SetContent(text);

			if (item.Value != null)
			{
				tagBuilder.Attributes["value"] = item.Value;
			}

			if (item.Selected)
			{
				tagBuilder.Attributes["selected"] = "selected";
			}

			if (item.Disabled)
			{
				tagBuilder.Attributes["disabled"] = "disabled";
			}

			return tagBuilder;
		}
Exemplo n.º 7
0
        public IActionResult Create()
        {
            List <SelectListItem> CatList = new List <SelectListItem>();


            var categories = _context.Categories.ToList();



            foreach (var item in categories)
            {
                var NewItem = new SelectListItem();

                NewItem.Value = item.CategoriesID.ToString();
                NewItem.Text  = item.CategoryName;

                CatList.Add(NewItem);
            }

            ViewBag.CatList = CatList;

            return(View());
        }
Exemplo n.º 8
0
        public ActionResult GetSalutationList(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Gender g = db.Genders.Find(id);

            if (g == null)
            {
                return(HttpNotFound());
            }
            List <SelectListItem> Salutations = new List <SelectListItem>();

            foreach (Salutation s in g.Salutations)
            {
                SelectListItem sli = new SelectListItem();
                sli.Text  = s.value.ToString();
                sli.Value = s.id.ToString();
                Salutations.Add(sli);
            }
            return(Json(Salutations, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 9
0
        private static TagBuilder GenerateOption(SelectListItem item, string text, bool selected)
        {
            var tagBuilder = new TagBuilder("option");

            tagBuilder.InnerHtml.SetContent(text);

            if (item.Value != null)
            {
                tagBuilder.Attributes["value"] = item.Value;
            }

            if (selected)
            {
                tagBuilder.Attributes["selected"] = "selected";
            }

            if (item.Disabled)
            {
                tagBuilder.Attributes["disabled"] = "disabled";
            }

            return(tagBuilder);
        }
Exemplo n.º 10
0
        public static IEnumerable <SelectListItem> GetControllers(string areaName)
        {
            List <SelectListItem> listControllers = new List <SelectListItem>();

            if (areaName.IsNotNullOrEmpty())
            {
                Assembly assembly = Assembly.Load("ATS");

                IEnumerable <Type> controllerTypes = from t in assembly.GetExportedTypes()
                                                     where typeof(IController).IsAssignableFrom(t) && t.Namespace.Contains(areaName)
                                                     orderby t.Name ascending
                                                     select t;
                foreach (var controllerType in controllerTypes)
                {
                    SelectListItem currentItem = new SelectListItem();
                    currentItem.Text  = controllerType.Name.Replace("Controller", string.Empty);
                    currentItem.Value = currentItem.Text;
                    listControllers.Add(currentItem);
                }
            }

            return(listControllers);
        }
Exemplo n.º 11
0
        public List <SelectListItem> PopulateDropdown()
        {
            var positions = _context.Position.ToList();
            List <SelectListItem> PositionOptions = new List <SelectListItem>();

            PositionOptions.Insert(0, new SelectListItem
            {
                Text     = "Select Preferred Position...",
                Value    = null,
                Selected = true
            });

            foreach (var p in positions)
            {
                SelectListItem li = new SelectListItem
                {
                    Value = p.Id.ToString(),
                    Text  = p.Name
                };
                PositionOptions.Add(li);
            }
            return(PositionOptions);
        }
Exemplo n.º 12
0
        public ActionResult AddByParent(long Id)
        {
            List <SelectListItem> catgegotyList = this.GetCatgegotyList();

            catgegotyList.FirstOrDefault <SelectListItem>((SelectListItem c) => c.Value.Equals(Id.ToString())).Selected = true;
            base.TempData["Categories"] = catgegotyList;
            CategoryInfo          category       = this._iCategoryService.GetCategory(Id);
            string                str            = category.TypeId.ToString();
            List <SelectListItem> typesList      = this.GetTypesList((long)-1);
            SelectListItem        selectListItem = typesList.FirstOrDefault <SelectListItem>((SelectListItem c) => c.Value.Equals(str));

            if (selectListItem != null)
            {
                selectListItem.Selected = true;
            }
            else
            {
                typesList.FirstOrDefault <SelectListItem>().Selected = true;
            }
            base.TempData["Types"] = typesList;
            base.TempData["Depth"] = category.Depth;
            return(base.RedirectToAction("Add"));
        }
        private List <SelectListItem> GetDesignationsForDropdownList()
        {
            var designations = aPayrollManager.GetAllDesignation();

            List <SelectListItem> items = new List <SelectListItem>()
            {
                new SelectListItem()
                {
                    Value = "", Text = "--Select--"
                }
            };

            foreach (Designation designation in designations)
            {
                SelectListItem item = new SelectListItem()
                {
                    Value = designation.Id.ToString(), Text = designation.DesignationName
                };
                items.Add(item);
            }

            return(items);
        }
        private List <SelectListItem> GetGendersForDropdownList()
        {
            var genders = aPayrollManager.GetAllGenders();

            List <SelectListItem> items = new List <SelectListItem>()
            {
                new SelectListItem()
                {
                    Value = "", Text = "--Select--"
                }
            };

            foreach (Gender gender in genders)
            {
                SelectListItem item = new SelectListItem()
                {
                    Value = gender.Id.ToString(), Text = gender.GenderName
                };
                items.Add(item);
            }

            return(items);
        }
        private List <SelectListItem> GetCategoriesForDropdownList()
        {
            var categories = aPayrollManager.GetAllEmpTypes();

            List <SelectListItem> items = new List <SelectListItem>()
            {
                new SelectListItem()
                {
                    Value = "", Text = "--Select--"
                }
            };

            foreach (EmployeeType employeeType in categories)
            {
                SelectListItem item = new SelectListItem()
                {
                    Value = employeeType.Id.ToString(), Text = employeeType.EmpType
                };
                items.Add(item);
            }

            return(items);
        }
        private List <SelectListItem> GetDepartmentsForDropdownList()
        {
            var departments = academicManager.GetAllDepartment();

            List <SelectListItem> items = new List <SelectListItem>()
            {
                new SelectListItem()
                {
                    Value = "", Text = "--Select--"
                }
            };

            foreach (Department department in departments)
            {
                SelectListItem item = new SelectListItem()
                {
                    Value = department.Id.ToString(), Text = department.DepartmentName
                };
                items.Add(item);
            }

            return(items);
        }
Exemplo n.º 17
0
        public ActionResult Reporte3()
        {
            var listaEmpresas      = empresas.getEmpresasByUser(Session["Usuario"] as SYA_Usuarios);
            var selectListEmpresas = listaEmpresas.Where(x => x.RegistroPatronal != null).Select(x => new SelectListItem()
            {
                Value = x.IdEmpresa.ToString(),
                Text  = x.RazonSocial,
            }).ToList();

            var itemNew = new SelectListItem()
            {
                Value    = "0",
                Text     = "- Todas -",
                Selected = true
            };

            selectListEmpresas.Insert(0, itemNew);


            ViewBag.ListaEmpresas = selectListEmpresas;

            return(View());
        }
Exemplo n.º 18
0
        public ActionResult Edit([Bind(Include = "ID,RUT,FICHA,COD_CONCEPTO,CONCEPTO,COD_CUENTA,PORCENTAJE,TIPO_CALCULO")] Config_ConceptosRetail config_ConceptosRetail, string comboboxCanales = "", string comboboxClientes = "")
        {
            if (ModelState.IsValid)
            {
                db.Entry(config_ConceptosRetail).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index", new { comboboxCanales = comboboxCanales, comboboxClientes = comboboxClientes }));
            }
            var listClientesCuentas = Models.DAO.DaoControlDocumento.getMasterCuentas();
            List <SelectListItem> listCuentasContables = new List <SelectListItem>();

            foreach (var item in listClientesCuentas)
            {
                SelectListItem selectedListItem = new SelectListItem
                {
                    Text  = item.TEXTO,
                    Value = item.VALOR
                };
                listCuentasContables.Add(selectedListItem);
            }
            ViewBag.CuentasContables = listCuentasContables;
            return(View(config_ConceptosRetail));
        }
Exemplo n.º 19
0
        void getInsurerMasterData()
        {
            var userId = User.FindFirst(ClaimTypes.NameIdentifier).Value;
            var orgId  = _context.Users.Where(x => x.Id == userId).FirstOrDefault().OrganisationId;
            //var globalList = _context.GlobalInsurers.ToList();
            var insMasterLst = _context.InsurerMasters.Where(i => i.OrganisationId == orgId).ToList();

            List <SelectListItem> ObjList = new List <SelectListItem>();

            foreach (InsurerMaster im in insMasterLst)
            {
                var name = im.Name; //globalList.Where(g => g.Id == im.GlobalInsurerId).FirstOrDefault().Name;

                SelectListItem si = new SelectListItem {
                    Text = name, Value = im.Id.ToString()
                };
                ObjList.Add(si);
            }

            var sortedList = ObjList.OrderBy(o => o.Text).ToList();

            ViewBag.InsuresList = sortedList;
        }
Exemplo n.º 20
0
        public ActionResult Comment(int BlogId)
        {
            var identityList = _identityService.Table.ToList();
            List <SelectListItem> drpList = new List <SelectListItem>();

            drpList.Add(new SelectListItem()
            {
                Text = "---告诉我你的真实身份---", Value = "-1", Selected = true
            });

            foreach (var item in identityList)
            {
                SelectListItem sitem = new SelectListItem();
                sitem.Text     = item.IdentityName;
                sitem.Value    = item.Id.ToString();
                sitem.Selected = false;
                drpList.Add(sitem);
            }

            ViewData["droplist"] = drpList;
            ViewBag.BlogId       = BlogId;
            return(PartialView());
        }
Exemplo n.º 21
0
        public ActionResult Edit(int?Id)
        {
            List <SelectListItem> teamlist = new List <SelectListItem>();
            TeamsRepository       teamsrep = new TeamsRepository();
            var myTeams = teamsrep.GetAllTeams().OrderBy(k => k.TeamName);

            if (myTeams.Count() > 0)
            {
                foreach (Team t in myTeams)
                {
                    SelectListItem sli = new SelectListItem();
                    sli.Value = t.Id.ToString();
                    sli.Text  = t.TeamName;
                    teamlist.Add(sli);
                }
                ViewData["Teams"] = teamlist;
            }
            //TeamsRepository teamsrep = new TeamsRepository();
            //Team team = teamsrep.GetTeam(Id);
            Match model = db.Matches.Where(w => w.Id == Id).FirstOrDefault();

            return(View(model));
        }
Exemplo n.º 22
0
    public static SelectList ToSelectList(Type enumType, string selectedItem)
    {
        List <SelectListItem> items = new List <SelectListItem>();

        foreach (var item in Enum.GetValues(enumType))
        {
            FieldInfo fi        = enumType.GetField(item.ToString());
            var       attribute = fi.GetCustomAttributes(typeof(EnumDescription), true).FirstOrDefault();
            var       title     = attribute == null?item.ToString() : ((EnumDescription)attribute).Text;

            // uncomment to skip enums without attributes
            //if (attribute == null)
            //    continue;
            var listItem = new SelectListItem
            {
                Value    = ((int)item).ToString(),
                Text     = title,
                Selected = selectedItem == ((int)item).ToString()
            };
            items.Add(listItem);
        }
        return(new SelectList(items, "Value", "Text", selectedItem));
    }
Exemplo n.º 23
0
        public IEnumerable <SelectListItem> GetFileList(string[] fileArray)
        {
            List <SelectListItem> newList = new List <SelectListItem>();

            foreach (string fileName in fileArray)
            {
                if (fileName.EndsWith(".css", StringComparison.OrdinalIgnoreCase) ||
                    fileName.EndsWith(".js", StringComparison.OrdinalIgnoreCase) ||
                    fileName.EndsWith(".cshtml", StringComparison.OrdinalIgnoreCase))
                {
                    string         removeString = Server.MapPath("~");
                    string         modifiedName = fileName.Remove(0, removeString.Length).Replace("Views\\themes\\", "");
                    SelectListItem selListItem  = new SelectListItem()
                    {
                        Value = modifiedName, Text = modifiedName
                    };
                    newList.Add(selListItem);
                }
            }
            IEnumerable <SelectListItem> abc = newList.AsEnumerable();

            return(abc);
        }
Exemplo n.º 24
0
        /// <summary>
        /// 编辑内容配置
        /// </summary>
        /// <returns></returns>
        public static List <SelectListItem> GetNewConfig()
        {
            List <SelectListItem> ListItem = new List <SelectListItem>();
            DataTable             dtDesc   = SystemManageDAL.GetConfigContent();

            if (dtDesc == null)
            {
                return(ListItem);
            }
            SelectListItem SelListItem = new SelectListItem();

            SelListItem.Value = "";
            SelListItem.Text  = "请选择";
            ListItem.Add(SelListItem);
            for (int i = 0; i < dtDesc.Rows.Count; i++)
            {
                SelListItem       = new SelectListItem();
                SelListItem.Value = dtDesc.Rows[i]["Type"].ToString();
                SelListItem.Text  = dtDesc.Rows[i]["ss"].ToString();
                ListItem.Add(SelListItem);
            }
            return(ListItem);
        }
Exemplo n.º 25
0
 private SelectListItem[] CreateDevList()
 {
     SelectListItem[] dropDownDeviceList = new SelectListItem[6];
     dropDownDeviceList[0] = new SelectListItem {
         Text = "Холодильник", Value = "fridge", Selected = true
     };
     dropDownDeviceList[1] = new SelectListItem {
         Text = "Телевизор (WebAPI)", Value = "tv"
     };
     dropDownDeviceList[2] = new SelectListItem {
         Text = "Микрофолновка", Value = "mw"
     };
     dropDownDeviceList[3] = new SelectListItem {
         Text = "Духовка", Value = "oven"
     };
     dropDownDeviceList[4] = new SelectListItem {
         Text = "Спутниковый тюнер", Value = "satellite"
     };
     dropDownDeviceList[5] = new SelectListItem {
         Text = "Приставка", Value = "gamebox"
     };
     return(dropDownDeviceList);
 }
Exemplo n.º 26
0
        public async Task Edit_Get_SetViewBagPosts()
        {
            Mock <EmployeeService>   mock  = new Mock <EmployeeService>();
            Mock <DepartmentService> dmock = new Mock <DepartmentService>();
            Mock <PostService>       pmock = new Mock <PostService>();

            pmock.Setup(m => m.GetAllAsync()).ReturnsAsync(new PostDTO[] {
                new PostDTO()
                {
                    Id = 2, Title = "Programmer", Department = new DepartmentDTO {
                        DepartmentName = "IT"
                    }
                }
            });
            EmployeeController controller = GetNewEmployeeController(mock.Object, dmock.Object, pmock.Object);

            ViewResult result = (await controller.Edit(1)) as ViewResult;

            SelectListItem item = (result.ViewBag.Posts as SelectList).FirstOrDefault();

            Assert.AreEqual("Programmer [IT]", item.Text);
            Assert.AreEqual("2", item.Value);
        }
Exemplo n.º 27
0
        public List <SelectListItem> getAllBrandsDistinctName()
        {
            DataTable             dataTable = new DataTable();
            List <SelectListItem> list      = new List <SelectListItem>();

            using (SqlConnection conn = new SqlConnection(cs))
            {
                string         query          = "select brand from medicine group by brand";
                SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(query, conn);
                sqlDataAdapter.Fill(dataTable);
            }
            for (int i = 0; i < dataTable.Rows.Count; i++)
            {
                DataRow        row  = dataTable.Rows[i];
                string         name = row[0].ToString();
                SelectListItem temp = new SelectListItem()
                {
                    Text = name, Value = i.ToString()
                };
                list.Add(temp);
            }
            return(list);
        }
Exemplo n.º 28
0
        public ActionResult Index()
        {
            var uow = new ControlTContext();

            var cajas    = new List <SelectListItem>();
            var selected = true;

            foreach (var caja in uow.Cajas.ToArray())
            {
                var li = new SelectListItem
                {
                    Text     = caja.Nombre,
                    Value    = caja.CajaID.ToString(CultureInfo.InvariantCulture),
                    Selected = selected
                };
                cajas.Add(li);
                selected = false;
            }

            var model = new MovimientosModel(cajas);

            return(View(model));
        }
Exemplo n.º 29
0
        private void cboLeadSources_SelectionChangeCommitted(object sender, EventArgs e)
        {
            try
            {
                cboAgencies.Enabled = btnAddAgency.Enabled = false;
                SelectListItem selItem = (SelectListItem)cboLeadSources.SelectedItem;
                if (selItem != null)
                {
                    if (selItem.ID == Program.LIST_DEFAULTS[(int)APP_DEFAULT_VALUES.LeadSourceAgency].DEFAULT_VALUE)
                    {
                        cboAgencies.DataSource    = _UNIT.PartiesService.GetAllParties("A");
                        cboAgencies.DisplayMember = "Description";
                        cboAgencies.ValueMember   = "ID";

                        cboAgencies.Enabled = btnAddAgency.Enabled = true;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "cboLeadSources_SelectionChangeCommitted", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 30
0
        public TicketwithListViewModel()
        {
            SelectListItems = new List <SelectListItem>();
            SelectListItem Şikayet = new SelectListItem()
            {
                Text  = "Şikayet",
                Value = Models.Type.Şikayet.ToString()
            };
            SelectListItem Öneri = new SelectListItem()
            {
                Text  = "Öneri",
                Value = Models.Type.Öneri.ToString()
            };
            SelectListItem Görüş = new SelectListItem()
            {
                Text  = "Görüş",
                Value = Type.Görüş.ToString()
            };

            SelectListItems.Add(Şikayet);
            SelectListItems.Add(Görüş);
            SelectListItems.Add(Öneri);
        }
Exemplo n.º 31
0
        public void CarregarDropDownLists()
        {
            SelectListItem item = new SelectListItem
            {
                Selected = true,
                Text     = "Selecione uma opção ...",
                Value    = string.Empty,
            };

            List <SelectListItem> selectListSalas = new List <SelectListItem> {
                item
            };

            List <Sala> salas = SalasFachada.ConsultarTodos();

            salas.ForEach(x => selectListSalas.Add(new SelectListItem
            {
                Text  = string.Concat(x.Nome, " - ", x.CapacidadeMaxima, " Lugares - ", x.ValorHora.ToString("C"), "/h"),
                Value = x.Id.ToString()
            }));

            ViewBag.VbSalas = selectListSalas;
        }
Exemplo n.º 32
0
        public List <SelectListItem> GetSemestersForDropDownList()
        {
            var semesters = aCourseManager.GetAllSemesters();

            List <SelectListItem> items = new List <SelectListItem>()
            {
                new SelectListItem()
                {
                    Value = "", Text = "--Select--"
                }
            };

            foreach (Semester item in semesters)
            {
                SelectListItem selectListItem = new SelectListItem()
                {
                    Value = item.Id.ToString(),
                    Text  = item.Name
                };
                items.Add(selectListItem);
            }
            return(items);
        }
Exemplo n.º 33
0
        private List <SelectListItem> GetSharedThemes()
        {
            List <SelectListItem> layouts = new List <SelectListItem>();

            string pathToViews = Path.Combine(_appBasePath, _options.SharedThemesFolderName);

            if (Directory.Exists(pathToViews))
            {
                var directoryInfo = new DirectoryInfo(pathToViews);
                var folders       = directoryInfo.GetDirectories();
                foreach (DirectoryInfo f in folders)
                {
                    SelectListItem layout = new SelectListItem
                    {
                        Text  = f.Name,
                        Value = f.Name
                    };
                    layouts.Add(layout);
                }
            }

            return(layouts);
        }
Exemplo n.º 34
0
        public ActionResult RegisterDietitian()
        {
            List <SelectListItem> lst = new List <SelectListItem>();

            using (DiabetEntities context = new DiabetEntities())
            {
                List <Parameter> lstP = context.Parameter.ToList();
                foreach (Parameter item in lstP)
                {
                    SelectListItem sItem = new SelectListItem()
                    {
                        Text = item.GroupName, Value = item.GroupCode.ToString()
                    };

                    lst.Add(sItem);
                }

                ViewBag.GetGender = new SelectList((List <SelectListItem>)lst, "Value", "Text");


                return(View());
            }
        }
Exemplo n.º 35
0
        public ActionResult Recettes(RecipesViewModels submitted)
        {
            model = DisplaySearchResult(submitted);
            var IngInList = db.Ingredients.ToList();
            List <SelectListItem> items = new List <SelectListItem>();

            foreach (var Ing in IngInList)
            {
                var item = new SelectListItem
                {
                    Value = Ing.id.ToString(),
                    Text  = Ing.name
                };
                items.Add(item);
            }
            MultiSelectList IngList = new MultiSelectList(items.OrderBy(i => i.Text), "Value", "Text");

            model.SelectIng = IngList;
            EditionLastAndNewRecipes.MeilleuresRecettes(model.NewAndBest.lastRecipes);
            EditionLastAndNewRecipes.DernieresRecettes(model.NewAndBest.bestRecipes);

            return(View(model));
        }
Exemplo n.º 36
0
        public static IEnumerable <SelectListItem> GetMonthList(int?selectedMonth = null, bool emptyFirstOption = false)
        {
            var monthList = new List <SelectListItem>();

            if (emptyFirstOption)
            {
                monthList.Add(new SelectListItem()
                {
                    Text = "", Value = ""
                });
            }
            foreach (Month entry in Enum.GetValues(typeof(Month)))
            {
                var month = new SelectListItem()
                {
                    Text     = entry.ToString(),
                    Value    = entry.ToInt().ToString(),
                    Selected = selectedMonth.HasValue && selectedMonth.Value == entry.ToInt()
                };
                monthList.Add(month);
            }
            return(monthList);
        }
Exemplo n.º 37
0
        public ActionResult GetDeptUser(string id)
        {
            try
            {
                if (Request.IsAjaxRequest())
                {
                    List<SelectListItem> ListS = new List<SelectListItem>();
                    SelectListItem sl = new SelectListItem();
                    sl.Text = "部门所有人可见";
                    sl.Value = "0";
                    ListS.Add(sl);
                    MembershipUserCollection users = Membership.GetAllUsers();
                    foreach (MembershipUser item in users)
                    {
                        sl = new SelectListItem();
                        ProfileBase objProfile = System.Web.Profile.ProfileBase.Create(item.UserName);
                        if (GetUserProfileItem(objProfile, "Department") == id)
                        {
                            sl.Text = GetUserProfileItem(objProfile, "NickName");
                            sl.Value = item.UserName;
                            ListS.Add(sl);
                        }

                    }
                    //.OrderBy(a => System.Web.Profile.ProfileBase.Create(a.UserName).GetPropertyValue("FirstName"));
                    return Json(ListS);
                }
                else
                {
                    return Content("-1");
                }
            }
            catch
            {
                return Content("-1");
            }
        }
Exemplo n.º 38
0
		public static IHtmlContent GenerateOption(SelectListItem item)
		{
			var tagBuilder = GenerateOption(item, item.Text);
			return tagBuilder;
		}
Exemplo n.º 39
0
        /// <summary>
        /// The query brand select list items.
        /// </summary>
        /// <param name="categoryID">
        /// The category id.
        /// </param>
        /// <returns>
        /// The <see cref="JsonResult"/>.
        /// </returns>
        public JsonResult QueryBrandSelectListItems(string categoryID)
        {
            if (string.IsNullOrEmpty(categoryID))
            {
                return null;
            }

            List<SelectListItem> selectListItems;
            try
            {
                selectListItems = new List<SelectListItem> { new SelectListItem { Value = "-1", Text = "请选择" } };

                var codition = string.Format("ProductCategoryID = {0} and layer = 1 ", categoryID);

                int totalCount;
                int pageCount;
                var paging = new Paging("[Product_Brand]", null, "ID", codition, 1, 30);
                var list = this.ProductBrandService.Query(paging, out pageCount, out totalCount);
                if (list == null)
                {
                    return this.Json(selectListItems, JsonRequestBehavior.AllowGet);
                }

                foreach (var brand in list)
                {
                    var selectListItem = new SelectListItem
                                             {
                                                 Value = brand.ID.ToString(CultureInfo.InvariantCulture),
                                                 Text = brand.BrandName,
                                             };

                    selectListItems.Add(selectListItem);
                }
            }
            catch (Exception exception)
            {
                throw new Exception(exception.Message, exception);
            }

            return this.Json(selectListItems, JsonRequestBehavior.AllowGet);
        }
Exemplo n.º 40
0
 public SelectListItem(SelectListItem item)
 {
     Text = item.Text;
     Value = item.Value;
     Selected = item.Selected;
 }
Exemplo n.º 41
0
        /// <summary>
        /// 根据父品牌编码查询子品牌数据
        /// </summary>
        /// <param name="parentBrandId">
        /// 父品牌编码
        /// </param>
        /// <returns>
        /// 查询结果
        /// </returns>
        public ActionResult QuerySubProductBrandByParentId(int parentBrandId)
        {
            var items = new List<SelectListItem>();
            var service = new ProductConsultService();
            var listSubBrand = service.QuerySubProductBrandByParentId(parentBrandId);
            if (listSubBrand == null)
            {
                return Json(null, JsonRequestBehavior.AllowGet);
            }

            foreach (var brand in listSubBrand)
            {
                var item = new SelectListItem()
                {
                    Text = brand.BrandName,
                    Value = brand.ID.ToString()
                };
                items.Add(item);
            }

            return Json(items, JsonRequestBehavior.AllowGet);
        }
Exemplo n.º 42
0
        /// <summary>
        /// The query sub category select list items.
        /// </summary>
        /// <param name="parentID">
        /// The parent id.
        /// </param>
        /// <returns>
        /// The <see cref="JsonResult"/>.
        /// </returns>
        public JsonResult QuerySubCategorySelectListItems(string parentID)
        {
            if (string.IsNullOrEmpty(parentID))
            {
                return null;
            }

            List<SelectListItem> selectListItems;
            try
            {
                var condtion = string.Format("ParentID = {0}", parentID);

                int totalCount;
                int pageCount;
                var paging = new Paging("[Product_Category]", null, "ID", condtion, 1, 100);
                var list = this.ProductCategoryService.Query(paging, out pageCount, out totalCount);

                selectListItems = new List<SelectListItem> { new SelectListItem { Value = "-1", Text = "请选择" } };
                if (list == null)
                {
                    return this.Json(selectListItems, JsonRequestBehavior.AllowGet);
                }

                foreach (var category in list)
                {
                    var selectListItem = new SelectListItem
                    {
                        Value = category.ID.ToString(CultureInfo.InvariantCulture),
                        Text = category.CategoryName,
                    };

                    selectListItems.Add(selectListItem);
                }
            }
            catch (Exception exception)
            {
                throw new Exception(exception.Message, exception);
            }

            return this.Json(selectListItems, JsonRequestBehavior.AllowGet);
        }
Exemplo n.º 43
0
        /// <summary>
        /// The query select list items.
        /// </summary>
        /// <returns>
        /// The <see cref="JsonResult"/>.
        /// </returns>
        public JsonResult QuerySelectListItems()
        {
            List<SelectListItem> selectListItems;
            try
            {
                int totalCount;
                int pageCount;
                var paging = new Paging("[Product_Category]", null, "ID", "ParentID = 0", 1, 10);
                var list = this.ProductCategoryService.Query(paging, out pageCount, out totalCount);
                if (list == null)
                {
                    return this.Json(null);
                }

                selectListItems = new List<SelectListItem> { new SelectListItem { Value = "-1", Text = "购酒网" } };
                foreach (var category in list)
                {
                    var selectListItem = new SelectListItem
                                             {
                                                 Value = category.ID.ToString(CultureInfo.InvariantCulture),
                                                 Text = category.CategoryName,
                                             };

                    selectListItems.Add(selectListItem);
                }
            }
            catch (Exception exception)
            {
                throw new Exception(exception.Message, exception);
            }

            return this.Json(selectListItems, JsonRequestBehavior.AllowGet);
        }
Exemplo n.º 44
0
        /// <summary>
        /// 查询所有短信列表.
        /// </summary>
        /// <returns>
        /// The <see cref="ActionResult"/>.
        /// </returns>
        public JsonResult QuerySelectSmsListItems()
        {
            List<User_Message_Sms> list;
            try
            {
                this.userMessageSmsService = new UserMessageSmsService();
                list = this.userMessageSmsService.QueryAll();
            }
            catch (Exception exception)
            {
                throw new Exception(exception.Message, exception);
            }

            if (list != null)
            {
                var items = new List<SelectListItem> { new SelectListItem { Value = "0", Text = "请选择" } };
                foreach (var sms in list)
                {
                    var selectListItem = new SelectListItem
                    {
                        Value = sms.ID.ToString(CultureInfo.InvariantCulture),
                        Text = sms.Name,
                    };
                    items.Add(selectListItem);
                }

                return this.Json(items, JsonRequestBehavior.AllowGet);
            }

            return this.Json(null, JsonRequestBehavior.AllowGet);
        }
Exemplo n.º 45
0
            protected override IEnumerable<SelectListItem> GetEnumSelectList(ModelMetadata metadata)
            {
                Metadata = metadata;
                SelectListItems = base.GetEnumSelectList(metadata);
                if (SelectListItems != null)
                {
                    // Perform a deep copy to help confirm the mutable items are not changed.
                    var copiedSelectListItems = new List<SelectListItem>();
                    CopiedSelectListItems = copiedSelectListItems;
                    foreach (var item in SelectListItems)
                    {
                        var copy = new SelectListItem
                        {
                            Disabled = item.Disabled,
                            Group = item.Group,
                            Selected = item.Selected,
                            Text = item.Text,
                            Value = item.Value,
                        };

                        copiedSelectListItems.Add(copy);
                    }
                }

                return SelectListItems;
            }
 public SelectListItem(SelectListItem item)
 {
 }