Пример #1
0
// #########################################################################################################
// #########################             Aceptar y cancelar del form           #############################
// #########################################################################################################

        private void btnAceptar_Click(object sender, EventArgs e)
        {
            credito.fiadores = new List <GarantiaFiador>();
            foreach (DataGridViewRow row in dgvFiadores.Rows)
            {
                GarantiaFiador fiador = row.Cells["fiadorObjeto"].Value as GarantiaFiador;
                credito.fiadores.Add(fiador);
            }

            credito.hipotecarias = new List <GarantiaHipotecaria>();
            foreach (DataGridViewRow row in dgvHipotecarias.Rows)
            {
                GarantiaHipotecaria hipotecaria = row.Cells["hipoObjeto"].Value as GarantiaHipotecaria;
                credito.hipotecarias.Add(hipotecaria);
            }

            credito.prendarias = new List <GarantiaPrendaria>();
            foreach (DataGridViewRow row in dgvPrendarias.Rows)
            {
                GarantiaPrendaria prendaria = row.Cells["prenObjeto"].Value as GarantiaPrendaria;
                credito.prendarias.Add(prendaria);
            }

            credito.depositos = new List <int>();
            foreach (DataGridViewRow row in dgvDepositos.Rows)
            {
                int idAhorro = (int)row.Cells["depositoObjeto"].Value;
                credito.depositos.Add(idAhorro);
            }

            this.Close();
        }
