Exemplo n.º 1
0
        /// <summary>
        /// consulta todas las aulas
        /// </summary>
        /// <returns>List</returns>
        public List<PlanillaDetalle> consultarTodos()
        {
            using (Database db = DatabaseFactory.openDatabase("rh_db"))
            {
                List<PlanillaDetalle> lista = new List<PlanillaDetalle>();
                MySqlCommand comando = new MySqlCommand("sp_planilla_detalle_SELECT_all");
                comando.CommandType = CommandType.Text;
                //indicamos el nombre de la tabla
                DataSet ds = db.executeReader(comando, "planilla_detalle");
                foreach (DataRow row in ds.Tables[0].Rows)
                {
                    PlanillaDetalle dato = new PlanillaDetalle();
                    if (!row["idEncabezado"].ToString().Equals(""))
                        dato.idEncabezado = Int32.Parse(row["idEncabezado"].ToString());

                    if (!row["idDetalle"].ToString().Equals(""))
                        dato.idDetalle = Int32.Parse(row["idDetalle"].ToString());

                    if (!row["producto"].ToString().Equals(""))
                        dato.producto.idProducto = Int32.Parse(row["producto"].ToString());

                    if (!row["monto"].ToString().Equals(""))
                        dato.monto = Double.Parse(row["monto"].ToString());

                    if (!row["tipo"].ToString().Equals(""))
                        dato.tipo = row["tipo"].ToString();

                    lista.Add(dato);
                }
                return lista;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// consulta una PlanillaDetalles
        /// </summary>
        /// <param name="dato"></param>
        /// <returns></returns>
        public PlanillaDetalle consultarId(PlanillaDetalle dato)
        {
            PlanillaDetalle planillaDetalle = this.planillaDetalleDA.consultarId(dato);
            if (planillaDetalle != null)
            {
                if (planillaDetalle.producto.idProducto != 0)
                {
                    planillaDetalle.producto = this.productoBL.consultarId(new Producto(planillaDetalle.producto.idProducto, planillaDetalle.tipo));
                }

            }
            return planillaDetalle;
        }
Exemplo n.º 3
0
        /// <summary>
        /// consulta una PlanillaDetalle
        /// </summary>
        /// <param name="dato"></param>
        /// <returns></returns>
        public PlanillaDetalle consultarId(PlanillaDetalle dato)
        {
            using (Database db = DatabaseFactory.openDatabase("rh_db"))
            {
                MySqlCommand comando = new MySqlCommand("sp_planilla_detalle_SELECT_ById");
                comando.CommandType = CommandType.StoredProcedure;
                comando.Parameters.AddWithValue("p_idEncabezado", dato.idEncabezado);
                comando.Parameters.AddWithValue("p_idDetalle", dato.idDetalle);
                //Despues del comando indicar el nombre de la tabla
                DataSet ds = db.executeReader(comando, "planilla_detalle");
                if (ds.Tables[0].Rows.Count > 0)
                {
                    DataRow row = ds.Tables[0].Rows[0];
                    if (!row["idEncabezado"].ToString().Equals(""))
                        dato.idEncabezado = Int32.Parse(row["idEncabezado"].ToString());

                    if (!row["idDetalle"].ToString().Equals(""))
                        dato.idDetalle = Int32.Parse(row["idDetalle"].ToString());

                    if (!row["producto"].ToString().Equals(""))
                        dato.producto.idProducto = Int32.Parse(row["producto"].ToString());

                    if (!row["monto"].ToString().Equals(""))
                        dato.monto = Double.Parse(row["monto"].ToString());

                    if (!row["tipo"].ToString().Equals(""))
                        dato.tipo = row["tipo"].ToString();

                }
                else
                {
                    dato = null;
                }
                return dato;
            }
        }
        private void calcualCCSS(String tipo)
        {
            if (Session["listaDetalles"] != null && this.cmbTipo.Text.Equals("PLANILLA"))
            {
                double totalPercepcion = 0;
                this.listaDetalles = (List<PlanillaDetalle>)Session["listaDetalles"];

                if (tipo.Equals("AGREGAR"))
                {
                    //si es el prper producto que se agrega y ademas es por planilla se agregan los rebajos de CCSS
                    if (this.listaDetalles.Count == 1)
                    {
                        for (int i = 1; i <= 3; i++)
                        {
                            PlanillaDetalle detalle = new PlanillaDetalle();
                            Producto producto = new Producto();
                            producto.idProducto = i;
                            producto.tipo = "DEDUCCIÓN";
                            producto.descripcion = deduccionBL.consultarId(new Deduccion(i)).descripcion;
                            detalle.descripcion = producto.descripcion;
                            detalle.producto = producto;
                            detalle.tipo = producto.tipo;
                            this.listaDetalles.Add(detalle);
                        }

                    }
                }

                //saca el subtotal de pescepciones sin invluir las comisiones
                foreach (PlanillaDetalle detalle in this.listaDetalles)
                {

                    if (detalle.tipo.Equals("PERCEPCIÓN") && detalle.producto.idProducto != 6 /*COMISIONES*/)
                    {
                        totalPercepcion = totalPercepcion + detalle.monto;
                    }
                }

                //aplica rebajos de caja
                foreach (PlanillaDetalle detalle in this.listaDetalles)
                {

                    if (detalle.tipo.Equals("DEDUCCIÓN"))
                    {
                        switch (detalle.producto.idProducto)
                        {
                            case 1:
                                detalle.monto = -1 * totalPercepcion * deduccionBL.consultarId(new Deduccion(1)).porcentaje / 100;
                                break;

                            case 2:
                                detalle.monto = -1 * totalPercepcion * deduccionBL.consultarId(new Deduccion(2)).porcentaje / 100;
                                break;

                            case 3:
                                detalle.monto = -1 * totalPercepcion * deduccionBL.consultarId(new Deduccion(3)).porcentaje / 100;
                                break;
                        }
                    }
                }

            }
        }
        protected void btnAgregarDetalle_Click(object sender, EventArgs e)
        {
            try
            {
                PlanillaDetalle detalle = new PlanillaDetalle();

                Producto producto = new Producto();
                producto.idProducto = Int32.Parse( this.cmbProducto.Value.ToString().Split('-')[1] );
                producto.tipo = this.cmbProducto.Value.ToString().Split('-')[0];
                producto.descripcion = this.cmbProducto.Text.Replace("PERCEPCIÓN", "").Replace("DEDUCCIÓN", "").Replace("-", "").Trim();

                detalle.descripcion = producto.descripcion;
                detalle.producto = producto;
                detalle.tipo= producto.tipo;

                if (detalle.tipo.Equals("PERCEPCIÓN"))
                {
                    detalle.monto = Double.Parse(this.txtMonto.Text);

                }
                else
                {
                    detalle.monto = Double.Parse(this.txtMonto.Text) * -1;
                }

                if (Session["listaDetalles"] != null)
                {
                    this.listaDetalles = (List<PlanillaDetalle>)Session["listaDetalles"];
                    detalle.idDetalle = this.listaDetalles.Count;
                    this.listaDetalles.Add(detalle);
                    this.calcualCCSS("AGREGAR");
                    Session["listaDetalles"] = this.listaDetalles;
                }

                this.cmbProducto.SelectedItem = null;
                this.txtMonto.Text = null;
                this.cargarDatos();
            }
            catch (Exception ex)
            {
                this.lblMensaje.Text = Utilidades.validarExepcionSQL(ex.Message);
                this.lblMensaje.CssClass = "errorMessage";
                Session["errorMessage"] = ex.Message;
            }
        }
        /// <summary>
        /// crea el encabezado de la liquitacion con sus detalles
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnCrear_Click(object sender, EventArgs e)
        {
            Int32 colaborador = Int32.Parse(this.cmbColaborador.Value.ToString());
            Double vacaciones = 0;
            Double preaviso = 0;
            Double totalMeses = 0;
            Double mensual = 0;
            Double diario = 0;
            Double cesantia = 0;
            Double aguinaldo = 0;
            Double total = 0;
            Int32 divisor2630 = 0;

            foreach (PagoMensual pago in this.planillaEncabezadoBL.consultarSalariosLiquidacion(colaborador))
            {
                totalMeses = totalMeses + pago.monto;
            }
            mensual = totalMeses / this.ASPxGridViewProducto.VisibleRowCount + 1;
            if (Int32.Parse(this.cmbPago.Value.ToString().Substring(1, 1)) >= 30)
            {
                divisor2630 = 30;
            }
            else
            {
                divisor2630 = 26;
            }
            diario = (mensual / divisor2630);
            vacaciones = diario * Int32.Parse(this.txtVacaciones.Text);
            preaviso = diario * Int32.Parse(this.txtPreaviso.Text);
            cesantia = diario * this.planillaEncabezadoBL.consultarCantidadDiasCesantia(colaborador);
            aguinaldo = this.planillaEncabezadoBL.consultarMontoAguinaldo(colaborador);
            total = vacaciones + preaviso + cesantia + aguinaldo;

            PlanillaEncabezado encabezado = new PlanillaEncabezado();
            encabezado.colaborador.idColaborador = colaborador;
            encabezado.estado = this.cmbModo.Text;
            encabezado.montoPago = total;
            encabezado.montoSalarioActual = total;
            encabezado.periodo = this.cmbPeriodo.Text;
            encabezado.sucursal.idSucursal = Int32.Parse(this.cmbSucursal.Value.ToString());
            encabezado.manual = PlanillaEncabezado.MANUAL_SI;
            encabezado.tipoCalculoPago = this.cmbTipo.Text;
            encabezado.usuarioCreacion = Session["usuario"].ToString();
            encabezado.idPlanilla = this.planillaEncabezadoBL.nuevo(encabezado);

            PlanillaDetalle detalle;

            if (aguinaldo > 0)
            {
                detalle = new PlanillaDetalle();
                detalle.idEncabezado = encabezado.idPlanilla;
                detalle.producto.idProducto = 7; //AGUINALDO
                detalle.tipo = Producto.PERCEPCION;
                detalle.monto = aguinaldo;
                this.planillaDetalleBL.nuevo(detalle);
            }

            if (vacaciones > 0)
            {
                detalle = new PlanillaDetalle();
                detalle.idEncabezado = encabezado.idPlanilla;
                detalle.producto.idProducto = 8;	//VACACIONES
                detalle.tipo = Producto.PERCEPCION;
                detalle.monto = vacaciones;
                this.planillaDetalleBL.nuevo(detalle);
            }

            if (preaviso > 0)
            {
                detalle = new PlanillaDetalle();
                detalle.idEncabezado = encabezado.idPlanilla;
                detalle.producto.idProducto = 14; //PREAVISO
                detalle.tipo = Producto.PERCEPCION;
                detalle.monto = preaviso;
                this.planillaDetalleBL.nuevo(detalle);
            }

            if (cesantia > 0)
            {
                detalle = new PlanillaDetalle();
                detalle.idEncabezado = encabezado.idPlanilla;
                detalle.producto.idProducto = 15; //CESANTIA
                detalle.tipo = Producto.PERCEPCION;
                detalle.monto = cesantia;
                this.planillaDetalleBL.nuevo(detalle);
            }
        }
Exemplo n.º 7
0
 /// <summary>
 /// agrega un nuevo registro
 /// </summary>
 public void nuevo(PlanillaDetalle dato)
 {
     if (!this.existe(dato))
     {
         this.planillaDetalleDA.nuevo(dato);
     }
     else
     {
         throw new Exception("Ya existe el registro.");
     }
 }
Exemplo n.º 8
0
 /// <summary>
 /// modificar un registro
 /// </summary>
 public void modificar(PlanillaDetalle dato)
 {
     if (this.existe(dato))
     {
         this.planillaDetalleDA.modificar(dato);
     }
     else
     {
         throw new Exception("Ya existe el registro.");
     }
 }
Exemplo n.º 9
0
 /// <summary>
 /// verifica si existe una PagoPendiente
 /// </summary>
 /// <param name="dato"></param>
 /// <returns>TRUE si existe FALSE en caso contrario</returns>
 public bool existe(PlanillaDetalle dato)
 {
     return this.planillaDetalleDA.existe(dato);
 }
Exemplo n.º 10
0
 /// <summary>
 /// calcula  todas las detalles
 /// </summary>
 /// <returns>List<Rol></returns>
 public bool eliminar(PlanillaDetalle dato)
 {
     return this.planillaDetalleDA.eliminar(dato);
 }
Exemplo n.º 11
0
 /// <summary>
 /// crea una PagoPendiente nuevo
 /// </summary>
 /// <param name="dato"></param>
 /// Se crea un dato de tipo PagoPendiente
 public void nuevo(PlanillaDetalle dato)
 {
     using (Database db = DatabaseFactory.openDatabase("rh_db"))
     {
         //Agregamos la instruccion con el stored procedure
         MySqlCommand comando = new MySqlCommand("sp_planilla_detalle_INSERT");
         comando.CommandType = CommandType.StoredProcedure;
         comando.Parameters.AddWithValue("p_idEncabezado", dato.idEncabezado);
         comando.Parameters.AddWithValue("p_producto", dato.producto.idProducto);
         comando.Parameters.AddWithValue("p_monto", dato.monto);
         comando.Parameters.AddWithValue("p_tipo", dato.tipo);
         db.executeNonQuery(comando);
     }
 }
Exemplo n.º 12
0
 /// <summary>
 /// verifica si existe una  PlanillaDetalle
 /// </summary>
 /// <param name="dato"></param>
 /// <returns>TRUE si existe FALSE en caso contrario</returns>
 public bool existe(PlanillaDetalle dato)
 {
     using (Database db = DatabaseFactory.openDatabase("rh_db"))
     {
         MySqlCommand comando = new MySqlCommand("sp_planilla_detalle_SELECT_ById");
         comando.CommandType = CommandType.StoredProcedure;
         comando.Parameters.AddWithValue("p_idEncabezado", dato.idEncabezado);
         comando.Parameters.AddWithValue("p_idDetalle", dato.idDetalle);
         DataSet ds = db.executeReader(comando, "planilla_detalle");
         if (ds.Tables[0].Rows.Count > 0)
         {
             return true;
         }
         else
         {
             return false;
         }
     }
 }
Exemplo n.º 13
0
        /// <summary>
        /// se elimna un registro
        /// </summary>
        /// <param name="periodo"></param>
        /// <param name="sucursal"></param>
        /// <param name="colaborador"></param>
        /// <returns></returns>
        public bool eliminar(PlanillaDetalle dato)
        {
            using (Database db = DatabaseFactory.openDatabase("rh_db"))
            {
                //Agregamos la instruccion con el stored procedure
                MySqlCommand comando = new MySqlCommand("sp_planilla_detalle_DELETE");
                comando.Parameters.AddWithValue("p_idEncabezado", dato.idEncabezado);
                comando.Parameters.AddWithValue("p_idDetalle", dato.idDetalle);
                comando.CommandType = CommandType.StoredProcedure;

                db.executeNonQuery(comando);
                return true;
            }
        }