public void LoadDatabases() { cmbDatabase.SelectedIndexChanged -= cmbDatabase_SelectedIndexChanged; EntityBusiness entityBusiness = new EntityBusiness(); var dbs = entityBusiness.GetServerList(); cmbDatabase.ComboBox.DisplayMember = "DbAlias"; cmbDatabase.ComboBox.ValueMember = "ServerID"; cmbDatabase.ComboBox.DataSource = dbs; string mainserver = new ConfigurationHelper().GetConfigurationValue("mainserver"); //string mainserver = System.Configuration.ConfigurationSettings.AppSettings["mainserver"]; if (mainserver != "0" && mainserver != "") cmbDatabase.ComboBox.SelectedValue = Convert.ToInt32(mainserver); else cmbDatabase.ComboBox.SelectedIndex = -1; cmbDatabase.SelectedIndexChanged += cmbDatabase_SelectedIndexChanged; }
public void LoadDatabases() { tscomserver.SelectedIndexChanged -= tscomserver_SelectedIndexChanged; EntityBusiness entityBusiness = new EntityBusiness(); var dbs = entityBusiness.GetServerList(); tscomserver.ComboBox.DisplayMember = "DbAlias"; tscomserver.ComboBox.ValueMember = "ServerID"; tscomserver.ComboBox.DataSource = dbs; string mainserver = new ConfigurationHelper().GetConfigurationValue("mainserver"); if (mainserver != "0" && mainserver != "") { tscomserver.ComboBox.SelectedValue = Convert.ToInt32(mainserver); maindb = dbs.Where(x => x.ServerID == Convert.ToInt32(mainserver)).FirstOrDefault(); //LoadOtherDBs(dbs, Convert.ToInt32(mainserver)); } else { tscomserver.ComboBox.SelectedIndex = -1; //LoadOtherDBs(dbs, 0); } tscomserver.SelectedIndexChanged += tscomserver_SelectedIndexChanged; }
private void frmHome_Load(object sender, EventArgs e) { try { LoadDatabases(); string serverid = new ConfigurationHelper().GetConfigurationValue("mainserver"); EntityBusiness data = new EntityBusiness(); var servers = data.GetServerList(); var server = servers.Where(x => x.ServerID == Convert.ToInt32(serverid)).FirstOrDefault(); if (server != null) { AppTimeConfiguration.MainServer = server; } } catch (Exception ex) { MessageBox.Show(ex.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Error); } }