Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using capaDALC;
- namespace capaLogicaNegocio
- {
- public class CL_Cliente
- {
- private string _rut;
- private string _nombre;
- private string _apellido;
- private string _telefono;
- #region
- public string Rut
- {
- get
- {
- return _rut;
- }
- set
- {
- _rut = value;
- }
- }
- public string Nombre
- {
- get
- {
- return _nombre;
- }
- set
- {
- _nombre = value;
- }
- }
- public string Apellido
- {
- get
- {
- return _apellido;
- }
- set
- {
- _apellido = value;
- }
- }
- public string Telefono
- {
- get
- {
- return _telefono;
- }
- set
- {
- _telefono = value;
- }
- }
- #endregion
- private CL_Contexto conexion;
- public CL_Cliente()
- {
- conexion = new CL_Contexto();
- }
- public CL_Cliente(string rut)
- {
- this.Rut = rut;
- }
- public bool agregar() {
- try
- {
- Cliente cliente = new Cliente();
- cliente.Rut = this.Rut;
- cliente.Nombres = this.Nombre;
- cliente.Apellidos = this.Apellido;
- cliente.Telefono = this.Telefono;
- conexion.Entidades.Cliente.Add(cliente);
- conexion.Entidades.SaveChanges();
- return true;
- }
- catch (Exception ex)
- {
- return false;
- }
- }
- public CL_Cliente buscar() {
- try
- {
- Cliente cliente = conexion.Entidades.Cliente.First(x=>x.Rut == this.Rut);
- CL_Cliente cli = new CL_Cliente();
- cli.Rut = cliente.Rut;
- cli.Nombre = cliente.Nombres;
- cli.Apellido = cliente.Apellidos;
- cli.Telefono = cliente.Telefono;
- return cli;
- }
- catch (Exception ex)
- {
- return null;
- }
- }
- public bool actualizar() {
- try
- {
- Cliente cliente = conexion.Entidades.Cliente.First(x => x.Rut == this.Rut);
- cliente.Rut = this.Rut;
- cliente.Nombres = this.Nombre;
- cliente.Apellidos = this.Apellido;
- cliente.Telefono = this.Telefono;
- conexion.Entidades.SaveChanges();
- return true;
- }
- catch (Exception ex)
- {
- return false;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement