protected void ddlRoleId_SelectedIndexChanged(object sender, EventArgs e) { if (ddlRoleId.SelectedItem.Value == "-Select-") { lblSelect.Visible = false; ddlPageSize.Visible = false; lvRoleMember.Visible = false; RoleMemberDataPager.Visible = false; } else { RoleMemberBE roleMember = new RoleMemberBE(); RoleMemberBAL roleMemberBAL = new RoleMemberBAL(); DataTable dt = new DataTable(); roleMember.RoleId = Convert.ToInt32(ddlRoleId.SelectedItem.Value); hdnRoleId.Value = roleMember.RoleId.ToString(); RoleMemberDataPager.SetPageProperties(0, RoleMemberDataPager.PageSize, true); lblSelect.Visible = true; ddlPageSize.Visible = true; lvRoleMember.Visible = true; RoleMemberDataPager.Visible = true; bindlvRoleMember(); recalcNoOfPages(); } }
protected void lvRoleMember_OnItemCommand(object sender, ListViewCommandEventArgs e) { RoleMemberBAL roleMemberBAL = new RoleMemberBAL(); RoleMemberBE roleMember = new RoleMemberBE(); roleMember.LastModifiedBy = ((UserBE)Session["LoggedInUser"]).UserId; LoggedIn master = (LoggedIn)this.Master; if (String.Equals(e.CommandName, "Add")) { if (!commonBAL.isUserAuthorisedForPageFunc(LoggedInUser.UserId, thisPageName, "add")) { master.ShowMessage("You are not authorised to perform this function. Please contact system administrator.", false); return; } string[] arg = new string[2]; arg = e.CommandArgument.ToString().Split(','); roleMember.UserId = Convert.ToInt32(arg[0]); roleMember.RoleId = Convert.ToInt32(arg[1]); if (roleMemberBAL.AddRoleMember(roleMember)) { bindlvRoleMember(); recalcNoOfPages(); master.ShowMessage("Successfully Added.", true); } else { master.ShowMessage("Unsuccessful.", false); } lvRoleMember.EditIndex = -1; } else if (String.Equals(e.CommandName, "Remove")) { if (!commonBAL.isUserAuthorisedForPageFunc(LoggedInUser.UserId, thisPageName, "add")) { master.ShowMessage("You are not authorised to perform this function. Please contact system administrator.", false); return; } string[] arg = new string[2]; arg = e.CommandArgument.ToString().Split(','); roleMember.UserId = Convert.ToInt32(arg[0]); roleMember.RoleId = Convert.ToInt32(arg[1]); if (roleMemberBAL.DeleteRoleMember(roleMember)) { bindlvRoleMember(); recalcNoOfPages(); master.ShowMessage("Successfully Removed.", true); } else { master.ShowMessage("Unsuccessful.", false); } lvRoleMember.EditIndex = -1; } }
public void BindRoleIdDDL() { RoleMemberBAL roleMemberBAL = new RoleMemberBAL(); DataTable dt = new DataTable(); if (roleMemberBAL.GetAllRoleId(ref dt)) { ddlRoleId.DataSource = dt; ddlRoleId.DataTextField = "RoleShortDesc"; ddlRoleId.DataValueField = "RoleId"; ddlRoleId.DataBind(); ddlRoleId.Items.Insert(0, new ListItem("-Select-", "-Select-")); } }
private void bindlvRoleMember() { RoleMemberBE roleMember = new RoleMemberBE(); RoleMemberBAL roleMemberBAL = new RoleMemberBAL(); DataTable dt = new DataTable(); roleMember.RoleId = Convert.ToInt32(hdnRoleId.Value.ToString()); if (roleMemberBAL.GetAllRoleMembers(ref dt, ref roleMember)) { this.lvRoleMember.DataSource = dt; lvRoleMember.Visible = true; RoleMemberDataPager.Visible = true; lvRoleMember.DataBind(); recalcNoOfPages(); } else { LoggedIn master = (LoggedIn)this.Master; master.ShowMessage("Unsuccessful", false); } }