/// <summary> /// Metodo que retorna informacion de un Modo de Pago /// </summary> /// <param name="con"></param> /// <returns></returns> public Mensaje <REC01_MEDIO_PAGO> obtenerModoPago(decimal con) { Mensaje <REC01_MEDIO_PAGO> result = new Mensaje <REC01_MEDIO_PAGO>(); result.codigo = 1; result.mensaje = "Ocurrio un Error en base de datos al obtener el Modo de Pago"; result.data = new REC01_MEDIO_PAGO(); try { using (var db = new EsquemaREC01()) { var concep = (from li in db.REC01_MEDIO_PAGO where li.MEDIO_PAGO == con && li.ESTADO_REGISTRO == "A" select li).SingleOrDefault(); if (concep != null) { result.data = concep; } else { result.codigo = -1; result.mensaje = "No existe informacion del Modo de Pago enviado"; result.data = new REC01_MEDIO_PAGO(); return(result); } result.codigo = 0; result.mensaje = "Ok"; return(result); } } catch (Exception ex) { result.codigo = -1; result.mensaje = "Ocurrio una Excepcion, referencia: " + ex.ToString(); result.mensajeError = ex.ToString(); return(result); } }
/// <summary> /// Metodo que retorna todos los Conceptos Activos - llena el combo de la pantalla del recibo /// </summary> /// <returns></returns> public Mensaje <List <REC01_CONCEPTO> > listarConceptosActivos() { Mensaje <List <REC01_CONCEPTO> > result = new Mensaje <List <REC01_CONCEPTO> >(); result.codigo = 1; result.mensaje = "Ocurrio un Error en base de datos al obtener los Conceptos"; result.data = new List <REC01_CONCEPTO>(); try { using (var db = new EsquemaREC01()) { var list = (from li in db.REC01_CONCEPTO.Where(a => a.ESTADO_REGISTRO == "A").OrderBy(a => a.CONCEPTO) select li).ToList(); if (list.Count > 0) { foreach (var item in list) { result.data.Add(item); } } else { result.codigo = -1; result.mensaje = "No existen Conceptos Registrados que mostrar, ir al Mantenimiento de Conceptos"; result.data = new List <REC01_CONCEPTO>(); return(result); } result.codigo = 0; result.mensaje = "Ok"; return(result); } } catch (Exception ex) { result.codigo = -1; result.mensaje = "Ocurrio una Excepcion, referencia: " + ex.ToString(); result.mensajeError = ex.ToString(); return(result); } }
/// <summary> /// Metodo que retorna informacion de un Banco /// </summary> /// <param name="pa"></param> /// <returns></returns> public Mensaje <REC01_PAIS> obtenerPais(REC01_PAIS pa) { Mensaje <REC01_PAIS> result = new Mensaje <REC01_PAIS>(); result.codigo = 1; result.mensaje = "Ocurrio un Error en base de datos al obtener el Pais"; result.data = new REC01_PAIS(); try { using (var db = new EsquemaREC01()) { var concep = (from li in db.REC01_PAIS where li.PAIS == pa.PAIS select li).SingleOrDefault(); if (concep != null) { result.data = concep; } else { result.codigo = -1; result.mensaje = "No existe informacion del Pais enviado"; result.data = new REC01_PAIS(); return(result); } result.codigo = 0; result.mensaje = "Ok"; return(result); } } catch (Exception ex) { result.codigo = -1; result.mensaje = "Ocurrio una Excepcion, referencia: " + ex.ToString(); result.mensajeError = ex.ToString(); return(result); } }
/// <summary> /// Metodo que retorna informacion de un Evento /// </summary> /// <param name="ev"></param> /// <returns></returns> public Mensaje <REC01_EVENTO> obtenerEvento(REC01_EVENTO ev) { Mensaje <REC01_EVENTO> result = new Mensaje <REC01_EVENTO>(); result.codigo = 1; result.mensaje = "Ocurrio un Error en base de datos al obtener el Evento"; result.data = new REC01_EVENTO(); try { using (var db = new EsquemaREC01()) { var concep = (from li in db.REC01_EVENTO where li.EVENTO == ev.EVENTO select li).SingleOrDefault(); if (concep != null) { result.data = concep; } else { result.codigo = -1; result.mensaje = "No existe informacion del Evento enviado"; result.data = new REC01_EVENTO(); return(result); } result.codigo = 0; result.mensaje = "Ok"; return(result); } } catch (Exception ex) { result.codigo = -1; result.mensaje = "Ocurrio una Excepcion, referencia: " + ex.ToString(); result.mensajeError = ex.ToString(); return(result); } }
public Mensaje <Participante> obtenerParticipante() { Mensaje <Participante> result = new Mensaje <Participante>(); result.codigo = 1; result.mensaje = "Ocurrio un error en Base de Datos"; result.data = new Participante(); try { using (var db = new EsquemaREC01()) { var part = db.REC01_PARTICIPANTE.Where(p => p.NIT.Trim() == this.nit.Trim()).Select(p => p).SingleOrDefault(); if (part == null) { result.codigo = -1; result.mensaje = "No existe informacion para el Nit: " + this.nit.ToString() + " Proceda a registrar el Recibo y en automatico quedara agregado el Participante en Base de Datos"; result.data = new Participante(); return(result); } else { dbModel = part; } } result.codigo = 0; result.mensaje = "Ok"; result.data = this; return(result); } catch (Exception ex) { result.codigo = -1; result.mensaje = "Ocurrio una excepcion al momento de obtener la informacion, ref: " + ex.ToString(); result.mensajeError = ex.ToString(); return(result); } }
/// <summary> /// Metodo que me retorna informacion del Correlativo de Recibo Fisico del Usuario y Evento en Sesion /// </summary> /// <returns></returns> public Mensaje <REC01_CORRELATIVO_RECIBO> obtenerCorrelativoFisico() { Mensaje <REC01_CORRELATIVO_RECIBO> result = new Mensaje <REC01_CORRELATIVO_RECIBO>(); result.codigo = 1; result.mensaje = "Ocurrio un error en Base de Datos al obtener el correlativo fisico"; result.data = new REC01_CORRELATIVO_RECIBO(); try { using (var db = new EsquemaREC01()) { var resultado = (from c in db.REC01_CORRELATIVO_RECIBO where c.EVENTO == Global.eventoActivo && c.USUARIO == Global.usuariologueado && c.ESTADO_REGISTRO == "A" select c).SingleOrDefault(); if (resultado != null) { result.data = resultado; } else { result.data = new REC01_CORRELATIVO_RECIBO(); } } result.codigo = 0; result.mensaje = "Ok"; return(result); } catch (Exception ex) { result.codigo = -1; result.mensaje = "Ocurrio una Excepcion, referencia: " + ex.ToString(); result.mensajeError = ex.ToString(); return(result); } }
/// <summary> /// Metodo que obtiene la informacion de un recibo para llenar el Reporte de Impresion /// </summary> /// <param name="rec"></param> /// <returns></returns> public List <reciboEntidad> obtenerRecibo() { List <reciboEntidad> result = new List <reciboEntidad>(); try { using (var db = new EsquemaREC01()) { StringBuilder sql = new StringBuilder(); sql.Append(_sqlrecibo); var resp = db.Database.SqlQuery <reciboEntidad>(sql.ToString(), new object[] { recibo, usuario }).ToList <reciboEntidad>(); result = resp; } return(result); } catch (Exception) { throw; } }
/// <summary> /// Metodo que devuelve listado de Recibos Anulados Global por rango de Fechas /// </summary> /// <returns></returns> public Mensaje <List <Reporteria> > fechaAnulacion() { Mensaje <List <Reporteria> > result = new Mensaje <List <Reporteria> >(); result.codigo = 1; result.mensaje = "Ocurrio un Error en base de datos al tratar de generar la informacion"; result.data = new List <Reporteria>(); try { using (var db = new EsquemaREC01()) { StringBuilder sqlGE = new StringBuilder(); sqlGE.Append(_sqlAnulacionFecha); var list = db.Database.SqlQuery <Reporteria>(sqlGE.ToString(), new object[] { fecha_inicial, fecha_final, idevento, fecha_inicial, fecha_final }).ToList <Reporteria>(); if (list.Count == 0) { result.codigo = 1; result.mensaje = "No existen registros para este Evento"; result.data = new List <Reporteria>(); return(result); } foreach (var item in list) { result.data.Add(item); } } return(result); } catch (Exception ex) { result.codigo = -1; result.mensaje = "Ocurrio una Excepcion al tratar de Recuperar los datos, referencia: " + ex.ToString(); result.mensajeError = ex.ToString(); return(result); } }
private Mensaje <Participante> guardarParticipante(REC01_RECIBO arg) { Mensaje <Participante> res = new Mensaje <Participante>(); res.codigo = 1; res.mensaje = "Ocurrio un error en base de datos"; res.data = new Participante(); try { using (var db = new EsquemaREC01()) { REC01_PARTICIPANTE nuevo = new REC01_PARTICIPANTE(); nuevo.NIT = arg.NIT.Trim(); nuevo.NOMBRE = arg.NOMBRE; nuevo.DIRECCION = arg.DIRECCION; nuevo.PAIS = arg.PAIS; nuevo.TELEFONO = arg.TELEFONO; nuevo.ESTADO_REGISTRO = "A"; nuevo.USUARIO_CREACION = Global.usuariologueado; nuevo.FECHA_CREACION = DateTime.Now; db.REC01_PARTICIPANTE.Add(nuevo); db.SaveChanges(); } res.codigo = 0; res.mensaje = "Se guardo el participante correctamente"; return(res); } catch (Exception ex) { res.codigo = -1; res.mensaje = "Ocurrio una excepcion al momento de registrar el Participante, ref: " + ex.ToString(); res.mensajeError = ex.ToString(); return(res); } }
public Mensaje <Participante> validaInfoParticipante(REC01_RECIBO arg) { Mensaje <Participante> result = new Mensaje <Participante>(); result.codigo = 1; result.mensaje = "Ocurrio un error en Base de Datos"; result.data = new Participante(); try { using (var db = new EsquemaREC01()) { //SI EL NIT ES C/F NO ES NECESARIO VALIDAR PARA REGISTRAR O ACTUALIZAR if (arg.NIT != "C/F") { var valida = db.REC01_PARTICIPANTE.Where(p => p.NIT.Trim() == arg.NIT.Trim()).Select(p => p).SingleOrDefault(); //SI EXISITE EL NIT, SE COMPARAN DATOS EN BD CON LOS QUE TRAE EL RECIBO Y SE EVALUA SI EXISTEN DIFERENCIAS if (valida != null) { //SI VARIAN LOS DATOS SE PROCEDE A ACTUALIZAR if (valida.NOMBRE != arg.NOMBRE || valida.DIRECCION != arg.DIRECCION || valida.PAIS != arg.PAIS || valida.TELEFONO != arg.TELEFONO) { Mensaje <Participante> resp = actualizarParticipante(arg); result.codigo = resp.codigo; result.mensaje = resp.mensaje; return(result); } //SI NO VARIAN LOS DATOS, NO SE REALIZA NINGUNA ACCION else { result.codigo = 0; result.mensaje = "Ok"; return(result); } } //SI EL NIT NO SE ENCUENTRA EN LA BD SE PROCEDE A REGISTRAR EL NUEVO PARTICIPANTE else { Mensaje <Participante> resp = guardarParticipante(arg); result.codigo = resp.codigo; result.mensaje = resp.mensaje; return(result); } } else { result.codigo = 0; result.mensaje = "Ok"; return(result); } } } catch (Exception ex) { result.codigo = -1; result.mensaje = "Ocurrio una excepcion al validar el Participante, ref: " + ex.ToString(); result.mensajeError = ex.ToString(); return(result); } }
/// <summary> /// Metodo que Actualiza un Recibo /// </summary> /// <param name="rec"></param> /// <returns></returns> public Mensaje <Recibo> ActualizarRecibo(REC01_RECIBO rec) { Mensaje <Recibo> result = new Mensaje <Recibo>(); result.codigo = 1; result.mensaje = "Ocurrio un error en base de datos al tratar de registrar el recibo"; result.data = new Recibo(); try { using (var db = new EsquemaREC01()) { var reciboExistente = (from r in db.REC01_RECIBO where r.RECIBO == rec.RECIBO && r.USUARIO_CREACION == Global.usuariologueado.ToUpper() select r).SingleOrDefault(); string letras = NumeroLetras.NumeroALetras(rec.TOTAL.ToString()).ToUpper(); if (rec.MEDIO_PAGO == 1)//MEDIO DE PAGO = 1 EQUIVALE A EFECTIVO { reciboExistente.NOMBRE = rec.NOMBRE.ToUpper(); reciboExistente.DIRECCION = rec.DIRECCION; reciboExistente.NIT = rec.NIT; reciboExistente.TELEFONO = rec.TELEFONO; reciboExistente.MEDIO_PAGO = rec.MEDIO_PAGO; reciboExistente.CONCEPTO = rec.CONCEPTO; reciboExistente.TOTAL = rec.TOTAL; reciboExistente.TOTAL_LETRAS = letras; reciboExistente.PRECIO = rec.PRECIO; reciboExistente.CANTIDAD = rec.CANTIDAD; reciboExistente.EVENTO = Global.eventoActivo;// reciboExistente.PAIS = rec.PAIS; reciboExistente.OBSERVACION_3 = rec.OBSERVACION_3.ToUpper(); reciboExistente.ESTADO_REGISTRO = "A"; reciboExistente.USUARIO_MODIFICACION = Global.usuariologueado.ToUpper();// reciboExistente.FECHA_MODIFICACION = DateTime.Now; //reciboExistente.RECIBO_FISICO = rec.RECIBO_FISICO;// //reciboExistente.SERIE_RECIBO = rec.SERIE_RECIBO;// } else if (rec.MEDIO_PAGO == 2)//MEDIO DE PAGO = 2 EQUIVALE A CHEQUE { reciboExistente.NOMBRE = rec.NOMBRE.ToUpper(); reciboExistente.DIRECCION = rec.DIRECCION; reciboExistente.NIT = rec.NIT; reciboExistente.TELEFONO = rec.TELEFONO; reciboExistente.MEDIO_PAGO = rec.MEDIO_PAGO; reciboExistente.BANCO = rec.BANCO; reciboExistente.NUMERO_CHEQUE = rec.NUMERO_CHEQUE; reciboExistente.CONCEPTO = rec.CONCEPTO; reciboExistente.TOTAL = rec.TOTAL; reciboExistente.TOTAL_LETRAS = letras; reciboExistente.PRECIO = rec.PRECIO; reciboExistente.CANTIDAD = rec.CANTIDAD; reciboExistente.EVENTO = rec.EVENTO;// reciboExistente.PAIS = rec.PAIS; reciboExistente.OBSERVACION_3 = rec.OBSERVACION_3.ToUpper(); reciboExistente.ESTADO_REGISTRO = "A"; reciboExistente.USUARIO_MODIFICACION = Global.usuariologueado.ToUpper(); reciboExistente.FECHA_MODIFICACION = DateTime.Now; //reciboExistente.RECIBO_FISICO = rec.RECIBO_FISICO; //reciboExistente.SERIE_RECIBO = rec.SERIE_RECIBO; } db.SaveChanges(); } result.codigo = 0; result.mensaje = "Se ha actualizado correctamente el Recibo No. : " + rec.RECIBO_FISICO; return(result); } catch (Exception ex) { result.codigo = -1; result.mensaje = "Ocurrio una excepcion, Referencia: " + ex.ToString(); result.mensajeError = ex.ToString(); return(result); } }
/// <summary> /// Metodo que Inserta un Recibo /// </summary> /// <param name="rec"></param> /// <returns></returns> public Mensaje <Recibo> NuevoRecibo(REC01_RECIBO rec) { Mensaje <Recibo> result = new Mensaje <Recibo>(); result.codigo = 1; result.mensaje = "Ocurrio un error en base de datos al tratar de registrar el recibo"; result.data = new Recibo(); try { using (var db = new EsquemaREC01()) { //SE OBTIENE CORRELATIVO INTERNO POR USUARIO var correlativo = (from c in db.REC01_CORRELATIVO_USUARIO where c.USUARIO == Global.usuariologueado.ToUpper() && c.ESTADO_REGISTRO == "A" select c).SingleOrDefault(); //SE VALIDA EL CORRELATIVO POR USUARIO, SI RETORNA NULO ES PORQUE EL USUARIO NO HA SIDO CREADO DESDE EL SISTEMA if (correlativo == null) { result.codigo = -1; result.mensaje = "No se pudo generar el recibo, el usuario no es operador o No fue creado desde el Sistema"; return(result); } //SE OBTIENE CORRELATIVO FISICO DE RECIBO var correlativoFisico = (from c in db.REC01_CORRELATIVO_RECIBO where c.EVENTO == Global.eventoActivo && c.USUARIO == Global.usuariologueado.ToUpper() && c.ESTADO_REGISTRO == "A" select c).SingleOrDefault(); //SE VERIFICA SI EXISTE UN RECIBO CON EL CORRELATIVO FISICO QUE SE ESTA TRATANDO DE ASIGNAR EN ESTADO ACTIVO var validaReciboFisico = (from vr in db.REC01_RECIBO where vr.RECIBO_FISICO == correlativoFisico.CORRELATIVO_ACTUAL && vr.SERIE_RECIBO == Global.serieActiva.ToUpper() && vr.ESTADO_REGISTRO == "A" select vr).SingleOrDefault(); if (validaReciboFisico != null) { result.codigo = -2; result.mensaje = "El correlativo: " + validaReciboFisico.RECIBO_FISICO + " con Serie " + Global.serieActiva + " ya ha sido utilizado anteriormente, no es posible volverlo a utilizar. Modifique el Rango Inicial o Actual en el Mantenimiento de Correlativos de Recibo o la Serie del Documento"; return(result); } else { string letras = NumeroLetras.NumeroALetras(rec.TOTAL.ToString()).ToUpper(); REC01_RECIBO nuevoRecibo = new REC01_RECIBO(); if (rec.MEDIO_PAGO == 1)//MEDIO DE PAGO = 1 EQUIVALE A EFECTIVO { nuevoRecibo.RECIBO = Convert.ToDecimal(correlativo.CORRELATIVO_DISPONIBLE); nuevoRecibo.NOMBRE = rec.NOMBRE.ToUpper(); nuevoRecibo.DIRECCION = rec.DIRECCION; nuevoRecibo.NIT = rec.NIT; nuevoRecibo.TELEFONO = rec.TELEFONO; nuevoRecibo.MEDIO_PAGO = rec.MEDIO_PAGO; nuevoRecibo.CONCEPTO = rec.CONCEPTO; nuevoRecibo.TOTAL = rec.TOTAL; nuevoRecibo.TOTAL_LETRAS = letras; nuevoRecibo.PRECIO = rec.PRECIO; nuevoRecibo.CANTIDAD = rec.CANTIDAD; nuevoRecibo.EVENTO = Global.eventoActivo; nuevoRecibo.PAIS = rec.PAIS; nuevoRecibo.OBSERVACION_3 = rec.OBSERVACION_3.ToUpper(); nuevoRecibo.ESTADO_REGISTRO = "A"; nuevoRecibo.USUARIO_CREACION = Global.usuariologueado.ToUpper(); nuevoRecibo.FECHA_CREACION = DateTime.Now; nuevoRecibo.RECIBO_FISICO = correlativoFisico.CORRELATIVO_ACTUAL; nuevoRecibo.SERIE_RECIBO = Global.serieActiva; } else if (rec.MEDIO_PAGO == 2)//MEDIO DE PAGO = 2 EQUIVALE A CHEQUE { nuevoRecibo.RECIBO = Convert.ToDecimal(correlativo.CORRELATIVO_DISPONIBLE); nuevoRecibo.NOMBRE = rec.NOMBRE.ToUpper(); nuevoRecibo.DIRECCION = rec.DIRECCION; nuevoRecibo.NIT = rec.NIT; nuevoRecibo.TELEFONO = rec.TELEFONO; nuevoRecibo.MEDIO_PAGO = rec.MEDIO_PAGO; nuevoRecibo.BANCO = rec.BANCO; nuevoRecibo.NUMERO_CHEQUE = rec.NUMERO_CHEQUE; nuevoRecibo.CONCEPTO = rec.CONCEPTO; nuevoRecibo.TOTAL = rec.TOTAL; nuevoRecibo.TOTAL_LETRAS = letras; nuevoRecibo.PRECIO = rec.PRECIO; nuevoRecibo.CANTIDAD = rec.CANTIDAD; nuevoRecibo.EVENTO = Global.eventoActivo; nuevoRecibo.PAIS = rec.PAIS; nuevoRecibo.OBSERVACION_3 = rec.OBSERVACION_3.ToUpper(); nuevoRecibo.ESTADO_REGISTRO = "A"; nuevoRecibo.USUARIO_CREACION = Global.usuariologueado.ToUpper(); nuevoRecibo.FECHA_CREACION = DateTime.Now; nuevoRecibo.RECIBO_FISICO = correlativoFisico.CORRELATIVO_ACTUAL; nuevoRecibo.SERIE_RECIBO = Global.serieActiva; } db.REC01_RECIBO.Add(nuevoRecibo); correlativo.CORRELATIVO_DISPONIBLE++; correlativoFisico.CORRELATIVO_ACTUAL++; db.SaveChanges(); } } result.codigo = 0; result.mensaje = "Se registro el recibo con nombre: " + rec.NOMBRE + " de forma Exitosa...!!!"; return(result); } catch (Exception ex) { result.codigo = -1; result.mensaje = "Ocurrio una Excepcion, referencia: " + ex.ToString(); result.mensajeError = ex.ToString(); return(result); } }
/// <summary> /// Metodo para Anular recibo /// </summary> /// <param name="re"></param> /// <returns></returns> public Mensaje <Recibo> AnularRecibo(REC01_ANULACION re) { Mensaje <Recibo> result = new Mensaje <Recibo>(); result.codigo = 1; result.mensaje = "Ocurrio un error en base de datos al tratar de Anular el Recibo"; result.data = new Recibo(); try { using (var trans = new TransactionScope()) { using (var db = new EsquemaREC01()) { //Se valida que exista el Reicibo REC01_RECIBO validaRecibo = (from r in db.REC01_RECIBO where r.RECIBO == re.RECIBO && r.USUARIO_CREACION.ToUpper() == re.USUARIO_CREACION.ToUpper() select r).FirstOrDefault(); if (validaRecibo == null) { result.codigo = -1; result.mensaje = "No existe el recibo indicado"; return(result); } validaRecibo.ESTADO_REGISTRO = "N"; validaRecibo.USUARIO_MODIFICACION = Global.usuariologueado; validaRecibo.FECHA_MODIFICACION = DateTime.Now; //Se procede a modificar el estado_registro del Recibo int res = db.SaveChanges(); if (res <= 0) { Transaction.Current.Rollback(); result.codigo = 2; result.mensaje = "No fue posible Cambiar el estado del Recibo"; return(result); } //Se obtiene el valor del correlativo de la tabla REC01_ANULACION para ser utilizado como identificador de Anulacion var valAnulado = (from a in db.REC01_ANULACION select a.ANULACION).ToList(); decimal corrAnulado = 0; if (valAnulado.Count > 0) { corrAnulado = valAnulado.Max() + 1; } else { corrAnulado = 1; } REC01_ANULACION nuevaAnulacion = new REC01_ANULACION() { ANULACION = corrAnulado, RECIBO = re.RECIBO, USUARIO_CREACION = re.USUARIO_CREACION, MOTIVO = re.MOTIVO, RECIBO_FISICO = re.RECIBO_FISICO, SERIE = re.SERIE.ToUpper(), ESTADO_REGISTRO = "A", USUARIO_ANULACION = Global.usuariologueado, FECHA_ANULACION = DateTime.Now }; db.REC01_ANULACION.Add(nuevaAnulacion); res = db.SaveChanges(); if (res <= 0) { Transaction.Current.Rollback(); result.codigo = 2; result.mensaje = "No fue posible registrar la Anulacion"; return(result); } } trans.Complete(); result.codigo = 0; result.mensaje = "Se Anulo el Recibo de forma Exitosa...!!!"; return(result); } } catch (Exception ex) { result.codigo = -1; result.mensaje = "Ocurrio una excepcion al tratar de Anular el Recibo, Referencia " + ex.ToString(); result.mensajeError = ex.ToString(); return(result); } }