Ver Mensaje Individual
  #3 (permalink)  
Antiguo 24/11/2009, 23:36
klaudio83
 
Fecha de Ingreso: octubre-2009
Mensajes: 70
Antigüedad: 14 años, 6 meses
Puntos: 0
Pregunta Respuesta: Cargar Datagridview con datos de busqueda desde otro winform

Excelente. te pasaste! Muchas pero muchas gracias. me funciono perfecto!

Pero sabes quize utilizar lo mismo en otro winform que tengo, mira te explico:

Tengo un winform(nueva_factura.vb) en ella se encuentran los datos del cliente, y ademas un ListView que contendra los productos con sus respectivo precio y cantidad.
Para agregar una nueva linea de producto presiono el boton "Nueva Linea" y se abre otro winform(nueva_linea_producto.vb) este tiene un boton para agregar un producto a traves de otro winform, una vez seleccionado se cargaran los datos del producto en nueva_linea_producto.vb y luego ingreso la cantidad y el precio asociado al producto. Y ademas el nueva_linea_producto.vb tiene un boton guardar.

La idea es que al apretar se ingrese automaticamente el producto con sus datos respectivos al Listview. pero que nueva_linea_producto.vb no se cierre inmediatamente, sino que permita ingresar otros productos.

Por lo tanto para este caso no me funciona lo que me mencionas, por que al intentar llamar a AgregarItem(...) despues del showdialog() y que esto funcione, tendria que cerrar nueva_linea_producto.vb al apretar el boton agregar.

Espero me puedas ayudar con esto, Muchas gracias por la respuesta anterior y por responder siempre tan buena onda.

Codigo: nueva_factura.vb
Código vb.net:
Ver original
  1. Public Sub AgregarItem(ByVal id As String, ByVal cod As String, ByVal nombre As String, ByVal cantidad As String, ByVal precio As String, ByVal total As String, ByVal obs As String)
  2.         Dim item As ListViewItem
  3.         item = New ListViewItem(id)
  4.         item.SubItems.Add(cod)
  5.         item.SubItems.Add(nombre)
  6.         item.SubItems.Add(cantidad)
  7.         item.SubItems.Add(precio)
  8.         item.SubItems.Add(total)
  9.         item.SubItems.Add(obs)
  10.         ListView1.Items.Add(item)
  11.  
  12.         modificar.Show()
  13.         eliminar.Show()
  14.  
  15.         LblNeto.Text = CalculaNeto()
  16.         LblNeto.Show()
  17.  
  18.         LblIva.Text = CalculaIva()
  19.         LblIva.Show()
  20.  
  21.         LblTotal.Text = CalculaTotal()
  22.         LblTotal.Show()
  23.        
  24.     End Sub

Codigo: nueva_linea_producto.vb
Código vb.net:
Ver original
  1. Private Sub guardar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles guardar.Click
  2.         If String.IsNullOrEmpty(txId.Text) Then
  3.             ep.SetError(txId, "Ingrese un Producto")
  4.             Exit Sub
  5.         End If
  6.  
  7.         If String.IsNullOrEmpty(txPrecio.Text) Then
  8.             ep.SetError(txPrecio, "Ingrese un Precio")
  9.             'Exit Sub
  10.             If String.IsNullOrEmpty(txCantidad.Text) Then
  11.                 ep.SetError(txCantidad, "Ingrese una Cantidad")
  12.                 Exit Sub
  13.             End If
  14.         End If
  15.         ep.Clear()
  16.         If String.IsNullOrEmpty(txCantidad.Text) Then
  17.             ep.SetError(txCantidad, "Ingrese una Cantidad")
  18.             'Exit Sub
  19.             If String.IsNullOrEmpty(txPrecio.Text) Then
  20.                 ep.SetError(txPrecio, "Ingrese un Precio")
  21.                 Exit Sub
  22.             End If
  23.         End If
  24.  
  25.         Dim fila As Integer      
  26.         For fila = 0 To My.Forms.nueva_factura.ListView1.Items.Count - 1
  27.                 Dim codProd As String = My.Forms.nueva_factura.ListView1.Items(fila).SubItems(0).Text
  28.                 If txId.Text = codProd Then
  29.                     MessageBox.Show("Este Producto, Ya se Encuentra en la Linea de Detalle", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
  30.                     Exit Sub
  31.             Next
  32.             ep.Clear()
  33.  
  34.             'AQUI ANTES LLAMABA A LA FUNCION AgregarItem(...)
  35.  
  36.             Call LimpiarTextBox(Me)
  37.         End If
  38.     End Sub