Skip to content

Instantly share code, notes, and snippets.

@xerardoo
Created April 23, 2014 15:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xerardoo/11219420 to your computer and use it in GitHub Desktop.
Save xerardoo/11219420 to your computer and use it in GitHub Desktop.
Clase DAO Clientes
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DevExpress.Xpo;
using DevExpress.Data.Filtering;
namespace Clientes_Orden.Model
{
/**
* @author: Lucio G. Pasos
* @email: gerardoo_2413@hotmail.com
* @date: 23/04/2014
* @description: Clase para el acceso a datos, Capa entre XPO - Clientes_Orden.SIGOB
*/
public class ClienteDAO
{
/**
* @author: Lucio G. Pasos
* @description: Metodo para insertar clientes
* @name: insertCliente
* @params: Nombre, ApPaterno, ApMaterno, Rfc, Direccion, Telefono
*
* */
public void insertCliente(string Nombre, string ApPaterno, string ApMaterno,
string Rfc, string Direccion, string Telefono) {
using (var uow = new UnitOfWork())
{
Cliente C = new Cliente(uow);
C.nombre = Nombre;
C.apPaterno = ApPaterno;
C.apMaterno = ApMaterno;
C.rfc = Rfc;
C.direccion = Direccion;
C.telefono = Telefono;
C.Save();
uow.CommitChanges();
}
}
/**
* @author: Lucio G. Pasos
* @description: Metodo para modificar clientes
* @name: updateCliente
* @params: IdCliente,Nombre, ApPaterno, ApMaterno, Rfc, Direccion, Telefono
*
* */
public void updateCliente(int IdCliente, string Nombre, string ApPaterno, string ApMaterno, string Rfc,
string Direccion, string Telefono)
{
using (var uow = new UnitOfWork())
{
Cliente update = uow.FindObject<Cliente>(CriteriaOperator.Parse("idCliente == '" + IdCliente + "'"));
update.nombre = Nombre;
update.apPaterno = ApPaterno;
update.apMaterno = ApMaterno;
update.rfc = Rfc;
update.direccion = Direccion;
update.telefono = Telefono;
update.Save();
uow.CommitChanges();
}
}
/**
* @author: Lucio G. Pasos
* @description: Metodo para eliminar un cliente
* @name: deleteCliente
* @params: IdCliente
*
* */
public void deleteCliente(int IdCliente){
using (var uow = new UnitOfWork())
{
Cliente getCliente =
new XPCollection<Cliente>(uow, CriteriaOperator.Parse("idCliente == '" + IdCliente + "'")).FirstOrDefault();
getCliente.Delete();
uow.CommitChanges();
}
}
/**
* @author: Lucio G. Pasos
* @description: Metodo para obtener todos los clientes
* @name: getClientes
* @params: Nombre, ApPaterno, ApMaterno
*
* */
public XPCollection<Cliente> getClientes(string Nombre, string ApPaterno, string ApMaterno)
{
using (var uow = new UnitOfWork())
{
XPCollection<Cliente> Clientes =
new XPCollection<Cliente>(uow,
CriteriaOperator.Parse("nombre LIKE '" + Nombre + "' AND apPaterno LIKE '" + ApPaterno + "' AND apPaterno LIKE '" + ApMaterno + "' "+ //todos iguales
" nombre LIKE '" + Nombre + "' OR apPaterno LIKE '" + ApPaterno + "' OR apMaterno LIKE '" + ApMaterno + "' "+ //uno coincide
" nombre LIKE '" + Nombre + "' AND apPaterno LIKE '" + ApPaterno + "' OR apMaterno LIKE '" + ApMaterno + "' "+ //nombre y apPaterno o apMaterno coiciden
" nombre LIKE '" + Nombre + "' OR apPaterno LIKE '" + ApPaterno + "' AND apMaterno LIKE '" + ApMaterno + "' "+ //apMaterno y apPaterno o nombre coiciden
" nombre LIKE '" + Nombre + "' OR apMaterno LIKE '" + ApMaterno + "' AND apPaterno LIKE '" + ApPaterno + "' ")); //apPaterno y apMaterno o nombre coiciden
return Clientes;//retorna la una lista de todos los clientes
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment