public bool Abono(ro_prestamo_Info info) { try { using (Entities_rrhh Context = new Entities_rrhh()) { ro_prestamo Entity = Context.ro_prestamo.FirstOrDefault(q => q.IdEmpresa == info.IdEmpresa && q.IdEmpleado == info.IdEmpleado && q.IdPrestamo == info.IdPrestamo); if (Entity == null) { return(false); } Entity.IdUsuarioUltAnu = info.IdUsuarioUltAnu; Entity.Fecha_UltAnu = info.Fecha_UltAnu = DateTime.Now; foreach (var item in info.lst_detalle) { ro_prestamo_detalle Entity_det = Context.ro_prestamo_detalle.FirstOrDefault(q => q.IdEmpresa == info.IdEmpresa && q.IdPrestamo == info.IdPrestamo && q.NumCuota == item.NumCuota); Entity_det.EstadoPago = item.EstadoPago; Entity_det.Saldo = Entity_det.Saldo - item.ValorAplicado; Context.SaveChanges(); } Context.SaveChanges(); } return(true); } catch (Exception) { throw; } }
public bool guardarDB(List <ro_prestamo_detalle_Info> info) { try { using (Entities_rrhh Context = new Entities_rrhh()) { foreach (var item in info) { ro_prestamo_detalle Entity = new ro_prestamo_detalle { IdEmpresa = item.IdEmpresa, IdPrestamo = item.IdPrestamo, NumCuota = item.NumCuota, SaldoInicial = item.SaldoInicial, TotalCuota = item.TotalCuota, Saldo = item.Saldo, FechaPago = item.FechaPago.Date, EstadoPago = item.EstadoPago = "PEN", Observacion_det = item.Observacion_det, IdNominaTipoLiqui = item.IdNominaTipoLiqui, Estado = true, }; Context.ro_prestamo_detalle.Add(Entity); } Context.SaveChanges(); } return(true); } catch (Exception) { throw; } }
public ro_prestamo_detalle_Info get_info(int IdEmpresa, decimal IdPrestamo, int Secuencia) { try { ro_prestamo_detalle_Info info = new ro_prestamo_detalle_Info(); using (Entities_rrhh Context = new Entities_rrhh()) { ro_prestamo_detalle Entity = Context.ro_prestamo_detalle.FirstOrDefault(q => q.IdEmpresa == IdEmpresa && q.IdPrestamo == IdPrestamo && q.IdPrestamo == IdPrestamo); if (Entity == null) { return(null); } info = new ro_prestamo_detalle_Info { IdEmpresa = Entity.IdEmpresa, IdPrestamo = Entity.IdPrestamo, NumCuota = Entity.NumCuota, SaldoInicial = Entity.SaldoInicial, TotalCuota = Entity.TotalCuota, Saldo = Entity.Saldo, FechaPago = Entity.FechaPago, EstadoPago = Entity.EstadoPago, Observacion_det = Entity.Observacion_det }; } return(info); } catch (Exception) { throw; } }
public bool Modificar_Cuotas_Forma_Pago(List <ro_prestamo_detalle_Info> listadetalle) { try { int secuencia = 0; using (EntitiesRoles context = new EntitiesRoles()) { ro_prestamo_detalle_Info info = new ro_prestamo_detalle_Info(); info = listadetalle.FirstOrDefault(); // elimino las cuotas de estado pendientes Eliminar_Cuotas_Pendientes(info.IdEmpresa, Convert.ToInt32(info.IdPrestamo)); var datos = (from a in context.ro_prestamo_detalle where a.IdEmpresa == info.IdEmpresa && a.IdPrestamo == info.IdPrestamo select a); if (datos.Count() > 0) { secuencia = (from prod in datos.Where(v => v.EstadoPago == "CAN") select prod.NumCuota).Max(); } foreach (var Item in listadetalle) { secuencia = secuencia + 1; ro_prestamo_detalle Deta = new ro_prestamo_detalle(); Deta.IdEmpresa = Item.IdEmpresa; Deta.IdPrestamo = Item.IdPrestamo; Deta.IdNominaTipoLiqui = Item.IdNominaTipoLiqui; Deta.NumCuota = secuencia; Deta.SaldoInicial = Item.SaldoInicial; Deta.Interes = Item.Interes; Deta.AbonoCapital = Item.AbonoCapital; Deta.TotalCuota = Item.TotalCuota; Deta.Saldo = Item.Saldo; Deta.FechaPago = Item.FechaPago; Deta.EstadoPago = Item.EstadoPago; Deta.Estado = Item.Estado; Deta.Observacion_det = Item.Observacion_det; Deta.IdUsuario = Item.IdUsuario; Deta.Fecha_Transac = Item.Fecha_Transac; Deta.nom_pc = Item.nom_pc; Deta.ip = Item.ip; context.ro_prestamo_detalle.Add(Deta); context.SaveChanges(); } } return(true); } catch (Exception ex) { string array = ToString(); tb_sis_Log_Error_Vzen_Data oDataLog = new tb_sis_Log_Error_Vzen_Data(); tb_sis_Log_Error_Vzen_Info Log_Error_sis = new tb_sis_Log_Error_Vzen_Info(ex.ToString(), "", array, "", "", "", "", "", DateTime.Now); oDataLog.Guardar_Log_Error(Log_Error_sis, ref mensaje); mensaje = ex.InnerException + " " + ex.Message; throw new Exception(ex.InnerException.ToString()); } }
public Boolean GuardarPrestamoDetalle(List <ro_prestamo_detalle_Info> Lst, ref decimal Id, ref string mensaje) { try { int NumCuota_ = 0; foreach (var Item in Lst) { using (EntitiesRoles Context = new EntitiesRoles()) { ro_prestamo_detalle Deta = new ro_prestamo_detalle(); NumCuota_ = NumCuota_ + 1; Deta.IdEmpresa = Item.IdEmpresa; Deta.IdNominaTipoLiqui = Item.IdNominaTipoLiqui; Deta.IdPrestamo = Id; Deta.NumCuota = NumCuota_; Deta.SaldoInicial = Item.SaldoInicial; Deta.Interes = Item.Interes; Deta.AbonoCapital = Item.AbonoCapital; Deta.TotalCuota = Item.TotalCuota; Deta.Saldo = Item.Saldo; Deta.FechaPago = Item.FechaPago; Deta.EstadoPago = Item.EstadoPago; Deta.Estado = Item.Estado; Deta.Observacion_det = Item.Observacion_det; Deta.IdUsuario = Item.IdUsuario; Deta.Fecha_Transac = Item.Fecha_Transac; Deta.nom_pc = Item.nom_pc; Deta.ip = Item.ip; Context.ro_prestamo_detalle.Add(Deta); Context.SaveChanges(); } } return(true); } catch (Exception ex) { string array = ToString(); tb_sis_Log_Error_Vzen_Data oDataLog = new tb_sis_Log_Error_Vzen_Data(); tb_sis_Log_Error_Vzen_Info Log_Error_sis = new tb_sis_Log_Error_Vzen_Info(ex.ToString(), "", array, "", "", "", "", "", DateTime.Now); oDataLog.Guardar_Log_Error(Log_Error_sis, ref mensaje); mensaje = ex.InnerException + " " + ex.Message; throw new Exception(ex.InnerException.ToString()); } }
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); } }