public bool Configure(Config conf) { // restauramos la configuracion this.conf = conf; // cargamos la configuracion this.temporizador.Interval = this.conf.getIntervalMs(); this.SelectedPath = this.conf.getPath(); this.db = this.conf.getDataBase(); // restauramos la configuracion para conectarse al servidor de Sql Server SQLServer sqlserver = new SQLServer(this.conf.getHost(), this.conf.getUser(), this.conf.getPassword(), this.conf.getDataBase()); if (sqlserver.testConnection()) { // si tenemos conexion con la base de datos this.dbxml = new DBtoXML(sqlserver.getConnection()); // restauramos la conexion this.tablesExport = this.conf.getTableNames(); // y restauramos las tablas que se tienen que exportar } else { Alert.Warning("No se ha podido configurar porque ha fallado la conexion con el servidor de bases de datos. El Programa no se ejecutara"); this.confirmConfigDelete(); return(false); } this.isConfigured = true; // indicamos que ya se ha cargado una cofiguracion return(true); }
private void conexionBtn_Click(object sender, EventArgs e) { this.user = userInput.Text; this.password = passwordInput.Text; Form dbform = new Form2(); SQLServer server = new SQLServer(this.sqlserver, this.user, this.password, this.database); if (server.testConnection()) { Program.dbxml = new DBtoXML(server.getConnection()); Program.dbName = this.database; dbform.Show(); this.Hide(); } else { Alert.Warning("Error al conectarse con la base de datos"); } }
private void connectSilentModeBtn_Click(object sender, EventArgs e) { this.user = userInput.Text; this.password = passwordInput.Text; Form standAloneForm = new Standalone(); // formulario para programar el modo silencioso SQLServer server = new SQLServer(this.sqlserver, this.user, this.password, this.database); if (server.testConnection()) { Program.dbxml = new DBtoXML(server.getConnection()); Program.dbName = this.database; this.saveConf(); standAloneForm.Show(); this.Hide(); } else { Alert.Warning("Error al conectarse con la base de datos"); } }