public void Create(ConfigEnt config) { var xmlSerializer = new XmlSerializer(typeof(ConfigEnt)); var fileInfo = new FileInfo("config.xml"); using (var streamReader = fileInfo.Open(FileMode.OpenOrCreate)) { xmlSerializer.Serialize(streamReader, config); } }
public static void Create(ConfigEnt config) { try { var configDal = new ConfigDal(); configDal.Create(config); } catch (Exception ex) { Logueo.LogAplicacion.Escribir($"No se pudo generar el fichero de configuración: {ex.Message}"); } }
public static List<BatchcabEnt> ReadAll(ConfigEnt config, DateTime fechaini, DateTime fechafin) { try { var batchcabDal = new BatchcabDal(); return batchcabDal.ReadAll(ConfigLog.GetConnectionString(config, 'G'), fechaini, fechafin); } catch (Exception ex) { Logueo.LogAplicacion.Escribir($"No se pudieron obtener los cabezales de asientos: {ex.Message}"); return null; } }
public static void Create(ConfigEnt config, DiarioapuntesEnt ent) { try { var diarioapuntesDal = new DiarioapuntesDal(); diarioapuntesDal.Create(ConfigLog.GetConnectionString(config, 'C'), ent); } catch (Exception ex) { Logueo.LogAplicacion.Escribir($"No se pudo generar el asiento: {ex.Message}"); } }
public static List<BatchrenEnt> ReadAll(ConfigEnt config, BatchcabEnt ent) { try { var batchrenDal = new BatchrenDal(); return batchrenDal.ReadAll(ConfigLog.GetConnectionString(config, 'G'), ent); } catch (Exception ex) { Logueo.LogAplicacion.Escribir($"No se pudieron obtener las lineas de asientos: {ex.Message}"); return null; } }
public MainWindow() { InitializeComponent(); Config = ConfigLog.Read(); if (Config == null) { new ConfigWindow().ShowDialog(); Config = ConfigLog.Read(); if (Config == null) { MessageBox.Show("Debe configurar la aplicacion para utilizarla", "Error", MessageBoxButton.OK, MessageBoxImage.Error); Close(); } } }
private void BtnTest_OnClick(object sender, RoutedEventArgs e) { if (!string.IsNullOrEmpty(TxtBoxInstancia.Text) && !string.IsNullOrEmpty(TxtBoxDbGestion.Text) && !string.IsNullOrEmpty(TxtBoxDbContable.Text) && !string.IsNullOrEmpty(TxtBoxUsuario.Text) && !string.IsNullOrEmpty(TxtBoxPassword.Text)) { _config = new ConfigEnt() { Instancia = TxtBoxInstancia.Text, DbGestion = TxtBoxDbGestion.Text, DbContable = TxtBoxDbContable.Text, Usuario = TxtBoxUsuario.Text, Password = TxtBoxPassword.Text }; using (var sqlConnection = new SqlConnection()) { try { sqlConnection.ConnectionString = ConfigLog.GetConnectionString(_config, 'G'); sqlConnection.Open(); sqlConnection.Close(); sqlConnection.ConnectionString = ConfigLog.GetConnectionString(_config, 'C'); sqlConnection.Open(); sqlConnection.Close(); TxtBoxInstancia.IsEnabled = false; TxtBoxDbGestion.IsEnabled = false; TxtBoxDbContable.IsEnabled = false; TxtBoxUsuario.IsEnabled = false; TxtBoxPassword.IsEnabled = false; CheckBoxOk.IsChecked = true; BtnTest.IsEnabled = false; BtnSubmit.IsEnabled = true; } catch { } } } else { MessageBox.Show("Revise los campos", "Error", MessageBoxButton.OK, MessageBoxImage.Asterisk); } }
public static string GetConnectionString(ConfigEnt config, char db) { string conn = null; switch (db) { case 'G': conn = $@"Data Source = {config.Instancia}; Initial Catalog = {config.DbGestion}; Persist Security Info = True; User ID = {config.Usuario}; Password = {config.Password};"; break; case 'C': conn = $@"Data Source = {config.Instancia}; Initial Catalog = {config.DbContable}; Persist Security Info = True; User ID = {config.Usuario}; Password = {config.Password};"; break; } return conn; }//asd
public static string GetConnectionString(ConfigEnt config, char db) { string conn = null; switch (db) { case 'G': conn = $@"Data Source = {config.Instancia}; Initial Catalog = {config.DbGestion}; Persist Security Info = True; User ID = {config.Usuario}; Password = {config.Password};"; break; case 'C': conn = $@"Data Source = {config.Instancia}; Initial Catalog = {config.DbContable}; Persist Security Info = True; User ID = {config.Usuario}; Password = {config.Password};"; break; } return(conn); }//asd