public bool SaveRoleAccessRightDetails(RoleAccessRightsBE roleAccessBE)
        {
            CommonDAL commondal = new CommonDAL();
            SqlConnection con = commondal.Connection();
            SqlCommand cmd = new SqlCommand();

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = "Sp_UM_RoleAccessRightUpdate";

            cmd.Parameters.Add("@PRAId", SqlDbType.Int).Value = roleAccessBE.PRAId;
            cmd.Parameters.Add("@RoleId", SqlDbType.Int).Value = roleAccessBE.RoleID;
            cmd.Parameters.Add("@AccessRights", SqlDbType.Int).Value = roleAccessBE.AddRec;
            cmd.Parameters.Add("@LastModifiedBy", SqlDbType.Int).Value = roleAccessBE.LastModifiedBy;

            cmd.Connection = con;
            //con.Open();

            int Count = cmd.ExecuteNonQuery();

            con.Close();

            if (Count == 2)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        public bool SaveRoleAccessRightDetails(RoleAccessRightsBE roleAccess)
        {
            RoleAccessRightsDAL roleAccessDAL = new RoleAccessRightsDAL();

            if (roleAccessDAL.SaveRoleAccessRightDetails(roleAccess))
            {
                return true;
            }
            else
            {
                return false;
            }

        }
        protected void ddlRoleId_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (ddlRoleId.SelectedItem.Value == "-Select-")
            {
                btnSave.Visible = false;
                lvRoleAccessRight.Visible = false;
                RoleAccessRightDataPager.Visible = false;
                ddlPageSize.Visible = false;
                lblSelect.Visible = false;
            }
            else
            {

                RoleAccessRightsBE RACCBE = new RoleAccessRightsBE();
                RoleAccessRightsBAL roleAccessBAL = new RoleAccessRightsBAL();
                DataTable dt = new DataTable();

                RACCBE.RoleID = Convert.ToInt32(ddlRoleId.SelectedItem.Value);
                hdnRoleId.Value = RACCBE.RoleID.ToString();
                RoleAccessRightDataPager.SetPageProperties(0, RoleAccessRightDataPager.PageSize, true);
                bindListView();
                recalcNoOfPages();
            }
        }
 public void AssignValueRoleAccessRightsBE(int iCell, ref RoleAccessRightsBE roleAccessBE, int Value)
 {
     switch (iCell)
     {
         case 5:
             roleAccessBE.AddRec = Value;
             break;
         case 7:
             roleAccessBE.AddRec = Value;
             break;
         case 9:
             roleAccessBE.AddRec = Value;
             break;
         case 11:
             roleAccessBE.ViewRec = Value;
             break;
         case 13:
             roleAccessBE.PrintRec = Value;
             break;
         case 15:
             roleAccessBE.Search = Value;
             break;
         case 17:
             roleAccessBE.Approve = Value;
             break;
     }
     recalcNoOfPages();
 }
        private void loadRoleAccessRightsBE(RoleAccessRightsBE roleAccessBE)
        {
            int a = 0;
            int count = 0;
            RoleAccessRightsBAL RACBAL = new RoleAccessRightsBAL();

            for (int iRow = 0; iRow < lvRoleAccessRight.Items.Count; iRow++)
            {
                for (int iCell = 5; iCell < lvRoleAccessRight.Items[0].Controls.Count - 1; iCell += 2)
                {
                    roleAccessBE.PRAId = Convert.ToInt32(lvRoleAccessRight.DataKeys[iRow].Value.ToString());
                    if (((CheckBox)lvRoleAccessRight.Items[iRow].Controls[iCell]).Checked)
                    {
                        a = 1;
                    }
                    else
                    {
                        a = 0;
                    }
                    AssignValueRoleAccessRightsBE(iCell, ref roleAccessBE, a);

                }

                if (RACBAL.SaveRoleAccessRightDetails(roleAccessBE))
                {
                    count = count + 1;
                    if (count == lvRoleAccessRight.Items.Count)
                    {

                        LoggedIn master = (LoggedIn)this.Master;
                        master.ShowMessage("Role Successfully Updated.", true);
                    }
               
                }
                else
                {
                     count = count + 1;
                     if (count == lvRoleAccessRight.Items.Count)
                     {
                         LoggedIn master = (LoggedIn)this.Master;
                         master.ShowMessage("Unsuccessful", false);
                     }
                }

            }

        }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (!commonBAL.isUserAuthorisedForPageFunc(LoggedInUser.UserId, thisPageName, "add"))
            {
                LoggedIn master = (LoggedIn)this.Master;
                master.ShowMessage("You are not authorised to perform this function. Please contact system administrator.", false);
                return;
            }
            RoleAccessRightsBAL roleAccessBAL = new RoleAccessRightsBAL();
            RoleAccessRightsBE roleAccessBE = new RoleAccessRightsBE();

            // roleAccessBE = loadRoleAccessRightsBE(roleAccessBE);
            roleAccessBE.RoleID = Convert.ToInt32(ddlRoleId.SelectedValue);
            roleAccessBE.LastModifiedBy = ((UserBE)Session["LoggedInUser"]).UserId;
            loadRoleAccessRightsBE(roleAccessBE);

        }