コード例 #1
0
        public int findById(Login login)
        {
            String passwordEncrypt = new Algoritmo_Encriptacion.Encriptacion().EncryptText(login.password);

            //String passwordDecencrypt = new Algoritmo_Encriptacion.Encriptacion().DecryptText(passwordEncrypt, login.password);
            try
            {
                using (SQLiteConnection c = new conexion_sqlite().getConection())
                {
                    c.Open();
                    String sql = "SELECT id FROM LOGIN WHERE username ='******' AND password = '******'";
                    using (SQLiteCommand cmd = new SQLiteCommand(sql, c))
                    {
                        using (SQLiteDataReader rdr = cmd.ExecuteReader())
                        {
                            if (rdr.Read())
                            {
                                return(1);
                            }
                            else
                            {
                                return(0);
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                return(0);
            }
        }
コード例 #2
0
        public String restore_password(Login login)
        {
            String password = null;

            try
            {
                using (SQLiteConnection c = new conexion_sqlite().getConection())
                {
                    c.Open();
                    String sql = "SELECT password FROM LOGIN WHERE username = '******'";
                    using (SQLiteCommand cmd = new SQLiteCommand(sql, c))
                    {
                        using (SQLiteDataReader rdr = cmd.ExecuteReader())
                        {
                            while (rdr.Read())
                            {
                                password = new Algoritmo_Encriptacion.Encriptacion().DecryptText(rdr["password"].ToString());
                            }
                        }
                    }
                }
                return(password);
            }
            catch (Exception e)
            {
                return(password);
            }
        }
コード例 #3
0
 public int agregar(Login login)
 {
     try
     {
         String password = new Algoritmo_Encriptacion.Encriptacion().EncryptText(login.password);
         using (SQLiteConnection c = new conexion_sqlite().getConection())
         {
             c.Open();
             String sql = "INSERT INTO LOGIN (username, password) values ('" + login.username + "','" + password + "')";
             using (SQLiteCommand cmd = new SQLiteCommand(sql, c))
             {
                 return(cmd.ExecuteNonQuery());
             }
         }
     }
     catch (Exception e)
     {
         MessageBox.Show(e.Message);
         return(0);
     }
 }
コード例 #4
0
        public int updateById(Manager manager_)
        {
            try
            {
                String username = new Algoritmo_Encriptacion.Encriptacion().EncryptText(manager_.username);
                String password = new Algoritmo_Encriptacion.Encriptacion().EncryptText(manager_.password);

                using (SQLiteConnection c = new conexion_sqlite().getConection())
                {
                    c.Open();
                    String sql = "UPDATE MANAGER set username ='******',password='******',url='" + manager_.url + "' WHERE id =" + manager_.id;
                    using (SQLiteCommand cmd = new SQLiteCommand(sql, c))
                    {
                        return(cmd.ExecuteNonQuery());
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                return(0);
            }
        }
コード例 #5
0
        public int agregar(Manager manager)
        {
            String password = new Algoritmo_Encriptacion.Encriptacion().EncryptText(manager.password);
            String username = new Algoritmo_Encriptacion.Encriptacion().EncryptText(manager.username);

            try
            {
                using (SQLiteConnection c = new conexion_sqlite().getConection())
                {
                    c.Open();
                    String sql = "INSERT INTO MANAGER (username, password, url, id_login) values ('" + username + "','" + password + "','" + manager.url + "'," + manager.login + ")";
                    using (SQLiteCommand cmd = new SQLiteCommand(sql, c))
                    {
                        return(cmd.ExecuteNonQuery());
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                return(0);
            }
        }