Ejemplo n.º 1
0
    protected void SortReferreralEmails(string sortExpression, params string[] sortExpr)
    {
        DataTable dataTable = ViewState["referreralemail_data"] as DataTable;

        if (dataTable != null)
        {
            if (ViewState["referreralemail_sortexpression"] == null)
            {
                ViewState["referreralemail_sortexpression"] = "";
            }

            DataView dataView = new DataView(dataTable);
            string[] sortData = ViewState["referreralemail_sortexpression"].ToString().Trim().Split(' ');

            string newSortExpr = (sortExpr.Length == 0) ?
                                 (sortExpression == sortData[0] && sortData[1] == "ASC") ? "DESC" : "ASC" :
                                 sortExpr[0];

            dataView.Sort = sortExpression + " " + newSortExpr;
            ViewState["referreralemail_sortexpression"] = sortExpression + " " + newSortExpr;

            GrdReferreralEmails.DataSource = dataView;
            GrdReferreralEmails.DataBind();
        }
    }
Ejemplo n.º 2
0
    protected void FillGrdReferreralEmails()
    {
        try
        {
            GrdReferreralEmails.Visible = true;

            Patient patient = PatientDB.GetByID(GetFormPTID());
            lblHeading.Text = "Referrer Emails For " + patient.Person.FullnameWithoutMiddlename;

            DataTable dt = ReferralDB.GetDataTable(false, patient.PatientID);
            dt.Columns.Add("email", typeof(String));

            for (int i = dt.Rows.Count - 1; i >= 0; i--)
            {
                int      orgEntityID = dt.Rows[i]["organisation_entity_id"] == DBNull.Value ? 0 : Convert.ToInt32(dt.Rows[i]["organisation_entity_id"]);
                string[] emailsList  = ContactAusDB.GetEmailsByEntityID(orgEntityID);

                if (emailsList.Length > 0)
                {
                    dt.Rows[i]["email"] = string.Join(",", emailsList);
                }
                else
                {
                    dt.Rows.RemoveAt(i);
                }
            }

            ViewState["referreralemail_data"] = dt;


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


                GrdReferreralEmails.DataBind();
            }
            else
            {
                dt.Rows.Add(dt.NewRow());
                GrdReferreralEmails.DataSource = dt;
                GrdReferreralEmails.DataBind();

                int TotalColumns = GrdReferreralEmails.Rows[0].Cells.Count;
                GrdReferreralEmails.Rows[0].Cells.Clear();
                GrdReferreralEmails.Rows[0].Cells.Add(new TableCell());
                GrdReferreralEmails.Rows[0].Cells[0].ColumnSpan = TotalColumns;
                GrdReferreralEmails.Rows[0].Cells[0].Text       = "No Referrer Emails Exist";
            }
        }
        catch (CustomMessageException ex)
        {
            SetErrorMessage(ex.ToString());
        }
        catch (Exception ex)
        {
            SetErrorMessage("", Utilities.IsDev() ? ex.ToString() : ex.Message);
        }
    }