public static Modelos.Prestamos buscarPrestamo(String comando) { conexion.Open(); SqlCommand cmd = new SqlCommand(comando, conexion); SqlDataReader lector = cmd.ExecuteReader(); Modelos.Prestamos prest = null; Modelos.Garante garante_p; Clientes clientes_P; if (lector.Read()) { int idSolicitud = Convert.ToInt32(lector["id_solicitud"]); int cant_cuota = Convert.ToInt32(lector["cantidad_cuota"]); int cantidad_solicitadas = Convert.ToInt32(lector["cantidad_solicitada"]); int intere = Convert.ToInt32(lector["interes_prestamos"]); int aprobacion = Convert.ToInt32(lector["aprobacion"]); int forma_de_pago = Convert.ToInt32(lector["forma_de_pago"]); int idcliente = Convert.ToInt32(lector["cliente"]); int idgarante = Convert.ToInt32(lector["garantes"]); DateTime fecha = Convert.ToDateTime(lector["fecha_de_solicitud"]); conexion.Close(); garante_p = buscarGarante("select * from garante where idGarante =" + "" + idgarante); clientes_P = buscarCliente("select * from Clietes where idCliente =" + idcliente); prest = new Modelos.Prestamos(cant_cuota, cantidad_solicitadas, intere, aprobacion, forma_de_pago, garante_p, clientes_P); prest.fecha_de_solicitud = fecha; } return(prest); }
protected void btnAprobar_Click(object sender, EventArgs e) { string valor = ""; if (DropDownList1.SelectedValue != "") { valor = DropDownList1.SelectedValue; Conexion.actualizar("update cuotas set estado=1 where id_cuota=" + valor); muestra_Cuotas(); Modelos.Prestamos pre = Conexion.buscarPrestamo("select * from solicitud_prestamo where id_solicitud =" + idPrestamo); Conexion.insertar("insert into Notificacion(tipo ,empleado,cliente,cantidad ,descripcion) values (3,'" + Aplicacion.usuarioActive.Nombre + "','" + pre.cliente.Nombre + "',0,'" + DropDownList1.SelectedItem + "')"); } else { ClientScript.RegisterStartupScript(GetType(), "hola", "<script> alert('debe seleccionar una cuota')</script>"); } }
protected void btnRalizarPrestamo_Click(object sender, EventArgs e) { Modelos.Garante gara = Conexion.buscarGarante("select * from garante where idGarante = " + ListBox2.SelectedValue); Clientes clie = Conexion.buscarCliente("select * from Clietes where idCliente = " + DropDownList1.SelectedValue); int cuota = 0; int cantidad_solicitada = 0; int intere = 0; int firma_pago = 0; try { cuota = Convert.ToInt32(txtCuotas.Text); cantidad_solicitada = Convert.ToInt32(txtCantidad.Text); intere = Convert.ToInt32(txtInteres.Text); firma_pago = Convert.ToInt32(txtCuotas.Text); } catch (Exception es) { } Modelos.Prestamos prestamos = new Modelos.Prestamos(cuota, cantidad_solicitada, intere, 0, firma_pago, gara, clie); prestamos.insertarPrestamos(); }
protected void btnAceptar_Click(object sender, EventArgs e) { int idPrestamo = Convert.ToInt32(ListBox1.SelectedValue); Conexion.actualizar("UPDATE solicitud_prestamo SET aprobacion= 1 WHERE id_solicitud =" + idPrestamo); txtAprobacion.Text = "Aprobado"; txtAprobacion.ForeColor = System.Drawing.Color.Green; Modelos.Prestamos prestamo = Conexion.buscarPrestamo("select * from solicitud_prestamo where id_solicitud =" + idPrestamo); ClientScript.RegisterStartupScript(GetType(), "hola", "<script> alert('fecha solicitud'" + prestamo.fecha_de_solicitud + ")</script>"); switch (prestamo.forma_de_pago) { case 15: Cantidad_a_suma = 15; break; case 1: Cantidad_a_suma = 1; break; case 7: Cantidad_a_suma = 7; break; case 30: Cantidad_a_suma = 30; break; } DataTable tabla = new DataTable(); tabla.Columns.Add("Cuota", typeof(int)); tabla.Columns.Add("Fechas de pago", typeof(String)); tabla.Columns.Add("Interes", typeof(String)); tabla.Columns.Add("Monto ", typeof(String)); tabla.Columns.Add("Monto a pagar", typeof(String)); tabla.Columns.Add("Interes a pagar", typeof(String)); double monto = 0; double intere = 0; double interesEnPor; double monto_a_pagar = 0; double cuota = 0; double cuota_a_pagar = 0; monto = prestamo.cantidad_Solicitada; interesEnPor = prestamo.interes / 100; intere = monto * interesEnPor; monto_a_pagar = monto + intere; cuota = prestamo.Cuota; cuota_a_pagar = monto_a_pagar / cuota; DateTime date; //Page.ClientScript.RegisterStartupScript(this.GetType(), "Scripts", "<script>alert('Asegurese cuota" +cuota+ "')</script>"); for (int i = 0; i < cuota; i++) { date = prestamo.fecha_de_solicitud; suma = suma + Cantidad_a_suma; DateTime otroDia = date.AddDays(suma); Int32 dia = otroDia.Day; Int32 mes = otroDia.Month; Int32 anio = otroDia.Year; Conexion.insertar("insert into cuotas values (" + i + 1 + "," + monto + "," + monto_a_pagar + "," + intere + "," + anio + "-" + mes + "-" + dia + ",0," + idPrestamo + ")"); } Conexion.insertar("insert into Notificacion(tipo ,empleado,cliente,cantidad ,descripcion) values (2,'" + Aplicacion.usuarioActive.Nombre + "','" + prestamo.cliente.Nombre + "'," + prestamo.cantidad_Solicitada + ",'a')"); }