/// <summary> /// 新增 角色 /// </summary> /// <returns></returns> public ActionResult AddRole() { try { string rolename = Request["RoleName"]; string description = Request["Description"]; UserEntity uInfo = ViewData["Account"] as UserEntity; RoleEntity roleAdd = new RoleEntity(); roleAdd.RoleName = rolename.Trim(); roleAdd.Description = description.Trim(); roleAdd.CreateBy = uInfo.AccountName; roleAdd.CreateTime = DateTime.Now; roleAdd.UpdateBy = uInfo.AccountName; roleAdd.UpdateTime = DateTime.Now; int roleId = new RoleBLL().AddRole(roleAdd); if (roleId > 0) { return(Content("{\"msg\":\"添加成功!\",\"success\":true}")); } else { return(Content("{\"msg\":\"添加失败!\",\"success\":false}")); } } catch (Exception ex) { return(Content("{\"msg\":\"添加失败," + ex.Message + "\",\"success\":false}")); } }
public ActionResult Save() { Role role = new Role(); try { string stated = Request.Form["stated"]; role.Id = Convert.ToInt32(Request.Form["Id"]); role.roleName = Request.Form["roleName"]; role.roleRemark = Request.Form["roleRemark"]; RoleBLL rbll = new RoleBLL(); if (stated == "add") { if (rbll.AddEntity(role)) { return(Content("{'success':'ok'}")); } } else if (stated == "update") { if (rbll.ModifyEntity(role)) { return(Content("{'success':'ok'}")); } } } catch { } return(Content("{}")); }
protected void btnDelete_Click(object sender, EventArgs e) { string roleCodes = ""; for (int i = 0; i < gvRole.Rows.Count; i++) { CheckBox chkUser = (CheckBox)(gvRole.Rows[i].FindControl("chkRole")); if (chkUser.Checked) { HiddenField hfRoleCode = (HiddenField)(gvRole.Rows[i].FindControl("hfRoleCode")); roleCodes += hfRoleCode.Value + ";"; } } if (!string.IsNullOrEmpty(roleCodes) && roleCodes.LastIndexOf(';') == (roleCodes.Length - 1)) { roleCodes = roleCodes.Remove(roleCodes.LastIndexOf(';')); } if (!string.IsNullOrEmpty(roleCodes)) { //DBManager.DeleteRoles(roleCodes); RoleBLL bll = new RoleBLL(); bll.DeleteRoles(roleCodes); BindData(); } }
protected void btn_Delete_Click(object sender, ImageClickEventArgs e) { string idList = string.Empty; foreach (GridViewRow dr in GridView1.Rows) { CheckBox chk = (CheckBox)dr.FindControl("chk"); if (chk != null && chk.Checked) { string _id = "'" + dr.Cells[1].Text.Trim() + "'"; string _name = dr.Cells[2].Text.Trim(); if (_name == "系统管理员" || _name == "超级管理员" || _id.Substring(3, 4) == "0000") { UtilityService.Alert(this.Page, "禁止删除管理员及默认人员类别"); return; } idList += _id + ","; } } if (idList.Length > 0) { idList = idList.TrimEnd(','); bool re = new RoleBLL().DeleteList(idList); if (re) { UtilityService.AlertAndRedirect(this.Page, "删除成功!", "RoleMgr.aspx"); } else { UtilityService.Alert(this.Page, "删除失败!"); } } }
protected void btnSave_Click(object sender, ImageClickEventArgs e) { RoleBLL bll = new RoleBLL(); if (Action.ToUpper() == "EDIT") { if (bll.UpdateRole(RoleCode, txtRoleName.Text, ddlProcess.SelectedValue, ddlOrg.SelectedValue, Description.Text)) { ClientScript.RegisterStartupScript(this.GetType(), "", "<script>AlertAndNewLoad('更新成功');</script>"); } else { ExecAlertScritp("更新失败!"); } } else { if (bll.AddNewRole(txtRoleName.Text, ddlProcess.SelectedValue, ddlOrg.SelectedValue, Description.Text)) { ClientScript.RegisterStartupScript(this.GetType(), "", "<script>AlertAndNewLoad('添加成功');</script>"); } else { ExecAlertScritp("添加失败!"); } } }
public ActionResult AgentForDelete(Dictionary <string, string> queryvalues, AgentInfo model) { if (AgentInfoBLL.GetRecordCount(model.AgentID) > 0) { return(Json(new { result = Result.AccountOfTheLowerAgentMustBeEmpty })); } if (RoleBLL.GetRecordCount(model.AgentID) > 0) { return(Json(new { result = Result.AccountOfTheLowerMemberMustBeEmpty })); } AgentInfo mi = AgentInfoBLL.GetModelByID(model); AgentInfo Higher = AgentInfoBLL.GetModelByID(new AgentInfo { AgentID = mi.HigherLevel.Value }); Higher.AmountAvailable = Higher.AmountAvailable + mi.AmountAvailable; Higher.HavaAmount = Higher.HavaAmount - mi.AmountAvailable; AgentInfoBLL.Update(Higher); int result = AgentInfoBLL.Delete(model); if (result > 0) { return(Json(new { result = 0 })); } return(Json(new { result = 1 })); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { bool IsSysAdmin = true; bool IsSceAdmin = true; if (null == Session["IsSYS"] || (Boolean)Session["IsSYS"] != true) { IsSysAdmin = false; IsSceAdmin = false; AdminInfoBLL _AdminInfoBLL = new AdminInfoBLL(); RoleBLL _RoleBLL = new RoleBLL(); int AdminID = int.Parse(Session["AdminID"].ToString()); int RoleID = _RoleBLL.GetRoleIDByAdminID(AdminID); IsSceAdmin = _AdminInfoBLL.CheckFunction(RoleID, "酒店管理"); } if (!(IsSysAdmin || IsSceAdmin)) { Response.Redirect("../../NotAllowed.aspx"); } else { CityBind(); } } }
public static MvcHtmlString GetMasterLevel(this HtmlHelper htmlHelper, string name, int selectedValue) { IEnumerable <Role> group = RoleBLL.GetMasterLevelModels(); string optgroup = ""; string option = ""; string alloptgroup = ""; foreach (Role item in group) { if (selectedValue == item.ID) { option += " <option selected='selected' value = '" + item.ID + "' > " + item.Account + " </option >"; } else { option += " <option value = '" + item.ID + "' > " + item.Account + " </option >"; } } alloptgroup += option; alloptgroup = "<select style = 'width: 100 %;' class='select2' id=" + name + " name=" + name + ">" + "<option value='-1'> 所有用户</option>" + alloptgroup + "</select>"; return(new MvcHtmlString(alloptgroup)); }
protected void btnSave_Click(object sender, ImageClickEventArgs e) { Int32 records = 0; if (validateData()) { Entities.Role oRole = new Entities.Role(); oRole.Role_Id = Convert.ToInt32(txtCode.Text); oRole.Description = txtName.Text; oRole.State = Convert.ToInt32(cboState.SelectedValue); oRole.oListSystemModule = FillList(); if (RoleBLL.getInstance().exists(oRole.Role_Id)) { records = RoleBLL.getInstance().modify(oRole); } else { if (RoleBLL.getInstance().existsName(txtName.Text) == false) { records = RoleBLL.getInstance().insert(oRole);//To insert a role } else { lblMessage.Text = "Debe Utilizar otra descrpcion."; } } blockControls(); loadData(); if (records > 0) { lblMessage.Text = "Datos almacenados correctamente."; } } }
/// <summary> /// 获取角色列表 /// </summary> /// <param name="model"></param> /// <returns></returns> public ActionResult GetRoleList(RoleSearch model) { int totalCount = 0; var whereLambda = PredicateBuilder.True <Role>(); Expression <Func <Role, DateTime> > orderLambda = d => d.UpdateTime; if (!string.IsNullOrEmpty(model.Name)) { whereLambda = whereLambda.AndAlso(d => d.RoleName.Contains(model.Name)); } var roles = new RoleBLL().Get(orderLambda, whereLambda, model.Order, model.Rows, model.Page, out totalCount); var roleList = roles.Select(d => new RoleList { Id = d.Id, Name = d.RoleName, UpdateTime = d.UpdateTime, UpdateBy = d.UpdateBy, Description = d.Description }).ToList(); var result = new DataResult <RoleList> { total = totalCount, rows = roleList }; return(Json(result, JsonRequestBehavior.AllowGet)); }
public ActionResult Creat(Role model) { var result = new Result(); try { if (string.IsNullOrEmpty(model.RoleName)) { result.Msg = "角色名称不能为空"; return(Json(result)); } model.Id = Guid.NewGuid(); model.CreateBy = Users.AccountName; model.CreateTime = DateTime.Now; model.UpdateBy = Users.AccountName; model.UpdateTime = DateTime.Now; var role = new RoleBLL().Create(model); if (role != null) { result.Msg = "添加成功!"; result.Success = true; } else { result.Msg = "添加失败!"; } return(Json(result)); } catch (Exception ex) { result.Msg = string.Format("添加失败!{0}", ex.Message); return(Json(result)); } }
public ActionResult RoleMenu(RoleMenuModel model) { var result = new Result(); try { if (model.RoleId == Guid.Empty) { result.Msg = "角色Id不能为空"; return(Json(result)); } var isSuceess = new RoleBLL().Authorize(model); if (isSuceess) { result.Msg = "授权成功!"; result.Success = true; } else { result.Msg = "授权失败!"; } return(Json(result)); } catch (Exception ex) { result.Msg = string.Format("授权失败!{0}", ex.Message); return(Json(result)); } }
public ActionResult Del(Guid id) { var result = new Result(); try { if (id == Guid.Empty) { result.Msg = "角色Id不能为空"; return(Json(result)); } var isSuccess = new RoleBLL().Del(id); if (isSuccess) { result.Msg = "删除成功!"; result.Success = true; } else { result.Msg = "删除失败!"; } return(Json(result)); } catch (Exception ex) { result.Msg = string.Format("删除失败!{0}", ex.Message); return(Json(result)); } }
public JsonResult AddNewRoleApps() { string _status = MyEnums.enumStatus.SUCCESS.ToString(); int result = 0; RoleModel roleMdl = new RoleModel(); if (Request.Form["Id"] == "") { roleMdl.RoleName = Request.Form["Role"].ToString(); roleMdl.CreatedBy = "SYSTEM"; roleMdl.CreatedDate = DateTime.Now; result = new RoleBLL().Insert(roleMdl, out _status); } else { roleMdl.RoleName = Request.Form["Role"].ToString(); roleMdl.Id = Convert.ToInt32(Request.Form["Id"].ToString()); roleMdl.ModifiedBy = "SYSTEM"; roleMdl.ModifiedDate = DateTime.Now; result = new RoleBLL().Update(roleMdl, out _status); } return(Json(new { Status = _status, Result = result }, JsonRequestBehavior.AllowGet)); }
private void button25_Click(object sender, EventArgs e) { Workflow wf = new Workflow(); RoleBLL bll = new RoleBLL(); bll.UpdateRole(new AddRoleServiceForm { Authority = new List <AuthorityNodeForCheck> { new AuthorityNodeForCheck { ID = "1", Checked = true, }, new AuthorityNodeForCheck { ID = "2", Checked = true, } }, ID = "3", }); var roles = bll.Query(new RoleQueryForm { ID = "3" }); }
protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e) { UserBLL userBLL = new UserBLL(); RoleBLL roleBLL = new RoleBLL(); GroupBLL groupBLL = new GroupBLL(); string UserName = ((TextBox)CreateUserWizardStep1.ContentTemplateContainer.FindControl("UserName")).Text; int roleID = Convert.ToInt32(((DropDownList)CreateUserWizardStep1.ContentTemplateContainer.FindControl("ddlRoles")).SelectedValue); int groupID = Convert.ToInt32(((DropDownList)CreateUserWizardStep1.ContentTemplateContainer.FindControl("ddlGroups")).SelectedValue); Role role = roleBLL.GetRoleByRoleID(roleID); User user = userBLL.GetUserByUserName_WithoutApplication(UserName); Group group = groupBLL.GetGroupByGroupID(groupID); roleBLL.AddUserToRole(user, role); groupBLL.AddUserToGroup(user, group); Label lblEmail = (Label)CompleteWizardStep1.ContentTemplateContainer.FindControl("lblEmail"); Label lblUserType = (Label)CompleteWizardStep1.ContentTemplateContainer.FindControl("lblUserType"); Label lblGroup = (Label)CompleteWizardStep1.ContentTemplateContainer.FindControl("lblGroup"); lblEmail.Text = UserName; lblUserType.Text = ((DropDownList)CreateUserWizardStep1.ContentTemplateContainer.FindControl("ddlRoles")).SelectedItem.Text; lblGroup.Text = ((DropDownList)CreateUserWizardStep1.ContentTemplateContainer.FindControl("ddlGroups")).SelectedItem.Text; Response.Redirect("~/secured/admin/users.aspx", true); }
public ActionResult GetEmployee() { try { int pageIndex = Convert.ToInt32(Request.QueryString["page"]); int pageSize = Convert.ToInt32(Request.QueryString["limit"]); string branchIds = Request.QueryString["id"]; string[] _ids = branchIds.Split(','); int[] ids = Array.ConvertAll <string, int>(_ids, id => { return(int.Parse(id)); }); EmployeeBLL eBll = new EmployeeBLL(); int rows = 0; int totalPages = 0; List <Employee> list = eBll.LoadPagedEntitys(pageIndex, pageSize, out rows, out totalPages, t => ids.Contains(t.branchId), true, t => t.Id); if (list != null && list.Count > 0) { List <Branch> branchList = new BranchBLL().GetEntitys(); list.ForEach(t => { branchList.ForEach(y => { if (t.branchId == y.Id) { t.branchName = y.branchName; } }); }); List <Role> roleList = new RoleBLL().GetEntitys(); list.ForEach(t => { roleList.ForEach(y => { if (t.roleId == y.Id) { t.roleName = y.roleName; } }); }); List <Position> positionList = new PositionBLL().GetEntitys(); list.ForEach(t => { positionList.ForEach(y => { if (t.positionId == y.Id) { t.positionName = y.positionName; } }); }); } string resJson = Common.Common.JsonSerialize(list); resJson = "{total:" + rows + ",root:" + resJson + "}"; return(Content(resJson)); } catch { } return(Content("{}")); }
public ActionResult UpdateRole(int userID, string userFullName, int roleID, RoleModel iRoleModel) { // Must be admin to access view if (((LoginModel)Session["loginModel"]) != null && ((LoginModel)Session["loginModel"]).RoleIDFK == 1) { ViewBag.ID = userID; ViewBag.FullName = userFullName; RoleMapper iRoleMapper = new RoleMapper(); Role iRole = new Role(); iRole = iRoleMapper.MapRole(iRoleModel); RoleBLL iRoleBLL = new RoleBLL(); List <Role> listRoles = iRoleBLL.CollectRoles(iRole); /* Get Role values from database and set it to * viewbag to pass it to view for drop downlist*/ IEnumerable <SelectListItem> roles = listRoles.Select(m => new SelectListItem { Value = m.RoleID.ToString(), Text = m.RoleName }); ViewBag.RoleId = roles; return(View(listRoles)); } else { return(RedirectToAction("login", "home")); } }
// GET: Role/Create public ActionResult Create() { RoleBLL defRole = new RoleBLL(); defRole.RoleID = 0; return(View(defRole)); }
public RoleController() { _roleBll = new RoleBLL(); _commonBll = new CommonBll(); _moduleBll = new ModuleBLL(); _organizationBll = new OrganizationBLL(); }
private void btnOk_Click(object sender, EventArgs e) { //判断验证码 if (skinCode1.CodeStr.ToLower() != txtCode.Text.ToLower()) { SelfForm.Msbox.Show("验证码不正确"); return; } //建立Role对象 Role model = new Role(); model.Name = txtName.Text.Trim(); model.Submitter_id = frmMain.current_user.Id; model.Remark = txtRemark.Text; //根据反射设置role的权限 Type type = model.GetType(); foreach (var permission in cklbPermission.CheckedItems) { type.GetProperty(permission.ToString()).SetValue(model, 1, null); } RoleBLL bll = new RoleBLL(); SelfForm.Msbox.Show(bll.AddRole(model) ? "添加成功" : "添加失败请重试"); }
/// <summary> /// 删除多个角色用户 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void bnDelete_Click(object sender, ImageClickEventArgs e) { if (this.GridView1.Rows.Count > 0) { RoleBLL bll = new RoleBLL(); string ids = ""; foreach (GridViewRow item in GridView1.Rows) { CheckBox ckSelect = (CheckBox)item.FindControl("ckSelect"); if (ckSelect.Checked) { if (string.IsNullOrEmpty(ids)) { ids = GridView1.DataKeys[item.RowIndex].Values[0].ToString(); } else { ids += "," + GridView1.DataKeys[item.RowIndex].Values[0].ToString(); } } } bool ret = bll.DeleteUserFromRoleUser(ids); if (ret) { LoadRoleUserMes(); ExecAlertScritp("删除成功!"); } else { ExecAlertScritp("删除失败!"); } } }
//管理员角色绑定 private void AdminRoleBind(int AdminID) { AdminInfoBLL _AdminInfoBLL = new AdminInfoBLL(); bool IsSys = _AdminInfoBLL.IsSys(AdminID); if (IsSys) { this.DropDownRole.Items.Clear(); ListItem item = new ListItem("系统管理员"); this.DropDownRole.Items.Add(item); this.DropDownRole.Enabled = false; } else { //与角色表中的数据绑定 RoleBLL _RoleBLL = new RoleBLL(); DataTable DT = _RoleBLL.GetAllRoleInfo(); DropDownRole.Items.Clear(); DropDownRole.DataSource = DT; DropDownRole.DataTextField = "RoleName"; DropDownRole.DataValueField = "RoleID"; DropDownRole.DataBind(); //获得当前编辑对象的管理角色个数 AdminRoleBLL _AdminRoleBLL = new AdminRoleBLL(); int AdminRoleCount = _AdminRoleBLL.GetCountByAdminID(AdminID); if (AdminRoleCount > 0) { int RoleID = _RoleBLL.GetRoleIDByAdminID(AdminID); DropDownRole.SelectedValue = RoleID.ToString(); } } }
//加载所有角色信息根据删除标识 0----未删除,1---一已删除 private void LoadAllRolesByDelFlag(int delFlag) { RoleBLL bll = new RoleBLL(); dgvRole.AutoGenerateColumns = false; //不自动创建列 dgvRole.DataSource = bll.GetAllRoleInfoByDelFlag(delFlag); }
private void Bind() { RoleBLL _RoleBLL = new RoleBLL(); ResourceBLL _ResourceBLL = new ResourceBLL(); //角色名绑定 int RoleID = int.Parse(Request.QueryString["RoleID"].ToString()); String RoleResName = Request.QueryString["RoleResName"].ToString(); String RoleName = _RoleBLL.GetRoleNameByRoleID(RoleID); this.txtRole.Text = RoleName; this.txtRole.Enabled = false; //绑定DropDownList DataTable DT = _ResourceBLL.GetAllResource(); DropDownRes.Items.Clear(); DropDownRes.DataSource = DT; DropDownRes.DataTextField = "ResourceName"; DropDownRes.DataValueField = "ResourceID"; DropDownRes.DataBind(); //锁定到当前资源名 if ("" != RoleResName) { int ResID = _ResourceBLL.GetIDByResName(RoleResName); this.DropDownRes.SelectedValue = ResID.ToString(); } }
private CommonRecive CallbackData(Dictionary <string, string> queryvalues, string billNo) { CommonRecive model = new CommonRecive(); int UserID = queryvalues.ContainsKey("UserID") ? Convert.ToInt32(queryvalues["UserID"].ToString()) : 0; int Type = queryvalues.ContainsKey("Type") ? Convert.ToInt32(queryvalues["Type"].ToString()) : 1; decimal Money = queryvalues.ContainsKey("Money") ? Convert.ToDecimal(queryvalues["Money"].ToString()) : 0; string ProductID = queryvalues.ContainsKey("ProductID") ? queryvalues["ProductID"].ToString() : ""; double Discounted = queryvalues.ContainsKey("Discounted") ? Convert.ToDouble(queryvalues["Discounted"].ToString()) : 0; string URL = queryvalues.ContainsKey("URL") ? queryvalues["URL"].ToString() : ""; model.Appid = "1103881749"; model.Amt = (int)(((int)Money * 100) * Discounted * 0.1); model.Sign = "123"; model.URL = ""; model.Payitem = billNo + "*" + Money + "*1"; model.Billno = billNo; model.URL = monicallbackUrl + "/" + URL; Role r = RoleBLL.GetModelByID(new Role() { ID = UserID }); model.Openid = r.OpenID; return(model); }
public ActionResult LeftTreeMenu() { var leftTreeMenuHtml = WebCache.GetLeftMenuCache(LoginUser); if (leftTreeMenuHtml == null) { if (LoginUser.IsAdmin) { leftTreeMenuHtml = new ResourceBLL().GetLeftTreeMenu(null); } else { var role = new RoleBLL().GetModel(i => i.ID == LoginUser.RoleID); if (role != null && !string.IsNullOrEmpty(role.ResourceID)) { var resourceIdArray = role.ResourceID.Split(','); var resourceIdList = new List<int>(); foreach (var resourceId in resourceIdArray) { resourceIdList.Add(Convert.ToInt32(resourceId)); } leftTreeMenuHtml = new ResourceBLL().GetLeftTreeMenu(resourceIdList); } } WebCache.SetLeftMenuCache(LoginUser, leftTreeMenuHtml ?? ""); } return Content(leftTreeMenuHtml); }
public void RoleAddIdList(HttpContext context) { int RoleId = 0; if (!string.IsNullOrEmpty(GetParam("RoleId ", context).ToString())) { RoleId = Convert.ToInt32(GetParam("RoleId ", context).ToString()); } string objOrder = GetParam("RoleModel", context); Role roleobj = JsonConvert.DeserializeObject <Role>(objOrder); roleobj.RoleType = 1; roleobj.RoleStatus = 1; roleobj.IsDeleted = 0; RoleBLL rolebll = new RoleBLL(); int result = 0; if (roleobj.RoleName != "") { if (roleobj.RoleId > 0) { //编辑 result = rolebll.Update(roleobj) ? 1 : 0; } else { result = rolebll.Add(roleobj); } } context.Response.Write(result); }
public List <Role> BindRole() { var roleBLL = new RoleBLL(); var roleList = roleBLL.GetAll(new Role(), ""); return(roleList); }
/// <summary> /// 删除事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void GridRole_DeleteCommand(object sender, GridCommandEventArgs e) { //获取Grid的主键值 string GridKey = e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["RoleID"].ToString(); RoleUserBLL Role_UserBLLs = new RoleUserBLL(); tblRole_User tblRole_Users = Role_UserBLLs.GetByRoleID(GridKey); if (tblRole_Users != null) { if (tblRole_Users.RoleID != null) { //正在使用不能删除! 警告Admin Can't delete! string strInfo = GetGlobalResourceObject("en_US", "RoleManagerForm_DeleteInfo").ToString(); RadWindowManager1.RadAlert(strInfo, 300, 100, "Warn", ""); return; } } RoleBLL RoleBLLs = new RoleBLL(); if (GridKey != string.Empty) { RoleBLLs.Delete(GridKey); } this.GridViewData(); }
protected override bool DeletingItem(object item) { RoleBLL bll = new RoleBLL(AppSettings.Current.ConnStr); Role info = (Role)item; CommandResult result = bll.Delete(info); if (result.Result != ResultCode.Successful) { MessageBox.Show(result.Message, "删除失败", MessageBoxButtons.OK, MessageBoxIcon.Warning); } return result.Result == ResultCode.Successful; }
protected override List<object> GetDataSource() { RoleBLL bll = new RoleBLL(AppSettings.Current.ConnStr); if (SearchCondition == null) { roles = bll.GetItems(null).QueryObjects.ToList(); } else { roles = bll.GetItems(SearchCondition).QueryObjects.ToList(); } List<object> source = new List<object>(); foreach (object o in roles) { source.Add(o); } return source; }
public void Init() { RoleBLL bll = new RoleBLL(AppSettings.Current.ConnStr); List<Role> roles = bll.GetItems(null).QueryObjects; if (roles != null) roles.Insert(0, new Role()); this.DataSource = roles; this.DisplayMember = "Name"; this.DropDownStyle = ComboBoxStyle.DropDownList; }