using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Data; using System.Data.Common; using System.Data.Sql; using System.Data.SqlClient; /// /// Summary description for Usuario /// public class Usuario { public Usuario() { // // TODO: Add constructor logic here // } private int _id; public int id { get { return _id; } set { _id = value; } } private string _email; public string email { get { return _email; } set { _email = value; } } private string _senha; public string senha { get { return _senha; } set { _senha = value; } } public DataSet GetAll() { using (SqlConnection Con = new SqlConnection(Conexao.GetConexaoAtiva())) { Con.Open(); SqlCommand cmd = new SqlCommand("select * from USUARIOS ", Con); SqlDataAdapter adapter = new SqlDataAdapter(cmd); DataSet ds = new DataSet(); adapter.Fill(ds, "DS"); return ds; } } public void GetEmailSenha(string email, string senha) { using (SqlConnection Con = new SqlConnection(Conexao.GetConexaoAtiva())) { Con.Open(); SqlCommand cmd = new SqlCommand("select * from USUARIOS where login = @login and senha = @senha and ativo = 1", Con); cmd.Parameters.AddWithValue("@login", email.ToString()); cmd.Parameters.AddWithValue("@senha", senha.ToString()); SqlDataReader DR = cmd.ExecuteReader(); if (DR.HasRows) { while (DR.Read()) { id = DR.GetInt32(0); email = DR.GetString(1); senha = DR.GetString(2); } } else { id = 0; } DR.Close(); } } }