private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { CedulaCliente = dataGridView1.Rows[e.RowIndex].Cells["Cedula"].Value.ToString(); NombreCliente = dataGridView1.Rows[e.RowIndex].Cells["Nombre"].Value.ToString(); IDCliente = dataGridView1.Rows[e.RowIndex].Cells["ID"].Value.ToString(); Apellidos = dataGridView1.Rows[e.RowIndex].Cells["Apellido"].Value.ToString(); Telefono = dataGridView1.Rows[e.RowIndex].Cells["Telefono"].Value.ToString(); Celular = dataGridView1.Rows[e.RowIndex].Cells["Celular"].Value.ToString(); Direccion = dataGridView1.Rows[e.RowIndex].Cells["Direccion"].Value.ToString(); if (CedulaCliente == "") { MessageBox.Show("Seleccione una fila para seleccionar el cliente", "Atencion", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { //Consulta para contar la cantidad de prestamos que tiene el cliente string comando = string.Format($"select count(idPrestamo) as Conteo from Prestamos where idCliente='{EscogerCliente.IDCliente}'"); DataSet data = LogicaUsuarios.Ejecutar(comando); OpcionPrestamo = data.Tables[0].Rows[0]["Conteo"].ToString().Trim(); //Consulta para seleccionar un cliente en especifico comando = string.Format($"select * from Clientes where idClient='{EscogerCliente.IDCliente}'"); data = LogicaUsuarios.Ejecutar(comando); OpcionCedula = data.Tables[0].Rows[0]["Cedula"].ToString().Trim(); OpcionCelular = data.Tables[0].Rows[0]["Celular"].ToString().Trim(); OpcionTelefono = data.Tables[0].Rows[0]["Telefono"].ToString().Trim(); this.Close(); } }
private void bGuardar_Click(object sender, EventArgs e) { try { if (tInteres.Text == string.Empty || tTiempo.Text == string.Empty || dateTimePrestamo.Text == "" || tMonto.Text == string.Empty || tCedula.Text == string.Empty || tNombreCliente.Text == string.Empty || tUsuario.Text == string.Empty) { Error(); } else { //Evaluando si el cliente ya tiene un prestamo registrado if (int.Parse(EscogerCliente.OpcionPrestamo) > 0) { Operaciones.Mensaje("El cliente solo puede tener un prestamo activo"); } else { LogicaPrestamos.Ingresar(int.Parse(tInteres.Text), int.Parse(tTiempo.Text), dateTimePrestamo.Value, int.Parse(Login.id), int.Parse(EscogerCliente.IDCliente), Estado(), double.Parse(tMonto.Text)); //Consulta para saber el id del prestamo que se esta creando, para luego asignarselo a la factura string comando = string.Format($"select * from Prestamos where idCliente='{EscogerCliente.IDCliente}'"); DataSet data = LogicaUsuarios.Ejecutar(comando); string idPrestamos = data.Tables[0].Rows[0]["idPrestamo"].ToString().Trim(); double totalPago = Operaciones.funcion(double.Parse(tMonto.Text), double.Parse(tInteres.Text), int.Parse(tTiempo.Text)); Operaciones.InsertarFactura(totalPago, double.Parse(tInteres.Text), int.Parse(idPrestamos), int.Parse(EscogerCliente.IDCliente), int.Parse(Login.id)); Operaciones.Mensaje("Prestamo Creado Correctamente"); this.Close(); } } } catch (Exception error) { Operaciones.Mensaje("Ha ocurrido un error al Crear el Prestamo"); } }
private void bIniciar_Click(object sender, EventArgs e) { try { //Consulta para obtener los datos de quien hace el login string codigo = string.Format("Select * from Usuarios where Usuario='{0}'", tUsuario.Text.Trim()); DataSet set = LogicaUsuarios.Ejecutar(codigo); string Nombre = set.Tables[0].Rows[0]["Nombre"].ToString().Trim(); string idU = set.Tables[0].Rows[0]["idUser"].ToString().Trim(); string contra = set.Tables[0].Rows[0]["Clave"].ToString().Trim(); string usuario = set.Tables[0].Rows[0]["Usuario"].ToString().Trim(); if (usuario == tUsuario.Text.Trim() && Encriptar.Desencriptar(contra) == tContra.Text.Trim()) { //Enviando los datos de quien hace el login a la app principal Aplicacion aplicacion = new Aplicacion(); nom = Nombre; id = idU; aplicacion.idUsuario = set.Tables[0].Rows[0][0].ToString(); aplicacion.nombre = set.Tables[0].Rows[0][1].ToString(); aplicacion.acceso = set.Tables[0].Rows[0][4].ToString(); aplicacion.Show(); this.Hide(); } else { Operaciones.Mensaje("El usuario o la clave no son correctos"); } } catch (Exception error) { Operaciones.Mensaje("El usuario o la clave no son correctos"); tUsuario.Text = "USUARIO"; tContra.Text = "PASSWORD"; } }