// ######################################################################################################### // ######################### 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(); }
// ######################################################################################################### // ######################### Para hipotecarias ############################# // ######################################################################################################### //Botón 'Agregar' private void btnHipotecariaAgregar_Click(object sender, EventArgs e) { List <TextBox> tbs = new List <TextBox> { txtHipotecarioDir, txtHipotecarioMedida, txtHipotecarioMatricula }; if (Validar.textBoxs(tbs)) { GarantiaHipotecaria hipotecaria; if (btnHipotecariaAgregar.Text == "Agregar") { hipotecaria = new GarantiaHipotecaria(txtHipotecarioDir.Text, txtHipotecarioMatricula.Text, txtHipotecarioMedida.Text); if (cmbHipotecarioPropietario.Text != "Deudor") { hipotecaria.fiador = (GarantiaFiador)(cmbHipotecarioPropietario.SelectedItem as ComboBoxItem).Value; } agregarHipotecariaADataGrid(hipotecaria); } else { hipotecaria = dgvHipotecarias.SelectedRows[0].Cells["hipoObjeto"].Value as GarantiaHipotecaria; int index = dgvHipotecarias.SelectedRows[0].Index; if (cmbHipotecarioPropietario.Text == "Deudor") { hipotecaria.fiador = null; } else { hipotecaria.fiador = (GarantiaFiador)(cmbHipotecarioPropietario.SelectedItem as ComboBoxItem).Value; } dgvHipotecarias.Rows[index].Cells["propietario"].Value = cmbHipotecarioPropietario.Text; dgvHipotecarias.Rows[index].Cells["matricula"].Value = hipotecaria.matricula = txtHipotecarioMatricula.Text; dgvHipotecarias.Rows[index].Cells["medida"].Value = hipotecaria.medidas = txtHipotecarioMedida.Text; dgvHipotecarias.Rows[index].Cells["hipoDir"].Value = hipotecaria.direccion = txtHipotecarioDir.Text; } limpiarControlesHipotecaria(); } else { MessageBox.Show("Ingrese todos los campos", "Error en la entrada de datos", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
//Al dar click en la celda. private void dgvHipotecarias_CellClick(object sender, DataGridViewCellEventArgs e) { if (!(dgvHipotecarias.Columns[e.ColumnIndex] is DataGridViewButtonColumn) && e.RowIndex >= 0) { GarantiaHipotecaria hipotecaria = dgvHipotecarias.Rows[e.RowIndex].Cells["hipoObjeto"].Value as GarantiaHipotecaria; cmbHipotecarioPropietario.Text = dgvHipotecarias.Rows[e.RowIndex].Cells["propietario"].Value.ToString(); txtHipotecarioMatricula.Text = hipotecaria.matricula; txtHipotecarioMedida.Text = hipotecaria.medidas; txtHipotecarioDir.Text = hipotecaria.direccion; btnHipotecariaAgregar.Text = "Modificar"; } else { limpiarControlesHipotecaria(); } }
//Agregar un nuevo row a hipotecaria. private void agregarHipotecariaADataGrid(GarantiaHipotecaria hipotecaria) { int index = dgvHipotecarias.Rows.Add(); dgvHipotecarias.Rows[index].Cells["hipoObjeto"].Value = hipotecaria; if (hipotecaria.fiador != null) { dgvHipotecarias.Rows[index].Cells["propietario"].Value = hipotecaria.fiador.nombres + " " + hipotecaria.fiador.apellidos; } else { dgvHipotecarias.Rows[index].Cells["propietario"].Value = "Deudor"; } dgvHipotecarias.Rows[index].Cells["matricula"].Value = hipotecaria.matricula; dgvHipotecarias.Rows[index].Cells["medida"].Value = hipotecaria.medidas; dgvHipotecarias.Rows[index].Cells["hipoDir"].Value = hipotecaria.direccion; }
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(); }