Exemplo n.º 1
0
        public List <Specialist> Obtener()
        {
            SqlConnection con = new SqlConnection(Resource.CadenaConexion);

            con.Open();
            List <Specialist> lista = new List <Specialist>();

            try
            {
                DocumentTypeManager documentTypeManager = new DocumentTypeManager();

                string sql = "select Id,Login,Names,LastNames," +
                             "Email,CompanyName,ServiceDescription," +
                             "DocumentTypeId,PhoneNumber," +
                             "Facebook,Website,Address,Reference,Latitude," +
                             "Longitude,Accredited,Membership,Rate," +
                             "Online,State from Specialists";

                SqlCommand    cmd    = new SqlCommand(sql, con);
                SqlDataReader reader = cmd.ExecuteReader(System.Data.CommandBehavior.CloseConnection);
                while (reader.Read())
                {
                    Specialist spe = new Specialist();
                    spe.id                 = reader.GetInt32(0);
                    spe.login              = reader.GetString(1);
                    spe.name               = reader.GetString(2);
                    spe.lastName           = reader.GetString(3);
                    spe.email              = reader.GetString(4);
                    spe.companyName        = reader.GetString(5);
                    spe.serviceDescription = reader.GetString(6);
                    spe.document           = documentTypeManager.Obtener(reader.GetInt32(7));
                    spe.phoneNumber        = reader.GetString(8);
                    spe.facebook           = reader.GetString(9);
                    spe.webSite            = reader.GetString(10);
                    spe.address            = reader.GetString(11);
                    spe.reference          = reader.GetString(12);
                    spe.latitude           = reader.GetDecimal(13);
                    spe.longitude          = reader.GetDecimal(14);
                    spe.acredited          = reader.GetBoolean(15);
                    spe.memberShip         = reader.GetBoolean(16);
                    spe.rate               = reader.GetDecimal(17);
                    spe.online             = reader.GetBoolean(18);
                    spe.state              = reader.GetBoolean(19);
                    lista.Add(spe);
                }
                reader.Close();
            }
            catch (Exception e)
            {
                System.Console.WriteLine(e);
            }
            if (con.State == System.Data.ConnectionState.Open)
            {
                con.Close();
            }
            return(lista);
        }
Exemplo n.º 2
0
        public Specialist Obtener(int id)
        {
            DocumentTypeManager documentTypeManager = new DocumentTypeManager();

            Specialist    spe = null;
            SqlConnection con = new SqlConnection(Resource.CadenaConexion);

            con.Open();
            string sql = "select Id,Login,Password,Names,LastNames," +
                         "Email,CompanyName,ServiceDescription," +
                         "DocumentTypeId,PhoneNumber," +
                         "Facebook,Website,Address,Reference,Latitude," +
                         "Longitude,Accredited,Membership,Rate," +
                         "Online,State from Specialists where Id = @idSpecialist";

            SqlCommand cmd = new SqlCommand(sql, con);

            cmd.Parameters.Add("@idSpecialist", System.Data.SqlDbType.NVarChar).Value = id;
            SqlDataReader reader =
                cmd.ExecuteReader(System.Data.CommandBehavior.CloseConnection);

            if (reader.Read())
            {
                spe                    = new Specialist();
                spe.id                 = reader.GetInt32(0);
                spe.login              = reader.GetString(1);
                spe.password           = reader.GetString(2);
                spe.name               = reader.GetString(3);
                spe.lastName           = reader.GetString(4);
                spe.email              = reader.GetString(5);
                spe.companyName        = reader.GetString(6);
                spe.serviceDescription = reader.GetString(7);
                spe.document           = documentTypeManager.Obtener(reader.GetInt32(8));
                spe.phoneNumber        = reader.GetString(9);
                spe.facebook           = reader.GetString(10);
                spe.webSite            = reader.GetString(11);
                spe.address            = reader.GetString(12);
                spe.reference          = reader.GetString(13);
                spe.latitude           = reader.GetDecimal(14);
                spe.longitude          = reader.GetDecimal(15);
                spe.acredited          = reader.GetBoolean(16);
                spe.memberShip         = reader.GetBoolean(17);
                spe.rate               = reader.GetDecimal(18);
                spe.online             = reader.GetBoolean(19);
                spe.state              = reader.GetBoolean(20);
            }
            reader.Close();
            if (con.State == System.Data.ConnectionState.Open)
            {
                con.Close();
            }
            return(spe);
        }
