Esempio n. 1
0
        public void registrarEvaluacionSolicitud(Solicitud solicitud)
        {
            SqlConnection  cn          = null;
            SqlTransaction transaccion = null;

            try
            {
                cn = HelperDB.GetSqlConnection();
                //Inicio de la transaccion
                transaccion = cn.BeginTransaction();
                //Estado 5= Aprobado , 4 Desaprobado
                SolicitudEstado nuevoEstado = estadoSolicitudRepository.obtenerPorId(solicitud.aprobado ? 5 : 4, cn, transaccion);
                if (nuevoEstado == null)
                {
                    throw new ArgumentNullException("No se encontro el estado APROBADO/DESAPROBADO para la solicitud");
                }
                solicitudRepository.registrarEvaluacionSolicitud(solicitud, nuevoEstado, cn, transaccion);
                transaccion.Commit();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                transaccion.Rollback();
                throw new Exception(e.Message);
            }
            finally
            {
                if (cn != null)
                {
                    cn.Close();
                    cn.Dispose();
                }
            }
        }
Esempio n. 2
0
        public List <Solicitud> obtenerSolicitudesPendientesPago()
        {
            SqlConnection    cn   = null;
            List <Solicitud> data = new List <Solicitud>();

            try
            {
                cn = HelperDB.GetSqlConnection();
                //1-GENERADO
                data = solicitudRepository.obtenerPorEstado(1, cn);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            finally
            {
                if (cn != null)
                {
                    cn.Close();
                    cn.Dispose();
                }
            }
            return(data);
        }
Esempio n. 3
0
        public List <Solicitud> obtenerSolicitudPorEstado(int idEstado)
        {
            SqlConnection    cn   = null;
            List <Solicitud> data = new List <Solicitud>();

            try
            {
                cn   = HelperDB.GetSqlConnection();
                data = solicitudRepository.obtenerPorEstado(idEstado, cn);
                foreach (Solicitud solicitud in data)
                {
                    solicitud.temas = solicitudTemaRepository.obtenerTemasPorSolicitud(solicitud, cn);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            finally
            {
                if (cn != null)
                {
                    cn.Close();
                    cn.Dispose();
                }
            }
            return(data);
        }
Esempio n. 4
0
        internal virtual void ClientDatabasesEnsureDeleted()
        {
            foreach (var tr in this.ClientRuns)
            {
                HelperDB.DropDatabase(tr.ClientProviderType, tr.DatabaseName);
            }

            this.ClientRuns.Clear();
        }
 public OsmPointsSearcher(HelperDB _hdb)
 {
     if (_hdb == null)
     {
         hdb = new HelperDB();
     }
     else
     {
         hdb = _hdb;
     }
 }
        public SyncAllColumnsFixture()
        {
            // create databases
            HelperDB.CreateDatabase(ProviderType.Sql, serverDbName);
            HelperDB.CreateDatabase(ProviderType.Sql, client1DbName);

            // create table
            HelperDB.ExecuteSqlScript(serverDbName, createTableScript);

            // insert table
            HelperDB.ExecuteSqlScript(serverDbName, datas);
        }
 public GooglePointsSearcher(HelperDB _hdb)
 {
     if (_hdb == null)
     {
         hdb = new HelperDB();
     }
     else
     {
         hdb = _hdb;
     }
     hgoogle = new HelperGoogle();
 }
        public List <Pessoa> Select()
        {
            var lsPessoas = new List <Pessoa>();

            try
            {
                var        SQL        = "select ID, NOME, CPF_CNPJ, TIPOPESSOA, DATANASCIMENTO from PESSOA";
                IDbCommand comandoSQL = conexao.CreateCommand();
                comandoSQL.CommandText = SQL;
                comandoSQL.CommandType = CommandType.Text;
                conexao.Open();

                IDataReader reader = comandoSQL.ExecuteReader();

                while (reader.Read())
                {
                    var OPessoa = new Pessoa();

                    OPessoa.Id       = Int32.Parse(reader[0].ToString());
                    OPessoa.Nome     = reader[1].ToString();
                    OPessoa.Cpf_Cnpj = reader[2].ToString();

                    if (reader.IsDBNull(3))
                    {
                        OPessoa.TipoPessoa = 'F';
                    }
                    else
                    {
                        OPessoa.TipoPessoa = char.Parse(reader[3].ToString());
                    }

                    if (reader.IsDBNull(4))
                    {
                        OPessoa.DataNascimento = HelperDB.MinValue();
                    }
                    else
                    {
                        OPessoa.DataNascimento = DateTime.Parse(reader[4].ToString());
                    }

                    lsPessoas.Add(OPessoa);
                }
                reader.Close();
            }
            finally
            {
                conexao.Close();
            }
            return(lsPessoas);
        }
Esempio n. 9
0
        private void btnSaoLuu_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog dlg = new FolderBrowserDialog();

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                bool isSuccess = HelperDB.BackupDatabase(dlg.SelectedPath);
                if (isSuccess)
                {
                    MessageBox.Show("Backup thanh cong");
                }
                else
                {
                    MessageBox.Show("Backup that bai");
                }
            }
        }
Esempio n. 10
0
        public void Save(HelperDB helper)
        {
            switch (this.Type)
            {
            case PointType.CustomerEpicentrK: helper.SetEpicentrKPoint(this);
                break;

            case PointType.CustomerNewLine: helper.SetNewLinePoint(this);
                break;

            case PointType.BoardPoint:
                break;

            case PointType.MarketPoint:
                break;
            }
        }
 public void Delete(Pessoa pessoa)
 {
     try
     {
         var        SQL        = "delete from PESSOA where ID = @ID";
         IDbCommand comandoSQL = conexao.CreateCommand();
         comandoSQL.CommandText = SQL;
         HelperDB.AddParameter(comandoSQL, "@ID", pessoa.Id);
         comandoSQL.CommandType = CommandType.Text;
         conexao.Open();
         comandoSQL.ExecuteNonQuery();
     }
     finally
     {
         conexao.Close();
     }
 }
 public void Delete(Usuario usuario)
 {
     try
     {
         var        SQL        = "delete from USUARIO where ID = @ID";
         IDbCommand comandoSQL = conexao.CreateCommand();
         comandoSQL.CommandText = SQL;
         HelperDB.AddParameter(comandoSQL, "@ID", usuario.Id);
         comandoSQL.CommandType = CommandType.Text;
         conexao.Open();
         comandoSQL.ExecuteNonQuery();
     }
     finally
     {
         conexao.Close();
     }
 }
Esempio n. 13
0
        /// <summary>
        /// Will configure the fixture on first test launch
        /// </summary>
        internal void Configure()
        {
            // Pattern double check to be sur one instance is not trying to create the databse during an other trying to delete the same one.
            lock (locker)
            {
                if (isConfigured)
                {
                    return;
                }

                lock (locker)
                {
                    if (isConfigured)
                    {
                        return;
                    }

                    // gets the server provider
                    this.ServerProvider = this.NewServerProvider(HelperDB.GetConnectionString(this.ProviderType, this.DatabaseName));

                    // create the server database
                    this.ServerDatabaseEnsureCreated();


                    // Get all provider fixture
                    var listOfBs = (from assemblyType in typeof(ProviderFixture).Assembly.DefinedTypes
                                    where typeof(ProviderFixture).IsAssignableFrom(assemblyType) &&
                                    assemblyType.BaseType == typeof(ProviderFixture)
                                    select assemblyType).ToArray();

                    foreach (var t in listOfBs)
                    {
                        var c        = GetDefaultConstructor(t);
                        var instance = c.Invoke(null) as ProviderFixture;
                        RegisterProvider(instance.ProviderType, instance);
                    }

                    // create the clients database
                    this.ClientDatabasesEnsureCreated();

                    isConfigured = true;
                }
            }
        }
Esempio n. 14
0
        private void btnPhucHoi_Click(object sender, EventArgs e)
        {
            OpenFileDialog dlg = new OpenFileDialog();

            dlg.Filter = "SQL SERVER database backup files|*.bak";
            dlg.Title  = "Database restore";
            if (dlg.ShowDialog() == DialogResult.OK)
            {
                bool isSuccess = HelperDB.RostoreDatabase(dlg.FileName);
                if (isSuccess)
                {
                    MessageBox.Show("Restore thanh cong");
                }
                else
                {
                    MessageBox.Show("Restore that bai");
                }
            }
        }
        public void Insert(Usuario usuario)
        {
            try
            {
                var SQL = "insert into USUARIO (LOGIN, SENHA, IDPESSOA) values (@LOGIN, @SENHA, @IDPESSOA)";

                IDbCommand comandoSQL = conexao.CreateCommand();
                comandoSQL.CommandText = SQL;
                HelperDB.AddParameter(comandoSQL, "@LOGIN", usuario.Login);
                HelperDB.AddParameter(comandoSQL, "@SENHA", usuario.Senha);
                HelperDB.AddParameter(comandoSQL, "@IDPESSOA", usuario.IdPessoa);
                comandoSQL.CommandType = CommandType.Text;
                conexao.Open();
                comandoSQL.ExecuteNonQuery();
            }
            finally
            {
                conexao.Close();
            }
        }
Esempio n. 16
0
        public void registrarMiembrosTesis(List <HorarioSustentacion> miembrosConHorario)
        {
            SqlConnection  cn          = null;
            SqlTransaction transaccion = null;

            try
            {
                cn = HelperDB.GetSqlConnection();
                //Inicio de la transaccion
                transaccion = cn.BeginTransaction();
                Solicitud solicitud = miembrosConHorario[0].solicitud;
                //Registrar el horario y los miembros
                foreach (HorarioSustentacion miembroHorario in miembrosConHorario)
                {
                    horarioRepository.registrarHorario(miembroHorario, cn, transaccion);
                }
                //Actualizar en estado FINALIZADO la solicitud
                //Estado 6= Finalizada
                SolicitudEstado nuevoEstado = estadoSolicitudRepository.obtenerPorId(6, cn, transaccion);
                if (nuevoEstado == null)
                {
                    throw new ArgumentNullException("No se encontro el estado FINALIZADO para la solicitud");
                }
                solicitudRepository.registrarEstadoFinalizado(solicitud, nuevoEstado, cn, transaccion);
                transaccion.Commit();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                transaccion.Rollback();
                throw new Exception(e.Message);
            }
            finally
            {
                if (cn != null)
                {
                    cn.Close();
                    cn.Dispose();
                }
            }
        }
        public void Update(Usuario usuario)
        {
            try
            {
                var SQL = "update USUARIO set LOGIN = @LOGIN, SENHA = @SENHA, IDPESSOA = @IDPESSOA where ID = @ID";

                IDbCommand comandoSQL = conexao.CreateCommand();
                comandoSQL.CommandText = SQL;
                HelperDB.AddParameter(comandoSQL, "@LOGIN", usuario.Login);
                HelperDB.AddParameter(comandoSQL, "@SENHA", usuario.Senha);
                HelperDB.AddParameter(comandoSQL, "@IDPESSOA", usuario.IdPessoa);

                comandoSQL.CommandType = CommandType.Text;
                conexao.Open();
                comandoSQL.ExecuteNonQuery();
            }
            finally
            {
                conexao.Close();
            }
        }
Esempio n. 18
0
        internal virtual void ClientDatabasesEnsureCreated()
        {
            // foreach server provider to test, there is a list of client / network
            foreach (var serverKey in this.lstClientsType)
            {
                // get the the network we want to use
                var networkType = serverKey.Key;

                // create all the client databases based in the flags we set
                foreach (var cpt in serverKey.Value.GetFlags())
                {
                    // cast (wait for C# 7.3 to be able to set an extension method where a generic T can be marked as Enum compliant :)
                    var clientProviderType = (ProviderType)cpt;

                    // check if we have the fixture provider to be able to create a client provider
                    if (!registeredProviders.ContainsKey(clientProviderType))
                    {
                        continue;
                    }

                    // generate a new database name
                    var dbName = GetRandomDatabaseName();

                    Console.WriteLine("Create client database called " + dbName + " for provider " + clientProviderType);

                    // get the connection string
                    var connectionString = HelperDB.GetConnectionString(clientProviderType, dbName);

                    // create the database on the client provider
                    HelperDB.CreateDatabase(clientProviderType, dbName);

                    // generate the client provider
                    var clientProvider = registeredProviders[clientProviderType].NewServerProvider(connectionString);

                    // then add the run
                    this.ClientRuns.Add(new ProviderRun(dbName, clientProvider, clientProviderType, networkType));
                }
            }
        }
        public void Insert(Pessoa pessoa)
        {
            try
            {
                var SQL = "insert into PESSOA (NOME, CPF_CNPJ, TIPOPESSOA, DATANASCIMENTO)" +
                          " values (@NOME, @CPF_CNPJ, @TIPOPESSOA, @DATANASCIMENTO)";

                IDbCommand comandoSQL = conexao.CreateCommand();
                comandoSQL.CommandText = SQL;
                HelperDB.AddParameter(comandoSQL, "@NOME", pessoa.Nome);
                HelperDB.AddParameter(comandoSQL, "@CPF_CNPJ", pessoa.Cpf_Cnpj);
                HelperDB.AddParameter(comandoSQL, "@TIPOPESSOA", pessoa.TipoPessoa);
                HelperDB.AddParameter(comandoSQL, "@DATANASCIMENTO", pessoa.DataNascimento);
                comandoSQL.CommandType = CommandType.Text;
                conexao.Open();
                comandoSQL.ExecuteNonQuery();
            }
            finally
            {
                conexao.Close();
            }
        }
        public void Update(Pessoa pessoa)
        {
            try
            {
                var SQL = "update PESSOA set NOME = @NOME, CPF_CNPJ = @CPF_CNPJ" +
                          " ,TIPOPESSOA = @TIPOPESSOA, DATANASCIMENTO = @DATANASCIMENTO where ID = @ID";

                IDbCommand comandoSQL = conexao.CreateCommand();
                comandoSQL.CommandText = SQL;
                HelperDB.AddParameter(comandoSQL, "@NOME", pessoa.Nome);
                HelperDB.AddParameter(comandoSQL, "@CPF_CNPJ", pessoa.Cpf_Cnpj);
                HelperDB.AddParameter(comandoSQL, "@TIPOPESSOA", pessoa.TipoPessoa);
                HelperDB.AddParameter(comandoSQL, "@ID", pessoa.Id);
                HelperDB.AddParameter(comandoSQL, "@DATANASCIMENTO", pessoa.DataNascimento);
                comandoSQL.CommandType = CommandType.Text;
                conexao.Open();
                comandoSQL.ExecuteNonQuery();
            }
            finally
            {
                conexao.Close();
            }
        }
Esempio n. 21
0
        public List <Alumno> obtenerAlumnosHabilitados()
        {
            SqlConnection cn   = null;
            List <Alumno> data = new List <Alumno>();

            try
            {
                cn   = HelperDB.GetSqlConnection();
                data = alumnoRepository.obtenerHabilitados(cn).ToList <Alumno>();;
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            finally
            {
                if (cn != null)
                {
                    cn.Close();
                    cn.Dispose();
                }
            }
            return(data);
        }
Esempio n. 22
0
        public Alumno buscarPorCodigo(string codigo)
        {
            SqlConnection cn     = null;
            Alumno        alumno = null;

            try
            {
                cn     = HelperDB.GetSqlConnection();
                alumno = alumnoRepository.buscarPorCodigo(codigo, cn);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            finally
            {
                if (cn != null)
                {
                    cn.Close();
                    cn.Dispose();
                }
            }
            return(alumno);
        }
Esempio n. 23
0
        public void registrarPagoSolicitud(PagoSolicitud pagoSolicitud)
        {
            SqlConnection  cn          = null;
            SqlTransaction transaccion = null;

            try
            {
                cn = HelperDB.GetSqlConnection();
                //Inicio de la transaccion
                transaccion = cn.BeginTransaction();
                //Estado 3= Cancelado
                SolicitudEstado estadoPagado = estadoSolicitudRepository.obtenerPorId(3, cn, transaccion);
                if (estadoPagado == null)
                {
                    throw new ArgumentNullException("No se encontro el estado PAGADO para la solicitud");
                }
                pagoSolicitudRepository.registrarPago(pagoSolicitud, cn, transaccion);
                //Modificar el estado de la solicitud
                solicitudRepository.cambiarEstadoPagadoSolicitud(pagoSolicitud.solicitud, estadoPagado, cn, transaccion);
                transaccion.Commit();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                transaccion.Rollback();
                throw new Exception(e.Message);
            }
            finally
            {
                if (cn != null)
                {
                    cn.Close();
                    cn.Dispose();
                }
            }
        }
Esempio n. 24
0
        public List <FormaDePago> obtenerFormasPagoHabilitadas()
        {
            SqlConnection      cn   = null;
            List <FormaDePago> data = new List <FormaDePago>();

            try
            {
                cn   = HelperDB.GetSqlConnection();
                data = formaPagoRepository.obtenerHabilitados(cn);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            finally
            {
                if (cn != null)
                {
                    cn.Close();
                    cn.Dispose();
                }
            }
            return(data);
        }
Esempio n. 25
0
        public System.Data.DataSet obtenerTodos()
        {
            SqlConnection cn = null;

            System.Data.DataSet dataSet = new System.Data.DataSet();
            try
            {
                cn      = HelperDB.GetSqlConnection();
                dataSet = alumnoRepository.obtenerTodos(cn);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            finally
            {
                if (cn != null)
                {
                    cn.Close();
                    cn.Dispose();
                }
            }
            return(dataSet);
        }
Esempio n. 26
0
        public List <Profesor> obtenerProfesoresHabilitados()
        {
            SqlConnection   cn   = null;
            List <Profesor> data = new List <Profesor>();

            try
            {
                cn   = HelperDB.GetSqlConnection();
                data = profesorRepository.obtenerHabilitados(cn);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            finally
            {
                if (cn != null)
                {
                    cn.Close();
                    cn.Dispose();
                }
            }
            return(data);
        }
Esempio n. 27
0
 public Tst()
 {
     hdb = new HelperDB();
 }
Esempio n. 28
0
 public void Dispose()
 {
     HelperDB.DropSqlDatabase(serverDbName);
     HelperDB.DropSqlDatabase(client1DbName);
 }
Esempio n. 29
0
 public CoreYandexPoints()
 {
     hdb     = new HelperDB();
     hyandex = new HelperYandex();
 }
Esempio n. 30
0
 public ServiceFinder()
 {
     hdb = new HelperDB();
     InitializeComponent();
 }