Ejemplo n.º 1
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);
            }
        }
Ejemplo n.º 2
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);
            }
        }
Ejemplo n.º 3
0
        public List <Manager> findByIdLogin(Login login, int flag)
        {
            List <Manager> lista = null;

            try {
                using (SQLiteConnection c = new conexion_sqlite().getConection())
                {
                    c.Open();
                    lista = new List <Manager>();
                    String sql = "SELECT id, username, password, url FROM MANAGER WHERE id_login = "******"id"].ToString());
                                String username = flag == 0 ? rdr["password"].ToString() : new Encriptacion().DecryptText(rdr["username"].ToString());
                                String password = flag == 0 ? rdr["password"].ToString() : new Encriptacion().DecryptText(rdr["password"].ToString());
                                String url      = rdr["url"].ToString();

                                Manager manager_ = new Manager(id, username, password, url);
                                lista.Add(manager_);
                            }
                        }
                    }
                }
                return(lista);
            }catch (Exception e) {
                return(lista);
            }
        }
Ejemplo n.º 4
0
 public int deleteById(Manager manager)
 {
     try
     {
         using (SQLiteConnection c = new conexion_sqlite().getConection())
         {
             c.Open();
             String sql = "DELETE FROM MANAGER WHERE id =" + manager.id;
             using (SQLiteCommand cmd = new SQLiteCommand(sql, c))
             {
                 return(cmd.ExecuteNonQuery());
             }
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
         return(0);
     }
 }
Ejemplo n.º 5
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);
     }
 }
Ejemplo n.º 6
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);
            }
        }
Ejemplo n.º 7
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);
            }
        }