private void tsbAdd_Click(object sender, EventArgs e) { if (tsbtxtRoleName.Text == "") { MessageBox.Show("请输入要添加的角色名称!"); } else { if (RoleBll.GetRole(tsbtxtRoleName.Text)) { try { RoleBll.AddRole(tsbtxtRoleName.Text); dataGridView1.DataSource = RoleBll.RoleFillDs().Tables[0]; MessageBox.Show("添加成功!"); } catch (Exception ee) { MessageBox.Show("添加失败!" + ee); throw; } } else { MessageBox.Show("角色已存在!"); } } }
/// <summary>添加角色 /// </summary> /// <param name="name">角色名称</param> /// <param name="isSuper">是否为管理员</param> /// <returns></returns> public ActionResult AddRole(string name, int isSuper) { RoleBll roleBll = new RoleBll(); bool result = roleBll.AddRole(new RoleEntity() { Name = name, IsSuper = isSuper }); return(Json(result)); }
public IActionResult Add(Role model) { var rst = new ReturnResult <bool>(); using var bll = new RoleBll(); if (model.id == 0) { model.role_id = EncryptHelper.CreateGuid(); rst = bll.AddRole(model); } else { rst = bll.UpdateRole(model); } return(Json(rst)); }