123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.Mvc;
- using Autofac;
- using Bowin.Web.Controls.Mvc;
- using EMIS.Utility;
- using EMIS.CommonLogic.AdministrativeOrgan;
- using EMIS.CommonLogic.SystemServices;
- using EMIS.ViewModel;
- namespace EMIS.Web.Controls
- {
- public static class CheckListExtentions
- {
- public static MvcHtmlString UserCampusList(this HtmlHelper htmlHelper,
- ListControlOptions listControlOptions, Guid userID,
- System.Collections.Generic.IDictionary<string, string> htmlAttributes = null)
- {
- using (var scope = AutofacHelper.Container.BeginLifetimeScope())
- {
- ICampusServices CampusServices = scope.Resolve<ICampusServices>();
- IUserServices UserServices = scope.Resolve<IUserServices>();
- var campusList = CampusServices.GetCampusListWithoutDataRange().Select(x => new ListControlItem { Text = x.Name, Value = x.CampusID });
- var userCampusList = UserServices.GetUserInchargeCampus(userID);
- listControlOptions.ItemList = campusList.ToList();
- listControlOptions.SelectedValues = userCampusList.Select(x => (object)x.CampusID).ToList();
- }
- return MvcHtmlString.Create(Bowin.Web.Controls.Mvc.CheckList.CreateControl(listControlOptions, htmlAttributes).Render());
- }
- public static MvcHtmlString UserCollegeList(this HtmlHelper htmlHelper,
- ListControlOptions listControlOptions, Guid userID,
- System.Collections.Generic.IDictionary<string, string> htmlAttributes = null)
- {
- using (var scope = AutofacHelper.Container.BeginLifetimeScope())
- {
- ICollegeServices CollegeServices = scope.Resolve<ICollegeServices>();
- IUserServices UserServices = scope.Resolve<IUserServices>();
- var collegeList = CollegeServices.GetCollegeViewListWithoutDataRange().Select(x => new ListControlItem { Text = x.Name, Value = x.CollegeID });
- var userCollegeList = UserServices.GetUserInchargeCollege(userID);
- listControlOptions.ItemList = collegeList.ToList();
- listControlOptions.SelectedValues = userCollegeList.Select(x => (object)x.CollegeID).ToList();
- }
- return MvcHtmlString.Create(Bowin.Web.Controls.Mvc.CheckList.CreateControl(listControlOptions, htmlAttributes).Render());
- }
- public static MvcHtmlString UserDepartmentList(this HtmlHelper htmlHelper,
- ListControlOptions listControlOptions, Guid userID,
- System.Collections.Generic.IDictionary<string, string> htmlAttributes = null)
- {
- using (var scope = AutofacHelper.Container.BeginLifetimeScope())
- {
- IDepartmentServices DepartmentServices = scope.Resolve<IDepartmentServices>();
- IUserServices UserServices = scope.Resolve<IUserServices>();
- var departmentList = DepartmentServices.GetDepartmentList().Select(x => new ListControlItem { Text = x.Name, Value = x.DepartmentID });
- var userDepartmentList = UserServices.GetUserInchargeDepartment(userID);
- listControlOptions.ItemList = departmentList.ToList();
- listControlOptions.SelectedValues = userDepartmentList.Select(x => (object)x.DepartmentID).ToList();
- }
- return MvcHtmlString.Create(Bowin.Web.Controls.Mvc.CheckList.CreateControl(listControlOptions, htmlAttributes).Render());
- }
- public static MvcHtmlString UserRoleList(this HtmlHelper htmlHelper,
- ListControlOptions listControlOptions, Guid userID,
- System.Collections.Generic.IDictionary<string, string> htmlAttributes = null)
- {
- using (var scope = AutofacHelper.Container.BeginLifetimeScope())
- {
- IRoleServices RoleServices = scope.Resolve<IRoleServices>();
- IUserServices UserServices = scope.Resolve<IUserServices>();
- var roleList = RoleServices.GetEnabledTeacherRoleViewList().Select(x => new ListControlItem { Text = x.RoleName, Value = x.RoleID });
- var userRoleList = UserServices.GetUserRoles(userID);
- listControlOptions.ItemList = roleList.ToList();
- listControlOptions.SelectedValues = userRoleList.Select(x => (object)x.RoleID).ToList();
- }
- return MvcHtmlString.Create(Bowin.Web.Controls.Mvc.CheckList.CreateControl(listControlOptions, htmlAttributes).Render());
- }
- /// <summary>
- /// 列出字典表的项的多选列表
- /// </summary>
- /// <param name="htmlHelper"></param>
- /// <param name="dictionaryItem"></param>
- /// <param name="listControlOptions"></param>
- /// <param name="htmlAttributes"></param>
- /// <returns></returns>
- public static MvcHtmlString DictionaryCheckList(this HtmlHelper htmlHelper, DictionaryItem dictionaryItem,
- ListControlOptions listControlOptions, System.Collections.Generic.IDictionary<string, string> htmlAttributes = null)
- {
- if (listControlOptions == null)
- {
- listControlOptions = new ListControlOptions();
- }
- listControlOptions.ItemList = DictionaryHelper.GetDictionaryValue(dictionaryItem).Where(x => x.RecordStatus == (int)SYS_STATUS.USABLE)
- .Select(x => new ListControlItem { Text = x.Name, Value = x.Value }).ToList();
- return MvcHtmlString.Create(Bowin.Web.Controls.Mvc.CheckList.CreateControl(listControlOptions, htmlAttributes).Render());
- }
- }
- }
|