protected void rpRoleList_ItemCommand(object source, RepeaterCommandEventArgs e) { if (e.CommandName == "Add") { if (e.Item.ItemType == ListItemType.Header) { TextBox txtRoleNameAdd = e.Item.FindControl("txtRoleNameAdd") as TextBox; Role role = new Role() { Role_Name = txtRoleNameAdd.Text, IsActive = true }; RoleDAL dal = new RoleDAL(); dal.AddRole(role); dal.Save(); } } else if (e.CommandName == "Delete") { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { HiddenField hfId = e.Item.FindControl("hfId") as HiddenField; RoleDAL dal = new RoleDAL(); dal.DeleteRole(int.Parse(hfId.Value)); } } Utility.BindDataToRepeater(rpRoleList, GetRoleList()); SetFocus(source); Response.Redirect("AccessControlManagement.aspx?tabno=2"); }
/// <summary> /// Delete a role /// </summary> /// <param name="roleName">Name of role that you want to delete.</param> /// <returns>Return the number of rows affected or return -1 if occur exception.</returns> public void DeleteRole(String roleName) { Role deleteRole = GetRole(roleName); int result = RD.DeleteRole(deleteRole.Role_Name); if (result == -1) { throw new Exception("An error occurred while executing this operation."); } }
public bool DeleteRole(RoleBE role) { RoleDAL roleDAL = new RoleDAL(); if (roleDAL.DeleteRole(role)) { return(true); } else { return(false); } }
/// <summary> /// To Delete Role /// </summary> /// <param name="roleID"></param> /// <returns></returns> public string DeleteRole(int roleID) { RoleDAL objRoleDAL = new RoleDAL(); return(objRoleDAL.DeleteRole(roleID)); }
public int DeleteRole(int RoleID) { return(rdal.DeleteRole(RoleID)); }
public IEnumerable <SalonAPI.Models.RoleDAL.tblRoles> Delete_Role(int RoleId) { return(objRole.DeleteRole(RoleId)); }
public void RoleDALMenu() { while (true) { System.Console.WriteLine("Welcome in Role"); System.Console.WriteLine("c - Create"); System.Console.WriteLine("r - read one"); System.Console.WriteLine("rall - read all"); System.Console.WriteLine("u - update"); System.Console.WriteLine("d - delete"); System.Console.WriteLine("else - exit"); string a = System.Console.ReadLine(); switch (a) { case "c": System.Console.WriteLine("Input RoleName:"); role = dal.CreateRole(new RoleDTO { RoleName = System.Console.ReadLine() }); System.Console.WriteLine("You add the: Id - " + role.RoleId + " Name - " + role.RoleName); System.Console.WriteLine("Press any key"); System.Console.WriteLine(""); System.Console.WriteLine(""); System.Console.ReadKey(); break; case "r": System.Console.Write("Choose Id: "); role = dal.GetRoleById(System.Convert.ToInt32(System.Console.ReadLine())); System.Console.WriteLine("You read the: Id - " + role.RoleId + " Name - " + role.RoleName); System.Console.WriteLine("Press any key"); System.Console.WriteLine(""); System.Console.WriteLine(""); System.Console.ReadKey(); break; case "rall": List <RoleDTO> categories = dal.GetAllRole(); for (int i = 0; i < role.Count; i++) { System.Console.WriteLine("Id - " + role[i].RoleId + " Name - " + role[i].RoleName); } System.Console.WriteLine("Press any key"); System.Console.WriteLine(""); System.Console.WriteLine(""); System.Console.ReadKey(); break; case "u": System.Console.WriteLine("Update Name:"); role = dal.UpdateRole(new RoleDTO { RoleName = System.Console.ReadLine() }); System.Console.WriteLine("You add the: Id - " + role.RoleId + " Name - " + role.RoleName); System.Console.WriteLine("Press any key"); System.Console.WriteLine(""); System.Console.WriteLine(""); System.Console.ReadKey(); break; case "d": System.Console.WriteLine("Choose Id:"); dal.DeleteRole(System.Convert.ToInt32(System.Console.ReadLine())); System.Console.WriteLine("Delete successful"); System.Console.WriteLine("Press any key"); System.Console.WriteLine(""); System.Console.WriteLine(""); System.Console.ReadKey(); break; case "else": break; } } }
/// <summary> /// 删除单个角色信息 /// </summary> /// <param name="roleId"></param> /// <param name="delType">0 ---logic 1= real</param> /// <returns></returns> public bool DeleteRoleLogic(int roleId) { return(roleDAL.DeleteRole(roleId, 0)); }