Esempio n. 1
0
        public string EditContacto(ContactoModel contacto)
        {
            string estado = string.Empty;

            try
            {
                using (SqlConnection sqlcon = new SqlConnection(CadenaConexion))
                {
                    sqlcon.Open();
                    SqlCommand command = new SqlCommand("Actualizar_contacto", sqlcon);
                    command.CommandType = CommandType.StoredProcedure;

                    command.Parameters.AddWithValue("@id", contacto._id);
                    command.Parameters.AddWithValue("@nombre", contacto.Nombre);
                    command.Parameters.AddWithValue("@paterno", contacto.Apellido_paterno);
                    command.Parameters.AddWithValue("@materno", contacto.Apellido_materno);
                    command.Parameters.AddWithValue("@Telefono", contacto.Telefono);
                    command.Parameters.AddWithValue("@id_cliente", contacto.id_cliente);


                    command.ExecuteNonQuery();
                    sqlcon.Close();
                }
                estado = "OK";
            }
            catch
            {
                estado = "ERROR";
            }
            return(estado);
        }
Esempio n. 2
0
        public List <ContactoModel> GetContactoByLike(string nombre, string apellido)
        {
            using (SqlConnection sqlcon = new SqlConnection(CadenaConexion))
            {
                sqlcon.Open();
                SqlCommand command = new SqlCommand("Buscar_contacto", sqlcon);
                command.CommandType = CommandType.StoredProcedure;

                command.Parameters.AddWithValue("@nombre", nombre);
                command.Parameters.AddWithValue("@apellido", apellido);
                SqlDataReader dr = command.ExecuteReader();


                while (dr.Read())
                {
                    var c = new ContactoModel();
                    c._id              = Convert.ToInt32(dr["_id"]);
                    c.Nombre           = dr["Nombre"].ToString();
                    c.Apellido_paterno = dr["Apellido_paterno"].ToString();
                    c.Apellido_materno = dr["Apellido_materno"].ToString();
                    c.Telefono         = dr["Telefono"].ToString();
                    c.id_cliente       = Convert.ToInt32(dr["id_cliente"]);

                    CONTACTOLIST.Add(c);
                }

                sqlcon.Close();;
            }
            return(CONTACTOLIST);
        }
Esempio n. 3
0
        public ContactoModel GetContactByID(int?id)
        {
            using (SqlConnection sqlcon = new SqlConnection(CadenaConexion))
            {
                sqlcon.Open();
                SqlCommand command = new SqlCommand("Buscar_contacto_id", sqlcon);
                command.CommandType = CommandType.StoredProcedure;

                command.Parameters.AddWithValue("@id", id);
                SqlDataReader dr = command.ExecuteReader();


                while (dr.Read())
                {
                    var c = new ContactoModel();
                    CONTACTO._id              = Convert.ToInt32(dr["_id"]);
                    CONTACTO.Nombre           = dr["Nombre"].ToString();
                    CONTACTO.Apellido_paterno = dr["Apellido_paterno"].ToString();
                    CONTACTO.Apellido_materno = dr["Apellido_materno"].ToString();
                    CONTACTO.Telefono         = dr["Telefono"].ToString();


                    CONTACTOLIST.Add(c);
                }

                sqlcon.Close();
            }

            return(CONTACTO);
        }
Esempio n. 4
0
        public List <ContactoModel> GetAllContacts()
        {
            using (SqlConnection sqlcon = new SqlConnection(CadenaConexion))
            {
                sqlcon.Open();
                SqlCommand command = new SqlCommand("Listar_contactos", sqlcon);
                command.CommandType = CommandType.StoredProcedure;

                SqlDataReader dr = command.ExecuteReader();

                while (dr.Read())
                {
                    var c = new ContactoModel();
                    c._id              = Convert.ToInt32(dr["_id"]);
                    c.Nombre           = dr["Nombre"].ToString();
                    c.Apellido_paterno = dr["Apellido_paterno"].ToString();
                    c.Apellido_materno = dr["Apellido_materno"].ToString();
                    c.Telefono         = dr["Telefono"].ToString();
                    c.id_cliente       = Convert.ToInt32(dr["id_cliente"]);


                    CONTACTOLIST.Add(c);
                }
                sqlcon.Close();;
            }

            return(CONTACTOLIST);
        }