private void btnEliminar_Click(object sender, EventArgs e) { try { if (this.dgvMovilidades.CurrentRow != null) { if (Util.ConfirmationMessage("¿Desea eliminar al Movilidad seleccionado?") == false) { return; } var uiAdelato = (BE.UI.Movilidad) this.dgvMovilidades.CurrentRow.DataBoundItem; int idMovilidad = uiAdelato.Id; bool rpta = new LN.Movilidad().Eliminar(idMovilidad); if (rpta == true) { Util.InformationMessage("Se eliminó el Movilidad"); this.CargarListadoMovilidades(); } } } catch (Exception ex) { Util.ErrorMessage(ex.Message); } }
public void CargarListadoMovilidades() { try { var lstUiMovilidades = new LN.Movilidad().Listar(); var sorted = new SortableBindingList <BE.UI.Movilidad>(lstUiMovilidades); this.dgvMovilidades.DataSource = sorted; int nroRegistros = lstUiMovilidades.Count; this.txtNroRegistros.Text = nroRegistros.ToString(); double sumRegistros = lstUiMovilidades.Sum(x => x.Monto); this.txtTotal.Text = sumRegistros.ToString("N2"); } catch (Exception ex) { throw ex; } }
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"); } #endregion #region Guardar this.uiMovilidadTranslado.Anho = int.Parse(this.cboAnho.SelectedValue.ToString()); var beMes = (BE.Record) this.cboMes.SelectedItem; this.uiMovilidadTranslado.MesNumero = int.Parse(beMes.Codigo); this.uiMovilidadTranslado.MesNombre = beMes.Nombre; this.uiMovilidadTranslado.EmpleadoCodigo = this.cboEmpleado.SelectedValue.ToString(); this.uiMovilidadTranslado.Monto = double.Parse(this.txtMonto.Text); bool rpta = false; string msg = ""; var lnMovilidad = new LN.Movilidad(); if (this.uiMovilidadTranslado.Id == 0) //Nuevo { rpta = lnMovilidad.Insertar(ref this.uiMovilidadTranslado); if (true) { msg = "Se registro la nuevo movilidad"; } } else //Actualizar { rpta = lnMovilidad.Actualizar(this.uiMovilidadTranslado); if (true) { msg = "Se actualizo la Movilidad"; } } if (rpta == true) { Util.InformationMessage(msg); this.frmList.CargarListadoMovilidades(); this.Close(); } #endregion } catch (Exception ex) { Util.ErrorMessage(ex.Message); } }