private void eliminarFEP(string codPegue) { bool existeFEP = DataAbonadoAccess.existeFechaEstadoPegue(codPegue); if (existeFEP) { DataAbonadoAccess.eliminarFechaEstadoPegue(codPegue); } }
/*private void contarResultados() * { * lblCantResultados.Text = $"Mostrandose: {dgvListados.Rows.Count} abonados."; * }*/ private void guardaPegueEditado() { string[] fechaEstadoPegue; string nombres = txtNombreTab2.Text; string apellidos = txtApellidosTab2.Text; string numIdentidad = txtNumeroIdentidadTab2.Text; string bloque = numBloque.Value.ToString(); string casa = numCasa.Value.ToString(); string tipoPegueNombre = cboTipoPegue.Text; int tipoPegueID = cboTipoPegue.SelectedIndex + 1; string estadoPegueNombre = cboEstado.Text; int estadoPegueID = cboEstado.SelectedIndex + 1; int cantidadMesesPagados = Convert.ToInt32(lblCantMesesPagados.Text); string codPegue = lblCodPegue.Text; int abonadoId = Convert.ToInt32(lblIdAbonado.Text); string nota = txtNota.Text; string mesEstado; string yearEstado; int mesEstadoID; pgbPorcentajeAlmacenado.Enabled = true; pgbPorcentajeAlmacenado.Visible = true; pgbPorcentajeAlmacenado.Value = 25; string numeroIdentidad = DataAbonadoAccess.obtenerNumIdentidadByID(abonadoId); int idTipoPegue = DataAbonadoAccess.obtenerTipoPegueIDPorNombre(tipoPegueNombre); int idEstadoPegue = DataAbonadoAccess.obtenerEstadoPegueIDPorNombre(estadoPegueNombre); bool tieneFechaEstadoPegue = DataAbonadoAccess.existeFechaEstadoPegue(codPegue); if (tieneFechaEstadoPegue) { fechaEstadoPegue = DataAbonadoAccess.obtenerMesDeFechaControlPegue(codPegue); mesEstado = cboMesEstado.Text; yearEstado = numYearEstado.Value.ToString(); mesEstadoID = cboMesEstado.SelectedIndex + 1; pgbPorcentajeAlmacenado.Value = 50; if (Convert.ToInt32(fechaEstadoPegue[4]) != estadoPegueID) { if (estadoPegueID == 0) { DataAbonadoAccess.eliminarFechaEstadoPegue(codPegue); } else { DataAbonadoAccess.eliminarFechaEstadoPegue(codPegue); guardarFechaEstadoPegue(estadoPegueID, mesEstadoID, codPegue, yearEstado); } } } else { mesEstado = cboMesEstado.Text; yearEstado = numYearEstado.Value.ToString(); mesEstadoID = cboMesEstado.SelectedIndex + 1; guardarFechaEstadoPegue(estadoPegueID, mesEstadoID, codPegue, yearEstado); } if (cantidadMesesPagados < lsbMeses.Items.Count) { cantidadMesesPagados = (cantidadMesesPagados == 0) ? 1 : cantidadMesesPagados; for (int i = cantidadMesesPagados; i <= lsbMeses.Items.Count; i++) { guardarControlPago(codPegue, i); } pgbPorcentajeAlmacenado.Value = 75; } DataAbonadoAccess.actualizarPegue(codPegue, casa, tipoPegueID, estadoPegueID, Convert.ToInt32(bloque), nota); pgbPorcentajeAlmacenado.Value = 100; pgbPorcentajeAlmacenado.Visible = false; pgbPorcentajeAlmacenado.Value = 0; resetearPegue(); resetearAbonadoEnPegue(); MessageBox.Show($"Pegue de {nombres} {apellidos} actualizado correctamente", "Pegue", MessageBoxButtons.OK); seleccionarPanelListados(); }
/* * mueve los datos de la tabla de listado al tab de pegues */ private void moverPegueAEdicion() { string[] meses = { "Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre" }; string[] fechaEstadoPegue; string tipoPegue = dgvListados.CurrentRow.Cells[3].Value.ToString(); string bloque = dgvListados.CurrentRow.Cells[4].Value.ToString(); string casa = dgvListados.CurrentRow.Cells[5].Value.ToString(); string estadoPegue = dgvListados.CurrentRow.Cells[6].Value.ToString(); int cantidadMesesPagados = Convert.ToInt32(dgvListados.CurrentRow.Cells[7].Value); int idAbonado = Convert.ToInt32(dgvListados.CurrentRow.Cells[0].Value); string nombre = dgvListados.CurrentRow.Cells[1].Value.ToString(); string apellido = dgvListados.CurrentRow.Cells[2].Value.ToString(); string numeroIdentidad = DataAbonadoAccess.obtenerNumIdentidadByID(idAbonado); int idTipoPegue = DataAbonadoAccess.obtenerTipoPegueIDPorNombre(tipoPegue); int idEstadoPegue = DataAbonadoAccess.obtenerEstadoPegueIDPorNombre(estadoPegue); string codiPegue = DataAbonadoAccess.obtenerCodigoPegueByPegue(bloque, casa); bool tieneFechaEstadoPegue = DataAbonadoAccess.existeFechaEstadoPegue(codiPegue); string notas = dgvListados.CurrentRow.Cells[8].Value.ToString(); if (tieneFechaEstadoPegue) { fechaEstadoPegue = DataAbonadoAccess.obtenerMesDeFechaControlPegue(codiPegue); //if() cboMesEstado.SelectedIndex = Convert.ToInt32(fechaEstadoPegue[0]) - 1; numYearEstado.Value = Convert.ToInt32(fechaEstadoPegue[2]); } lblCantMesesPagados.Text = cantidadMesesPagados.ToString(); numBloque.Value = Convert.ToInt32(bloque); numCasa.Value = Convert.ToInt32(casa); cboTipoPegue.SelectedIndex = idTipoPegue - 1; cboEstado.SelectedIndex = idEstadoPegue - 1; DataAbonadoAccess.excluirMes(cboMes, cantidadMesesPagados); lblCodPegue.Text = codiPegue; txtNombreTab2.Text = nombre; txtApellidosTab2.Text = apellido; txtNumeroIdentidadTab2.Text = numeroIdentidad; lblIdAbonado.Text = idAbonado.ToString(); txtNota.Text = notas; lblCantPegues.Text = $"Modificando pegue"; lblTitulo.Text = "Modificando el pegue de:"; for (int i = 0; i < cantidadMesesPagados; i++) { lsbMeses.Items.Add(meses[i]); } btnSiguientePegue.Enabled = false; btnSiguientePegue.Visible = false; btnGuardarPegue.Enabled = true; btnGuardarPegue.Visible = true; seleccionarPanelPegues(); }