Exemplo n.º 1
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                #region Validaciones
                if (this.uiGratificacion == null ||
                    this.uiGratificacion.EmpleadoCodigo.Length == 0 ||
                    this.uiGratificacion.Periodo.Length == 0)
                {
                    throw new Exception("Realice una busqueda por empleado y periodo");
                }
                #endregion

                #region Guardar

                this.uiGratificacion.SueldoBase                = double.Parse(this.txtSueldoBase.Text);
                this.uiGratificacion.AsignacionFamiliar        = double.Parse(this.txtSueldoAsigFam.Text);
                this.uiGratificacion.BonoNocturno              = double.Parse(this.txtBonoNocturno.Text);
                this.uiGratificacion.BonoHorasExtras           = double.Parse(this.txtBonoExtra.Text);
                this.uiGratificacion.DescuentoRetencioJudicial = double.Parse(this.txtDescuentoRJ.Text);
                this.uiGratificacion.DescuentoImpuestos        = double.Parse(this.txtDescuentoImpuesto.Text);
                this.uiGratificacion.GratificacionBruta        = double.Parse(this.txtGratificacionBruta.Text);
                this.uiGratificacion.GratificacionBono         = double.Parse(this.txtGratificacionBonificacion.Text);
                this.uiGratificacion.GratificacionNeta         = double.Parse(this.txtGratificacionNeta.Text);
                this.uiGratificacion.GratificacionPago         = double.Parse(this.txtGratificacionPago.Text);

                bool   rpta            = false;
                string msg             = "";
                var    lnGratificacion = new LN.Gratificacion();
                if (this.uiGratificacion.Id == 0) //Nuevo
                {
                    rpta = lnGratificacion.Insertar(ref this.uiGratificacion);
                    if (true)
                    {
                        msg = "Se registro la gratificacion";
                    }
                }
                else  //Actualizar
                {
                    rpta = lnGratificacion.Actualizar(this.uiGratificacion);
                    if (true)
                    {
                        msg = "Se actualizo la gratificacion";
                    }
                }

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

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