private void tsbGuardar_Click(object sender, EventArgs e) { try { this.Cursor = Cursors.WaitCursor; if (LosDatosIngresadosSonCorrectos()) { BancosEN oRegistroEN = InformacionDelRegistro(); BancosLN oRegistroLN = new BancosLN(); if (oRegistroLN.ValidarRegistroDuplicado(oRegistroEN, Program.oDatosDeConexion, "AGREGAR")) { MessageBox.Show(oRegistroLN.Error, "Guardar información", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (oRegistroLN.Agregar(oRegistroEN, Program.oDatosDeConexion)) { txtIdentificador.Text = oRegistroEN.idBancos.ToString(); ValorLlavePrimariaEntidad = oRegistroEN.idBancos; EvaluarErrorParaMensajeAPantalla(oRegistroLN.Error, "Guardar"); oRegistroEN = null; oRegistroLN = null; this.Cursor = Cursors.Default; if (CerrarVentana == true) { this.Close(); } else { OperacionARealizar = "Modificar"; ObtenerValoresDeConfiguracion(); LlamarMetodoSegunOperacion(); EstablecerTituloDeVentana(); DeshabilitarControlesSegunOperacionesARealizar(); } } else { throw new ArgumentException(oRegistroLN.Error); } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Guardar la información del registro", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { this.Cursor = Cursors.Default; } }
private void LlenarCamposDesdeBaseDatosSegunID() { this.Cursor = Cursors.WaitCursor; BancosEN oRegistrosEN = new BancosEN(); BancosLN oRegistrosLN = new BancosLN(); oRegistrosEN.idBancos = ValorLlavePrimariaEntidad; if (oRegistrosLN.ListadoPorIdentificador(oRegistrosEN, Program.oDatosDeConexion)) { if (oRegistrosLN.TraerDatos().Rows.Count > 0) { //idBancos, DesBancos, Debitos, Creditos DataRow Fila = oRegistrosLN.TraerDatos().Rows[0]; txtDescripcion.Text = Fila["Bancos"].ToString(); oRegistrosEN = null; oRegistrosLN = null; } else { string Mensaje; Mensaje = string.Format("El registro solicitado de {0} no ha sido encontrado." + "\n\r-----Causas---- " + "\n\r1. Este registro pudo haber sido eliminado por otro usuario." + "\n\r2. El listado no está actualizado.", NombreEntidad); MessageBox.Show(Mensaje, "Listado", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); oRegistrosEN = null; oRegistrosLN = null; this.Close(); } } else { this.Cursor = Cursors.Default; MessageBox.Show(oRegistrosLN.Error, "Listado", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); oRegistrosEN = null; oRegistrosLN = null; } this.Cursor = Cursors.Default; }
private void LLenarListado() { try { this.Cursor = Cursors.WaitCursor; BancosEN oRegistrosEN = new BancosEN(); BancosLN oRegistrosLN = new BancosLN(); oRegistrosEN.Where = WhereDinamico(); if (oRegistrosLN.Listado(oRegistrosEN, Program.oDatosDeConexion)) { dgvLista.Columns.Clear(); System.Diagnostics.Debug.Print(oRegistrosLN.TraerDatos().Rows.Count.ToString()); if (ActivarFiltros == true) { dgvLista.DataSource = AgregarColumnaSeleccionar(oRegistrosLN.TraerDatos()); } else { dgvLista.DataSource = oRegistrosLN.TraerDatos(); } FormatearDGV(); this.dgvLista.ClearSelection(); tsbNoRegistros.Text = "No. Registros: " + oRegistrosLN.TotalRegistros().ToString(); } else { throw new ArgumentException(oRegistrosLN.Error); } }catch (Exception ex) { MessageBox.Show(ex.Message, "Llenar listado de registro en la lista", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { this.Cursor = Cursors.Default; } }
private void tsbEliminar_Click(object sender, EventArgs e) { try { this.Cursor = Cursors.WaitCursor; if (LosDatosIngresadosSonCorrectos()) { if (txtIdentificador.Text.Length == 0 || txtIdentificador.Text == "0") { MessageBox.Show("No se puede continuar. Ha ocurrido un error y el registro no ha sido cargado correctamente.", OperacionARealizar, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } if (MessageBox.Show("¿Está seguro que desea eliminar el registro?", "Eliminar la Confirmación", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button3) == System.Windows.Forms.DialogResult.No) { return; } BancosEN oRegistroEN = InformacionDelRegistro(); BancosLN oRegistroLN = new BancosLN(); if (oRegistroLN.ValidarSiElRegistroEstaVinculado(oRegistroEN, Program.oDatosDeConexion, "ELIMINAR")) { this.Cursor = Cursors.Default; MessageBox.Show(oRegistroLN.Error, this.OperacionARealizar, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } if (oRegistroLN.Eliminar(oRegistroEN, Program.oDatosDeConexion)) { txtIdentificador.Text = oRegistroEN.idBancos.ToString(); ValorLlavePrimariaEntidad = oRegistroEN.idBancos; EvaluarErrorParaMensajeAPantalla(oRegistroLN.Error, "Eliminar"); oRegistroEN = null; oRegistroLN = null; this.Cursor = Cursors.Default; if (CerrarVentana == true) { this.Close(); } } else { throw new ArgumentException(oRegistroLN.Error); } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Eliminar la información del registro", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { this.Cursor = Cursors.Default; } }