I have 6 different methods that refresh controls and tables, eg.
Code: Select all
try { //null if no saved Anesthetic Record yet
RefreshProvComboBoxes();
}
catch { }
Code: Select all
private void RefreshProvComboBoxes() { //This will 'Do the right thing' and show providers on old anesthetic records after they are marked 'Hidden' in OD
//and not include them in the provider comboboxes if they are now 'Hidden' providers
//Anesthetist comboBox
List<Provider> listShort = new List<Provider>();
listShort = Providers.GetDeepCopy(true);
this.comboAnesthetist.Items.Clear();
comboAnesthetist.Items.Add(Lan.g(this, ""));
//Surgeon comboBox
this.comboSurgeon.Items.Clear();
comboSurgeon.Items.Add(Lan.g(this, ""));
//Surgical assistant comboBox
this.comboAsst.Items.Clear();
comboAsst.Items.Add(Lan.g(this, ""));
//Surgical assistant 2 comboBox
this.comboAsst2.Items.Clear();
comboAsst2.Items.Add(Lan.g(this, ""));
//Circulator comboBox
this.comboCirc.Items.Clear();
comboCirc.Items.Add(Lan.g(this, ""));
string lastAddedAnesth = String.Empty; //these prevent duplicate items from being added to list
string lastAddedSurgeon = String.Empty;
string lastAddedAsst = String.Empty;
string lastAddedAsst2 = String.Empty;
string lastAddedCirc = String.Empty;
for (int i = 0; i < Providers.GetDeepCopy(true).Count; i++) { //ListShort is the list of non-hidden providers; ListLong is all providers
if (AnestheticRecords.GetAnesthProvType(listShort[i].ProvNum) == 1 && AnesthLocations.IsProvider(listShort[i].ProvNum, LocationNum) == true && AnesthDataCur != null) { //Anesthetists and Surgeons //refresh Anesthetist ComboBoxes
if (AnesthDataCur.Anesthetist != String.Empty && lastAddedAnesth != AnesthDataCur.Anesthetist) {
comboAnesthetist.Items.Add(AnesthDataCur.Anesthetist);
lastAddedAnesth = AnesthDataCur.Anesthetist;
}
if (AnesthDataCur.Anesthetist != listShort[i].LName + "," + listShort[i].FName) {
comboAnesthetist.Items.Add(listShort[i].LName + "," + listShort[i].FName);
}
//refresh Surgeon ComboBoxes
if (AnesthDataCur.Surgeon != String.Empty && lastAddedSurgeon != AnesthDataCur.Surgeon) {
comboSurgeon.Items.Add(AnesthDataCur.Surgeon);
lastAddedSurgeon = AnesthDataCur.Surgeon;
}
if (AnesthDataCur.Surgeon != listShort[i].LName + "," + listShort[i].FName) {
comboSurgeon.Items.Add(listShort[i].LName + "," + listShort[i].FName);
}
}
else if (AnestheticRecords.GetAnesthProvType(listShort[i].ProvNum) == 2 && Anesthesia.Location.IsProvider(listShort[i].ProvNum, LocationNum) == true && AnesthDataCur != null) { //Assistants and Circulators //refresh Assistant ComboBoxes
if (AnesthDataCur.Asst != string.Empty && lastAddedAsst != AnesthDataCur.Asst) {
comboAsst.Items.Add(AnesthDataCur.Asst);
lastAddedAsst = AnesthDataCur.Asst;
}
if (AnesthDataCur.Asst != listShort[i].LName + "," + listShort[i].FName) {
comboAsst.Items.Add(listShort[i].LName + "," + listShort[i].FName);
}
if (AnesthDataCur.Asst2 != string.Empty && lastAddedAsst2 != AnesthDataCur.Asst2) {
comboAsst2.Items.Add(AnesthDataCur.Asst2);
lastAddedAsst2 = AnesthDataCur.Asst2;
}
if (AnesthDataCur.Asst2 != listShort[i].LName + "," + listShort[i].FName) {
comboAsst2.Items.Add(listShort[i].LName + "," + listShort[i].FName);
}
//refresh Circulator ComboBoxes
if (AnesthDataCur.Circulator != string.Empty && lastAddedCirc != AnesthDataCur.Circulator) {
comboCirc.Items.Add(AnesthDataCur.Circulator);
lastAddedCirc = AnesthDataCur.Circulator;
}
if (AnesthDataCur.Circulator != listShort[i].LName + "," + listShort[i].FName) {
comboCirc.Items.Add(listShort[i].LName + "," + listShort[i].FName);
}
}
}
comboAnesthetist.Sorted = true;
comboSurgeon.Sorted = true;
comboAsst.Sorted = true;
comboAsst2.Sorted = true;
comboCirc.Sorted = true;
}