Exemplo n.º 3
0
        public List <Customer> Obtener()
        {
            SqlConnection con = new SqlConnection(Resource.CadenaConexion);

            con.Open();
            List <Customer> lista = new List <Customer>();

            try
            {
                DocumentTypeManager documentTypeManager = new DocumentTypeManager();

                string sql = "Select Id,Login,Names,LastNames,Email," +
                             "DocumentTypeId,PhoneNumber,Address," +
                             "Reference,Latitude,Longitude,Rate," +
                             "Online,State from Customers";
                SqlCommand    cmd    = new SqlCommand(sql, con);
                SqlDataReader reader = cmd.ExecuteReader(System.Data.CommandBehavior.CloseConnection);
                while (reader.Read())
                {
                    Customer spe = new Customer();
                    spe.id          = reader.GetInt32(0);
                    spe.login       = reader.GetString(1);
                    spe.name        = reader.GetString(2);
                    spe.lastName    = reader.GetString(3);
                    spe.email       = reader.GetString(4);
                    spe.document    = documentTypeManager.Obtener(reader.GetInt32(5));
                    spe.phoneNumber = reader.GetString(6);
                    spe.address     = reader.GetString(7);
                    spe.reference   = reader.GetString(8);
                    spe.latitude    = reader.GetDecimal(9);
                    spe.longitude   = reader.GetDecimal(10);
                    spe.rate        = reader.GetDecimal(11);
                    spe.online      = reader.GetBoolean(12);
                    spe.state       = reader.GetBoolean(13);
                    lista.Add(spe);
                }
                reader.Close();
            }
            catch (Exception e)
            {
                System.Console.WriteLine(e);
            }
            if (con.State == System.Data.ConnectionState.Open)
            {
                con.Close();
            }
            return(lista);
        }
Exemplo n.º 4
0
        public Customer Obtener(int id)
        {
            DocumentTypeManager documentTypeManager = new DocumentTypeManager();
            Customer            spe = null;
            SqlConnection       con = new SqlConnection(Resource.CadenaConexion);

            con.Open();
            string sql = "Select Id,Login,Password,Names,LastNames,Email," +
                         "DocumentTypeId,PhoneNumber,Address," +
                         "Reference,Latitude,Longitude,Rate," +
                         "Online,State from Customers where Id = @idClient";
            SqlCommand cmd = new SqlCommand(sql, con);

            cmd.Parameters.Add("@idClient", System.Data.SqlDbType.NVarChar).Value = id;
            SqlDataReader reader =
                cmd.ExecuteReader(System.Data.CommandBehavior.CloseConnection);

            if (reader.Read())
            {
                spe             = new Customer();
                spe.id          = reader.GetInt32(0);
                spe.login       = reader.GetString(1);
                spe.password    = reader.GetString(2);
                spe.name        = reader.GetString(3);
                spe.lastName    = reader.GetString(4);
                spe.email       = reader.GetString(5);
                spe.document    = documentTypeManager.Obtener(reader.GetInt32(6));
                spe.phoneNumber = reader.GetString(7);
                spe.address     = reader.GetString(8);
                spe.reference   = reader.GetString(9);
                spe.latitude    = reader.GetDecimal(10);
                spe.longitude   = reader.GetDecimal(11);
                spe.rate        = reader.GetDecimal(12);
                spe.online      = reader.GetBoolean(13);
                spe.state       = reader.GetBoolean(14);
            }
            reader.Close();
            if (con.State == System.Data.ConnectionState.Open)
            {
                con.Close();
            }
            return(spe);
        }