Esempio n. 1
0
        }//

        /// <summary>
        ///
        /// </summary>
        /// <param name="login"></param>
        /// <param name="senha"></param>
        /// <param name="ativo"></param>
        /// <param name="perfil"></param>
        /// <param name="email"></param>
        /// <param name="con"></param>
        /// <returns></returns>
        public static Boolean cadastraUsuario(string login, string senha, bool ativo, int perfil, string email, OleDbConnection con)
        {
            bool   flag = false;
            string sql  = "Insert Into Usuarios(login,senha,ativo,perfil,email) values(?,?,?,?,?)";

            try
            {
                OleDbCommand cmd = new OleDbCommand(sql, con);

                cmd.Parameters.Add(new System.Data.OleDb.OleDbParameter("login", login));
                cmd.Parameters.Add(new System.Data.OleDb.OleDbParameter("senha", Acesso.GerarHash(senha)));
                cmd.Parameters.Add(new System.Data.OleDb.OleDbParameter("ativo", ativo));
                cmd.Parameters.Add(new System.Data.OleDb.OleDbParameter("perfil", perfil));
                cmd.Parameters.Add(new System.Data.OleDb.OleDbParameter("email", email));

                int rg = cmd.ExecuteNonQuery();
                if (rg > 0)
                {
                    flag = true;
                }
                else
                {
                    flag = false;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(flag);
        }//
Esempio n. 2
0
        }//

        /// <summary>
        ///         ///
        /// </summary>
        /// <param name="login"></param>
        /// <param name="senha"></param>
        /// <param name="con"></param>
        /// <returns></returns>
        public static Boolean alteraSenha(string login, string senha, OleDbConnection con)
        {
            bool   flag = false;
            string sql  = "Update Usuarios set senha = ? Where login = ?";

            try
            {
                OleDbCommand cmd = new OleDbCommand(sql, con);

                cmd.Parameters.Add(new System.Data.OleDb.OleDbParameter("login", login));
                cmd.Parameters.Add(new System.Data.OleDb.OleDbParameter("senha", Acesso.GerarHash(senha)));
                int rg = cmd.ExecuteNonQuery();
                if (rg > 0)
                {
                    flag = true;
                }
                else
                {
                    flag = false;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(flag);
        }//