Пример #1
0
		private void FillClinics() {
			if(!Db.HasDatabaseConnection && !Security.IsUserLoggedIn) {
				return;
			}
			try {
				if(!PrefC.HasClinicsEnabled) {
					Visible=false;
					return;
				}
				Items.Clear();
				List<Clinic> listClinics=Clinics.GetForUserod(Security.CurUser);
				if(!Security.CurUser.ClinicIsRestricted || listClinics.Count > 1) {
					Items.Add(new ODBoxItem<Clinic>(Lan.g("ComboBoxClinicMulti","All"),new Clinic { Abbr=Lan.g("ComboBoxClinicMulti","All"),
						Description=Lan.g("ComboBoxClinicMulti","All"),ClinicNum=CLINIC_NUM_ALL }));
				}
				if(!Security.CurUser.ClinicIsRestricted) {
					Items.Add(new ODBoxItem<Clinic>(Lan.g("ComboBoxClinicMulti",HqDescription),new Clinic { Abbr=Lan.g("ComboBoxClinicMulti",HqDescription),
						Description=Lan.g("ComboBoxClinicMulti",HqDescription),ClinicNum=0 }));
				}
				foreach(Clinic clinic in listClinics.OrderBy(x => x.Abbr)) {
					Items.Add(new ODBoxItem<Clinic>(clinic.Abbr,clinic));
				}
				if(Items.Count > 0) {
					ListSelectedClinicNums=new List<long> { Clinics.ClinicNum };
				}
			}
			catch(Exception ex) {
				ex.DoNothing();
			}
		}
Пример #2
0
 private void FillClinics()
 {
     if (!Db.HasDatabaseConnection && !Security.IsUserLoggedIn)
     {
         return;
     }
     try {
         if (!PrefC.HasClinicsEnabled)
         {
             Visible = false;
             return;
         }
         Items.Clear();
         List <Clinic> listClinics = Clinics.GetForUserod(Security.CurUser, true, Lan.g("ComboBoxClinic", HqDescription));
         if (!DoIncludeUnassigned)
         {
             listClinics.RemoveAll(x => x.ClinicNum == CLINIC_NUM_UNASSIGNED);
         }
         //Always include the 'All' option regardless of how many clinics are in our list.
         //This is for the windows that treat 'All' as a way to include items that do not have a clinic set (e.g. Operatories windows).
         if (DoIncludeAll)                 //&& listClinics.Count > 1
         {
             Items.Add(new ODBoxItem <Clinic>(Lan.g("ComboBoxClinic", "All"), new Clinic {
                 Abbr        = Lan.g("ComboBoxClinic", "All"),
                 Description = Lan.g("ComboBoxClinic", "All"),
                 ClinicNum   = CLINIC_NUM_ALL
             }));
         }
         foreach (Clinic clinic in listClinics.OrderBy(x => x.Abbr))
         {
             Items.Add(new ODBoxItem <Clinic>(clinic.Abbr, clinic));
         }
         if (Clinics.ClinicNum == 0)
         {
             if (DoIncludeUnassigned)
             {
                 SelectedClinicNum = CLINIC_NUM_UNASSIGNED;
             }
             else if (DoIncludeAll)
             {
                 SelectedClinicNum = CLINIC_NUM_ALL;
             }
         }
         else
         {
             SelectedClinicNum = Clinics.ClinicNum;
         }
     }
     catch (Exception ex) {
         ex.DoNothing();
     }
 }
Пример #3
0
 ///<summary>This runs on load and with certain property changes that would only change at initialization.  Performance hit should be very small. This also does an Invalidate so that the "combobox" will update.  This also automatically selects a reasonable initial clinic, usually the current clinic. </summary>
 private void FillClinics()
 {
     if (!IsTestModeNoDb)
     {
         if (!Db.HasDatabaseConnection && !Security.IsUserLoggedIn)
         {
             return;
         }
     }
     try {
         if (!IsTestModeNoDb)
         {
             if (!PrefC.HasClinicsEnabled)                     //Already not visible after load handler.
             {
                 return;
             }
         }
         _listClinics.Clear();
         if (IncludeAll)                 //Comes first
         {
             _listClinics.Add(new Clinic {
                 Abbr        = "All",
                 Description = "All",
                 ClinicNum   = CLINIC_NUM_ALL
             });
         }
         //Does not  guarantee that HQ clinic will be included. Only if user has permission to view it.
         List <Clinic> listClinicsForUser = null;
         if (IsTestModeNoDb)
         {
             listClinicsForUser = new List <Clinic>();
             for (int i = 0; i < 40; i++)
             {
                 listClinicsForUser.Add(new Clinic {
                     Abbr = "Clinic" + i.ToString(), Description = "Clinic" + i.ToString(), ClinicNum = i
                 });
             }
             if (IncludeAll)
             {
                 listClinicsForUser.Add(new Clinic {
                     Abbr = HqDescription, Description = HqDescription, ClinicNum = 0
                 });
             }
         }
         else
         {
             listClinicsForUser = Clinics.GetForUserod(_userod, true, HqDescription);
         }
         //Add HQ clinic when necessary.
         Clinic clinicUnassigned = listClinicsForUser.Find(x => x.ClinicNum == CLINIC_NUM_UNASSIGNED);
         //unassigned is next
         if (_forceShowUnassigned)
         {
             _listClinics.Add(new Clinic {
                 Abbr = HqDescription, Description = HqDescription, ClinicNum = 0
             });
         }
         else if (IncludeUnassigned && clinicUnassigned != null)
         {
             _listClinics.Add(clinicUnassigned);
         }
         //then, the other items, except unassigned
         listClinicsForUser.RemoveAll(x => x.ClinicNum == CLINIC_NUM_UNASSIGNED);
         _listClinics.AddRange(listClinicsForUser);
         //Will already be ordered alphabetically if that pref was set.  Unfortunately, a restart is required for that pref.
         //Setting selected---------------------------------------------------------------------------------------------------------------
         if (Clinics.ClinicNum == 0)
         {
             if (IncludeUnassigned)
             {
                 SelectedClinicNum = CLINIC_NUM_UNASSIGNED;
             }
             else if (IncludeAll)
             {
                 SetSelectedClinicNum(CLINIC_NUM_ALL);
             }
         }
         else
         {
             //if Security.CurUser.ClinicIsRestricted, there will be only one clinic in the list, and it will not include default (0).
             SelectedClinicNum = Clinics.ClinicNum;
         }
     }
     catch (Exception e) {
         e.DoNothing();
     }
     Invalidate();
 }