public List <Modelo.hDisponivel> SelectAll() { Modelo.hDisponivel aArea; List <Modelo.hDisponivel> aListAreas = new List <Modelo.hDisponivel>(); SqlConnection conn = new SqlConnection(connectionstring); conn.Open(); SqlCommand cmd = conn.CreateCommand(); cmd.CommandText = "Select * from horario_Disponivel"; SqlDataReader dr = cmd.ExecuteReader(); if (dr.HasRows) { while (dr.Read()) { aArea = new Modelo.hDisponivel( Alternadores.AlternadorI(dr["dia_semana"].ToString()), dr["hora_inicio"].ToString(), dr["hora_fim"].ToString(), Alternadores.AlternadorI(dr["id_AreaPoliesportiva"].ToString()) ); aListAreas.Add(aArea); } } dr.Close(); conn.Close(); return(aListAreas); }
public List <Modelo.AreaSport> SelectAll() { Modelo.AreaSport aAreaSports; List <Modelo.AreaSport> aListAreaSports = new List <Modelo.AreaSport>(); SqlConnection conn = new SqlConnection(connectionString); conn.Open(); SqlCommand cmd = conn.CreateCommand(); cmd.CommandText = "Select * from area_Atividade"; SqlDataReader dr = cmd.ExecuteReader(); if (dr.HasRows) { while (dr.Read()) { aAreaSports = new Modelo.AreaSport( Alternadores.AlternadorI(dr["id_AtividadeEsportiva"].ToString()), Alternadores.AlternadorI(dr["id_AreaPoliesportiva"].ToString())); aListAreaSports.Add(aAreaSports); } } dr.Close(); conn.Close(); return(aListAreaSports); }
public List <Modelo.Usuario> SelectAll() { Modelo.Usuario aUsuario; List <Modelo.Usuario> aListUsuario = new List <Modelo.Usuario>(); SqlConnection conn = new SqlConnection(connectionString); conn.Open(); SqlCommand cmd = conn.CreateCommand(); cmd.CommandText = "Select * from usuario"; SqlDataReader dr = cmd.ExecuteReader(); if (dr.HasRows) { while (dr.Read()) { aUsuario = new Modelo.Usuario( dr["senha"].ToString(), Alternadores.AlternadorI(dr["tipo_Usuario"].ToString()), dr["nome"].ToString(), dr["email"].ToString(), dr["email"].ToString(), dr["telefone"].ToString() ); aListUsuario.Add(aUsuario); } } dr.Close(); conn.Close(); return(aListUsuario); }
public static int Identity() { int i = 0; SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["SGEConnectionString"].ConnectionString); conn.Open(); SqlCommand com = conn.CreateCommand(); SqlCommand cmd = new SqlCommand(); cmd.CommandText = @"select top(1) id from usuario order by id desc"; cmd.Connection = conn; SqlDataReader dr = cmd.ExecuteReader(); if (dr.HasRows) { while (dr.Read()) { i = Alternadores.AlternadorI(dr["id"].ToString()); } } dr.Close(); conn.Close(); return(i + 1); }
public List <Modelo.Usuario> Select(string id) { Modelo.Usuario aUsuario; List <Modelo.Usuario> aListUsuario = new List <Modelo.Usuario>(); SqlConnection conn = new SqlConnection(connectionString); conn.Open(); SqlCommand cmd = conn.CreateCommand(); cmd.CommandText = "Select * from Usuario Where id = @id"; cmd.Parameters.AddWithValue("@id", id); SqlDataReader dr = cmd.ExecuteReader(); if (dr.HasRows) { while (dr.Read()) { aUsuario = new Modelo.Usuario(dr["senha"].ToString(), Alternadores.AlternadorI(dr["tipo_Usuario"].ToString()), dr["nome"].ToString(), dr["email"].ToString(), dr["telefones"].ToString()); aListUsuario.Add(aUsuario); } } else { return(null); } dr.Close(); conn.Close(); return(aListUsuario); }
public List <Modelo.SolicitacaoReserva> SelectAll() { Modelo.SolicitacaoReserva aSolicitacaoReserva; List <Modelo.SolicitacaoReserva> aListSolicitacaoReserva = new List <Modelo.SolicitacaoReserva>(); SqlConnection conn = new SqlConnection(connectionstring); conn.Open(); SqlCommand cmd = conn.CreateCommand(); cmd.CommandText = "Select * from solicitacao_Reserva"; SqlDataReader dr = cmd.ExecuteReader(); if (dr.HasRows) { while (dr.Read()) { aSolicitacaoReserva = new Modelo.SolicitacaoReserva( Alternadores.AlternadorDT(dr["horario_Solicitacao"].ToString()), dr["atividades_Realizadas"].ToString(), dr["motivo_Solicitacao"].ToString(), Alternadores.AlternadorDT(dr["Data_ini"].ToString()), Alternadores.AlternadorDT(dr["Data_fim"].ToString()), Alternadores.AlternadorI(dr["id_Usuario_Solicitante"].ToString()), Alternadores.AlternadorI(dr["id_AreaPoliesportiva"].ToString()) ); aListSolicitacaoReserva.Add(aSolicitacaoReserva); } } dr.Close(); conn.Close(); return(aListSolicitacaoReserva); }
public bool InsertAreaImg(string url, int idArea) { try { Modelo.Img mimg = new Modelo.Img(url); SqlConnection conn = new SqlConnection(connectionstring); conn.Open(); SqlCommand cmd = conn.CreateCommand(); cmd.CommandText = @"Insert into Img (img_Url) values (@url) Select max(id) as id from Img"; cmd.Parameters.AddWithValue("@url", url); SqlDataReader dr = cmd.ExecuteReader(); int id = 0; if (dr.HasRows) { int i = 0; while (dr.Read()) { if (i > 0) { break; } id = Alternadores.AlternadorI(dr["id"].ToString()); i++; } } dr.Close(); SqlCommand ncmd = conn.CreateCommand(); if (id > 0) { ncmd.CommandText = "Insert into Area_Img (id_Area,id_Img) values (@idA,@idI)"; ncmd.Parameters.AddWithValue("@idA", Identity()); ncmd.Parameters.AddWithValue("@idI", id); ncmd.ExecuteNonQuery(); } else { throw new Exception(); } return(true); } catch { return(false); } }