public virtual DatosEntity GetEstacionesFromReader(IDataReader reader) { DatosEntity entity = null; try { entity = new DatosEntity(); entity.Id = reader["id"] == System.DBNull.Value ? 0 : (int)reader["id"]; entity.Nombre = reader["nombre"] == System.DBNull.Value ? "Null":(string)reader["nombre"]; entity.Latitud = reader["latitud"] == System.DBNull.Value ? 0 : Convert.ToDecimal(reader["latitud"]); entity.Longitud = reader["longitud"] == System.DBNull.Value ? 0 : Convert.ToDecimal(reader["longitud"]); entity.IdUsuario = 0; entity.Usuario = "Null"; entity.Password = "******"; entity.NombreUsuario = "Null"; entity.Apellido = "Null"; }catch (Exception ex) { throw new Exception("Error al consultar datos...", ex); } return(entity); }
public virtual DatosEntity GetEstacionesFromReader1(IDataReader reader) { DatosEntity entity = null; try { entity = new DatosEntity(); entity.Id = 0; entity.Nombre = "Null"; entity.Latitud = 0; entity.Longitud = 0; entity.IdUsuario = reader["id_usuarios"] == System.DBNull.Value ? 0 : (int)reader["id_usuarios"];; entity.Usuario = reader["usr"] == System.DBNull.Value ? "Null" : (string)reader["usr"]; entity.Password = reader["pwd"] == System.DBNull.Value ? "Null" : (string)reader["pwd"]; entity.NombreUsuario = reader["nombre"] == System.DBNull.Value ? "Null" : (string)reader["nombre"]; entity.Apellido = reader["apellidoM"] == System.DBNull.Value ? "Null" : (string)reader["apellidoM"]; } catch (Exception ex) { throw new Exception("Error al consultar datos...", ex); } return(entity); }
public override List <DatosEntity> GetDatosUsuario(string user, string passwrd) { DatosEntity entityEstacion = null; List <DatosEntity> List = new List <DatosEntity>(); SqlConnection connection = new SqlConnection(DataAccess.SqlGlobalConectionString); SqlCommand command = new SqlCommand("select id_usuarios,usr,pwd,nombre,apellidoM from caborca_usuarios where usr='******' and pwd='" + passwrd + "' ", connection); command.CommandType = System.Data.CommandType.Text; SqlDataReader reader = null; try { if (connection.State == ConnectionState.Closed) { connection.Open(); } reader = command.ExecuteReader(); while (reader.Read()) { entityEstacion = new DatosEntity(); entityEstacion = GetEstacionesFromReader1(reader); List.Add(entityEstacion); } } catch (Exception ex) { throw new Exception("Error al consultar Estaciones..." + ex.Message, ex); } finally { connection.Close(); reader.Close(); connection.Dispose(); } return(List); }
public override List <DatosEntity> GetDatosEstacion(int id) { DatosEntity entityEstacion = null; List <DatosEntity> List = new List <DatosEntity>(); SqlConnection connection = new SqlConnection(DataAccess.SqlGlobalConectionString); SqlCommand command = new SqlCommand("select id,nombre,latitud,longitud from caborca_estaciones where id=" + id, connection); command.CommandType = System.Data.CommandType.Text; SqlDataReader reader = null; try { if (connection.State == ConnectionState.Closed) { connection.Open(); } reader = command.ExecuteReader(); while (reader.Read()) { entityEstacion = new DatosEntity(); entityEstacion = GetEstacionesFromReader(reader); List.Add(entityEstacion); } } catch (Exception ex) { throw new Exception("Error al consultar Estaciones..." + ex.Message, ex); } finally { connection.Close(); reader.Close(); connection.Dispose(); } return(List); }