public bool BuscarContrato() { try { Biblioteca.Entidades.Planes Plan; Plan = new Entidades.Planes(); Biblioteca.DALC.Contrato Con; Con = Entidades.Contrato.First(a => a.Numero.Equals(NumeroContrato)); this.NumeroContrato = Con.Numero; this.Creacion = Con.FechaCreacion; this.Termino = (DateTime)Con.FechaTermino; this.Titular = Con.RutCliente; this.PlanAsociado = Con.CodigoPlan; Plan.BuscarPlan(Con.CodigoPlan);//esto esta bien this.Poliza = Plan.PolizaActual; this.InicioVigencia = Con.FechaInicioVigencia; this.FinVigencia = Con.FechaFinVigencia; this.Vigente = Con.Vigente; this.ConDeclaracionSalud = Con.DeclaracionSalud; this.PrimaAnual = Con.PrimaAnual; this.PrimaMensual = Con.PrimaMensual; this.Observaciones = Con.Observaciones; return(true); } catch (Exception ex) { Logger.Mensaje(ex.Message); return(false); } }
public double calculoPrimasanual(string codigo, string rut) { try { double Calculo = 0; Biblioteca.Entidades.Planes Plan; Plan = new Entidades.Planes(); Biblioteca.Entidades.Contratos Cont; Cont = new Entidades.Contratos(); double primab; Biblioteca.Entidades.Clientes cli; cli = new Clientes(); cli.Buscar(); Plan.BuscarPlan(codigo); //le paso el valor de la prima base //1 UF = $ 26.633,18 Pesos Chilenos Double uf = 26633.18; primab = Plan.PrimaBase * uf; int edad = (DateTime.Now.Year - cli.FechaNacimiento.Year); Double recargoEdad = 0; Double recargoSexo = 0; Double recargoEstCiv = 0; //////////////////////////////////////////////////////////////////////////////////////// //recargo por edad if (edad >= 18 && edad <= 25) { recargoEdad = 0.036 * uf; } else { if (edad >= 26 && edad <= 45) { recargoEdad = 0.024 * uf; } else { if (edad > 45) { recargoEdad = 0.06 * uf; } } } //////////////////////////////////////////////////////////////////////////////////////// //recargo x sexo if (cli.IdSexo == 1) //hombre { recargoSexo = 0.024 * uf; } else { if (cli.IdSexo == 2) //mujer { recargoSexo = 0.012 * uf; } } //////////////////////////////////////////////////////////////////////////////////////// //recargo por estado civil switch (cli.IdEstadoCivil) { case 1: //soltero recargoEstCiv = 0.048 * uf; break; case 2: //casado recargoEstCiv = 0.024 * uf; break; //case 3://divorciado // break; //case 4://viudo //break; default: //otro recargoEstCiv = 0.036 * uf; break; } //////////////////////////////////////////////////////////////////////////////////////// Calculo = primab + recargoEdad + recargoEstCiv + recargoSexo; //retorna la PrimaAnual return(Calculo); } catch (Exception) { return(0); } }
public Entidades.Planes RecuperarUno(int id) { MySqlConnection oConn = Datos.General.CreateConnection(); using (oConn) { oConn.Open(); MySqlCommand oCmd = new MySqlCommand(); using (oCmd) { oCmd.Connection = oConn; oCmd.CommandType = CommandType.StoredProcedure; oCmd.CommandText = "PlanesRecuperarUno"; oCmd.Parameters.AddWithValue("@IdPlan", id); Entidades.Planes oPlanes = new Entidades.Planes(); try { MySqlDataReader oReader = oCmd.ExecuteReader(); using (oReader) { while (oReader.Read()) { Entidades.Plan oPlan = new Entidades.Plan(); oPlan.IdPlan = Convert.ToInt32(oReader["IdPlan"]); oPlan.Anio = Convert.ToInt32(oReader["Anio"]); int id_especialidad = Convert.ToInt32(oReader["Especialidad"]); oPlan.especialidad = new Especialidades().RecuperarUno(id_especialidad)[0]; oPlanes.Add(oPlan); oPlan = null; } return oPlanes; } } finally { oPlanes = null; } } } }