Пример #2
0
// #########################################################################################################
// ###########################                  Para prendarias                #############################
// #########################################################################################################

        //Botón 'Agregar'
        private void btnPrendariaAgregar_Click(object sender, EventArgs e)
        {
            List <TextBox> tbs = new List <TextBox>
            {
                txtPrendariaDescripcion, txtPrendariaNombre
            };

            if (Validar.textBoxs(tbs))
            {
                GarantiaPrendaria prendaria;

                if (btnPrendariaAgregar.Text == "Agregar")
                {
                    prendaria = new GarantiaPrendaria(txtPrendariaNombre.Text, txtPrendariaDescripcion.Text);

                    if (cmbPredariaPropietario.Text != "Deudor")
                    {
                        prendaria.fiador = (GarantiaFiador)(cmbPredariaPropietario.SelectedItem as ComboBoxItem).Value;
                    }

                    agregarPrendariaADataGrid(prendaria);
                }
                else
                {
                    prendaria = dgvPrendarias.SelectedRows[0].Cells["prenObjeto"].Value as GarantiaPrendaria;
                    int index = dgvPrendarias.SelectedRows[0].Index;

                    if (cmbPredariaPropietario.Text == "Deudor")
                    {
                        prendaria.fiador = null;
                    }
                    else
                    {
                        prendaria.fiador = (GarantiaFiador)(cmbPredariaPropietario.SelectedItem as ComboBoxItem).Value;
                    }

                    dgvPrendarias.Rows[index].Cells["prenPropietario"].Value = cmbPredariaPropietario.Text;
                    dgvPrendarias.Rows[index].Cells["bien"].Value            = prendaria.bien = txtPrendariaNombre.Text;
                    dgvPrendarias.Rows[index].Cells["prenDesc"].Value        = prendaria.descripcion = txtPrendariaDescripcion.Text;
                }

                limpiarControlesPrendaria();
            }

            else
            {
                MessageBox.Show("Ingrese todos los campos", "Error en la entrada de datos", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #3
0
        //Click en la tabla de prendarias.
        private void dgvPrendarias_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (!(dgvPrendarias.Columns[e.ColumnIndex] is DataGridViewButtonColumn) && e.RowIndex >= 0)
            {
                GarantiaPrendaria prendaria = dgvPrendarias.Rows[e.RowIndex].Cells["prenObjeto"].Value as GarantiaPrendaria;

                cmbPredariaPropietario.Text  = dgvPrendarias.Rows[e.RowIndex].Cells["prenPropietario"].Value.ToString();
                txtPrendariaNombre.Text      = prendaria.bien;
                txtPrendariaDescripcion.Text = prendaria.descripcion;

                btnPrendariaAgregar.Text = "Modificar";
            }
            else
            {
                limpiarControlesPrendaria();
            }
        }
Пример #4
0
        //Agregar un objeto GarantiaPrendaria al DataGrid.
        private void agregarPrendariaADataGrid(GarantiaPrendaria prendaria)
        {
            int index = dgvPrendarias.Rows.Add();

            dgvPrendarias.Rows[index].Cells["prenObjeto"].Value = prendaria;

            if (prendaria.fiador != null)
            {
                dgvPrendarias.Rows[index].Cells["prenPropietario"].Value = prendaria.fiador.nombres + " " + prendaria.fiador.apellidos;
            }
            else
            {
                dgvPrendarias.Rows[index].Cells["prenPropietario"].Value = "Deudor";
            }

            dgvPrendarias.Rows[index].Cells["bien"].Value     = prendaria.bien;
            dgvPrendarias.Rows[index].Cells["prenDesc"].Value = prendaria.descripcion;
        }
        public static void selectGarantias(Credito credito)
        {
            string        query;
            SqlDataReader dataReader;

            query = "select dui, nombres, apellidos, direccion, telefono, nit, id from asociados.fiador where id_credito = "
                    + credito.id.ToString();
            dataReader = Queries.getDataReader(query);

            credito.fiadores = new List <GarantiaFiador>();
            while (dataReader.Read())
            {
                GarantiaFiador fiador = new GarantiaFiador();
                fiador.dui       = dataReader.GetString(0);
                fiador.nombres   = dataReader.GetString(1);
                fiador.apellidos = dataReader.GetString(2);
                fiador.direccion = dataReader.GetString(3);
                fiador.telefono  = dataReader.GetString(4);
                fiador.nit       = dataReader.GetString(5);
                fiador.id        = dataReader.GetInt32(6);

                credito.fiadores.Add(fiador);
            }
            dataReader.Close();


            query = "select bien, descripcion, id_fiador from asociados.prendaria where id_credito = "
                    + credito.id.ToString();
            dataReader = Queries.getDataReader(query);

            credito.prendarias = new List <GarantiaPrendaria>();
            while (dataReader.Read())
            {
                GarantiaPrendaria prendaria = new GarantiaPrendaria();
                prendaria.bien        = dataReader.GetString(0);
                prendaria.descripcion = dataReader.GetString(1);

                int id;
                Int32.TryParse(dataReader.GetValue(2).ToString(), out id);
                if (id != 0)
                {
                    foreach (GarantiaFiador fiador in credito.fiadores)
                    {
                        if (fiador.id == id)
                        {
                            prendaria.fiador = fiador;
                        }
                    }
                }

                credito.prendarias.Add(prendaria);
            }
            dataReader.Close();


            query = "select direccion, matricula, medidas, id_fiador from asociados.hipotecaria where id_credito = "
                    + credito.id.ToString();
            dataReader = Queries.getDataReader(query);

            credito.hipotecarias = new List <GarantiaHipotecaria>();
            while (dataReader.Read())
            {
                GarantiaHipotecaria hipotecaria = new GarantiaHipotecaria();
                hipotecaria.direccion = dataReader.GetString(0);
                hipotecaria.matricula = dataReader.GetString(1);
                hipotecaria.medidas   = dataReader.GetString(2);

                int id;
                Int32.TryParse(dataReader.GetValue(3).ToString(), out id);
                if (id != 0)
                {
                    foreach (GarantiaFiador fiador in credito.fiadores)
                    {
                        if (fiador.id == id)
                        {
                            hipotecaria.fiador = fiador;
                        }
                    }
                }

                credito.hipotecarias.Add(hipotecaria);
            }
            dataReader.Close();

            query = "select gar.id_ahorro, aho.codigo from asociados.ahorro aho inner join asociados.garantiadeposito gar on "
                    + "aho.id = gar.id_ahorro and gar.id_credito = " + credito.id.ToString();
            dataReader = Queries.getDataReader(query);

            credito.depositos    = new List <int>();
            credito.codDepositos = new List <string>();
            while (dataReader.Read())
            {
                credito.depositos.Add(dataReader.GetInt32(0));
                credito.codDepositos.Add(dataReader.GetString(1));
            }
            dataReader.Close();
        }