Exemplo n.º 1
0
        public bool InsertarCliente(Cliente cliente)
        {
            try
            {
                //creamos un cliente de DALC, ya que el tiene
                //acceso a la BBDD
                Belife.DALC.Cliente c = new Belife.DALC.Cliente();
                c.Rut             = cliente.Rut;
                c.Nombres         = cliente.Nombres;
                c.Apellidos       = cliente.Apellidos;
                c.FechaNacimiento = cliente.FechaNacimiento;

                c.Sexo          = cliente.Sex;
                c.EstadoCivilId = cliente.EstadoCivilId;
                //le decimos al entity framework que guarde
                //el cliente
                db.Cliente.Add(c);
                //db.Cliente.Remove(c);
                db.SaveChanges();
                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
Exemplo n.º 2
0
        public bool EliminarClientes(string rut)
        {
            try
            {
                //para eliminar primero debemos buscar
                Belife.DALC.Cliente c = this.db.Cliente.Find(rut);

                this.db.Cliente.Remove(c);
                this.db.SaveChanges();
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Exemplo n.º 3
0
        public bool ModificarCliente(Cliente cliente)
        {
            try
            {
                //para poder modificar primero debemos buscar el cliente
                Belife.DALC.Cliente c = this.db.Cliente.Find(cliente.Rut);
                c.Nombres         = cliente.Nombres;
                c.Apellidos       = cliente.Apellidos;
                c.FechaNacimiento = cliente.FechaNacimiento;
                c.EstadoCivilId   = cliente.EstadoCivilId;
                c.Sexo            = cliente.Sex;

                //para actualizar un registro hay que cambiar su estado
                this.db.Entry(c).State = System.Data.EntityState.Modified;
                this.db.SaveChanges();
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }