public void Delete(int Id) { Init(); try { using (LQCEEntities context = new LQCEEntities()) { RepositorioTIPO_FACTURA repositorio = new RepositorioTIPO_FACTURA(context); TIPO_FACTURA _TIPO_FACTURA = repositorio.GetById(Id); if(Equals(_TIPO_FACTURA ,null)) { throw new Exception(String.Concat("No se ha encontrado TIPO_FACTURA con Id =",Id.ToString())); } _TIPO_FACTURA.ACTIVO = false; context.SaveChanges(); } } catch(Exception ex) { ISException.RegisterExcepcion(ex); Error = ex.Message; throw ex; } }
public void Delete(int Id) { Init(); try { using (LQCEEntities context = new LQCEEntities()) { RepositorioTIPO_FACTURA repositorio = new RepositorioTIPO_FACTURA(context); TIPO_FACTURA _TIPO_FACTURA = repositorio.GetById(Id); if (Equals(_TIPO_FACTURA, null)) { throw new Exception(String.Concat("No se ha encontrado TIPO_FACTURA con Id =", Id.ToString())); } _TIPO_FACTURA.ACTIVO = false; context.SaveChanges(); } } catch (Exception ex) { ISException.RegisterExcepcion(ex); Error = ex.Message; throw ex; } }
public void Update(int Id, string RUT_FACTURA, string NOMBRE_FACTURA, bool AFECTO_IVA, string NOMBRE_REPORTE_FACTURA, string NOMBRE_REPORTE_FACTURA_INDIVIDUAL = "") { Init(); try { using (LQCEEntities context = new LQCEEntities()) { RepositorioTIPO_FACTURA repositorio = new RepositorioTIPO_FACTURA(context); TIPO_FACTURA _TIPO_FACTURA = repositorio.GetById(Id); if (Equals(_TIPO_FACTURA, null)) { throw new Exception(String.Concat("No se ha encontrado TIPO_FACTURA con Id =", Id.ToString())); } //properties if (!string.IsNullOrEmpty(RUT_FACTURA)) { _TIPO_FACTURA.RUT_FACTURA = RUT_FACTURA; } if (!string.IsNullOrEmpty(NOMBRE_FACTURA)) { _TIPO_FACTURA.NOMBRE_FACTURA = NOMBRE_FACTURA; } _TIPO_FACTURA.AFECTO_IVA = AFECTO_IVA; if (!string.IsNullOrEmpty(NOMBRE_REPORTE_FACTURA)) { _TIPO_FACTURA.NOMBRE_REPORTE_FACTURA = NOMBRE_REPORTE_FACTURA; } if (!string.IsNullOrEmpty(NOMBRE_REPORTE_FACTURA_INDIVIDUAL)) { _TIPO_FACTURA.NOMBRE_REPORTE_FACTURA_INDIVIDUAL = NOMBRE_REPORTE_FACTURA_INDIVIDUAL; } //parents context.SaveChanges(); } } catch (Exception ex) { ISException.RegisterExcepcion(ex); Error = ex.Message; throw ex; } }
public TIPO_FACTURA GetByIdWithReferences(int ID) { Init(); try { using (LQCEEntities context = new LQCEEntities()) { RepositorioTIPO_FACTURA repositorio = new RepositorioTIPO_FACTURA(context); return(repositorio.GetByIdWithReferences(ID)); } } catch (Exception ex) { ISException.RegisterExcepcion(ex); Error = ex.Message; throw ex; } }
public List <TIPO_FACTURA> GetAllWithReferences() { Init(); try { using (LQCEEntities context = new LQCEEntities()) { RepositorioTIPO_FACTURA repositorio = new RepositorioTIPO_FACTURA(context); return(repositorio.GetAllWithReferences().OrderBy(i => i.ID).ToList()); } } catch (Exception ex) { ISException.RegisterExcepcion(ex); Error = ex.Message; throw ex; } }
public List <TIPO_FACTURA> GetByFilterWithReferences(string RUT_FACTURA = "", string NOMBRE_FACTURA = "", bool?AFECTO_IVA = null, string NOMBRE_REPORTE_FACTURA = "", string NOMBRE_REPORTE_FACTURA_INDIVIDUAL = "") { Init(); try { using (LQCEEntities context = new LQCEEntities()) { RepositorioTIPO_FACTURA repositorio = new RepositorioTIPO_FACTURA(context); return(repositorio.GetByFilterWithReferences(RUT_FACTURA, NOMBRE_FACTURA, AFECTO_IVA, NOMBRE_REPORTE_FACTURA, NOMBRE_REPORTE_FACTURA_INDIVIDUAL).OrderBy(i => i.ID).ToList()); } } catch (Exception ex) { ISException.RegisterExcepcion(ex); Error = ex.Message; throw ex; } }
public int Add(int COMUNAId, int CONVENIOId, int TIPO_PRESTACIONId, int TIPO_FACTURAId, string RUT, string NOMBRE, int? DESCUENTO = null, string DIRECCION = "", string FONO = "", string GIRO = "") { Init(); try { using (LQCEEntities context = new LQCEEntities()) { RepositorioCOMUNA _repositorioCOMUNA = new RepositorioCOMUNA(context); COMUNA _objCOMUNA = _repositorioCOMUNA.GetById(COMUNAId); if(Equals(_objCOMUNA,null)) { throw new Exception(String.Concat("No se ha encontrado COMUNA con Id =",COMUNAId.ToString())); } RepositorioCONVENIO _repositorioCONVENIO = new RepositorioCONVENIO(context); CONVENIO _objCONVENIO = _repositorioCONVENIO.GetById(CONVENIOId); if(Equals(_objCONVENIO,null)) { throw new Exception(String.Concat("No se ha encontrado CONVENIO con Id =",CONVENIOId.ToString())); } RepositorioTIPO_PRESTACION _repositorioTIPO_PRESTACION = new RepositorioTIPO_PRESTACION(context); TIPO_PRESTACION _objTIPO_PRESTACION = _repositorioTIPO_PRESTACION.GetById(TIPO_PRESTACIONId); if(Equals(_objTIPO_PRESTACION,null)) { throw new Exception(String.Concat("No se ha encontrado TIPO_PRESTACION con Id =",TIPO_PRESTACIONId.ToString())); } RepositorioTIPO_FACTURA _repositorioTIPO_FACTURA = new RepositorioTIPO_FACTURA(context); TIPO_FACTURA _objTIPO_FACTURA = _repositorioTIPO_FACTURA.GetById(TIPO_FACTURAId); if(Equals(_objTIPO_FACTURA,null)) { throw new Exception(String.Concat("No se ha encontrado TIPO_FACTURA con Id =",TIPO_FACTURAId.ToString())); } CLIENTE _CLIENTE = new CLIENTE(); //properties _CLIENTE.RUT = RUT; _CLIENTE.NOMBRE = NOMBRE; _CLIENTE.DESCUENTO = DESCUENTO; _CLIENTE.DIRECCION = DIRECCION; _CLIENTE.FONO = FONO; _CLIENTE.GIRO = GIRO; _CLIENTE.ACTIVO = true; //parents _CLIENTE.COMUNA = _objCOMUNA; _CLIENTE.CONVENIO = _objCONVENIO; _CLIENTE.TIPO_PRESTACION = _objTIPO_PRESTACION; _CLIENTE.TIPO_FACTURA = _objTIPO_FACTURA; context.AddObject("CLIENTE",_CLIENTE); context.SaveChanges(); return _CLIENTE.ID; } } catch(Exception ex) { ISException.RegisterExcepcion(ex); Error = ex.Message; throw ex; } }
public void Update(int Id, int COMUNAId, int CONVENIOId, int TIPO_PRESTACIONId, int TIPO_FACTURAId, string RUT, string NOMBRE, int? DESCUENTO = null, string DIRECCION = "", string FONO = "", string GIRO = "") { Init(); try { using (LQCEEntities context = new LQCEEntities()) { RepositorioCLIENTE repositorio = new RepositorioCLIENTE(context); CLIENTE _CLIENTE = repositorio.GetById(Id); if(Equals(_CLIENTE,null)) { throw new Exception(String.Concat("No se ha encontrado CLIENTE con Id =",Id.ToString())); } RepositorioCOMUNA _repositorioCOMUNA = new RepositorioCOMUNA(context); COMUNA _objCOMUNA = _repositorioCOMUNA.GetById(COMUNAId); if(Equals(_objCOMUNA,null)) { throw new Exception(String.Concat("No se ha encontrado COMUNA con Id =",COMUNAId.ToString())); } RepositorioCONVENIO _repositorioCONVENIO = new RepositorioCONVENIO(context); CONVENIO _objCONVENIO = _repositorioCONVENIO.GetById(CONVENIOId); if(Equals(_objCONVENIO,null)) { throw new Exception(String.Concat("No se ha encontrado CONVENIO con Id =",CONVENIOId.ToString())); } RepositorioTIPO_PRESTACION _repositorioTIPO_PRESTACION = new RepositorioTIPO_PRESTACION(context); TIPO_PRESTACION _objTIPO_PRESTACION = _repositorioTIPO_PRESTACION.GetById(TIPO_PRESTACIONId); if(Equals(_objTIPO_PRESTACION,null)) { throw new Exception(String.Concat("No se ha encontrado TIPO_PRESTACION con Id =",TIPO_PRESTACIONId.ToString())); } RepositorioTIPO_FACTURA _repositorioTIPO_FACTURA = new RepositorioTIPO_FACTURA(context); TIPO_FACTURA _objTIPO_FACTURA = _repositorioTIPO_FACTURA.GetById(TIPO_FACTURAId); if(Equals(_objTIPO_FACTURA,null)) { throw new Exception(String.Concat("No se ha encontrado TIPO_FACTURA con Id =",TIPO_FACTURAId.ToString())); } //properties if (!string.IsNullOrEmpty(RUT)) { _CLIENTE.RUT = RUT; } if (!string.IsNullOrEmpty(NOMBRE)) { _CLIENTE.NOMBRE = NOMBRE; } if (DESCUENTO.HasValue) { _CLIENTE.DESCUENTO = DESCUENTO.Value; } if (!string.IsNullOrEmpty(DIRECCION)) { _CLIENTE.DIRECCION = DIRECCION; } if (!string.IsNullOrEmpty(FONO)) { _CLIENTE.FONO = FONO; } if (!string.IsNullOrEmpty(GIRO)) { _CLIENTE.GIRO = GIRO; } //parents _CLIENTE.COMUNA = _objCOMUNA; _CLIENTE.CONVENIO = _objCONVENIO; _CLIENTE.TIPO_PRESTACION = _objTIPO_PRESTACION; _CLIENTE.TIPO_FACTURA = _objTIPO_FACTURA; context.SaveChanges(); } } catch(Exception ex) { ISException.RegisterExcepcion(ex); Error = ex.Message; throw ex; } }
public void Update(int Id, int CLIENTEId, int FACTURACIONId, int TIPO_FACTURAId, int CORRELATIVO, string RUT_LABORATORIO, int NETO, int IVA, int TOTAL, string NOMBRE_CLIENTE = "", string RUT_CLIENTE = "", string DIRECCION = "", string NOMBRE_COMUNA = "", int?NUMERO_FACTURA = null, int?DESCUENTO = null, string FONO = "", string GIRO = "", string DETALLE = "", bool?PAGADA = null) { Init(); try { using (LQCEEntities context = new LQCEEntities()) { RepositorioFACTURA repositorio = new RepositorioFACTURA(context); FACTURA _FACTURA = repositorio.GetById(Id); if (Equals(_FACTURA, null)) { throw new Exception(String.Concat("No se ha encontrado FACTURA con Id =", Id.ToString())); } RepositorioCLIENTE _repositorioCLIENTE = new RepositorioCLIENTE(context); CLIENTE _objCLIENTE = _repositorioCLIENTE.GetById(CLIENTEId); if (Equals(_objCLIENTE, null)) { throw new Exception(String.Concat("No se ha encontrado CLIENTE con Id =", CLIENTEId.ToString())); } RepositorioFACTURACION _repositorioFACTURACION = new RepositorioFACTURACION(context); FACTURACION _objFACTURACION = _repositorioFACTURACION.GetById(FACTURACIONId); if (Equals(_objFACTURACION, null)) { throw new Exception(String.Concat("No se ha encontrado FACTURACION con Id =", FACTURACIONId.ToString())); } RepositorioTIPO_FACTURA _repositorioTIPO_FACTURA = new RepositorioTIPO_FACTURA(context); TIPO_FACTURA _objTIPO_FACTURA = _repositorioTIPO_FACTURA.GetById(TIPO_FACTURAId); if (Equals(_objTIPO_FACTURA, null)) { throw new Exception(String.Concat("No se ha encontrado TIPO_FACTURA con Id =", TIPO_FACTURAId.ToString())); } //properties _FACTURA.CORRELATIVO = CORRELATIVO; if (!string.IsNullOrEmpty(NOMBRE_CLIENTE)) { _FACTURA.NOMBRE_CLIENTE = NOMBRE_CLIENTE; } if (!string.IsNullOrEmpty(RUT_CLIENTE)) { _FACTURA.RUT_CLIENTE = RUT_CLIENTE; } if (!string.IsNullOrEmpty(DIRECCION)) { _FACTURA.DIRECCION = DIRECCION; } if (!string.IsNullOrEmpty(NOMBRE_COMUNA)) { _FACTURA.NOMBRE_COMUNA = NOMBRE_COMUNA; } if (NUMERO_FACTURA.HasValue) { _FACTURA.NUMERO_FACTURA = NUMERO_FACTURA.Value; } if (!string.IsNullOrEmpty(RUT_LABORATORIO)) { _FACTURA.RUT_LABORATORIO = RUT_LABORATORIO; } if (DESCUENTO.HasValue) { _FACTURA.DESCUENTO = DESCUENTO.Value; } if (!string.IsNullOrEmpty(FONO)) { _FACTURA.FONO = FONO; } if (!string.IsNullOrEmpty(GIRO)) { _FACTURA.GIRO = GIRO; } if (!string.IsNullOrEmpty(DETALLE)) { _FACTURA.DETALLE = DETALLE; } _FACTURA.NETO = NETO; _FACTURA.IVA = IVA; _FACTURA.TOTAL = TOTAL; if (PAGADA.HasValue) { _FACTURA.PAGADA = PAGADA.Value; } //parents _FACTURA.CLIENTE = _objCLIENTE; _FACTURA.FACTURACION = _objFACTURACION; _FACTURA.TIPO_FACTURA = _objTIPO_FACTURA; context.SaveChanges(); } } catch (Exception ex) { ISException.RegisterExcepcion(ex); Error = ex.Message; throw ex; } }
public int Add(int CLIENTEId, int FACTURACIONId, int TIPO_FACTURAId, int CORRELATIVO, string RUT_LABORATORIO, int NETO, int IVA, int TOTAL, string NOMBRE_CLIENTE = "", string RUT_CLIENTE = "", string DIRECCION = "", string NOMBRE_COMUNA = "", int?NUMERO_FACTURA = null, int?DESCUENTO = null, string FONO = "", string GIRO = "", string DETALLE = "", bool?PAGADA = null) { Init(); try { using (LQCEEntities context = new LQCEEntities()) { RepositorioCLIENTE _repositorioCLIENTE = new RepositorioCLIENTE(context); CLIENTE _objCLIENTE = _repositorioCLIENTE.GetById(CLIENTEId); if (Equals(_objCLIENTE, null)) { throw new Exception(String.Concat("No se ha encontrado CLIENTE con Id =", CLIENTEId.ToString())); } RepositorioFACTURACION _repositorioFACTURACION = new RepositorioFACTURACION(context); FACTURACION _objFACTURACION = _repositorioFACTURACION.GetById(FACTURACIONId); if (Equals(_objFACTURACION, null)) { throw new Exception(String.Concat("No se ha encontrado FACTURACION con Id =", FACTURACIONId.ToString())); } RepositorioTIPO_FACTURA _repositorioTIPO_FACTURA = new RepositorioTIPO_FACTURA(context); TIPO_FACTURA _objTIPO_FACTURA = _repositorioTIPO_FACTURA.GetById(TIPO_FACTURAId); if (Equals(_objTIPO_FACTURA, null)) { throw new Exception(String.Concat("No se ha encontrado TIPO_FACTURA con Id =", TIPO_FACTURAId.ToString())); } FACTURA _FACTURA = new FACTURA(); //properties _FACTURA.CORRELATIVO = CORRELATIVO; _FACTURA.NOMBRE_CLIENTE = NOMBRE_CLIENTE; _FACTURA.RUT_CLIENTE = RUT_CLIENTE; _FACTURA.DIRECCION = DIRECCION; _FACTURA.NOMBRE_COMUNA = NOMBRE_COMUNA; _FACTURA.NUMERO_FACTURA = NUMERO_FACTURA; _FACTURA.RUT_LABORATORIO = RUT_LABORATORIO; _FACTURA.DESCUENTO = DESCUENTO; _FACTURA.FONO = FONO; _FACTURA.GIRO = GIRO; _FACTURA.DETALLE = DETALLE; _FACTURA.NETO = NETO; _FACTURA.IVA = IVA; _FACTURA.TOTAL = TOTAL; _FACTURA.PAGADA = PAGADA; _FACTURA.ACTIVO = true; //parents _FACTURA.CLIENTE = _objCLIENTE; _FACTURA.FACTURACION = _objFACTURACION; _FACTURA.TIPO_FACTURA = _objTIPO_FACTURA; context.AddObject("FACTURA", _FACTURA); context.SaveChanges(); return(_FACTURA.ID); } } catch (Exception ex) { ISException.RegisterExcepcion(ex); Error = ex.Message; throw ex; } }
public void Update(int Id, string RUT_FACTURA, string NOMBRE_FACTURA, bool AFECTO_IVA, string NOMBRE_REPORTE_FACTURA, string NOMBRE_REPORTE_FACTURA_INDIVIDUAL = "") { Init(); try { using (LQCEEntities context = new LQCEEntities()) { RepositorioTIPO_FACTURA repositorio = new RepositorioTIPO_FACTURA(context); TIPO_FACTURA _TIPO_FACTURA = repositorio.GetById(Id); if(Equals(_TIPO_FACTURA,null)) { throw new Exception(String.Concat("No se ha encontrado TIPO_FACTURA con Id =",Id.ToString())); } //properties if (!string.IsNullOrEmpty(RUT_FACTURA)) { _TIPO_FACTURA.RUT_FACTURA = RUT_FACTURA; } if (!string.IsNullOrEmpty(NOMBRE_FACTURA)) { _TIPO_FACTURA.NOMBRE_FACTURA = NOMBRE_FACTURA; } _TIPO_FACTURA.AFECTO_IVA = AFECTO_IVA; if (!string.IsNullOrEmpty(NOMBRE_REPORTE_FACTURA)) { _TIPO_FACTURA.NOMBRE_REPORTE_FACTURA = NOMBRE_REPORTE_FACTURA; } if (!string.IsNullOrEmpty(NOMBRE_REPORTE_FACTURA_INDIVIDUAL)) { _TIPO_FACTURA.NOMBRE_REPORTE_FACTURA_INDIVIDUAL = NOMBRE_REPORTE_FACTURA_INDIVIDUAL; } //parents context.SaveChanges(); } } catch(Exception ex) { ISException.RegisterExcepcion(ex); Error = ex.Message; throw ex; } }
public List<TIPO_FACTURA> GetByFilterWithReferences(string RUT_FACTURA = "", string NOMBRE_FACTURA = "", bool? AFECTO_IVA = null, string NOMBRE_REPORTE_FACTURA = "", string NOMBRE_REPORTE_FACTURA_INDIVIDUAL = "") { Init(); try { using (LQCEEntities context = new LQCEEntities()) { RepositorioTIPO_FACTURA repositorio = new RepositorioTIPO_FACTURA(context); return repositorio.GetByFilterWithReferences(RUT_FACTURA, NOMBRE_FACTURA, AFECTO_IVA, NOMBRE_REPORTE_FACTURA, NOMBRE_REPORTE_FACTURA_INDIVIDUAL).OrderBy(i => i.ID).ToList(); } } catch (Exception ex) { ISException.RegisterExcepcion(ex); Error = ex.Message; throw ex; } }
public List<TIPO_FACTURA> GetAllWithReferences() { Init(); try { using (LQCEEntities context = new LQCEEntities()) { RepositorioTIPO_FACTURA repositorio = new RepositorioTIPO_FACTURA(context); return repositorio.GetAllWithReferences().OrderBy(i => i.ID).ToList(); } } catch (Exception ex) { ISException.RegisterExcepcion(ex); Error = ex.Message; throw ex; } }
public void Update(int Id, int COMUNAId, int CONVENIOId, int TIPO_PRESTACIONId, int TIPO_FACTURAId, string RUT, string NOMBRE, int?DESCUENTO = null, string DIRECCION = "", string FONO = "", string GIRO = "") { Init(); try { using (LQCEEntities context = new LQCEEntities()) { RepositorioCLIENTE repositorio = new RepositorioCLIENTE(context); CLIENTE _CLIENTE = repositorio.GetById(Id); if (Equals(_CLIENTE, null)) { throw new Exception(String.Concat("No se ha encontrado CLIENTE con Id =", Id.ToString())); } RepositorioCOMUNA _repositorioCOMUNA = new RepositorioCOMUNA(context); COMUNA _objCOMUNA = _repositorioCOMUNA.GetById(COMUNAId); if (Equals(_objCOMUNA, null)) { throw new Exception(String.Concat("No se ha encontrado COMUNA con Id =", COMUNAId.ToString())); } RepositorioCONVENIO _repositorioCONVENIO = new RepositorioCONVENIO(context); CONVENIO _objCONVENIO = _repositorioCONVENIO.GetById(CONVENIOId); if (Equals(_objCONVENIO, null)) { throw new Exception(String.Concat("No se ha encontrado CONVENIO con Id =", CONVENIOId.ToString())); } RepositorioTIPO_PRESTACION _repositorioTIPO_PRESTACION = new RepositorioTIPO_PRESTACION(context); TIPO_PRESTACION _objTIPO_PRESTACION = _repositorioTIPO_PRESTACION.GetById(TIPO_PRESTACIONId); if (Equals(_objTIPO_PRESTACION, null)) { throw new Exception(String.Concat("No se ha encontrado TIPO_PRESTACION con Id =", TIPO_PRESTACIONId.ToString())); } RepositorioTIPO_FACTURA _repositorioTIPO_FACTURA = new RepositorioTIPO_FACTURA(context); TIPO_FACTURA _objTIPO_FACTURA = _repositorioTIPO_FACTURA.GetById(TIPO_FACTURAId); if (Equals(_objTIPO_FACTURA, null)) { throw new Exception(String.Concat("No se ha encontrado TIPO_FACTURA con Id =", TIPO_FACTURAId.ToString())); } //properties if (!string.IsNullOrEmpty(RUT)) { _CLIENTE.RUT = RUT; } if (!string.IsNullOrEmpty(NOMBRE)) { _CLIENTE.NOMBRE = NOMBRE; } if (DESCUENTO.HasValue) { _CLIENTE.DESCUENTO = DESCUENTO.Value; } if (!string.IsNullOrEmpty(DIRECCION)) { _CLIENTE.DIRECCION = DIRECCION; } if (!string.IsNullOrEmpty(FONO)) { _CLIENTE.FONO = FONO; } if (!string.IsNullOrEmpty(GIRO)) { _CLIENTE.GIRO = GIRO; } //parents _CLIENTE.COMUNA = _objCOMUNA; _CLIENTE.CONVENIO = _objCONVENIO; _CLIENTE.TIPO_PRESTACION = _objTIPO_PRESTACION; _CLIENTE.TIPO_FACTURA = _objTIPO_FACTURA; context.SaveChanges(); } } catch (Exception ex) { ISException.RegisterExcepcion(ex); Error = ex.Message; throw ex; } }
public int Add(int COMUNAId, int CONVENIOId, int TIPO_PRESTACIONId, int TIPO_FACTURAId, string RUT, string NOMBRE, int?DESCUENTO = null, string DIRECCION = "", string FONO = "", string GIRO = "") { Init(); try { using (LQCEEntities context = new LQCEEntities()) { RepositorioCOMUNA _repositorioCOMUNA = new RepositorioCOMUNA(context); COMUNA _objCOMUNA = _repositorioCOMUNA.GetById(COMUNAId); if (Equals(_objCOMUNA, null)) { throw new Exception(String.Concat("No se ha encontrado COMUNA con Id =", COMUNAId.ToString())); } RepositorioCONVENIO _repositorioCONVENIO = new RepositorioCONVENIO(context); CONVENIO _objCONVENIO = _repositorioCONVENIO.GetById(CONVENIOId); if (Equals(_objCONVENIO, null)) { throw new Exception(String.Concat("No se ha encontrado CONVENIO con Id =", CONVENIOId.ToString())); } RepositorioTIPO_PRESTACION _repositorioTIPO_PRESTACION = new RepositorioTIPO_PRESTACION(context); TIPO_PRESTACION _objTIPO_PRESTACION = _repositorioTIPO_PRESTACION.GetById(TIPO_PRESTACIONId); if (Equals(_objTIPO_PRESTACION, null)) { throw new Exception(String.Concat("No se ha encontrado TIPO_PRESTACION con Id =", TIPO_PRESTACIONId.ToString())); } RepositorioTIPO_FACTURA _repositorioTIPO_FACTURA = new RepositorioTIPO_FACTURA(context); TIPO_FACTURA _objTIPO_FACTURA = _repositorioTIPO_FACTURA.GetById(TIPO_FACTURAId); if (Equals(_objTIPO_FACTURA, null)) { throw new Exception(String.Concat("No se ha encontrado TIPO_FACTURA con Id =", TIPO_FACTURAId.ToString())); } CLIENTE _CLIENTE = new CLIENTE(); //properties _CLIENTE.RUT = RUT; _CLIENTE.NOMBRE = NOMBRE; _CLIENTE.DESCUENTO = DESCUENTO; _CLIENTE.DIRECCION = DIRECCION; _CLIENTE.FONO = FONO; _CLIENTE.GIRO = GIRO; _CLIENTE.ACTIVO = true; //parents _CLIENTE.COMUNA = _objCOMUNA; _CLIENTE.CONVENIO = _objCONVENIO; _CLIENTE.TIPO_PRESTACION = _objTIPO_PRESTACION; _CLIENTE.TIPO_FACTURA = _objTIPO_FACTURA; context.AddObject("CLIENTE", _CLIENTE); context.SaveChanges(); return(_CLIENTE.ID); } } catch (Exception ex) { ISException.RegisterExcepcion(ex); Error = ex.Message; throw ex; } }
public void Update(int Id, int CLIENTEId, int FACTURACIONId, int TIPO_FACTURAId, int CORRELATIVO, string RUT_LABORATORIO, int NETO, int IVA, int TOTAL, string NOMBRE_CLIENTE = "", string RUT_CLIENTE = "", string DIRECCION = "", string NOMBRE_COMUNA = "", int? NUMERO_FACTURA = null, int? DESCUENTO = null, string FONO = "", string GIRO = "", string DETALLE = "", bool? PAGADA = null) { Init(); try { using (LQCEEntities context = new LQCEEntities()) { RepositorioFACTURA repositorio = new RepositorioFACTURA(context); FACTURA _FACTURA = repositorio.GetById(Id); if(Equals(_FACTURA,null)) { throw new Exception(String.Concat("No se ha encontrado FACTURA con Id =",Id.ToString())); } RepositorioCLIENTE _repositorioCLIENTE = new RepositorioCLIENTE(context); CLIENTE _objCLIENTE = _repositorioCLIENTE.GetById(CLIENTEId); if(Equals(_objCLIENTE,null)) { throw new Exception(String.Concat("No se ha encontrado CLIENTE con Id =",CLIENTEId.ToString())); } RepositorioFACTURACION _repositorioFACTURACION = new RepositorioFACTURACION(context); FACTURACION _objFACTURACION = _repositorioFACTURACION.GetById(FACTURACIONId); if(Equals(_objFACTURACION,null)) { throw new Exception(String.Concat("No se ha encontrado FACTURACION con Id =",FACTURACIONId.ToString())); } RepositorioTIPO_FACTURA _repositorioTIPO_FACTURA = new RepositorioTIPO_FACTURA(context); TIPO_FACTURA _objTIPO_FACTURA = _repositorioTIPO_FACTURA.GetById(TIPO_FACTURAId); if(Equals(_objTIPO_FACTURA,null)) { throw new Exception(String.Concat("No se ha encontrado TIPO_FACTURA con Id =",TIPO_FACTURAId.ToString())); } //properties _FACTURA.CORRELATIVO = CORRELATIVO; if (!string.IsNullOrEmpty(NOMBRE_CLIENTE)) { _FACTURA.NOMBRE_CLIENTE = NOMBRE_CLIENTE; } if (!string.IsNullOrEmpty(RUT_CLIENTE)) { _FACTURA.RUT_CLIENTE = RUT_CLIENTE; } if (!string.IsNullOrEmpty(DIRECCION)) { _FACTURA.DIRECCION = DIRECCION; } if (!string.IsNullOrEmpty(NOMBRE_COMUNA)) { _FACTURA.NOMBRE_COMUNA = NOMBRE_COMUNA; } if (NUMERO_FACTURA.HasValue) { _FACTURA.NUMERO_FACTURA = NUMERO_FACTURA.Value; } if (!string.IsNullOrEmpty(RUT_LABORATORIO)) { _FACTURA.RUT_LABORATORIO = RUT_LABORATORIO; } if (DESCUENTO.HasValue) { _FACTURA.DESCUENTO = DESCUENTO.Value; } if (!string.IsNullOrEmpty(FONO)) { _FACTURA.FONO = FONO; } if (!string.IsNullOrEmpty(GIRO)) { _FACTURA.GIRO = GIRO; } if (!string.IsNullOrEmpty(DETALLE)) { _FACTURA.DETALLE = DETALLE; } _FACTURA.NETO = NETO; _FACTURA.IVA = IVA; _FACTURA.TOTAL = TOTAL; if (PAGADA.HasValue) { _FACTURA.PAGADA = PAGADA.Value; } //parents _FACTURA.CLIENTE = _objCLIENTE; _FACTURA.FACTURACION = _objFACTURACION; _FACTURA.TIPO_FACTURA = _objTIPO_FACTURA; context.SaveChanges(); } } catch(Exception ex) { ISException.RegisterExcepcion(ex); Error = ex.Message; throw ex; } }
public int Add(int CLIENTEId, int FACTURACIONId, int TIPO_FACTURAId, int CORRELATIVO, string RUT_LABORATORIO, int NETO, int IVA, int TOTAL, string NOMBRE_CLIENTE = "", string RUT_CLIENTE = "", string DIRECCION = "", string NOMBRE_COMUNA = "", int? NUMERO_FACTURA = null, int? DESCUENTO = null, string FONO = "", string GIRO = "", string DETALLE = "", bool? PAGADA = null) { Init(); try { using (LQCEEntities context = new LQCEEntities()) { RepositorioCLIENTE _repositorioCLIENTE = new RepositorioCLIENTE(context); CLIENTE _objCLIENTE = _repositorioCLIENTE.GetById(CLIENTEId); if(Equals(_objCLIENTE,null)) { throw new Exception(String.Concat("No se ha encontrado CLIENTE con Id =",CLIENTEId.ToString())); } RepositorioFACTURACION _repositorioFACTURACION = new RepositorioFACTURACION(context); FACTURACION _objFACTURACION = _repositorioFACTURACION.GetById(FACTURACIONId); if(Equals(_objFACTURACION,null)) { throw new Exception(String.Concat("No se ha encontrado FACTURACION con Id =",FACTURACIONId.ToString())); } RepositorioTIPO_FACTURA _repositorioTIPO_FACTURA = new RepositorioTIPO_FACTURA(context); TIPO_FACTURA _objTIPO_FACTURA = _repositorioTIPO_FACTURA.GetById(TIPO_FACTURAId); if(Equals(_objTIPO_FACTURA,null)) { throw new Exception(String.Concat("No se ha encontrado TIPO_FACTURA con Id =",TIPO_FACTURAId.ToString())); } FACTURA _FACTURA = new FACTURA(); //properties _FACTURA.CORRELATIVO = CORRELATIVO; _FACTURA.NOMBRE_CLIENTE = NOMBRE_CLIENTE; _FACTURA.RUT_CLIENTE = RUT_CLIENTE; _FACTURA.DIRECCION = DIRECCION; _FACTURA.NOMBRE_COMUNA = NOMBRE_COMUNA; _FACTURA.NUMERO_FACTURA = NUMERO_FACTURA; _FACTURA.RUT_LABORATORIO = RUT_LABORATORIO; _FACTURA.DESCUENTO = DESCUENTO; _FACTURA.FONO = FONO; _FACTURA.GIRO = GIRO; _FACTURA.DETALLE = DETALLE; _FACTURA.NETO = NETO; _FACTURA.IVA = IVA; _FACTURA.TOTAL = TOTAL; _FACTURA.PAGADA = PAGADA; _FACTURA.ACTIVO = true; //parents _FACTURA.CLIENTE = _objCLIENTE; _FACTURA.FACTURACION = _objFACTURACION; _FACTURA.TIPO_FACTURA = _objTIPO_FACTURA; context.AddObject("FACTURA",_FACTURA); context.SaveChanges(); return _FACTURA.ID; } } catch(Exception ex) { ISException.RegisterExcepcion(ex); Error = ex.Message; throw ex; } }
public TIPO_FACTURA GetByIdWithReferences(int ID) { Init(); try { using (LQCEEntities context = new LQCEEntities()) { RepositorioTIPO_FACTURA repositorio = new RepositorioTIPO_FACTURA(context); return repositorio.GetByIdWithReferences(ID); } } catch (Exception ex) { ISException.RegisterExcepcion(ex); Error = ex.Message; throw ex; } }