public ro_PrestamoMasivo_Info get_info(int IdEmpresa, decimal IdCarga) { try { ro_PrestamoMasivo_Info info = new ro_PrestamoMasivo_Info(); using (Entities_rrhh Context = new Entities_rrhh()) { ro_PrestamoMasivo Entity = Context.ro_PrestamoMasivo.FirstOrDefault(q => q.IdEmpresa == IdEmpresa && q.IdCarga == IdCarga); if (Entity == null) { return(null); } info = new ro_PrestamoMasivo_Info { IdEmpresa = Entity.IdEmpresa, IdSucursal = Entity.IdSucursal, IdCarga = Entity.IdCarga, Fecha_PriPago = Entity.Fecha_PriPago, NumCuotas = Entity.NumCuotas, descuento_mensual = Entity.descuento_mensual, descuento_men_quin = Entity.descuento_men_quin, descuento_quincena = Entity.descuento_quincena, Observacion = Entity.Observacion }; } return(info); } catch (Exception) { throw; } }
public bool anularDB(ro_PrestamoMasivo_Info info) { try { using (Entities_rrhh Context = new Entities_rrhh()) { ro_PrestamoMasivo Entity = Context.ro_PrestamoMasivo.FirstOrDefault(q => q.IdEmpresa == info.IdEmpresa && q.IdCarga == info.IdCarga); if (Entity == null) { return(false); } Entity.Estado = info.Estado = false; Entity.IdUsuarioUltAnu = info.IdUsuarioUltAnu; Entity.Fecha_UltAnu = info.Fecha_UltAnu = DateTime.Now; Entity.MotiAnula = info.MotiAnula; Context.SaveChanges(); } return(true); } catch (Exception) { throw; } }
public bool modificarDB(ro_PrestamoMasivo_Info info) { try { var ro_parametro = odata.get_info(info.IdEmpresa); using (Entities_rrhh Context = new Entities_rrhh()) { ro_PrestamoMasivo Entity = Context.ro_PrestamoMasivo.FirstOrDefault(q => q.IdEmpresa == info.IdEmpresa && q.IdCarga == info.IdCarga); if (Entity == null) { return(false); } Entity.Fecha_PriPago = info.Fecha_PriPago; Entity.NumCuotas = info.NumCuotas; Entity.descuento_mensual = info.descuento_mensual; Entity.descuento_men_quin = info.descuento_men_quin; Entity.descuento_quincena = info.descuento_quincena; Entity.Observacion = info.Observacion; Context.SaveChanges(); } return(true); } catch (Exception ex) { tb_LogError_Data LogData = new tb_LogError_Data(); LogData.GuardarDB(new tb_LogError_Info { Descripcion = ex.Message, InnerException = ex.InnerException == null ? null : ex.InnerException.Message, Clase = "ro_prestamo_Data", Metodo = "modificarDB", IdUsuario = info.IdUsuario }); return(false); } }
public bool guardarDB(ro_PrestamoMasivo_Info info) { try { var ro_parametro = odata.get_info(info.IdEmpresa); using (Entities_rrhh Context = new Entities_rrhh()) { ro_PrestamoMasivo Entity = new ro_PrestamoMasivo { IdEmpresa = info.IdEmpresa, IdCarga = info.IdCarga = get_id(info.IdEmpresa), Fecha_PriPago = info.Fecha_PriPago, NumCuotas = info.NumCuotas, descuento_mensual = info.descuento_mensual, descuento_men_quin = info.descuento_men_quin, descuento_quincena = info.descuento_quincena, Observacion = info.Observacion, Estado = info.Estado = true, IdUsuario = info.IdUsuario, Fecha_Transac = info.Fecha_Transac = DateTime.Now }; Context.ro_PrestamoMasivo.Add(Entity); Context.SaveChanges(); } return(true); } catch (Exception ex) { tb_LogError_Data LogData = new tb_LogError_Data(); LogData.GuardarDB(new tb_LogError_Info { Descripcion = ex.Message, InnerException = ex.InnerException == null ? null : ex.InnerException.Message, Clase = "ro_prestamo_Data", Metodo = "guardarDB", IdUsuario = info.IdUsuario }); return(false); } }
public bool anularDB(ro_PrestamoMasivo_Info info) { try { using (Entities_rrhh Context = new Entities_rrhh()) { ro_PrestamoMasivo Entity = Context.ro_PrestamoMasivo.Where(q => q.IdEmpresa == info.IdEmpresa && q.IdSucursal == info.IdSucursal && q.IdCarga == info.IdCarga).FirstOrDefault(); var prestamo_masivo_detalle = Context.ro_PrestamoMasivo_Det.Where(q => q.IdEmpresa == info.IdEmpresa && q.IdCarga == info.IdCarga).ToList(); if (Entity == null) { return(false); } Entity.Estado = info.Estado = false; Entity.IdUsuarioUltAnu = info.IdUsuarioUltAnu; Entity.Fecha_UltAnu = info.Fecha_UltAnu = DateTime.Now; Entity.MotiAnula = info.MotiAnula; if (prestamo_masivo_detalle != null || prestamo_masivo_detalle.Count() > 0) { foreach (var item in prestamo_masivo_detalle) { ro_prestamo Entity_Prestamo = Context.ro_prestamo.Where(q => q.IdEmpresa == info.IdEmpresa && q.IdPrestamo == item.IdPrestamo).FirstOrDefault(); Entity_Prestamo.Estado = false; } } Context.SaveChanges(); } return(true); } catch (Exception) { throw; } }
public bool guardarDB(ro_PrestamoMasivo_Info info) { try { var ro_parametro = odata.get_info(info.IdEmpresa); var Secuencia = 1; decimal IdPrestamo = odata_prestamo.get_id(info.IdEmpresa); using (Entities_rrhh Context = new Entities_rrhh()) { ro_PrestamoMasivo Entity = new ro_PrestamoMasivo { IdEmpresa = info.IdEmpresa, IdSucursal = info.IdSucursal, IdCarga = info.IdCarga = get_id(info.IdEmpresa), Fecha_PriPago = info.Fecha_PriPago, NumCuotas = info.NumCuotas, descuento_mensual = info.descuento_mensual, descuento_men_quin = info.descuento_men_quin, descuento_quincena = info.descuento_quincena, Observacion = info.Observacion, Estado = info.Estado = true, IdUsuario = info.IdUsuario, Fecha_Transac = info.Fecha_Transac = DateTime.Now }; Context.ro_PrestamoMasivo.Add(Entity); foreach (var item in info.lst_detalle) { ro_PrestamoMasivo_Det Entity_Det = new ro_PrestamoMasivo_Det { IdEmpresa = info.IdEmpresa, IdSucursal = info.IdSucursal, IdCarga = info.IdCarga, Secuencia = Secuencia++, IdEmpleado = item.IdEmpleado, IdRubro = item.IdRubro, Monto = item.Monto, NumCuotas = item.NumCuotas }; var info_prestamo = new ro_prestamo_Info { IdEmpresa = info.IdEmpresa, IdPrestamo = IdPrestamo++, IdEmpleado = item.IdEmpleado, IdRubro = item.IdRubro, descuento_mensual = info.descuento_mensual, descuento_men_quin = info.descuento_men_quin, descuento_quincena = info.descuento_quincena, Fecha = info.Fecha_PriPago.Date, MontoSol = item.Monto, NumCuotas = item.NumCuotas, Fecha_PriPago = info.Fecha_PriPago.Date, Observacion = info.Observacion, GeneraOP = true, Estado = true, EstadoAprob = ro_parametro.EstadoCreacionPrestamos, IdUsuario = info.IdUsuario, Fecha_Transac = info.Fecha_Transac = DateTime.Now }; if (info.descuento_men_quin == true) { info_prestamo = get_calculoquincenal_y_men(info_prestamo); } if (info.descuento_quincena == true) { info_prestamo = get_calculoquincenal(info_prestamo); } if (info.descuento_mensual == true) { info_prestamo = get_calculomensual(info_prestamo); } if (info_prestamo == null) { return(false); } else { ro_prestamo Entity_Cab_Prestamo = new ro_prestamo { IdEmpresa = info_prestamo.IdEmpresa, IdPrestamo = info_prestamo.IdPrestamo, IdEmpleado = info_prestamo.IdEmpleado, IdRubro = info_prestamo.IdRubro, descuento_mensual = info_prestamo.descuento_mensual, descuento_men_quin = info_prestamo.descuento_men_quin, descuento_quincena = info_prestamo.descuento_quincena, Fecha = info_prestamo.Fecha_PriPago.Date, MontoSol = info_prestamo.MontoSol, NumCuotas = info_prestamo.NumCuotas, Fecha_PriPago = info_prestamo.Fecha_PriPago.Date, Observacion = info_prestamo.Observacion, GeneraOP = info_prestamo.GeneraOP, Estado = info_prestamo.Estado, EstadoAprob = info_prestamo.EstadoAprob, IdUsuario = info_prestamo.IdUsuario, Fecha_Transac = info_prestamo.Fecha_Transac }; Entity_Det.IdPrestamo = Entity_Cab_Prestamo.IdPrestamo; Context.ro_prestamo.Add(Entity_Cab_Prestamo); Context.ro_PrestamoMasivo_Det.Add(Entity_Det); foreach (var item_prest in info_prestamo.lst_detalle) { ro_prestamo_detalle Entity_Det_Prestamo = new ro_prestamo_detalle { IdEmpresa = info_prestamo.IdEmpresa, IdPrestamo = info_prestamo.IdPrestamo, NumCuota = item_prest.NumCuota, SaldoInicial = item_prest.SaldoInicial, TotalCuota = item_prest.TotalCuota, Saldo = item_prest.Saldo, FechaPago = item_prest.FechaPago, EstadoPago = item_prest.EstadoPago, Estado = true, Observacion_det = item_prest.Observacion_det, IdNominaTipoLiqui = item_prest.IdNominaTipoLiqui }; Context.ro_prestamo_detalle.Add(Entity_Det_Prestamo); } } } Context.SaveChanges(); } return(true); } catch (Exception ex) { tb_LogError_Data LogData = new tb_LogError_Data(); LogData.GuardarDB(new tb_LogError_Info { Descripcion = ex.Message, InnerException = ex.InnerException == null ? null : ex.InnerException.Message, Clase = "ro_prestamo_Data", Metodo = "guardarDB", IdUsuario = info.IdUsuario }); return(false); } }