public HttpResponseMessage Post([FromBody] SysRole sysRoleInfo) { return(ActionWarpper.Process(sysRoleInfo, OperationCodes.ASYSRL, () => { var sysRoleRepo = RepositoryManager.GetRepository <ISysRoleRepository>(); var sysRolePermissionRepo = RepositoryManager.GetRepository <ISysRolePermissionRepository>(); if (sysRoleInfo == null) { return Request.CreateResponse(HttpStatusCode.BadRequest, "sysRoleInfo is null"); } sysRoleRepo.Insert(sysRoleInfo); sysRoleInfo.SysRolePermissions.ForEach(x => sysRolePermissionRepo.Insert(x)); return Request.CreateResponse(HttpStatusCode.OK, sysRoleInfo); }, this)); }
public virtual void Create(ref ValidationErrors errors, Apps.Models.Sys.SysRoleModel model) { SysRole entity = m_Rep.GetById(model.Id); if (entity != null) { errors.Add(Resource.PrimaryRepeat); return; } entity = new SysRole(); entity.Id = model.Id; entity.Name = model.Name; entity.Description = model.Description; entity.CreateTime = model.CreateTime; entity.CreatePerson = model.CreatePerson; m_Rep.Create(entity); }
public ActionResult Create(SysRole entity, string FunctionIDs) { try { entity.SysMenuList = Container.Instance.Resolve <IServiceSysMenu>().Qry(new List <ICriterion>() { Expression.In("ID", AppHelper.StrToArray(FunctionIDs)) }); Container.Instance.Resolve <IServiceSysRole>().Add(entity); return(RedirectToAction("Index")); } catch { return(View(entity)); } }
private void toolStripMenuItemAddSub_Click(object sender, EventArgs e) { UltraTreeNode node = ultraTreeRole.ActiveNode; if (node != null) { SysRole role = node.Tag as SysRole; DlgRoleEdit dlg = new DlgRoleEdit(role, EditType.AddChild, this.Action); if (dlg.ShowDialog(this) == DialogResult.OK) { SysRole cRole = dlg.Role; UltraTreeNode child = new UltraTreeNode(cRole.RoleId); child.Text = cRole.RoleName; child.Tag = cRole; node.Nodes.Add(child); } } }
public CustomJsonResult CreateRole(int operater, SysRole role) { var isExistName = _db.SysRole.Where(m => m.Name == role.Name).FirstOrDefault(); if (isExistName != null) { return(new CustomJsonResult(ResultType.Failure, ResultCode.Failure, "该用户名已经存在")); } role.PId = 0; role.CreateTime = DateTime.Now; role.Creator = operater; _db.SysRole.Add(role); _db.SaveChanges(); AddOperateHistory(operater, Enumeration.OperateType.New, role.Id, string.Format("新建角色{0}(ID:{1})", role.Name, role.Id)); return(new CustomJsonResult(ResultType.Success, ResultCode.Success, "添加成功")); }
public ActionResult Create(string id) { if (!string.IsNullOrWhiteSpace(id)) { using (SysMenuBLL bll = new SysMenuBLL()) { SysMenu entityId = bll.GetById(id); if (entityId != null) { SysRole entity = new SysRole(); entity.SysMenuId = id + '&' + entityId.Name; return(View(entity)); } } } return(View()); }
/// <summary> /// 保存 /// </summary> /// <param name="mo"></param> /// <returns></returns> public string SaveSysRole(SysRole mo, string savetype) { int num = 0; using (var ru = new RepositoryUse()) { if (savetype == "add") { mo.CreateTime = DateTime.Now; num = ru.SysRoleRepository.Insert(mo); } else { num = ru.SysRoleRepository.Update(mo); } } return(num > 0 ? "success" : "fail"); }
public bool Register(String name, String description) { if (_roleRepository.GetFilter(it => it.Name.Equals(name)).FirstOrDefault() != null) { //throw new DomainException(Constant.ROLE_REPEATED); throw new DomainBusinessException(Constant.ROLE_REPEATED); } else { SysRole role = new SysRole() { Name = name, Description = description }; _roleRepository.Add(role); _unitOfWork.Commit(); return(true); } }
public JsonResult Add(RoleModel model) { var identityManager = new AspNetIdentiyAuthorizeRelay <SysUser>(CurrentDb); if (!identityManager.RoleExists(model.Name)) { SysRole role = new SysRole(); role.PId = model.PId; role.Name = model.Name; role.Description = model.Description; identityManager.CreateRole(role); return(Json(ResultType.Success, ManagerOperateTipUtils.ADD_SUCCESS)); } else { return(Json(ResultType.Failure, ManagerOperateTipUtils.ROLE_EXISTS)); } }
public async Task <ActionResult> AuthModule(string id) { //var roleMenus = await SysRoleMenuDAL.QueryUserRole(u => u.RoleId == Convert.ToInt32(id), null, null); //(List<SysMenu> list, long count) menus = await SysMenuDAL.QueryAsync(w => w.Status == 1); //ViewBag.Menus = menus.list.Select(s => new SelectListItem { Selected = roleMenus.list.Exists(ss => ss.RoleId == s.Id), Text = s.MenuName, Value = s.Id.ToString() }).ToList(); SysRole model = new SysRole() { }; if (!string.IsNullOrEmpty(id) && id != "0") { int _id = Convert.ToInt32(id); model = await SysRoleDAL.GetByOneAsync(w => w.Id == _id); } return(View(model)); }
private void BindRoles() { try { List <SysRole> roleList = SysRole.GetRoleList(); if (roleList != null) { this.drpRole.DataSource = roleList; this.drpRole.DataBind(); this.drpRole.Items.Insert(0, "--请选择--"); } } catch { this.PrintfError("数据错"); return; } }
public SysRoleModel GetById(string id) { if (IsExist(id)) { SysRole entity = m_Rep.GetById(id); SysRoleModel model = new SysRoleModel(); model.Id = entity.Id; model.Name = entity.Name; model.Description = entity.Description; model.CreateTime = entity.CreateTime; model.CreatePerson = entity.CreatePerson; return(model); } else { return(null); } }
public ActionResult Index(int?page, int?size, string msg, AlertMsgType?msgType) { SysRole role = CurrentUser.Role(3).Role(); ViewBag.canWrite = role.SysRolePermission.Where(x => x.MenuId == 3920 && x.PermissionId == 2 && x.PermissionFlag).Count() > 0; ViewBag.canDelete = role.SysRolePermission.Where(x => x.MenuId == 3920 && x.PermissionId == 3 && x.PermissionFlag).Count() > 0; List <SysRole> lst = new List <SysRole>(); try { if (!string.IsNullOrWhiteSpace(msg)) { WidgetAlertModel alert = new WidgetAlertModel() { Message = msg }; if (msgType.HasValue) { alert.Type = msgType.Value; } ViewBag.Alert = alert; } int total = uow.Role.Counts(SITE_ID); WidgetPaginationModel Pagination = new WidgetPaginationModel("Index", "Role", "") { Page = (page ?? 1), Size = (size ?? 10), SortExp = "", Total = total }; ViewBag.Pagination = Pagination; lst = uow.Role.Gets(Pagination.Page, Pagination.Size, SITE_ID); } catch (Exception ex) { WidgetAlertModel Alert = new WidgetAlertModel() { Type = AlertMsgType.Danger, Message = ex.GetMessage() }; ViewBag.Alert = Alert; } return(View(lst)); }
/// <summary> /// 获取岗位 /// </summary> /// <param name="UserId">人员Id</param> /// <returns>岗位</returns> public static string getPost(string UserId, string DeptId, string type) { string result = ""; string pk_gw = ""; if (string.IsNullOrEmpty(UserId)) { return(""); } string MiddleDBName = ConfigurationManager.AppSettings["MiddleDBName"]; string workNo = SysUser.Find(UserId).WorkNo; if (type == "CompanyId") { pk_gw = DataHelper.QueryValue("select top 1 PK_gw from " + MiddleDBName + "..fld_ryxx where psncode='" + workNo + "' and pk_corp='" + DeptId + "'") + ""; } else { //有可能一个公司有多条,根据部门Path取 int gws = DataHelper.QueryValue <int>("select count(1) from " + MiddleDBName + "..fld_ryxx where psncode='" + workNo + "' and pk_corp=(select top 1 pk_corp from " + MiddleDBName + "..fld_bmml where pk_deptdoc='" + DeptId + "')"); if (gws > 1) { string path = DataHelper.QueryValue("select [path]+GroupId from SysGroup where GroupId='" + DeptId + "'") + ""; pk_gw = DataHelper.QueryValue("select top 1 pk_gw from " + MiddleDBName + "..fld_ryxx where psncode='" + workNo + "' and '" + path + "' like '%'+ pk_deptdoc+'%'") + ""; } else { pk_gw = DataHelper.QueryValue("select top 1 PK_gw from " + MiddleDBName + "..fld_ryxx where psncode='" + workNo + "' and pk_corp=(select top 1 pk_corp from " + MiddleDBName + "..fld_bmml where pk_deptdoc='" + DeptId + "')") + ""; } } if (string.IsNullOrEmpty(pk_gw)) { pk_gw = DataHelper.QueryValue("select top 1 PK_gw from SysUser where UserId='" + UserId + "' and isnull(outdutydate,'')=''") + ""; } SysRole role = SysRole.TryFind(pk_gw); if (role != null) { result = role.Name; } return(result); }
public ActionResult Delete(int id) { try { SysRole role = CurrentUser.Role(3).Role(); bool canDelete = role.SysRolePermission.Where(x => x.MenuId == 3220 && x.PermissionId == 3 && x.PermissionFlag).Count() > 0; if (!canDelete) { return(RedirectToAction("Index", "KPT", new { msg = "ไม่มีสิทธิ์ในการลบข้อมูล", msgType = AlertMsgType.Danger })); } TblKpt ob = db.TblKpt.Find(id); if (ob == null) { return(RedirectToAction("Index", "KPT", new { msg = "ไม่พบข้อมูลที่ต้องการ", msgType = AlertMsgType.Warning })); } var subs = db.TblKptDetail.Where(x => x.KptId == id); db.TblKptDetail.RemoveRange(subs); var stations = db.TblKptStation.Where(x => x.KptId == id); var stationAttachs = db.TblKptStationAttachment.Where(x => stations.Select(y => y.StationId).Contains(x.StationId)); List <string> imgsPath = stationAttachs.Select(x => x.AttachPath).ToList(); var stationDetails = db.TblKptStationDetail.Where(x => stations.Select(y => y.StationId).Contains(x.StationId)); db.TblKptStationDetail.RemoveRange(stationDetails); db.TblKptStationAttachment.RemoveRange(stationAttachs); db.TblKptStation.RemoveRange(stations); db.TblKpt.Remove(ob); db.SaveChanges(); if (imgsPath.Count() > 0) { foreach (string path in imgsPath) { string svPath = Server.MapPath("~/" + path); if (FileIO.Exists(svPath)) { FileIO.Delete(svPath); } } } return(RedirectToAction("Index", "KPT", new { msg = "ลบข้อมูลเรียบร้อยแล้ว", msgType = AlertMsgType.Success })); } catch (Exception ex) { return(RedirectToAction("Index", "KPT", new { msg = ex.GetMessage(), msgType = AlertMsgType.Danger })); } }
public ActionResult QueryData() { int page = Request.Form["page"] != "" ? Convert.ToInt32(Request.Form["page"]) : 0; int size = Request.Form["rows"] != "" ? Convert.ToInt32(Request.Form["rows"]) : 0; string sort = Request.Form["sort"] != "" ? Request.Form["sort"] : ""; string order = Request.Form["order"] != "" ? Request.Form["order"] : ""; string Name = Request.Form["Name"] != null ? Request.Form["Name"] : ""; SysRole sysRole = new SysRole() { Name = Name }; if (page < 1) { return(Content("")); } var lstSysRole = SysRoleDao.Instance.LoadPageList(page, size, sysRole).ToList(); JsonHelper json = new JsonHelper(); string strJson = string.Empty; foreach (SysRole item in lstSysRole) { json.AddItem("ID", item.ID.ToString()); json.AddItem("Name", item.Name); json.AddItem("Description", item.Description == null ? string.Empty : item.Description); //item.RoleNames = SysRoleServices.GetRoleNames(item.ID); //json.AddItem("RoleNames", item.RoleNames); json.ItemOk(); } json.totlalCount = SysRoleDao.Instance.GetTotalCount(sysRole); if (json.totlalCount > 0) { strJson = json.ToEasyuiGridJsonString(); } else { strJson = @"[]"; } // json = "{ \"rows\":[ { \"ID\":\"48\",\"NewsTitle\":\"mr\",\"NewsContent\":\"mrsoft\",\"CreateTime\":\"2013-12-23\",\"CreateRole\":\"ceshi\",\"ModifyTime\":\"2013-12-23\",\"ModifyRole\":\"ceshi\"} ],\"total\":3}"; return(Content(strJson)); }
public ActionResult Create(SysRole role) { try { if (ModelState.IsValid) { role.Status = Convert.ToInt32(Request.Form["ModelState"]); role.Remark = Request.Form["Remark"]; logic.AddRole(role); return(this.RefreshParent()); } SetViewBagData(); return(View()); } catch (Exception ex) { return(this.Back("新增角色改模块发生异常。" + ex.Message)); } }
/// <summary> /// 将数据插入表 /// </summary> /// <param name="M">赋值后的实体</param> /// <returns></returns> public static void Insert(SysRole M) { IDbHelper Sql = GetHelper(); StringBuilder sb = new StringBuilder(); sb.Append("insert into [SysRole]([RoleName],[RoleGroup],[URL],[AddRole],[EditRole],[DelRole]) values("); sb.Append("N'" + M.RoleName + "'"); sb.Append(","); sb.Append(M.RoleGroup.ToS()); sb.Append(","); sb.Append("N'" + M.URL + "'"); sb.Append(","); sb.Append(M.AddRole.ToS()); sb.Append(","); sb.Append(M.EditRole.ToS()); sb.Append(","); sb.Append(M.DelRole.ToS()); sb.Append(")"); if (DataBase.CmsDbType == DataBase.DbType.SqlServer) { sb.Append(";select @@Identity"); } if (DataBase.CmsDbType == DataBase.DbType.SQLite) { sb.Append(";select last_insert_rowid()"); } if (DataBase.CmsDbType == DataBase.DbType.MySql) { sb.Append(";select LAST_INSERT_ID()"); } if (DataBase.CmsDbType == DataBase.DbType.Access) { sb.Append(";select max(ID) from SysRole"); } if (DataBase.CmsDbType == DataBase.DbType.Oracle) { sb.Append(";select LAST_INSERT_ID()"); } M.ID = Sql.ExecuteScalar(CommandType.Text, sb.ToString()).ToInt32(); }
public HttpResponseMessage Put(int id, [FromBody] SysRole sysRoleInfo) { return(ActionWarpper.Process(sysRoleInfo, OperationCodes.MSYSRL, () => { sysRoleInfo.RoleID = id; var sysRoleRepo = RepositoryManager.GetRepository <ISysRoleRepository>(); var sysRolePermissionRepo = RepositoryManager.GetRepository <ISysRolePermissionRepository>(); var originalsysRoleInfo = sysRoleRepo.GetByKey(id); if (originalsysRoleInfo == null) { return Request.CreateResponse(HttpStatusCode.BadRequest, string.Format("role Id={0} does not exist.", id)); } #region role permissions var addedPermissions = new List <SysRolePermission>(); var deletedPermissionIds = new List <int>(); if (sysRoleInfo.SysRolePermissions != null && sysRoleInfo.SysRolePermissions.Any()) { var originalPermissionIDs = originalsysRoleInfo.SysRolePermissions.Select(d => d.SysRolePermissionID); var currentPermissionIDs = sysRoleInfo.SysRolePermissions.Select(d => d.SysRolePermissionID); deletedPermissionIds = originalPermissionIDs.Except(currentPermissionIDs).ToList(); addedPermissions = sysRoleInfo.SysRolePermissions.FindAll(d => d.SysRolePermissionID == 0); deletedPermissionIds.ForEach(d => sysRolePermissionRepo.Delete(d)); addedPermissions.ForEach(d => sysRolePermissionRepo.Insert(d)); sysRoleInfo.SysRolePermissions.FindAll(d => d.SysRolePermissionID != 0).ForEach(d => sysRolePermissionRepo.Update(d)); } else { deletedPermissionIds = originalsysRoleInfo.SysRolePermissions.Select(d => d.SysRolePermissionID).ToList(); deletedPermissionIds.ForEach(d => sysRolePermissionRepo.Delete(d)); } #endregion sysRoleRepo.Update(sysRoleInfo); return Request.CreateResponse(HttpStatusCode.OK); }, this)); }
/// <summary> /// DataTable转换为list /// </summary> /// <param name="dt"></param> /// <returns></returns> protected static List <SysRole> DataTableToList(DataTable dt) { List <SysRole> Ms = new List <SysRole>(); for (int i = 0; i < dt.Rows.Count; i++) { SysRole M = new SysRole(); M.ID = dt.Rows[i]["ID"].ToInt32(); M.RoleName = dt.Rows[i]["RoleName"].ToString(); M.RoleGroup = dt.Rows[i]["RoleGroup"].ToInt32(); M.URL = dt.Rows[i]["URL"].ToString(); M.AddRole = dt.Rows[i]["AddRole"].ToBoolean(); M.EditRole = dt.Rows[i]["EditRole"].ToBoolean(); M.DelRole = dt.Rows[i]["DelRole"].ToBoolean(); Ms.Add(M); } return(Ms); }
public string SaveSysRole(SysRole mo, string savetype) { int num = 0; using (var db = new ContextBase()) { if (savetype == "add") { mo.CreateTime = DateTime.Now; db.SysRole.Add(mo); } else { db.SysRole.Update(mo); } num = db.SaveChanges(); } return(num > 0 ? "success" : "fail"); }
public ActionResult Insert(FormCollection form) { string writeMsg = string.Empty; SysRole item = new SysRole(); item.Name = Request.Form["Name"] != "" ? Request.Form["Name"] : ""; item.Description = Request.Form["Description"] != "" ? Request.Form["Description"] : ""; bool result = SysRoleDao.Instance.Insert(item); if (result) { writeMsg = "{msg:\"保存成功!\",id:" + item.ID.ToString() + "}"; } else { writeMsg = "{msg:\"保存失败!\",id:0}"; } return(Content(writeMsg)); }
/// <summary> /// 添加权限信息 /// </summary> /// <param name="sysMenuDto"></param> /// <returns></returns> public async Task AddAsync(IEnumerable <SysPermissionDto> sysMenuDto) { List <SysPermission> sysRoleMenus = new List <SysPermission>(); string RoleId = sysMenuDto.FirstOrDefault().RoleId; SysRole sysRole = await _sysRoleService.GetObjectAsync(_ => _.Id == RoleId); // foreach (var item in sysMenuDto) { item.RoleCode = sysRole.RoleCode; SysPermission sysPermission = new SysPermission(item); sysRoleMenus.Add(sysPermission); } #region 正确方式1 传统方式 //var db = BaseData.BaseDB.BaseDataContext; //IEnumerable<SysPermission> entitis = await db.Set<SysPermission>().Where(o => o.RoleId == sysMenuDto.FirstOrDefault().RoleId).ToListAsync(); //db.Set<SysPermission>().RemoveRange(entitis); //db.Set<SysPermission>().AddRange(sysRoleMenus); //await db.SaveChangesAsync(); //await DbToCacheAsync();//暂时 #endregion #region 异常方法 //await BeginTransactionAsync(async () => //{ // IEnumerable<SysPermission> entitis = await GetFullListAsync(_ => _.RoleId == sysMenuDto.FirstOrDefault().RoleId); // await DeleteAllAsync(entitis); // await SaveObjectListAsync(sysRoleMenus); // await DbToCacheAsync();//暂时 //}); #endregion #region 正确方式2 多次调用DbContext.SaveChanges 方式 // https://docs.microsoft.com/zh-cn/ef/core/miscellaneous/connection-resiliency#execution-strategies-and-transactions await ServiceBase.ResilientTransaction.New(BaseData.BaseDB.BaseDataContext).ExecuteAsync(async() => { IEnumerable <SysPermission> entitis = await GetFullListAsync(_ => _.RoleId == sysMenuDto.FirstOrDefault().RoleId); await DeleteAllAsync(entitis); // 此处会调用SaveChangeAsync await SaveObjectListAsync(sysRoleMenus); // 此处会调用SaveChangeAsync await DbToCacheAsync(); //暂时 }); #endregion }
/// <summary> /// 添加 /// </summary> /// <param name="entity"></param> /// <param name="qx"></param> /// <returns></returns> public int Add(SysRole entity, string qx) { entity.AddTime = DateTime.Now; db.SysRoles.Add(entity); if (!string.IsNullOrWhiteSpace(qx)) { foreach (var item in qx.Split(',')) { int route_id = TypeHelper.ObjectToInt(item); db.SysRoleRoutes.Add( new SysRoleRoute() { SysRole = entity, SysRouteID = route_id } ); } } return(db.SaveChanges()); }
public ActionResultVM CopySysRoleAuth(SysRole mo, string copyid) { var vm = new ActionResultVM(); var list = db.SysRole.Where(x => x.SrId == mo.SrId || x.SrId == copyid).ToList(); var copymo = list.Find(x => x.SrId == copyid); foreach (var item in list) { item.SrMenus = copymo.SrMenus; item.SrButtons = copymo.SrButtons; } db.SysRole.UpdateRange(list); int num = db.SaveChanges(); vm.Set(num > 0); return(vm); }
/// <summary> /// 更新角色信息 /// </summary> /// <param name="model"></param> /// <returns></returns> public int Update(SysRole model) { using (var db = GetInstance()) { model.IsEnabled = model.IsEnabled == null ? "0" : "1"; model.AllowEdit = model.AllowEdit == null ? "0" : "1"; model.ModifyUser = OperatorProvider.Instance.Current.Account; model.ModifyTime = DateTime.Now; return(db.Updateable <SysRole>(model).UpdateColumns(it => new { it.Name, it.IsEnabled, it.Remark, it.SortCode, it.ModifyUser, it.ModifyTime }).ExecuteCommand()); } }
public virtual IHttpActionResult Add(SysRoleAddRequest request) { var entity = new SysRole { }; var result = _sysRoleService.Add(entity); if (result > 0) { return(Succeed(new SysRoleAddResponse { Id = entity.Id }, "新增成功")); } else { return(Fail("新增失败")); } }
private string Transaction(List <SysDataAuth> lstdataAuth) { try { bool isInOrg = true; SysRole role = null; if (lstdataAuth.Count > 0) { string sysRoleId = lstdataAuth[0].SysRoleId; role = DataContext.SysRole.FirstOrDefault(p => p.SysRoleId == sysRoleId); if (role != null) { isInOrg = role.SysOrganization.IsInterior; } } foreach (SysDataAuth item in lstdataAuth) { if (!isInOrg) { string orgId = item.SysOrganizationId; if (DataContext.SysOrganization.Count(g => g.SysOrganizationId == orgId && g.IsInterior == true) > 0) { return("<=OrgOfAuthDataIsError>"); } } DataContext.SysDataAuth.Attach(item); DataContext.Entry(item).State = string.IsNullOrEmpty(item.SysDataAuthId) ? EntityState.Added : EntityState.Modified; if (string.IsNullOrEmpty(item.SysDataAuthId)) { item.SysDataAuthId = Guid.NewGuid().ToString(); } DataContext.SaveChanges(); } return(""); } catch (Exception ex) { return(ex.Message); } }
public JsonResult SaveRole() { var data = Request.GetArrayList("data"); var sysRoleDal = flexibleContext.GetService <SysRoleDal>(); string siteID = Request.GetSqlParamer("SiteID"); for (int i = 0, l = data.Count; i < l; i++) { Hashtable o = (Hashtable)data[i]; String id = o["ID"] != null ? o["ID"].ToString() : ""; //根据记录状态,进行不同的增加、删除、修改操作 String state = o["_state"] != null ? o["_state"].ToString() : ""; String roleName = o["RoleName"].ToString(); decimal sortNo = Convert.ToDecimal(o["SortNo"]); if (state == "added" || id == "") //新增:id为空,或_state为added { SysRole model = new SysRole(); model.ID = "{" + Guid.NewGuid().ToString() + "}"; model.RoleName = roleName; model.SortNo = sortNo; model.WebSiteID = siteID; sysRoleDal.Insert(model); } else if (state == "removed" || state == "deleted") { sysRoleDal.DeleteExt(id); } else if (state == "modified" || state == "") //更新:_state为空或modified { var model = sysRoleDal.GetModel(id); model.RoleName = roleName; model.SortNo = sortNo; sysRoleDal.Update(model, x => x.ID); } } var result = new { }; return(Json(result)); }
public IActionResult Change(string id) { var pid = FytRequest.GetQueryString("pid"); SysRole model = new SysRole(); var rel_list = new List <string>(); using (var db = SugarBase.GetIntance()) { if (!string.IsNullOrEmpty(id)) { model = db.Queryable <SysRole>().Where(m => m.RoleID == id).First(); var rel_list1 = db.Queryable <SysRoleModule>().Where(m => m.RoleID == model.RoleID).ToList(); if (rel_list1 != null) { foreach (var item in rel_list1) { rel_list.Add(item.ModuleID); } } } else { model.RoleID = ""; } var menu_list = db.Queryable <SysModule>().ToList(); if (rel_list.Count > 0) { foreach (var item in menu_list) { if (rel_list.Contains(item.ID)) { item.LAY_CHECKED = true; } } } ViewBag.MenuList = menu_list; ViewBag.RelMenuList = rel_list; } return(View(model)); }
//保存 private void btnSave_Click(object sender, EventArgs e) { try { this.Cursor = Cursors.WaitCursor; if (validationProvider.Validate()) { SysRole role; string code = groupHeader.Tag.ToString().Split('|')[1]; if (groupHeader.Tag.ToString().StartsWith("NEW")) { role = new SysRole(); role.RoleCode = txtRoleCode.Text.Trim(); role.ModifyUser = Identity.CurrentUser.UserName; role.ModifyDate = DateTime.Now; } else { role = dataSource.Find(obj => obj.RoleCode == code); } role.RoleName = txtRoleName.Text.Trim(); if (groupHeader.Tag.ToString().StartsWith("NEW")) WcfServiceHelper.Client.InsertRole(role); else WcfServiceHelper.Client.UpdateRole(role); BindList(); popupContainer.Hide(); ControlsHelper.ShowAlertMessage(this.ParentForm, "保存", "保存成功"); } } catch (Exception ex) { ControlsHelper.ShowErrorMessage("保存失败", ex.Message); } finally { this.Cursor = Cursors.Default; } }
public void SaveRole() { string proleid = Parameters["proleid"]; string prolename = Parameters["prolename"]; string proledesc = Parameters["proledesc"]; SysRoleBiz biz = new SysRoleBiz(); SysRole item = new SysRole(); item.FRoleId = string.IsNullOrEmpty(proleid) ? 0 : Convert.ToInt64(proleid); item.FRoleName = prolename; item.FRoleDesc = proledesc; ErrorEntity ErrInfo = new ErrorEntity(); if (item.FRoleId == 0) { biz.Insert(item, out ErrInfo); } else { biz.Update(item, out ErrInfo); } Response.Write(ErrInfo.ToJson()); }
public void GetRoleData() { string _id = Parameters["pid"]; SysRoleBiz biz = new SysRoleBiz(); SysRole item = new SysRole(); item = biz.Select(_id); string datasource = Utils.ConvertToJson(item); Response.Write(datasource); }
public void Insert(string FpSBranchID,long IParentRole,string SRoleName,string SEngRoleName,int? IOrder,long? FkIFunctionID,DateTime? TDateCreated,string SImgPath,string SDesc,string SIconPath,int? IntShortCutKey,int? IsMid) { SysRole item = new SysRole(); item.FpSBranchID = FpSBranchID; item.IParentRole = IParentRole; item.SRoleName = SRoleName; item.SEngRoleName = SEngRoleName; item.IOrder = IOrder; item.FkIFunctionID = FkIFunctionID; item.TDateCreated = TDateCreated; item.SImgPath = SImgPath; item.SDesc = SDesc; item.SIconPath = SIconPath; item.IntShortCutKey = IntShortCutKey; item.IsMid = IsMid; item.Save(UserName); }
public void AddToSysRole(SysRole sysRole) { base.AddObject("SysRole", sysRole); }
public static SysRole CreateSysRole(int id) { SysRole sysRole = new SysRole(); sysRole.ID = id; return sysRole; }
public void Update(long IRole,string FpSBranchID,long IParentRole,string SRoleName,string SEngRoleName,int? IOrder,long? FkIFunctionID,DateTime? TDateCreated,string SImgPath,string SDesc,string SIconPath,int? IntShortCutKey,int? IsTabView,string SParameterList,int? IsMultiview,int? BEnabled) { SysRole item = new SysRole(); item.MarkOld(); item.IsLoaded = true; item.IRole = IRole; item.FpSBranchID = FpSBranchID; item.IParentRole = IParentRole; item.SRoleName = SRoleName; item.SEngRoleName = SEngRoleName; item.IOrder = IOrder; item.FkIFunctionID = FkIFunctionID; item.TDateCreated = TDateCreated; item.SImgPath = SImgPath; item.SDesc = SDesc; item.SIconPath = SIconPath; item.IntShortCutKey = IntShortCutKey; item.IsTabView = IsTabView; item.SParameterList = SParameterList; item.IsMultiview = IsMultiview; item.BEnabled = BEnabled; item.Save(UserName); }