Exemplo n.º 1
0
    public static System.Collections.Hashtable GetAllInHashtable(bool incSupportStaff = false, bool showIsFired = false, bool showIsExternal = false, bool showOnlyExternal = false)
    {
        System.Collections.Hashtable hash = new System.Collections.Hashtable();

        DataTable tbl = StaffDB.GetDataTable_StaffInfo(incSupportStaff, showIsFired, showIsExternal, showOnlyExternal);

        for (int i = 0; i < tbl.Rows.Count; i++)
        {
            Staff staff = Load(tbl.Rows[i]);
            staff.Person        = PersonDB.Load(tbl.Rows[i]);
            staff.Person.Title  = IDandDescrDB.Load(tbl.Rows[i], "title_id", "descr");
            staff.Field         = IDandDescrDB.Load(tbl.Rows[i], "field_field_id", "field_descr");
            staff.StaffPosition = StaffPositionDB.Load(tbl.Rows[i], "staff_position_");
            staff.CostCentre    = CostCentreDB.Load(tbl.Rows[i], "cost_centre_");
            hash[staff.StaffID] = staff;
        }

        return(hash);
    }
Exemplo n.º 2
0
    protected void FillGrid()
    {
        lblNbrProviders.Text = StaffDB.GetCountOfProviders().ToString();

        string searchSurname = "";

        if (Request.QueryString["surname_search"] != null && Request.QueryString["surname_search"].Length > 0)
        {
            searchSurname         = Request.QueryString["surname_search"];
            txtSearchSurname.Text = Request.QueryString["surname_search"];
        }
        bool searchSurnameOnlyStartsWith = true;

        if (Request.QueryString["surname_starts_with"] != null && Request.QueryString["surname_starts_with"].Length > 0)
        {
            searchSurnameOnlyStartsWith           = Request.QueryString["surname_starts_with"] == "0" ? false : true;
            chkSurnameSearchOnlyStartWith.Checked = searchSurnameOnlyStartsWith;
        }
        else
        {
            chkSurnameSearchOnlyStartWith.Checked = searchSurnameOnlyStartsWith;
        }



        DataTable dt = StaffDB.GetDataTable_StaffInfo(Convert.ToBoolean(Session["IsStakeholder"]), chkShowFired.Checked, false, false, searchSurname, searchSurnameOnlyStartsWith);

        // remove "Patient Login" staff member and Call Centre staff memebers
        for (int i = dt.Rows.Count - 1; i >= 0; i--)
        {
            if (((int)dt.Rows[i]["staff_id"]) == -6 || ((int)dt.Rows[i]["staff_id"]) == -7 || ((int)dt.Rows[i]["staff_id"]) == -8)
            {
                dt.Rows.RemoveAt(i);
            }
        }

        // hide higher privleiged users from lower priveliged users
        UserView userView = UserView.GetInstance();

        for (int i = dt.Rows.Count - 1; i >= 0; i--)
        {
            if (!userView.IsStakeholder && Convert.ToBoolean(dt.Rows[i]["is_stakeholder"]))
            {
                dt.Rows.RemoveAt(i);
                continue;
            }
            if (!userView.IsStakeholder && !userView.IsMasterAdmin && Convert.ToBoolean(dt.Rows[i]["is_master_admin"]))
            {
                dt.Rows.RemoveAt(i);
                continue;
            }
        }

        dt.DefaultView.Sort = "firstname, surname, middlename";
        dt = dt.DefaultView.ToTable();
        Session["staffinfo_data"] = dt;


        this.GrdStaff.AllowPaging = false;

        /*
         * if (!IsPostBack)
         *  chkUsePaging.Checked = dt.Rows.Count > 50;
         * this.GrdStaff.AllowPaging = chkUsePaging.Checked;
         */

        if (dt.Rows.Count > 0)
        {
            if (IsPostBack && Session["staffinfo_sortexpression"] != null && Session["staffinfo_sortexpression"].ToString().Length > 0)
            {
                DataView dataView = new DataView(dt);
                dataView.Sort       = Session["staffinfo_sortexpression"].ToString();
                GrdStaff.DataSource = dataView;
            }
            else
            {
                GrdStaff.DataSource = dt;
            }

            try
            {
                GrdStaff.DataBind();
                GrdStaff.PagerSettings.FirstPageText = "1";
                GrdStaff.PagerSettings.LastPageText  = GrdStaff.PageCount.ToString();
                GrdStaff.DataBind();
            }
            catch (Exception ex)
            {
                HideTableAndSetErrorMessage("", ex.ToString());
            }
        }
        else
        {
            dt.Rows.Add(dt.NewRow());
            GrdStaff.DataSource = dt;
            GrdStaff.DataBind();

            int TotalColumns = GrdStaff.Rows[0].Cells.Count;
            GrdStaff.Rows[0].Cells.Clear();
            GrdStaff.Rows[0].Cells.Add(new TableCell());
            GrdStaff.Rows[0].Cells[0].ColumnSpan = TotalColumns;
            GrdStaff.Rows[0].Cells[0].Text       = "No Record Found";
        }
    }
    protected void FillGrid()
    {
        string searchSurname = "";

        if (Request.QueryString["surname_search"] != null && Request.QueryString["surname_search"].Length > 0)
        {
            searchSurname         = Request.QueryString["surname_search"];
            txtSearchSurname.Text = Request.QueryString["surname_search"];
        }
        bool searchSurnameOnlyStartsWith = true;

        if (Request.QueryString["surname_starts_with"] != null && Request.QueryString["surname_starts_with"].Length > 0)
        {
            searchSurnameOnlyStartsWith           = Request.QueryString["surname_starts_with"] == "0" ? false : true;
            chkSurnameSearchOnlyStartWith.Checked = searchSurnameOnlyStartsWith;
        }
        else
        {
            chkSurnameSearchOnlyStartWith.Checked = searchSurnameOnlyStartsWith;
        }



        DataTable dt = StaffDB.GetDataTable_StaffInfo(Convert.ToBoolean(Session["IsStakeholder"]), chkShowFired.Checked, true, true, searchSurname, searchSurnameOnlyStartsWith);

        // remove "Call Center" staff member
        for (int i = dt.Rows.Count - 1; i >= 0; i--)
        {
            if (((int)dt.Rows[i]["staff_id"]) == -5)
            {
                dt.Rows.RemoveAt(i);
            }
        }

        dt.DefaultView.Sort = "firstname, surname, middlename";
        dt = dt.DefaultView.ToTable();
        Session["externalstaffinfo_data"] = dt;


        this.GrdStaff.AllowPaging = false;

        /*
         * if (!IsPostBack)
         *  chkUsePaging.Checked = dt.Rows.Count > 50;
         * this.GrdStaff.AllowPaging = chkUsePaging.Checked;
         */

        if (dt.Rows.Count > 0)
        {
            if (IsPostBack && Session["externalstaffinfo_sortexpression"] != null && Session["externalstaffinfo_sortexpression"].ToString().Length > 0)
            {
                DataView dataView = new DataView(dt);
                dataView.Sort       = Session["externalstaffinfo_sortexpression"].ToString();
                GrdStaff.DataSource = dataView;
            }
            else
            {
                GrdStaff.DataSource = dt;
            }

            try
            {
                GrdStaff.DataBind();
                GrdStaff.PagerSettings.FirstPageText = "1";
                GrdStaff.PagerSettings.LastPageText  = GrdStaff.PageCount.ToString();
                GrdStaff.DataBind();
            }
            catch (Exception ex)
            {
                HideTableAndSetErrorMessage("", ex.ToString());
            }
        }
        else
        {
            dt.Rows.Add(dt.NewRow());
            GrdStaff.DataSource = dt;
            GrdStaff.DataBind();

            int TotalColumns = GrdStaff.Rows[0].Cells.Count;
            GrdStaff.Rows[0].Cells.Clear();
            GrdStaff.Rows[0].Cells.Add(new TableCell());
            GrdStaff.Rows[0].Cells[0].ColumnSpan = TotalColumns;
            GrdStaff.Rows[0].Cells[0].Text       = "No Record Found";
        }
    }
