Пример #1
0
    protected void FillGrid()
    {
        Patient patient = GetFormPatient();

        if (patient == null)
        {
            SetErrorMessage("Invalid patient id");
            return;
        }


        DataTable dt = PatientHistoryDB.GetDataTable_ByPatientID(patient.PatientID);


        Hashtable offeringsHash = OfferingDB.GetHashtable(true, -1, null, true);

        PatientDB.AddACOfferings(ref offeringsHash, ref dt, "ac_inv_offering_id", "ac_inv_offering_name", "ac_pat_offering_id", "ac_pat_offering_name",
                                 "ac_inv_aged_care_patient_type_id", "ac_inv_aged_care_patient_type_descr",
                                 "ac_pat_aged_care_patient_type_id", "ac_pat_aged_care_patient_type_descr"
                                 );

        //in display, have pt type
        //- if mcd/dva/emergency : Medicare (Low Care)
        //- if LC/HC/ETC         : Low Care
        dt.Columns.Add("ac_offering", typeof(String));
        for (int i = 0; i < dt.Rows.Count; i++)
        {
            int    ac_inv_offering_id   = dt.Rows[i]["ac_inv_offering_id"] == DBNull.Value ? -1 : Convert.ToInt32(dt.Rows[i]["ac_inv_offering_id"]);
            int    ac_pat_offering_id   = dt.Rows[i]["ac_pat_offering_id"] == DBNull.Value ? -1 : Convert.ToInt32(dt.Rows[i]["ac_pat_offering_id"]);
            string ac_inv_offering_name = dt.Rows[i]["ac_inv_offering_name"] == DBNull.Value ? string.Empty : Convert.ToString(dt.Rows[i]["ac_inv_offering_name"]);
            string ac_pat_offering_name = dt.Rows[i]["ac_pat_offering_name"] == DBNull.Value ? string.Empty : Convert.ToString(dt.Rows[i]["ac_pat_offering_name"]);

            int    ac_inv_aged_care_patient_type_id    = dt.Rows[i]["ac_inv_aged_care_patient_type_id"] == DBNull.Value ? -1 : Convert.ToInt32(dt.Rows[i]["ac_inv_aged_care_patient_type_id"]);
            string ac_inv_aged_care_patient_type_descr = dt.Rows[i]["ac_inv_aged_care_patient_type_descr"] == DBNull.Value ? string.Empty : Convert.ToString(dt.Rows[i]["ac_inv_aged_care_patient_type_descr"]);
            int    ac_pat_aged_care_patient_type_id    = dt.Rows[i]["ac_pat_aged_care_patient_type_id"] == DBNull.Value ? -1 : Convert.ToInt32(dt.Rows[i]["ac_pat_aged_care_patient_type_id"]);
            string ac_pat_aged_care_patient_type_descr = dt.Rows[i]["ac_pat_aged_care_patient_type_descr"] == DBNull.Value ? string.Empty : Convert.ToString(dt.Rows[i]["ac_pat_aged_care_patient_type_descr"]);


            if (ac_inv_offering_id == -1)
            {
                dt.Rows[i]["ac_offering"] = string.Empty;
            }
            else if ((new List <int> {
                2, 3, 4, 5
            }).Contains(ac_inv_aged_care_patient_type_id))
            {
                dt.Rows[i]["ac_offering"] = ac_inv_offering_name;
            }
            else if ((new List <int> {
                6, 7, 8, 9, 10
            }).Contains(ac_inv_aged_care_patient_type_id))
            {
                dt.Rows[i]["ac_offering"] = ac_inv_offering_name + " (" + ac_pat_offering_name + ")";
            }
            else // (?)
            {
                dt.Rows[i]["ac_offering"] = ac_inv_offering_name;
            }
        }


        Session["patientedithistory_data"] = dt;

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


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

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