public static void SaveConnectionString(string connectionStringName, string connectionString, string server, string database, string user, string pass, int opcion) { string data; SqlConnectionStringBuilder sqlString = new SqlConnectionStringBuilder() { DataSource = server, // Server name InitialCatalog = database, //Database UserID = user, //Username Password = pass, //Password // PersistSecurityInfo = true, MultipleActiveResultSets = true, }; if (opcion == 1) { //Build an Entity Framework connection string EntityConnectionStringBuilder entityString = new EntityConnectionStringBuilder() { Provider = "System.Data.SqlClient", Metadata = "res://*/Context.SEMP2013_Context.csdl|res://*/Context.SEMP2013_Context.ssdl|res://*/Context.SEMP2013_Context.msl", ProviderConnectionString = sqlString.ToString() + ";App=EntityFramework;" //App // Provider = "System.Data.SqlClient", //Metadata = "res://*/Context.Context.csdl|res://*/Context.Context.ssdl|res://*/Context.Context.msl", //ProviderConnectionString = sqlString.ToString() + ";App=EntityFramework;" //App }; data = entityString.ConnectionString; // assumes a connectionString name in .config of MyDbEntities var db = new SEMP2013_Context(); // so only reference the changed properties // using the object parameters by name db.ChangeDatabase ( initialCatalog: database, userId: user, password: pass, dataSource: server // could be ip address 120.273.435.167 etc ); Configuration appconfig = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); appconfig.ConnectionStrings.ConnectionStrings[connectionStringName].ConnectionString = data; appconfig.Save(ConfigurationSaveMode.Modified, true); Properties.Settings.Default.Save(); } else { data = sqlString.ConnectionString; Configuration appconfig = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); appconfig.ConnectionStrings.ConnectionStrings[connectionStringName].ConnectionString = data; appconfig.Save(ConfigurationSaveMode.Modified, true); Properties.Settings.Default.Save(); } }
public DepositosyRetiros() { InitializeComponent(); db = new SEMP2013_Context(); backgroundWorker1.WorkerReportsProgress = true; backgroundWorker1.WorkerSupportsCancellation = true; }
public NotasPagoForm() { InitializeComponent(); db = new SEMP2013_Context(); backgroundWorker1.WorkerReportsProgress = true; backgroundWorker1.WorkerSupportsCancellation = true; }
public ApartadosHistorialForm() { InitializeComponent(); db = new SEMP2013_Context(); backgroundWorker1.WorkerReportsProgress = true; backgroundWorker1.WorkerSupportsCancellation = true; }
public bool updateAutorizaRem(int consec, string autoriza, string autorizo, DateTime fecha, string comentario) { using (var context = new SEMP2013_Context()) { using (System.Data.Entity.DbContextTransaction dbTran = context.Database.BeginTransaction()) { try { var remision = context.remisiones. Where(p => p.consec == consec).FirstOrDefault(); if (remision == null) { return(false); } remision.audita = autoriza; remision.auditado = autorizo.Substring(0, 3); remision.fechaAuditado = fecha; remision.comentarioAuditado = comentario; context.remisiones.Attach(remision); context.Entry(remision).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); dbTran.Commit(); return(true); } catch (Exception ex) { //Rollback transaction if exception occurs dbTran.Rollback(); return(false); } } } }
public AutPrestModel() { db = new SEMP2013_Context(); }
public HistorialApartadosModel() { db = new SEMP2013_Context(); }
public ApartadosModel() { db = new SEMP2013_Context(); }
public depositosRetirosModel() { db = new SEMP2013_Context(); }
public PromDescModel() { db = new SEMP2013_Context(); }
public AutorizaRemisionesMNLModel() { db = new SEMP2013_Context(); }
public BuscarLocalidad() { db = new SEMP2013_Context(); }
private SEMP2013_Context db;// = new MySqlConnectionContext(); public LocalidadModel() { db = new SEMP2013_Context(); }
public NotasPagoModel() { db = new SEMP2013_Context(); }
public ContratosModel() { db = new SEMP2013_Context(); }
public AleatoriosForm() { db = new SEMP2013_Context(); InitializeComponent(); }
public AuditoriaRemisionesMNL() { db = new SEMP2013_Context(); }
public InventarioModel() { db = new SEMP2013_Context(); }
private SEMP2013_Context db;// = new MySqlConnectionContext(); public LoginModel() { db = new SEMP2013_Context(); //db.Database.Connection.ConnectionString = Settings.Default["data"].ToString(); }
public BolsasModel() { db = new SEMP2013_Context(); }
public TomaFisicaForm() { db = new SEMP2013_Context(); InitializeComponent(); }
public Audtoma() { db = new SEMP2013_Context(); }
public BuscarLocalidad() { db = new SEMP2013_Context(); // db.Database.Connection.ConnectionString = Settings.Default["data"].ToString(); }