Exemplo n.º 4
0
    /*
     * protected bool IsValidFormOrg()
     * {
     *  string orgID = Request.QueryString["org"];
     *  return orgID != null && Regex.IsMatch(orgID, @"^\d+$") && OrganisationDB.Exists(Convert.ToInt32(orgID));
     * }
     * protected int GetFormOrg(bool checkIsValid = true)
     * {
     *  if (checkIsValid && !IsValidFormOrg())
     *      throw new Exception("Invalid url org");
     *  return Convert.ToInt32(Request.QueryString["org"]);
     * }
     *
     * protected bool IsValidFormOrgs()
     * {
     *  string orgIDs = Request.QueryString["orgs"];
     *  return orgIDs != null && Regex.IsMatch(orgIDs, @"^[\d,]+$") && OrganisationDB.Exists(orgIDs);
     * }
     * protected string GetFormOrgs(bool checkIsValid = true)
     * {
     *  if (checkIsValid && !IsValidFormOrgs())
     *      throw new Exception("Invalid url orgs");
     *  return Request.QueryString["orgs"];
     * }
     */

    #endregion

    #region GrdStaff

    protected void FillStaffGrid()
    {
        DataTable dt = StaffDB.GetDataTable_StaffInfo(false, false, false, false, txtSearchSurname.Text.Trim(), chkSurnameSearchOnlyStartWith.Checked);

        bool onlyProviders = IsValidFormOnlyProviders() ? GetFormOnlyProviders(false) : false;

        if (onlyProviders)
        {
            lblHeading.Text = "Providers";
            for (int i = dt.Rows.Count - 1; i >= 0; i--)
            {
                if (!StaffDB.Load(dt.Rows[i]).IsProvider)
                {
                    dt.Rows.RemoveAt(i);
                }
            }
        }

        Session["staff_data"] = dt;

        if (dt.Rows.Count > 0)
        {
            if (IsPostBack && Session["staff_sortExpression"] != null && Session["staff_sortExpression"].ToString().Length > 0)
            {
                DataView dataView = new DataView(dt);
                dataView.Sort       = Session["staff_sortExpression"].ToString();
                GrdStaff.DataSource = dataView;
            }
            else
            {
                GrdStaff.DataSource = dt;
            }

            try
            {
                GrdStaff.DataBind();

                // don't need paging -- already have scrolling -- and there won't be too many staff to send in one page
                GrdStaff.PagerSettings.FirstPageText = "1";
                GrdStaff.PagerSettings.LastPageText  = GrdStaff.PageCount.ToString();
                GrdStaff.DataBind();
            }
            catch (Exception ex)
            {
                this.lblErrorMessage.Visible = true;
                this.lblErrorMessage.Text    = ex.ToString();
            }
        }
        else
        {
            dt.Rows.Add(dt.NewRow());
            GrdStaff.DataSource = dt;
            GrdStaff.DataBind();

            int TotalColumns = GrdStaff.Rows[0].Cells.Count;
            GrdStaff.Rows[0].Cells.Clear();
            GrdStaff.Rows[0].Cells.Add(new TableCell());
            GrdStaff.Rows[0].Cells[0].ColumnSpan = TotalColumns;
            GrdStaff.Rows[0].Cells[0].Text       = "No Record Found";
        }
    }