Пример #1
0
        public int Actualizar(ref BE.Afp beAfp)
        {
            try
            {
                string sp           = "SpTbAfpActualizar";
                int    rowsAffected = 0;

                using (SqlConnection cnn = new SqlConnection(ConnectionManager.ConexionLocal))
                {
                    cnn.Open();

                    SqlCommand cmd = new SqlCommand(sp, cnn);
                    cmd.CommandType = CommandType.StoredProcedure;

                    cmd.Parameters.Add(new SqlParameter("@IDAFP", beAfp.IdAfp));
                    cmd.Parameters.Add(new SqlParameter("@CODIGO", beAfp.Codigo));
                    cmd.Parameters.Add(new SqlParameter("@NOMBRE", beAfp.Nombre));
                    cmd.Parameters.Add(new SqlParameter("@DESCRIPCION", beAfp.Descripcion));
                    cmd.Parameters.Add(new SqlParameter("@ACTIVO", beAfp.Activo));

                    rowsAffected = cmd.ExecuteNonQuery();
                }

                return(rowsAffected);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #2
0
        public bool Obtener(ref BE.Afp beAfp)
        {
            bool flag = false;

            try
            {
                string sp = "SpTbAfpObtener";

                SqlConnection cnn = new SqlConnection(ConnectionManager.ConexionLocal);
                SqlCommand    cmd = new SqlCommand(sp, cnn);
                cmd.CommandType = CommandType.StoredProcedure;

                SqlDataAdapter dad = new SqlDataAdapter(cmd);
                dad.SelectCommand.Parameters.Add(new SqlParameter("@IDAFP", beAfp.IdAfp));

                DataTable dt = new DataTable();
                dad.Fill(dt);

                if ((dt.Rows.Count == 1))
                {
                    DataRow dr = dt.Rows[0];
                    Cargar(ref beAfp, ref dr);
                    flag = true;
                }

                return(flag);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #3
0
        public DataTable Listar(BE.Afp beAfp)
        {
            try
            {
                string sp = "SpTbAfpListar";

                SqlConnection cnn = new SqlConnection(ConnectionManager.ConexionLocal);
                SqlCommand    cmd = new SqlCommand(sp, cnn);
                cmd.CommandType = CommandType.StoredProcedure;

                SqlDataAdapter dad = new SqlDataAdapter(cmd);
                dad.SelectCommand.Parameters.Add(new SqlParameter("@CODIGO", beAfp.Codigo));
                dad.SelectCommand.Parameters.Add(new SqlParameter("@NOMBRE", beAfp.Nombre));
                dad.SelectCommand.Parameters.Add(new SqlParameter("@DESCRIPCION", beAfp.Descripcion));
                dad.SelectCommand.Parameters.Add(new SqlParameter("@ACTIVO", beAfp.Activo));

                DataTable dt = new DataTable();
                dad.Fill(dt);

                return(dt);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #4
0
        public List <BE.Afp> ListarCombo()
        {
            List <BE.Afp> lstAfp = new List <BE.Afp>();

            try
            {
                var daAfp = new DA.Afp();

                DataTable dt = daAfp.Listar(new BE.Afp()
                {
                    Activo = true
                });

                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    var dr    = dt.Rows[i];
                    var beAFP = new BE.Afp();
                    daAfp.Cargar(ref beAFP, ref dr);
                    lstAfp.Add(beAFP);
                }

                return(lstAfp);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #5
0
        public BE.AfpComision Obtener(int idAfpComision)
        {
            BE.AfpComision beAfpComision = null;
            try
            {
                string sp = "SpTbAfpComisionObtener2";

                using (SqlConnection cnn = new SqlConnection(ConnectionManager.ConexionLocal))
                {
                    cnn.Open();

                    SqlCommand cmd = new SqlCommand(sp, cnn);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add(new SqlParameter("@IDAFPCOMISION", idAfpComision));

                    SqlDataReader reader = cmd.ExecuteReader();
                    if (reader.Read())
                    {
                        beAfpComision = new BE.AfpComision();

                        beAfpComision.IdAfpComision           = reader["IdAfpComision"] == DBNull.Value ? 0 : int.Parse(reader["IdAfpComision"].ToString());
                        beAfpComision.Anho                    = reader["Anho"] == DBNull.Value ? 0 : int.Parse(reader["Anho"].ToString());
                        beAfpComision.Mes                     = reader["Mes"] == DBNull.Value ? 0 : int.Parse(reader["Mes"].ToString());
                        beAfpComision.PorcentajeFondo         = reader["PorcentajeFondo"] == DBNull.Value ? 0.0 : double.Parse(reader["PorcentajeFondo"].ToString());
                        beAfpComision.PorcentajeSeguro        = reader["PorcentajeSeguro"] == DBNull.Value ? 0.0 : double.Parse(reader["PorcentajeSeguro"].ToString());
                        beAfpComision.PorcentajeComisionFlujo = reader["PorcentajeComisionFlujo"] == DBNull.Value ? 0.0 : double.Parse(reader["PorcentajeComisionFlujo"].ToString());
                        beAfpComision.PorcentajeComisionMixta = reader["PorcentajeComisionMixta"] == DBNull.Value ? 0.0 : double.Parse(reader["PorcentajeComisionMixta"].ToString());

                        if (reader["IdAfp"] != DBNull.Value)
                        {
                            int idAfp = reader["IdAfp"] == DBNull.Value ? 0 : int.Parse(reader["IdAfp"].ToString());
                            var beAfp = new BE.Afp()
                            {
                                IdAfp = idAfp
                            };

                            if (new DA.Afp().Obtener(ref beAfp))
                            {
                                beAfpComision.Afp = beAfp;
                            }
                        }
                    }
                }

                return(beAfpComision);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #6
0
 public void Cargar(ref BE.Afp beAfp, ref DataRow dr)
 {
     try
     {
         beAfp.IdAfp       = dr["IdAfp"] == DBNull.Value ? 0 : int.Parse(dr["IdAfp"].ToString());
         beAfp.Codigo      = dr["Codigo"] == DBNull.Value ? "" : dr["Codigo"].ToString();
         beAfp.Nombre      = dr["Nombre"] == DBNull.Value ? "" : dr["Nombre"].ToString();
         beAfp.Descripcion = dr["Descripcion"] == DBNull.Value ? "" : dr["Descripcion"].ToString();
         beAfp.Activo      = dr["Activo"] == DBNull.Value ? false : bool.Parse(dr["Activo"].ToString());
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Пример #7
0
        private void BtnSave_Click(object sender, EventArgs e)
        {
            try
            {
                int anho = int.Parse(this.cboAnho.SelectedValue.ToString());
                int mes  = int.Parse(this.cboMes.SelectedValue.ToString());

                foreach (BE.UI.AfpComision uiComision in this.lstUiComisiones)
                {
                    var beAfp = new BE.Afp()
                    {
                        IdAfp  = uiComision.AfpID,
                        Nombre = uiComision.AfpNombre
                    };

                    var beComision = new BE.AfpComision
                    {
                        Afp                     = beAfp,
                        IdAfpComision           = uiComision.IdAfpComision,
                        Anho                    = anho,
                        Mes                     = mes,
                        PorcentajeFondo         = uiComision.PorcentajeFondo,
                        PorcentajeSeguro        = uiComision.PorcentajeSeguro,
                        PorcentajeComisionFlujo = uiComision.PorcentajeComisionFlujo,
                        PorcentajeComisionMixta = uiComision.PorcentajeComisionMixta,
                    };

                    var lnComision = new LN.AfpComision();
                    if (beComision.IdAfpComision > 0)
                    {
                        lnComision.Actualizar(beComision);
                    }
                    else
                    {
                        lnComision.Insertar(ref beComision);
                    }
                }

                Util.InformationMessage("Se guardo los datos de la Comision");

                this.CargarComisiones();
            }
            catch (Exception ex)
            {
                Util.ErrorMessage(ex.Message);
            }
        }
Пример #8
0
        public List <BE.UI.PlanillaDetalle> ListarPlantillaDetalle()
        {
            try
            {
                var lstUiPlantillaDetalle = new List <BE.UI.PlanillaDetalle>();

                var daPlanilla = new DA.Planilla();

                var bePlanilla = daPlanilla.Obtener(this.anho, this.mes);
                if (bePlanilla != null)
                {
                    int idPlanilla           = bePlanilla.ID;
                    var lstBePlanillaDetalle = new DA.Planilla().Detalle(idPlanilla);

                    foreach (BE.PlanillaDetalle beDetalle in lstBePlanillaDetalle)
                    {
                        var uiPlanillaDetalle = new BE.UI.PlanillaDetalle();

                        uiPlanillaDetalle.Periodo = this.anho.ToString() + "/" + this.mes.ToString();

                        uiPlanillaDetalle.EmpleadoCodigo = beDetalle.CodigoEmpleado;
                        uiPlanillaDetalle.EmpleadoNombre = new DA.Trabajador().ObtenerNombreCompleto(beDetalle.CodigoEmpleado);

                        var beCargo = new DA.Cargo().Obtener(beDetalle.IdCargo);
                        if (beCargo != null)
                        {
                            uiPlanillaDetalle.CargoID     = beDetalle.IdCargo;
                            uiPlanillaDetalle.CargoNombre = beCargo.Nombre;
                        }

                        uiPlanillaDetalle.Base = beDetalle.SueldoBase;
                        uiPlanillaDetalle.AsignacionFamiliar = beDetalle.AsignacionFamiliar;

                        uiPlanillaDetalle.CalcularPor = "M";

                        uiPlanillaDetalle.BonoNocturnoCantidad    = beDetalle.CantidadMinutosBonoNocturno;
                        uiPlanillaDetalle.BonoNocturnoTotal       = beDetalle.TotalMinutoBonoNocturno;
                        uiPlanillaDetalle.BonoHorasExtrasCantidad = beDetalle.CantidadMinutosBonoHorasExtras;
                        uiPlanillaDetalle.BonoHorasExtrasTotal    = beDetalle.TotalMinutoBonoHorasExtras;
                        uiPlanillaDetalle.BonoFeriadoCantidad     = beDetalle.CantidadMinutosBonoFeriado;
                        uiPlanillaDetalle.BonoFeriadoTotal        = beDetalle.TotalMinutoBonoFeriado;

                        uiPlanillaDetalle.DescuentoTardanzaCantidad     = beDetalle.CantidadMinutosDescuentoTardanza;
                        uiPlanillaDetalle.DescuentoTardanzaTotal        = beDetalle.TotalMinutoDescuentoTardanza;
                        uiPlanillaDetalle.DescuentoInasistenciaCantidad = beDetalle.CantidadMinutosDescuentoInasistencia;
                        uiPlanillaDetalle.DescuentoInasistenciaTotal    = beDetalle.TotalDescuentoInasistencia;

                        uiPlanillaDetalle.SnpNombre = "ONP";
                        uiPlanillaDetalle.SnpTotal  = beDetalle.SnpTotal;

                        if (beDetalle.Afp != null && beDetalle.Afp.IdAfp > 0)
                        {
                            var beAfp = new BE.Afp()
                            {
                                IdAfp = beDetalle.Afp.IdAfp
                            };
                            if (new DA.Afp().Obtener(ref beAfp))
                            {
                                uiPlanillaDetalle.AfpID     = beAfp.IdAfp;
                                uiPlanillaDetalle.AfpNombre = beAfp.Nombre;
                            }
                        }

                        uiPlanillaDetalle.AfpTipo = beDetalle.AfpTipo;
                        uiPlanillaDetalle.AfpAporteObligatorio = beDetalle.AfpAporteObligatorio;
                        uiPlanillaDetalle.AfpAporteVoluntario  = beDetalle.AfpAporteVoluntario;
                        uiPlanillaDetalle.AfpSeguro            = beDetalle.AfpSeguro;
                        uiPlanillaDetalle.AfpComision          = beDetalle.AfpComision;
                        uiPlanillaDetalle.AfpTotal             = beDetalle.AfpTotal;

                        uiPlanillaDetalle.ImpuestoTotal          = beDetalle.ImpuestoTotal;
                        uiPlanillaDetalle.RetencionJudicialTotal = beDetalle.RetencionJudicialTotal;
                        uiPlanillaDetalle.AdelantoTotal          = beDetalle.AdelantoTotal;
                        uiPlanillaDetalle.PrestamoTotal          = beDetalle.PrestamoTotal;
                        uiPlanillaDetalle.GratificacionTotal     = 0.0;
                        uiPlanillaDetalle.EsSaludTotal           = beDetalle.EsSaludTotal;
                        uiPlanillaDetalle.MovilidadTotal         = beDetalle.TotalMovilidad;

                        uiPlanillaDetalle.TotalBase  = beDetalle.TotalSueldoBase;
                        uiPlanillaDetalle.TotalBruto = beDetalle.TotalSueldoBruto;
                        uiPlanillaDetalle.TotalNeto  = beDetalle.TotalSueldoNeto;
                        uiPlanillaDetalle.TotalPagar = beDetalle.TotaPago;

                        lstUiPlantillaDetalle.Add(uiPlanillaDetalle);
                    }
                }
                bePlanilla = null;

                return(lstUiPlantillaDetalle);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }