private void btnEliminar_Click(object sender, EventArgs e)
        {
            try
            {
                if (this.dgvBonos.CurrentRow != null)
                {
                    if (Util.ConfirmationMessage("¿Desea eliminar el Bono seleccionado?") == false)
                    {
                        return;
                    }

                    var uiBonoEmpleado = (BE.UI.BonoEmpleado) this.dgvBonos.CurrentRow.DataBoundItem;

                    int  idObservacion = uiBonoEmpleado.ID;
                    bool rpta          = new LN.BonoEmpleado().Eliminar(idObservacion);

                    if (rpta == true)
                    {
                        Util.InformationMessage("Se eliminó el Bono seleccionado");
                        this.CargarListadoBonos();
                    }
                }
            }
            catch (Exception ex)
            {
                Util.ErrorMessage(ex.Message);
            }
        }
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                if (this.lstUiBonosEmpleados.Count == 0)
                {
                    throw new Exception("Debe realizar un calculo de bonos");
                }

                if (Util.ConfirmationMessage("¿Desea guardar los bonos calculados?") == false)
                {
                    return;
                }

                bool rpta           = false;
                var  lnBonoEmpleado = new LN.BonoEmpleado();
                for (int i = 0; i < this.lstUiBonosEmpleados.Count; i++)
                {
                    BE.UI.BonoEmpleado uiBonoEmpleado = this.lstUiBonosEmpleados[i];
                    rpta = lnBonoEmpleado.Insertar(ref uiBonoEmpleado);
                    this.lstUiBonosEmpleados[i].ID = uiBonoEmpleado.ID;
                }

                Util.InformationMessage("Se guardo los bonos calculados");

                if (this.frmList != null)
                {
                    this.frmList.CargarListadoBonos();
                }

                this.Close();
            }
            catch (Exception ex)
            {
                Util.ErrorMessage(ex.Message);
            }
        }
        public void CargarListadoBonos()
        {
            try
            {
                int    anho           = int.Parse(this.cboAnho.SelectedValue.ToString());
                int    mes            = int.Parse(this.cboMes.SelectedValue.ToString());
                string codigoEmpleado = this.txtEmpleadoCodigo.Text;

                var lstUiBonos = new LN.BonoEmpleado().Listar(anho, mes, codigoEmpleado);
                var cntBonos   = lstUiBonos.Count;
                var sumBonos   = lstUiBonos.Sum(x => x.Monto);

                var sorted = new SortableBindingList <BE.UI.BonoEmpleado>(lstUiBonos);

                this.dgvBonos.DataSource = sorted;

                this.txtNroRegistros.Text = cntBonos.ToString();
                this.txtTotal.Text        = sumBonos.ToString("N2");
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                #region Validaciones

                if (this.cboEmpleado.SelectedIndex == 0)
                {
                    this.cboEmpleado.Focus();
                    throw new Exception("Seleccione un empleado");
                }

                if (this.cboBono.SelectedIndex == 0)
                {
                    this.cboBono.Focus();
                    throw new Exception("Seleccione un tipo de Bono");
                }

                if (this.txtMotivo.Text.Trim().Length == 0)
                {
                    this.txtMotivo.Focus();
                    throw new Exception("Ingrese el motivo del Bono");
                }

                if (this.txtMonto.Text.Trim().Length == 0)
                {
                    this.txtMonto.Focus();
                    throw new Exception("Ingrese el monto del Bono");
                }

                double monto = 0;
                if (double.TryParse(this.txtMonto.Text, out monto) == false)
                {
                    this.txtMonto.Focus();
                    throw new Exception("Ingrese el monto del Bono");
                }
                else if (monto == 0.0)
                {
                    this.txtMonto.Focus();
                    throw new Exception("Ingrese el monto del Bono");
                }

                #endregion

                #region Guardar

                this.uiBonoEmpleado.Fecha                  = this.dtpFecha.Value;
                this.uiBonoEmpleado.EmpleadoCodigo         = ((BE.Record) this.cboEmpleado.SelectedItem).Codigo;
                this.uiBonoEmpleado.EmpleadoNombreCompleto = ((BE.Record) this.cboEmpleado.SelectedItem).Nombre;
                this.uiBonoEmpleado.BonoID                 = ((BE.UI.Bono) this.cboBono.SelectedItem).Id;
                this.uiBonoEmpleado.BonoTipo               = ((BE.UI.Bono) this.cboBono.SelectedItem).Calculado ? "Calculado" : "Manual"; //Manual o Calculado
                this.uiBonoEmpleado.BonoNombre             = ((BE.UI.Bono) this.cboBono.SelectedItem).Nombre;
                this.uiBonoEmpleado.Monto                  = double.Parse(this.txtMonto.Text);
                this.uiBonoEmpleado.Motivo                 = this.txtMotivo.Text;

                bool   rpta           = false;
                string msg            = "";
                var    lnBonoEmpleado = new LN.BonoEmpleado();
                if (this.uiBonoEmpleado.ID == 0) //Nuevo
                {
                    rpta = lnBonoEmpleado.Insertar(ref this.uiBonoEmpleado);
                    if (true)
                    {
                        msg = "Se registro el nuevo bono";
                    }
                }
                else  //Actualizar
                {
                    rpta = lnBonoEmpleado.Actualizar(this.uiBonoEmpleado);
                    if (true)
                    {
                        msg = "Se actualizo el bono";
                    }
                }

                if (rpta == true)
                {
                    Util.InformationMessage(msg);
                    this.frmList.CargarListadoBonos();
                    this.Close();
                }

                #endregion
            }
            catch (Exception ex)
            {
                Util.ErrorMessage(ex.Message);
            }
        }