private void LoadDepartments() { try { if (Settings.Default.TmpDbLocation == "") return; var da = new DataAccess(Settings.Default.TmpDbLocation, Settings.Default.NetworkLocation); var deps = da.GetDepartments(); foreach (var department in deps) { cmbccFrom.Items.Add(new ComboBoxItemDepartment { ItemObject = department }); cmbccTo.Items.Add(new ComboBoxItemDepartment { ItemObject = department }); } if (cmbccFrom.Items.Count > 0) cmbccFrom.SelectedIndex = 0; if (cmbccTo.Items.Count > 0) cmbccTo.SelectedIndex = cmbccTo.Items.Count - 1; } catch { //do nothing } }
private void LoadCostCentres() { try { if (Settings.Default.TmpDbLocation == "") return; var da = new DataAccess(Settings.Default.TmpDbLocation, Settings.Default.NetworkLocation); var cc = da.GetCostCentres(); foreach (var costCentre in cc) { cmbccFrom.Items.Add(new ComboBoxItemCostCentre { ItemObject = costCentre }); cmbccTo.Items.Add(new ComboBoxItemCostCentre { ItemObject = costCentre }); } if (cmbccFrom.Items.Count > 0) cmbccFrom.SelectedIndex = 0; if (cmbccTo.Items.Count > 0) cmbccTo.SelectedIndex = cmbccTo.Items.Count - 1; } catch { //do nothing } }