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.txtMonto.Text.Trim().Length == 0) { this.txtMonto.Focus(); throw new Exception("Ingrese el monto del bono"); } if (double.Parse(this.txtMonto.Text) == 0.0) { this.txtMonto.Focus(); throw new Exception("Ingrese el monto del bono"); } if (int.Parse(this.txtCantidadCuotas.Text) == 0.0 || this.bePrestamo.Cuotas.Count == 0) { throw new Exception("Ingrese una o mas cuotas"); } #endregion #region Guardar this.bePrestamo.Fecha = this.dtpFecha.Value; this.bePrestamo.CodigoEmpleado = this.cboEmpleado.SelectedValue.ToString(); this.bePrestamo.Motivo = this.txtMotivo.Text; this.bePrestamo.Monto = double.Parse(this.txtMonto.Text); this.bePrestamo.Pagado = this.chkPagado.Checked; this.bePrestamo.NumeroCuotas = int.Parse(this.txtCantidadCuotas.Text); bool rpta = false; string msg = ""; var lnPrestamo = new LN.Prestamo(); if (this.bePrestamo.IdPrestamo == 0) //Nuevo { rpta = lnPrestamo.Insertar(ref this.bePrestamo); if (true) { msg = "Se registro el nuevo adelanto"; } } else //Actualizar { rpta = lnPrestamo.Actualizar(this.bePrestamo, this.lstIdCuotasNuevas, this.lstIdCuotasEliminadas); if (true) { msg = "Se actualizo el adelanto"; } } if (rpta == true) { Util.InformationMessage(msg); this.frmList.CargarListadoPrestamos(); this.Close(); } #endregion } catch (Exception ex) { Util.ErrorMessage(ex.Message); } }