コード例 #1
0
        private void BtnSave_Click(object sender, EventArgs e)
        {
            try
            {
                #region Validaciones
                if (this.cboEmpleado.SelectedIndex == 0)
                {
                    this.cboEmpleado.Focus();
                    throw new Exception("Seleccione un empleado");
                }

                if (this.cboMotivoCese.SelectedIndex == 0)
                {
                    this.cboMotivoCese.Focus();
                    throw new Exception("Seleccione un motivo de cese");
                }
                #endregion

                #region Guardar

                //this.beLiquidacion.Fecha = this.dtpFecha.Value;
                //this.beLiquidacion.CodigoEmpleado = this.cboEmpleado.SelectedValue.ToString();
                //this.beLiquidacion.CodigoTipo = this.cboTipos.SelectedValue.ToString();
                //this.beLiquidacion.Numero = this.txtNumero.Text;
                //this.beLiquidacion.Monto = double.Parse(this.txtMonto.Text);
                //this.beLiquidacion.IdBanco = int.Parse(this.cboBancos.SelectedValue.ToString());

                bool   rpta       = false;
                string msg        = "";
                var    lnAdelanto = new LN.Liquidacion();
                if (this.uiLiquidacion.IdLiquidacion == 0) //Nuevo
                {
                    rpta = lnAdelanto.Insertar(ref this.uiLiquidacion);
                    if (true)
                    {
                        msg = "Se registro la nueva liquidación";
                    }
                }
                else  //Actualizar
                {
                    rpta = lnAdelanto.Actualizar(this.uiLiquidacion);
                    if (true)
                    {
                        msg = "Se actualizo la liquidación";
                    }
                }

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

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