private void LLenarGrupoDeCuentas() { try { this.Cursor = Cursors.WaitCursor; GrupoDeCuentasEN oRegistroEN = new GrupoDeCuentasEN(); GrupoDeCuentasLN oRegistroLN = new GrupoDeCuentasLN(); oRegistroEN.Where = ""; oRegistroEN.OrderBy = ""; if (oRegistroLN.ListadoParaCombos(oRegistroEN, Program.oDatosDeConexion)) { cmbGruposDeCuentas.DataSource = oRegistroLN.TraerDatos(); cmbGruposDeCuentas.DisplayMember = "DescGrupoDeCuentas"; cmbGruposDeCuentas.ValueMember = "idGrupoDeCuentas"; cmbGruposDeCuentas.SelectedIndex = -1; } else { throw new ArgumentException(oRegistroLN.Error); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Información del grupo de cuentas", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { this.Cursor = Cursors.Default; } }
private void tsbGuardar_Click(object sender, EventArgs e) { try { this.Cursor = Cursors.WaitCursor; if (LosDatosIngresadosSonCorrectos()) { GrupoDeCuentasEN oRegistroEN = InformacionDelRegistro(); GrupoDeCuentasLN oRegistroLN = new GrupoDeCuentasLN(); 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.idGrupoDeCuentas.ToString(); ValorLlavePrimariaEntidad = oRegistroEN.idGrupoDeCuentas; 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; GrupoDeCuentasEN oRegistrosEN = new GrupoDeCuentasEN(); GrupoDeCuentasLN oRegistrosLN = new GrupoDeCuentasLN(); oRegistrosEN.idGrupoDeCuentas = ValorLlavePrimariaEntidad; if (oRegistrosLN.ListadoPorIdentificador(oRegistrosEN, Program.oDatosDeConexion)) { if (oRegistrosLN.TraerDatos().Rows.Count > 0) { //idGrupoDeCuentas, DescGrupoDeCuentas, Debitos, Creditos DataRow Fila = oRegistrosLN.TraerDatos().Rows[0]; txtDescGrupoDeCuentas.Text = Fila["DescGrupoDeCuentas"].ToString(); cmbCredito.Text = Fila["Creditos"].ToString(); cmbDebito.Text = Fila["Debitos"].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; GrupoDeCuentasEN oRegistrosEN = new GrupoDeCuentasEN(); GrupoDeCuentasLN oRegistrosLN = new GrupoDeCuentasLN(); 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; } GrupoDeCuentasEN oRegistroEN = InformacionDelRegistro(); GrupoDeCuentasLN oRegistroLN = new GrupoDeCuentasLN(); 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.idGrupoDeCuentas.ToString(); ValorLlavePrimariaEntidad = oRegistroEN.idGrupoDeCuentas; 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; } }
private void tsbActualizar_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 aplicar los cambios al registro seleccionado?", "Actualizar la Confirmación", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button3) == System.Windows.Forms.DialogResult.No) { return; } GrupoDeCuentasEN oRegistroEN = InformacionDelRegistro(); GrupoDeCuentasLN oRegistroLN = new GrupoDeCuentasLN(); if (oRegistroLN.ValidarSiElRegistroEstaVinculado(oRegistroEN, Program.oDatosDeConexion, "ACTUALIZAR")) { if (PermitirModificarRegistrosVinculados == true && AplicarCambio == true) { if (MessageBox.Show(string.Format("¿Está seguro que desea guardar los cambios en el registro seleccionado ya que este se encuentra asociado a otras Entidades de manera interna? {0} {1}", System.Environment.NewLine, oRegistroLN.Error), "Confirmación", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button3) == System.Windows.Forms.DialogResult.No) { this.Cursor = Cursors.Default; return; } } else { MessageBox.Show(oRegistroLN.Error, this.OperacionARealizar, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); this.Cursor = Cursors.Default; return; } } if (oRegistroLN.ValidarRegistroDuplicado(oRegistroEN, Program.oDatosDeConexion, "ACTUALIZAR")) { this.Cursor = Cursors.Default; MessageBox.Show(oRegistroLN.Error, "Actualizar la información", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (oRegistroLN.Actualizar(oRegistroEN, Program.oDatosDeConexion)) { txtIdentificador.Text = oRegistroEN.idGrupoDeCuentas.ToString(); ValorLlavePrimariaEntidad = oRegistroEN.idGrupoDeCuentas; EvaluarErrorParaMensajeAPantalla(oRegistroLN.Error, "Actualizar"); 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, "Actualizar la información del registro", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { this.Cursor = Cursors.Default; } }