/// <summary>
 /// Adding the page to the permission
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnAddPage_Click(object sender, System.EventArgs e)
 {
     try
     {
         perm = new clsPermissions();
         perm.cAction = "I";
         perm.iId = PermId;
         perm.iPageId = Convert.ToInt32(ddlNewPages.SelectedValue);
         if(perm.PagesPermissionDetail() == -1)
         {
             Session["lastpage"] = "admin_permission_detail.aspx?id=" + PermId.ToString();
             Session["error"] = _functions.ErrorMessage(116);
             Response.Redirect("error.aspx", false);
             return;
         }
         else
             Response.Redirect("admin_permission_detail.aspx?id=" + PermId.ToString(), false);
     }
     catch(Exception ex)
     {
         _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName);
         Session["lastpage"] = "admin_permissions_detail.aspx?id=" + PermId.ToString();
         Session["error"] = ex.Message;
         Session["error_report"] = ex.ToString();
         Response.Redirect("error.aspx", false);
     }
     finally
     {
         if(perm != null)
             perm.Dispose();
     }
 }
 /// <summary>
 /// Delete page from the permission
 /// </summary>
 /// <param name="source"></param>
 /// <param name="e"></param>
 private void dgPages_DeleteCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
 {
     try
     {
         perm = new clsPermissions();
         perm.cAction = "D";
         perm.iId = PermId;
         perm.iPageId = Convert.ToInt32(e.Item.Cells[0].Text);
         if(perm.PagesPermissionDetail() == -1)
         {
             Session["lastpage"] = "admin_permission_detail.aspx?id=" + PermId.ToString();
             Session["error"] = _functions.ErrorMessage(116);
             Response.Redirect("error.aspx", false);
             return;
         }
         else
             Response.Redirect("admin_permission_detail.aspx?id=" + PermId.ToString(), false);
     }
     catch(Exception ex)
     {
         _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName);
         Session["lastpage"] = "admin_permissions_detail.aspx?id=" + PermId.ToString();
         Session["error"] = ex.Message;
         Session["error_report"] = ex.ToString();
         Response.Redirect("error.aspx", false);
     }
     finally
     {
         if(perm != null)
             perm.Dispose();
     }
 }