Ejemplo n.º 1
0
        private void FillTable()
        {
            Referrals.RefreshCache();
            listRef = Referrals.GetDeepCopy();
            if (!checkHidden.Checked)
            {
                listRef.RemoveAll(x => x.IsHidden);
            }
            if (!checkShowPat.Checked)
            {
                listRef.RemoveAll(x => x.PatNum > 0);
            }
            if (!checkShowDoctor.Checked)
            {
                listRef.RemoveAll(x => x.IsDoctor);
            }
            if (!checkShowOther.Checked)
            {
                listRef.RemoveAll(x => x.PatNum == 0 && !x.IsDoctor);
            }
            if (checkPreferred.Checked)
            {
                listRef.RemoveAll(x => !x.IsPreferred);
            }
            if (!string.IsNullOrWhiteSpace(textSearch.Text))
            {
                string[] searchTokens = textSearch.Text.ToLower().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                listRef.RemoveAll(x => searchTokens.Any(y => !x.FName.ToLower().Contains(y) && !x.LName.ToLower().Contains(y)));
            }
            int  scrollValue    = gridMain.ScrollValue;
            long selectedRefNum = -1;

            if (gridMain.GetSelectedIndex() > -1)
            {
                selectedRefNum = ((Referral)gridMain.Rows[gridMain.GetSelectedIndex()].Tag).ReferralNum;
            }
            gridMain.BeginUpdate();
            gridMain.Columns.Clear();
            gridMain.Columns.Add(new ODGridColumn(Lan.g("TableSelectRefferal", "LastName"), 150));
            gridMain.Columns.Add(new ODGridColumn(Lan.g("TableSelectRefferal", "FirstName"), 80));
            gridMain.Columns.Add(new ODGridColumn(Lan.g("TableSelectRefferal", "MI"), 30));
            gridMain.Columns.Add(new ODGridColumn(Lan.g("TableSelectRefferal", "Title"), 70));
            gridMain.Columns.Add(new ODGridColumn(Lan.g("TableSelectRefferal", "Specialty"), 60));
            gridMain.Columns.Add(new ODGridColumn(Lan.g("TableSelectRefferal", "Patient"), 45));
            gridMain.Columns.Add(new ODGridColumn(Lan.g("TableSelectRefferal", "Note"), 250));
            gridMain.Rows.Clear();
            ODGridRow row;
            int       indexSelectedRef = -1;

            foreach (Referral refCur in listRef)
            {
                row = new ODGridRow();
                row.Cells.Add(refCur.LName);
                row.Cells.Add(refCur.FName);
                row.Cells.Add(refCur.MName.Left(1).ToUpper());                //Left(1) will return empty string if MName is null or empty string, so ToUpper is null safe
                row.Cells.Add(refCur.Title);
                row.Cells.Add(refCur.IsDoctor?Lan.g("enumDentalSpecialty", Defs.GetName(DefCat.ProviderSpecialties, refCur.Specialty)):"");
                row.Cells.Add(refCur.PatNum > 0?"X":"");
                row.Cells.Add(refCur.Note);
                if (refCur.IsHidden)
                {
                    row.ColorText = Color.Gray;
                }
                row.Tag = refCur;
                gridMain.Rows.Add(row);
                if (refCur.ReferralNum == selectedRefNum)
                {
                    indexSelectedRef = gridMain.Rows.Count - 1;
                }
            }
            gridMain.EndUpdate();
            if (indexSelectedRef > -1)
            {
                gridMain.SetSelected(indexSelectedRef, true);
            }
            gridMain.ScrollValue  = scrollValue;
            labelResultCount.Text = gridMain.Rows.Count.ToString() + Lan.g(this, " results found");
        }