Esempio n. 1
0
        private void FillGrid()
        {
            Pharmacies.RefreshCache();
            _listPharmacies = Pharmacies.GetDeepCopy();
            //Key=>PharmacyNum & Value=>List of clinics
            SerializableDictionary <long, List <Clinic> > dictPharmClinics = null;

            if (PrefC.HasClinicsEnabled)
            {
                dictPharmClinics = Clinics.GetDictClinicsForPharmacy(_listPharmacies.Select(x => x.PharmacyNum).ToArray());
            }
            gridMain.BeginUpdate();
            gridMain.ListGridColumns.Clear();
            GridColumn col = new GridColumn(Lan.g("TablePharmacies", "Store Name"), 130);

            gridMain.ListGridColumns.Add(col);
            col = new GridColumn(Lan.g("TablePharmacies", "Phone"), 90);
            gridMain.ListGridColumns.Add(col);
            col = new GridColumn(Lan.g("TablePharmacies", "Fax"), 90);
            gridMain.ListGridColumns.Add(col);
            col = new GridColumn(Lan.g("TablePharmacies", "Address"), 120);
            gridMain.ListGridColumns.Add(col);
            col = new GridColumn(Lan.g("TablePharmacies", "City"), 90);
            gridMain.ListGridColumns.Add(col);
            if (PrefC.HasClinicsEnabled)
            {
                col = new GridColumn(Lan.g("TablePharmacies", "Clinics"), 115);
                gridMain.ListGridColumns.Add(col);
            }
            col = new GridColumn(Lan.g("TablePharmacies", "Note"), 100);
            gridMain.ListGridColumns.Add(col);
            gridMain.ListGridRows.Clear();
            GridRow row;
            string  txt;

            foreach (Pharmacy pharm in _listPharmacies)
            {
                row = new GridRow();
                row.Cells.Add(pharm.StoreName);
                row.Cells.Add(pharm.Phone);
                if (Programs.GetCur(ProgramName.DentalTekSmartOfficePhone).Enabled)
                {
                    row.Cells[row.Cells.Count - 1].ColorText = Color.Blue;
                    row.Cells[row.Cells.Count - 1].Underline = YN.Yes;
                }
                row.Cells.Add(pharm.Fax);
                txt = pharm.Address;
                if (pharm.Address2 != "")
                {
                    txt += "\r\n" + pharm.Address2;
                }
                row.Cells.Add(txt);
                row.Cells.Add(pharm.City);
                if (PrefC.HasClinicsEnabled)
                {
                    List <Clinic> listClinics;
                    if (!dictPharmClinics.TryGetValue(pharm.PharmacyNum, out listClinics))
                    {
                        listClinics = new List <Clinic>();
                    }
                    row.Cells.Add(string.Join(",", listClinics.Select(x => x.Abbr)));
                }
                row.Cells.Add(pharm.Note);
                gridMain.ListGridRows.Add(row);
            }
            gridMain.EndUpdate();
        }