Example #1
0
        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();
            }
        }
Example #2
0
        public DepositosyRetiros()
        {
            InitializeComponent();
            db = new SEMP2013_Context();

            backgroundWorker1.WorkerReportsProgress      = true;
            backgroundWorker1.WorkerSupportsCancellation = true;
        }
Example #3
0
        public NotasPagoForm()
        {
            InitializeComponent();
            db = new SEMP2013_Context();

            backgroundWorker1.WorkerReportsProgress      = true;
            backgroundWorker1.WorkerSupportsCancellation = true;
        }
Example #4
0
        public ApartadosHistorialForm()
        {
            InitializeComponent();
            db = new SEMP2013_Context();

            backgroundWorker1.WorkerReportsProgress      = true;
            backgroundWorker1.WorkerSupportsCancellation = true;
        }
Example #5
0
        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);
                    }
                }
            }
        }
Example #6
0
 public AutPrestModel()
 {
     db = new SEMP2013_Context();
 }
Example #7
0
 public HistorialApartadosModel()
 {
     db = new SEMP2013_Context();
 }
Example #8
0
 public ApartadosModel()
 {
     db = new SEMP2013_Context();
 }
 public depositosRetirosModel()
 {
     db = new SEMP2013_Context();
 }
Example #10
0
 public PromDescModel()
 {
     db = new SEMP2013_Context();
 }
Example #11
0
 public AutorizaRemisionesMNLModel()
 {
     db = new SEMP2013_Context();
 }
Example #12
0
 public BuscarLocalidad()
 {
     db = new SEMP2013_Context();
 }
Example #13
0
 private SEMP2013_Context db;// = new MySqlConnectionContext();
 public LocalidadModel()
 {
     db = new SEMP2013_Context();
 }
Example #14
0
 public NotasPagoModel()
 {
     db = new SEMP2013_Context();
 }
Example #15
0
 public ContratosModel()
 {
     db = new SEMP2013_Context();
 }
Example #16
0
 public AleatoriosForm()
 {
     db = new SEMP2013_Context();
     InitializeComponent();
 }
Example #17
0
 public AuditoriaRemisionesMNL()
 {
     db = new SEMP2013_Context();
 }
Example #18
0
 public InventarioModel()
 {
     db = new SEMP2013_Context();
 }
Example #19
0
        private SEMP2013_Context db;// = new MySqlConnectionContext();

        public LoginModel()
        {
            db = new SEMP2013_Context();
            //db.Database.Connection.ConnectionString = Settings.Default["data"].ToString();
        }
Example #20
0
 public BolsasModel()
 {
     db = new SEMP2013_Context();
 }
Example #21
0
 public TomaFisicaForm()
 {
     db = new SEMP2013_Context();
     InitializeComponent();
 }
Example #22
0
 public Audtoma()
 {
     db = new SEMP2013_Context();
 }
Example #23
0
 public BuscarLocalidad()
 {
     db = new SEMP2013_Context();
     // db.Database.Connection.ConnectionString = Settings.Default["data"].ToString();
 }