Ver Mensaje Individual
  #1 (permalink)  
Antiguo 13/06/2011, 20:03
future89
 
Fecha de Ingreso: diciembre-2010
Mensajes: 106
Antigüedad: 13 años, 4 meses
Puntos: 10
Pregunta manejar cambios en un formulario usando teclas funcion

holas,
mi problema es el siguiente, como estoy recien en esto de programar en visual
nose como implementar mi ventana de ventas, nose como continuar la venta ya sea ingresando el monto, y siquiero volver hacias atras para agregar mas productos, sumar el total de los precio en el textbox de total, en fin muchas cosas de esta pantalla



luego apreto F9 y oculto el textbox y el label de abajo y pongo visible el texbox paara el monto.
sera lo correcto????? y como podria volver atrás???



me quedan pocos días :$


aqui el codigo de todo el form

Código vb:
Ver original
  1. Imports System.Data.SqlClient
  2. Public Class VentaLibros
  3.     Private myConn As New SqlConnection
  4.     Private myCmd As New SqlCommand
  5.     Dim myReader2 As SqlDataReader
  6.     Private results As String
  7.     Dim adaptor As New SqlClient.SqlDataAdapter
  8.     Dim dataset As New DataSet
  9.  
  10.     Private Sub VentaLibros_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
  11.         If e.KeyValue = Keys.F1 Or Keys.F2 Or Keys.F3 Or Keys.F4 Or Keys.F5 Or Keys.F6 Or Keys.F7 Or Keys.F8 Or Keys.F9 Or Keys.F10 Or Keys.F11 Or Keys.F12 Or Keys.Escape Then
  12.             FuncKeysModule(e.KeyValue)
  13.             e.Handled = True
  14.         End If
  15.     End Sub
  16.     Private Sub VentaLibros_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  17.         TbMonto.Visible = False
  18.         ingreseMonto.Visible = False
  19.     End Sub
  20.  
  21.     Private Sub TbProducto_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TbProducto.KeyDown
  22.         If e.KeyValue = Keys.F1 Or Keys.F2 Or Keys.F3 Or Keys.F4 Or Keys.F5 Or Keys.F6 Or Keys.F7 Or Keys.F8 Or Keys.F9 Or Keys.F10 Or Keys.F11 Or Keys.F12 Or Keys.Escape Then
  23.             FuncKeysModule(e.KeyValue)
  24.             e.Handled = True
  25.         End If
  26.     End Sub
  27.  
  28.     Private Sub TbProducto_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TbProducto.KeyPress
  29.         'Valido que se ingrese solo numeros
  30.  
  31.         If Char.IsNumber(e.KeyChar) Then
  32.             e.Handled = False
  33.             'Valido que se presione Backspace,Enter
  34.        ElseIf Char.IsControl(e.KeyChar) Then
  35.             e.Handled = False
  36.             'Las demas teclas quedan bloqueadas
  37.        Else
  38.             e.Handled = True
  39.         End If
  40.  
  41.         'Si mando un ENTER entonces que busque
  42.        If e.KeyChar = Convert.ToChar(Keys.Enter) Then
  43.  
  44.            
  45.             myConn = New SqlConnection("Initial Catalog=libroteka;Data Source=localhost;Integrated Security=SSPI;")
  46.        
  47.             myCmd = myConn.CreateCommand
  48.             myCmd.CommandText = "SELECT * FROM libros WHERE cod_libro ='" & TbProducto.Text & "' "
  49.  
  50.  
  51.             adaptor.SelectCommand = myCmd
  52.             adaptor.Fill(dataset, "0")
  53.  
  54.             Dim count = dataset.Tables(0).Rows.Count
  55.             If count > 0 Then
  56.  
  57.                 myConn.Open()
  58.                 With Ltver.Items.Add(TbProducto.Text, "cod_libro")
  59.                     .SubItems.Add(dataset.Tables(0).Rows(0).Item("nombre_libro"))
  60.                     .SubItems.Add(dataset.Tables(0).Rows(0).Item("precio"))
  61.  
  62.                
  63.                 End With
  64.  
  65.  
  66.             End If
  67.         End If
  68.  
  69.  
  70.         TbProducto.Clear()
  71.         dataset.Clear()
  72.         myConn.Close()
  73.  
  74.  
  75.         myConn.Close()
  76.  
  77.      
  78.     End Sub
  79.  
  80.     Private Sub TbProducto_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TbProducto.TextChanged
  81.  
  82.      
  83.     End Sub
  84.  
  85.     Private Sub Ltver_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Ltver.KeyDown
  86.         If e.KeyValue = Keys.F1 Or Keys.F2 Or Keys.F3 Or Keys.F4 Or Keys.F5 Or Keys.F6 Or Keys.F7 Or Keys.F8 Or Keys.F9 Or Keys.F10 Or Keys.F11 Or Keys.F12 Or Keys.Escape Then
  87.             FuncKeysModule(e.KeyValue)
  88.             e.Handled = True
  89.         End If
  90.     End Sub
  91.  
  92.    
  93.     Public Sub FuncKeysModule(ByVal value As Keys)
  94.         'Check what function key is in a pressed state, and then perform the corresponding action.
  95.        Select Case value
  96.             Case Keys.F1
  97.                 'Add the code for the function key F1 here.
  98.                MessageBox.Show("F1 pressed")
  99.             Case Keys.F2
  100.                 'Add the code for the function key F2 here.
  101.                MessageBox.Show("F2 pressed")
  102.             Case Keys.F3
  103.                 'Add the code for the function key F3 here.
  104.                MessageBox.Show("F3 pressed")
  105.             Case Keys.F4
  106.                 'Add the code for the function key F4 here.
  107.                MessageBox.Show("F4 pressed")
  108.             Case Keys.F5
  109.                 'Add the code for the function key F5 here.
  110.                MessageBox.Show("F5 pressed")
  111.             Case Keys.F6
  112.                 'Add the code for the function key F6 here.
  113.                MessageBox.Show("F6 pressed")
  114.             Case Keys.F7
  115.                 'Add the code for the function key F7 here.
  116.                MessageBox.Show("F7 pressed")
  117.             Case Keys.F8
  118.                 'Add the code for the function key F8 here.
  119.                MessageBox.Show("F8 pressed")
  120.             Case Keys.F9
  121.                 TbProducto.Visible = False
  122.                 Label4.Visible = False
  123.  
  124.                 TbMonto.Visible = True
  125.                 ingreseMonto.Visible = True
  126.                
  127.             Case Keys.F10
  128.                 'Add the code for the function key F10 here.
  129.                MessageBox.Show("F10 pressed")
  130.             Case Keys.F11
  131.                 'Add the code for the function key F11 here.
  132.                MessageBox.Show("F11 pressed")
  133.             Case Keys.F12
  134.                 'Add the code for the key F12 here
  135.                MessageBox.Show("F12 pressed")
  136.             Case Keys.Escape
  137.                 MessageBox.Show("Escapate")
  138.         End Select
  139.     End Sub
  140.  
  141.     Private Sub TextBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
  142.         If e.KeyValue = Keys.F1 Or Keys.F2 Or Keys.F3 Or Keys.F4 Or Keys.F5 Or Keys.F6 Or Keys.F7 Or Keys.F8 Or Keys.F9 Or Keys.F10 Or Keys.F11 Or Keys.F12 Then
  143.             FuncKeysModule(e.KeyValue)
  144.             e.Handled = True
  145.         End If
  146.     End Sub
  147.  
  148. End Class