Exemplo n.º 1
0
        /*
         * 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();
        }