コード例 #1
0
    protected string GetLine(int id, Person p, string colSep, string rowSep, bool incRowSep, bool incDOB, bool incAddresses, bool incPhoneNbrs, bool incRefInfo)
    {
        string result = string.Empty;

        if (incRowSep)
        {
            result += rowSep;
        }
        result += id.ToString() + colSep + p.Firstname + colSep + p.Middlename + colSep + p.Surname;
        if (incDOB)
        {
            result += colSep + (p.Dob == DateTime.MinValue ? "" : p.Dob.ToString("dd-MM-yyyy"));
        }
        if (incAddresses)
        {
            result += colSep + GetAddresses(p.EntityID);
        }
        if (incPhoneNbrs)
        {
            result += colSep + GetPhoneNbrs(p.EntityID);
        }

        if (incRefInfo)
        {
            string orgNames = string.Empty;
            string provNbrs = string.Empty;

            System.Data.DataTable tbl  = RegisterReferrerDB.GetDataTable_OrganisationsOf(id);
            RegisterReferrer[]    list = new RegisterReferrer[tbl.Rows.Count];
            for (int i = 0; i < tbl.Rows.Count; i++)
            {
                list[i] = RegisterReferrerDB.Load(tbl.Rows[i]);
                list[i].Organisation = OrganisationDB.Load(tbl.Rows[i], "", "organisation_entity_id", "organisation_is_deleted");
                orgNames            += (orgNames.Length == 0 ? "" : "\r\n") + list[i].Organisation.Name;
                provNbrs            += (provNbrs.Length == 0 ? "" : "\r\n") + list[i].ProviderNumber;
            }

            result += colSep + orgNames;
            result += colSep + provNbrs;
        }

        return(result);
    }
コード例 #2
0
    protected void FillGrid()
    {
        string searchName = "";

        if (Request.QueryString["name_search"] != null && Request.QueryString["name_search"].Length > 0)
        {
            searchName         = Request.QueryString["name_search"];
            txtSearchName.Text = Request.QueryString["name_search"];
        }
        bool searchNameOnlyStartsWith = true;

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

        int orgID = 0;

        if (Request.QueryString["org"] != null && Regex.IsMatch(Request.QueryString["org"], @"\d{1,10}") && OrganisationDB.Exists(Convert.ToInt32(Request.QueryString["org"])))
        {
            orgID = Convert.ToInt32(Request.QueryString["org"]);
        }

        // get count
        Hashtable countHash        = new Hashtable();
        Hashtable countDeletedHash = new Hashtable();
        DataTable dt_reg_refs      = RegisterReferrerDB.GetDataTable(orgID, -1, true, new int[] { 191 }, "", false, "", "", "", false);

        foreach (DataRow row in dt_reg_refs.Rows)
        {
            int org_id = Convert.ToInt32(row["organisation_id"]);

            if (!Convert.ToBoolean(row["is_deleted"]))
            {
                countHash[org_id] = (countHash[org_id] == null) ? 1 : ((int)countHash[org_id]) + 1;
            }
            else
            {
                countDeletedHash[org_id] = (countDeletedHash[org_id] == null) ? 1 : ((int)countDeletedHash[org_id]) + 1;
            }
        }


        DataTable dt = null;

        if (Request.QueryString["referrer"] == null)
        {
            dt = OrganisationDB.GetDataTable(orgID, chkShowDeleted.Checked, true, true, true, true, false, searchName, searchNameOnlyStartsWith, "191");

            dt.Columns.Add("count", typeof(Int32));
            dt.Columns.Add("count_deleted", typeof(Int32));
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                int org_id = Convert.ToInt32(dt.Rows[i]["organisation_id"]);
                dt.Rows[i]["count"]         = countHash[org_id] == null ? 0 : (int)countHash[org_id];
                dt.Rows[i]["count_deleted"] = countDeletedHash[org_id] == null ? 0 : (int)countDeletedHash[org_id];
            }
        }
        else
        {
            if (!Regex.IsMatch(Request.QueryString["referrer"], @"^\d+$"))
            {
                HideTableAndSetErrorMessage("Invalid url referrer");
                return;
            }
            Referrer referrer = ReferrerDB.GetByID(Convert.ToInt32(Request.QueryString["referrer"]));
            if (referrer == null)
            {
                HideTableAndSetErrorMessage("Invalid url referrer");
                return;
            }

            lblHeading.Text = "Referrer Clinics of " + referrer.Person.FullnameWithoutMiddlename;

            dt = RegisterReferrerDB.GetDataTable_OrganisationsOf(referrer.ReferrerID, true, chkShowDeleted.Checked, searchName, searchNameOnlyStartsWith);

            dt.Columns.Add("is_deleted", typeof(Boolean));
            dt.Columns.Add("entity_id", typeof(Int32));
            dt.Columns.Add("count", typeof(Int32));
            dt.Columns.Add("count_deleted", typeof(Int32));
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                int org_id = Convert.ToInt32(dt.Rows[i]["organisation_id"]);
                dt.Rows[i]["count"]         = countHash[org_id] == null ? 0 : (int)countHash[org_id];
                dt.Rows[i]["count_deleted"] = countDeletedHash[org_id] == null ? 0 : (int)countDeletedHash[org_id];

                // update these so when delete/undelete - it removes the connection, not the org
                dt.Rows[i]["organisation_id"] = dt.Rows[i]["register_referrer_id"];
                dt.Rows[i]["is_deleted"]      = dt.Rows[i]["register_referrer_is_deleted"];
                dt.Rows[i]["entity_id"]       = dt.Rows[i]["organisation_entity_id"];
            }
        }



        // add suburb_name

        Hashtable entityIDsHash = new Hashtable();

        for (int i = 0; i < dt.Rows.Count; i++)
        {
            entityIDsHash[Convert.ToInt32(dt.Rows[i]["entity_id"])] = 1;
        }

        int[] entityIDs = new int[entityIDsHash.Keys.Count];
        entityIDsHash.Keys.CopyTo(entityIDs, 0);

        Hashtable emailHash = PatientsContactCacheDB.GetBullkAddress(entityIDs, -1);

        dt.Columns.Add("suburb_name", typeof(string));
        for (int i = 0; i < dt.Rows.Count; i++)
        {
            int    entityID   = Convert.ToInt32(dt.Rows[i]["entity_id"]);
            string suburbName = GetSuburb(emailHash, entityID);
            dt.Rows[i]["suburb_name"] = suburbName == null ? "" : suburbName;
        }



        Session["referrerinfoclinic_data"] = dt;

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


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

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

        if (Request.QueryString["referrer"] != null)
        {
            GrdReferrer.FooterRow.Visible = false;
            GrdReferrer.Columns[GrdReferrer.Columns.Count - 2].Visible = false;
        }
    }