Exemple #1
0
    public DataTable GetMenuAccess(int?User_Id, int?Menu_Id)
    {
        try
        {
            return(objMenuBLL.Get_MenuAccess(User_Id, Menu_Id));
        }

        catch
        {
            throw;
        }
    }
 protected void Page_Load(object sender, EventArgs e)
 {
     UserAccessValidation();
     if (!IsPostBack)
     {
         fill_mainmodules();
         Load_DepartmentList_filter();
         DataTable dt = objBLL.Get_MenuAccess(null, null);
         RadGrid1.DataSource = dt;
         RadGrid1.DataBind();
     }
 }
    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        try
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                Label Menu_Link = (Label)e.Row.FindControl("lblLink");
                if (Menu_Link.Text.ToLower() == "infrastructure/dashboard_common.aspx" || Menu_Link.Text.ToLower() == "infrastructure/dashboard.aspx")
                {
                    CheckBox checkView     = (CheckBox)e.Row.FindControl("Access_View");
                    CheckBox checkMenu     = (CheckBox)e.Row.FindControl("Access_Menu");
                    CheckBox checkAdd      = (CheckBox)e.Row.FindControl("Access_Add");
                    CheckBox checkEdit     = (CheckBox)e.Row.FindControl("Access_Edit");
                    CheckBox checkDelete   = (CheckBox)e.Row.FindControl("Access_Delete");
                    CheckBox checkApprove  = (CheckBox)e.Row.FindControl("Access_Approve");
                    CheckBox checkAdmin    = (CheckBox)e.Row.FindControl("Access_Admin");
                    CheckBox checkUnverify = (CheckBox)e.Row.FindControl("Unverify");
                    CheckBox checkRevoke   = (CheckBox)e.Row.FindControl("Revoke");
                    CheckBox checkUrgent   = (CheckBox)e.Row.FindControl("Urgent");
                    CheckBox checkClose    = (CheckBox)e.Row.FindControl("Close");
                    CheckBox checkUnclose  = (CheckBox)e.Row.FindControl("Unclose");


                    //checkView.Checked = true;
                    //checkView.Enabled = false;

                    //checkMenu.Checked = true;
                    //checkMenu.Enabled = false;
                    //checkAdd.Checked = true;
                    //checkAdd.Enabled = false;
                    //checkEdit.Checked = true;
                    //checkEdit.Enabled = false;
                    //checkDelete.Checked = true;
                    //checkDelete.Enabled = false;
                    //checkApprove.Checked = true;
                    //checkApprove.Enabled = false;
                    //checkAdmin.Checked = true;
                    //checkAdmin.Enabled = false;
                    //checkUnverify.Checked = true;
                    //checkUnverify.Enabled = false;
                    //checkRevoke.Checked = true;
                    //checkRevoke.Enabled = false;
                    //checkUrgent.Checked = true;
                    //checkUrgent.Enabled = false;
                    //checkClose.Checked = true;
                    //checkClose.Enabled = false;
                    //checkUnclose.Checked = true;
                    //checkUnclose.Enabled = false;
                }
                else
                {
                    Label     Menu_Id = (Label)e.Row.FindControl("Menu_Id");
                    DataTable dt      = objMenuBLL.Get_MenuAccess(null, Convert.ToInt32(Menu_Id.Text));

                    #region loop
                    for (Int32 i = 0; i < dt.Rows.Count; i++)
                    {
                        if (dt.Rows[i]["Key_Name"].ToString() == "Access_View")
                        {
                            CheckBox check     = (CheckBox)e.Row.FindControl("Access_View");
                            CheckBox checkMenu = (CheckBox)e.Row.FindControl("Access_Menu");
                            if (Convert.ToBoolean(dt.Rows[i]["Key_Enabled"]) == true)
                            {
                                check.Enabled     = true;
                                checkMenu.Enabled = true;
                            }
                            else
                            {
                                check.Enabled     = false;
                                checkMenu.Enabled = false;
                                // check.Checked = false;
                            }
                            check.Text = dt.Rows[i]["Description"].ToString();
                        }
                        if (dt.Rows[i]["Key_Name"].ToString() == "Access_Add")
                        {
                            CheckBox check = (CheckBox)e.Row.FindControl("Access_Add");
                            if (Convert.ToBoolean(dt.Rows[i]["Key_Enabled"]) == true)
                            {
                                check.Enabled = true;
                            }
                            else
                            {
                                check.Enabled = false;
                                //  check.Checked = false;
                            }
                            check.Text = dt.Rows[i]["Description"].ToString();
                        }
                        if (dt.Rows[i]["Key_Name"].ToString() == "Access_Edit")
                        {
                            CheckBox check = (CheckBox)e.Row.FindControl("Access_Edit");
                            if (Convert.ToBoolean(dt.Rows[i]["Key_Enabled"]) == true)
                            {
                                check.Enabled = true;
                            }
                            else
                            {
                                check.Enabled = false;
                                //  check.Checked = false;
                            }
                            check.Text = dt.Rows[i]["Description"].ToString();
                        }
                        if (dt.Rows[i]["Key_Name"].ToString() == "Access_Delete")
                        {
                            CheckBox check = (CheckBox)e.Row.FindControl("Access_Delete");
                            if (Convert.ToBoolean(dt.Rows[i]["Key_Enabled"]) == true)
                            {
                                check.Enabled = true;
                            }
                            else
                            {
                                check.Enabled = false;
                                //  check.Checked = false;
                            }
                            check.Text = dt.Rows[i]["Description"].ToString();
                        }
                        if (dt.Rows[i]["Key_Name"].ToString() == "Access_Approve")
                        {
                            CheckBox check = (CheckBox)e.Row.FindControl("Access_Approve");
                            if (Convert.ToBoolean(dt.Rows[i]["Key_Enabled"]) == true)
                            {
                                check.Enabled = true;
                            }
                            else
                            {
                                check.Enabled = false;
                                // check.Checked = false;
                            }
                            check.Text = dt.Rows[i]["Description"].ToString();
                        }
                        if (dt.Rows[i]["Key_Name"].ToString() == "Access_Admin")
                        {
                            CheckBox check = (CheckBox)e.Row.FindControl("Access_Admin");
                            if (Convert.ToBoolean(dt.Rows[i]["Key_Enabled"]) == true)
                            {
                                check.Enabled = true;
                            }
                            else
                            {
                                check.Enabled = false;
                                //   check.Checked = false;
                            }
                            check.Text = dt.Rows[i]["Description"].ToString();
                            if (ViewState["UserType"].ToString().ToLower() != "admin")
                            {
                                check.Enabled = false;
                            }
                        }

                        if (dt.Rows[i]["Key_Name"].ToString() == "Unverify")
                        {
                            CheckBox check = (CheckBox)e.Row.FindControl("Unverify");
                            if (Convert.ToBoolean(dt.Rows[i]["Key_Enabled"]) == true)
                            {
                                check.Enabled = true;
                            }
                            else
                            {
                                check.Enabled = false;
                                // check.Checked = false;
                            }
                            check.Text = dt.Rows[i]["Description"].ToString();
                        }
                        if (dt.Rows[i]["Key_Name"].ToString() == "Revoke")
                        {
                            CheckBox check = (CheckBox)e.Row.FindControl("Revoke");
                            if (Convert.ToBoolean(dt.Rows[i]["Key_Enabled"]) == true)
                            {
                                check.Enabled = true;
                            }
                            else
                            {
                                check.Enabled = false;
                                //   check.Checked = false;
                            }
                            check.Text = dt.Rows[i]["Description"].ToString();
                        }
                        if (dt.Rows[i]["Key_Name"].ToString() == "Urgent")
                        {
                            CheckBox check = (CheckBox)e.Row.FindControl("Urgent");
                            if (Convert.ToBoolean(dt.Rows[i]["Key_Enabled"]) == true)
                            {
                                check.Enabled = true;
                            }
                            else
                            {
                                check.Enabled = false;
                                //  check.Checked = false;
                            }
                            check.Text = dt.Rows[i]["Description"].ToString();
                        }
                        if (dt.Rows[i]["Key_Name"].ToString() == "Close")
                        {
                            CheckBox check = (CheckBox)e.Row.FindControl("Close");
                            if (Convert.ToBoolean(dt.Rows[i]["Key_Enabled"]) == true)
                            {
                                check.Enabled = true;
                            }
                            else
                            {
                                check.Enabled = false;
                                //    check.Checked = false;
                            }
                            check.Text = dt.Rows[i]["Description"].ToString();
                        }
                        if (dt.Rows[i]["Key_Name"].ToString() == "Unclose")
                        {
                            CheckBox check = (CheckBox)e.Row.FindControl("Unclose");
                            if (Convert.ToBoolean(dt.Rows[i]["Key_Enabled"]) == true)
                            {
                                check.Enabled = true;
                            }
                            else
                            {
                                check.Enabled = false;
                                //   check.Checked = false;
                            }
                            check.Text = dt.Rows[i]["Description"].ToString();
                        }
                    }
                    #endregion
                }
            }
        }
        catch
        {
        }
    }