protected void FillGrid()
    {
        try
        {
            ManageDocPermissions obj = new ManageDocPermissions();
            userid = Convert.ToString(Session["userid"]);

            ds = new DataSet();
            ds = obj.GetPermittedDocuments(userid);

            int count = ds.Tables[0].Rows.Count;

            if (count > 0)
            {
                flag = true;
            }
            else
            {
                flag = false;
                LinkButton2.Visible = false;
                LinkButton3.Visible = false;
            }

            PagedDataSource pgd = new PagedDataSource();
            pgd.DataSource       = ds.Tables[0].DefaultView;
            pgd.CurrentPageIndex = CurrentPageIndex;
            pgd.AllowPaging      = true;

            if (count < 8)
            {
                pgd.PageSize = count;
            }
            else
            {
                pgd.PageSize = 8;
            }

            LinkButton2.Enabled = !(pgd.IsLastPage);
            LinkButton3.Enabled = !(pgd.IsFirstPage);

            dataclients.DataSource = pgd;
            dataclients.DataBind();
        }
        catch (Exception)
        {
            flag = false;
            LinkButton2.Visible = false;
            LinkButton3.Visible = false;
        }
    }
Пример #2
0
    protected void Submit(object sender, EventArgs e)
    {
        try
        {
            int uploadid = Convert.ToInt32(Request.QueryString["docid"]);
            ManageDocPermissions objperm = new ManageDocPermissions();


            foreach (GridViewRow row in grdusers.Rows)
            {
                CheckBox cb = (CheckBox)row.FindControl("selectact");
                if (cb != null && cb.Checked)
                {
                    value = 0;
                    string memberid = grdusers.DataKeys[row.RowIndex].Value.ToString();

                    if (objperm.NewPermission(uploadid, memberid))
                    {
                        value = 1;
                    }

                    string      userid = Convert.ToString(Session["userid"]);
                    RecordUsage rec    = new RecordUsage();
                    rec.record(userid, "permission");
                }
            }
        }
        catch (Exception ex) { value = 0; }
        if (value == 1)
        {
            message = "Document access permission allotted to members successfully..";
            title   = "Success Report";
            FillGrid();
        }
        else if (value == 0)
        {
            message = "Permission allottment failed.. Try again..";
            title   = "Failure Report";
        }

        string script = "window.onload = function(){ alert('";

        script += message;
        script += "')};";
        ClientScript.RegisterStartupScript(this.GetType(), title, script, true);
    }