public bool Registrar(ref BE.UI.PlanillaBoleta uiPlanillaBoleta) { try { BE.PlanillaBoleta bePlanillaBoleta = UiToBe(uiPlanillaBoleta); int rowsAffected = 0; var daPlanillaBoleta = new DA.PlanillaBoleta(); if (bePlanillaBoleta.IdPlanillaBoleta == 0) { rowsAffected = daPlanillaBoleta.Insertar(ref bePlanillaBoleta); if (rowsAffected > 0) { uiPlanillaBoleta.Id = bePlanillaBoleta.IdPlanillaBoleta; } } else { rowsAffected = daPlanillaBoleta.Actualizar(bePlanillaBoleta); } return(rowsAffected > 0); } catch (Exception ex) { throw ex; } }
private BE.PlanillaBoleta UiToBe(BE.UI.PlanillaBoleta uiPlanillaBoleta) { var bePlanillaBoleta = new BE.PlanillaBoleta(); bePlanillaBoleta.IdPlanillaBoleta = uiPlanillaBoleta.Id; //Obtener las propiedades que sean publicas y se puedan escribir var lstPropertiesInfosBE = bePlanillaBoleta.GetType().GetProperties() .Where(x => x.CanWrite == true && x.PropertyType.IsPublic == true) .ToList(); //Obtener las propuedades que sean publicas y se puedan escribir var lstPropertiesInfosUI = uiPlanillaBoleta.GetType().GetProperties() .Where(x => x.PropertyType.IsPublic == true) .ToList(); foreach (PropertyInfo propertyInfoBE in lstPropertiesInfosBE) { var propertyName = propertyInfoBE.Name; PropertyInfo propertyInfoUI = lstPropertiesInfosUI.Where(x => x.Name == propertyName).FirstOrDefault(); if (propertyInfoUI != null) { propertyInfoBE.SetValue(bePlanillaBoleta, propertyInfoUI.GetValue(uiPlanillaBoleta)); } } return(bePlanillaBoleta); }
/// <summary> /// Cargar o Calcular los datos de la boleta /// </summary> /// <param name="anho">Anho de consulta. Ejm: 2017</param> /// <param name="mes">Mes de consulta. Ejm: 1, 12</param> /// <param name="codigoEmpleado">Codigo del Empleado</param> private void Cargar(int anho, int mes, string codigoEmpleado) { try { this.uiPlanillaBoleta = new LN.PlanillaBoleta().Obtener(anho, mes, codigoEmpleado); if (uiPlanillaBoleta == null) { this.uiPlanillaBoleta = CalcularBoleta(anho, mes, codigoEmpleado); } } catch (Exception ex) { throw ex; } }
public BE.UI.PlanillaBoleta Obtener(int idPlanillaBoleta) { try { BE.UI.PlanillaBoleta uiPlanillaBoleta = null; var bePlanillaBoleta = new DA.PlanillaBoleta().Obtener(idPlanillaBoleta); if (bePlanillaBoleta != null) { uiPlanillaBoleta = BeToUi(bePlanillaBoleta); } return(uiPlanillaBoleta); } catch (Exception ex) { throw ex; } }
public BE.UI.PlanillaBoleta Obtener(int anho, int mes, string codigoEmpleado) { try { BE.UI.PlanillaBoleta uiPlanillaBoleta = null; var bePlanillaBoleta = new DA.PlanillaBoleta().Obtener(anho, mes, codigoEmpleado); if (bePlanillaBoleta != null) { uiPlanillaBoleta = BeToUi(bePlanillaBoleta); } return(uiPlanillaBoleta); } catch (Exception ex) { throw ex; } }
private BE.UI.PlanillaBoleta CalcularBoleta(int anho, int mes, string codigoEmpleado) { try { var uiDetalle = new LN.Planilla(anho, mes).ObtenerPlantillaDetalle(codigoEmpleado); if (uiDetalle != null) { this.uiPlanillaBoleta = new BE.UI.PlanillaBoleta(); this.uiPlanillaBoleta.Id = 0; var uiPlanilla = new LN.Planilla(anho, mes).Obtener(); if (this.uiPlanillaBoleta != null) { this.uiPlanillaBoleta.IdPlanilla = uiPlanilla.ID; } uiPlanilla = null; this.uiPlanillaBoleta.Anho = anho; this.uiPlanillaBoleta.Mes = mes; this.uiPlanillaBoleta.MesNombre = Util.GetNameOfMonth(mes); this.uiPlanillaBoleta.MesDias = DateTime.DaysInMonth(anho, mes); #region Asignar datos de Empresa var beEmpresa = new LN.Empresa().Obtener(); this.uiPlanillaBoleta.EmpresaNombre = beEmpresa.NombreComercial; this.uiPlanillaBoleta.EmpresaRuc = beEmpresa.RUC; this.uiPlanillaBoleta.EmpresaDistrito = beEmpresa.Ubigeo.Nombre; this.uiPlanillaBoleta.EmpresaDireccion = beEmpresa.DomicilioFiscal; beEmpresa = null; #endregion #region Asignar datos de Empleado var beEmpleado = new LN.Empleado().Obtener(uiDetalle.EmpleadoCodigo); this.uiPlanillaBoleta.EmpleadoCodigo = beEmpleado.Codigo; this.uiPlanillaBoleta.EmpleadoNombres = beEmpleado.Nombres; this.uiPlanillaBoleta.EmpleadoApellidos = $"{beEmpleado.ApellidoPaterno} {beEmpleado.ApellidoMaterno}"; this.uiPlanillaBoleta.EmpleadoNroDocumento = beEmpleado.NumeroDocumento; beEmpleado = null; var beEmpleadoRecurso = new LN.Empleado().ObtenerRecurso(uiDetalle.EmpleadoCodigo); this.uiPlanillaBoleta.EmpleadoCargo = beEmpleadoRecurso.Cargo.Nombre; this.uiPlanillaBoleta.EmpleadoFechaIngreso = beEmpleadoRecurso.FechaInicio; this.uiPlanillaBoleta.EmpleadoFechaCese = beEmpleadoRecurso.FechaCese; this.uiPlanillaBoleta.EmpleadoEsSaludCodigo = beEmpleadoRecurso.Autogenerado; if (beEmpleadoRecurso.ONP == true) { this.uiPlanillaBoleta.EmpleadoSppCodigo = ""; this.uiPlanillaBoleta.EmpleadoSppEntidad = uiDetalle.SnpNombre; } else { this.uiPlanillaBoleta.EmpleadoSppCodigo = beEmpleadoRecurso.CUSPP; this.uiPlanillaBoleta.EmpleadoSppEntidad = uiDetalle.AfpNombre; } beEmpleadoRecurso = null; var uiVacacion = new LN.Vacacion().ObtenerUltimo(codigoEmpleado); if (uiVacacion != null) { this.uiPlanillaBoleta.EmpleadoVacacionSalida = uiVacacion.VacacionFechaInicial; this.uiPlanillaBoleta.EmpleadoVacacionRetorno = uiVacacion.VacacionFechaFinal; } uiVacacion = null; #endregion #region Asignar datos del Resumen this.uiPlanillaBoleta.DiasLaborados = 0; this.uiPlanillaBoleta.DiasNoLaborados = 0; this.uiPlanillaBoleta.DiasSinGoceHaber = 0; this.uiPlanillaBoleta.DiasSubsidiado = 0; this.uiPlanillaBoleta.HorasNormales = 0; #endregion #region Asignar datos del Sueldo this.uiPlanillaBoleta.Sueldo = uiDetalle.Base; this.uiPlanillaBoleta.AsignacionFamiliar = uiDetalle.AsignacionFamiliar; this.uiPlanillaBoleta.BonificacionNocturna = uiDetalle.BonoNocturnoTotal; this.uiPlanillaBoleta.MovilidadTranslado = new LN.Movilidad().ObtenerTotal(anho, mes, codigoEmpleado); this.uiPlanillaBoleta.SubsidioDescansoMedico = 0.0; //FALTA this.uiPlanillaBoleta.BonificacionHorasExtras = uiDetalle.BonoHorasExtrasTotal; this.uiPlanillaBoleta.CantidadHorasExtras = uiDetalle.BonoHorasExtrasCantidad; this.uiPlanillaBoleta.Cts = 0.0; //FALTA this.uiPlanillaBoleta.Vacaciones = 0.0; //FALTA this.uiPlanillaBoleta.FeriadoDominical = 0.0; //FALTA this.uiPlanillaBoleta.Gratificacion = 0.0; //FALTA this.uiPlanillaBoleta.BonificacionGratificacion = 0.0; //FALTA #endregion #region Asignar datos de Aportes y Deducciones this.uiPlanillaBoleta.AfpFondoMonto = uiDetalle.AfpAporteObligatorio; this.uiPlanillaBoleta.AfpSeguroMonto = uiDetalle.AfpSeguro; this.uiPlanillaBoleta.AfpComisionMonto = uiDetalle.AfpComision; this.uiPlanillaBoleta.IpssVidaMonto = 0.0; //FALTA this.uiPlanillaBoleta.OnpMonto = uiDetalle.SnpTotal; this.uiPlanillaBoleta.RentaQuintaMonto = 0.0; //FALTA this.uiPlanillaBoleta.InasistenciasDias = uiDetalle.DescuentoInasistenciaCantidad; this.uiPlanillaBoleta.InasistenciasMonto = uiDetalle.DescuentoInasistenciaTotal; this.uiPlanillaBoleta.AdelantoMonto = uiDetalle.AdelantoTotal; this.uiPlanillaBoleta.TardanzaMinutos = uiDetalle.DescuentoTardanzaCantidad; this.uiPlanillaBoleta.TardanzaMonto = uiDetalle.DescuentoTardanzaTotal; this.uiPlanillaBoleta.GratificacionMonto = 0.0; //FALTA this.uiPlanillaBoleta.RetencionJudicialMonto = uiDetalle.RetencionJudicialTotal; this.uiPlanillaBoleta.SeguroVidaTrabajadorMonto = 0.0; //FALTA this.uiPlanillaBoleta.IpssSaludTrabajadorMonto = 0.0; //FALTA this.uiPlanillaBoleta.SeguroVidaEmpleadoMonto = 0.0; //FALTA this.uiPlanillaBoleta.IpssSaludEmpleadoMonto = 0.0; //FALTA #endregion //var propertyInfos = uiBoleta.GetType().GetProperties() // .Where(x => x.PropertyType == typeof(double) && x.CanWrite == true) // .ToList(); //foreach (var prop in propertyInfos) //{ // prop.SetValue(uiBoleta, Math.Round((double)prop.GetValue(uiBoleta), 2)); //} uiPlanillaBoleta.GetType().GetProperties() .Where(x => x.PropertyType == typeof(double) && x.CanWrite == true) .ToList() .ForEach(x => x.SetValue( uiPlanillaBoleta, Math.Round((double)x.GetValue(uiPlanillaBoleta), 2) ) ); } return(uiPlanillaBoleta); } catch (Exception ex) { throw ex; } }