elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Rompecabezas de Bitcoin, Medio millón USD en premios


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación General
| | |-+  .NET (C#, VB.NET, ASP)
| | | |-+  Programación Visual Basic (Moderadores: LeandroA, seba123neo)
| | | | |-+  Ayuda con Listview (evitar duplicados en lista de facturación) plis!!!
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: Ayuda con Listview (evitar duplicados en lista de facturación) plis!!!  (Leído 6,950 veces)
GhostLT

Desconectado Desconectado

Mensajes: 82


To know the truth,you must risk everything


Ver Perfil
Ayuda con Listview (evitar duplicados en lista de facturación) plis!!!
« en: 20 Septiembre 2009, 15:36 pm »

 Es necesario consultar 3 campos en el listview para determinar que no esta repetido (material,medidaancho y medidalargo) si estos 3 son verdadero entonces que me mande un mensaje que ya esta en la lista

Private Sub cmdagregar_Click()
'validar que esten seleccionados los campos
If txtmaterial.Text = "" Then MsgBox " Seleccione el tipo de Material", vbInformation, "Aviso": Exit Sub
If Combo2.Text = "" Then MsgBox "Seleccione Medida de Largo", vbInformation, "Aviso": Exit Sub
If Combo3.Text = "" Then MsgBox "Seleccione la Cantidad a Imprimir", vbInformation, "Aviso": Exit Sub
If Combo1.Text = "" Then MsgBox "Desea Aplicar Descuento", vbInformation, "Aviso": Exit Sub
If txtentrega.Text = "" Then MsgBox "Seleccione Fecha de Entrega", vbInformation, "Aviso": Exit Sub
'validar que el producto no se encuentre ya en el detalle
Dim i As Long
Dim j As Long
With ListView1
    .View = lvwList
For i = 1 To .ListItems.Count
For j = i + 1 To .ListItems.Count
If .ListItems.item(i).ListItems.item(i).SubItems(1) And .ListItems.item(i).SubItems(2) = .ListItems.item(j) And _
                                                                 .ListItems.item(j).SubItems(1) And .ListItems.item(j).SubItems(2) Then
MsgBox "Esa Información ya existe en la lista de Facturación", vbInformation, "Aviso": Exit Sub
End If
If j = .ListItems.Count Then
Exit For
End If
Next

With RsTemporalFacturaPlotter
    .Requery
    .AddNew
    !material = txtmaterial.Text
    !medidaancho = CDbl(txtancho.Text)
    !medidalargo = CDbl(txtlargo.Text)
    !cantidad = txtcantidad.Text
    !descuento = CDbl(txtdescuento.Text)
    !importe = CDbl(txtimporte.Text)
    !semana = lblsemana.Caption
    !Hora = lblhora.Caption
    .Update
End With
agregar                     'llena el listview1 con los datos que meti
'calcular los totales
txtsubtotal.Text = Sumar    'suma toda la lista de precios del campo precio del listview1
txtiva.Text = txtsubtotal.Text * 0.1
txttotal.Text = txtsubtotal.Text + txtsubtotal.Text * 0.1
limpiar         'limpia todo el pedo
End Sub

Gracias por su atención


En línea

There is some fiction in you truth, and some truth in you fiction
GhostLT

Desconectado Desconectado

Mensajes: 82


To know the truth,you must risk everything


Ver Perfil
Re: Ayuda con Listview (evitar duplicados en lista de facturación) plis!!!
« Respuesta #1 en: 25 Septiembre 2009, 15:22 pm »

Uff!!! porfin encontre la solución
Private Sub cmdagregar_Click()
'validar que esten seleccionados los campos
'If txtmaterial.Text = "" Then MsgBox " Seleccione el tipo de Material", vbInformation, "Aviso": Exit Sub
If Combo2.Text = "" Then MsgBox "Seleccione Medida de Largo", vbInformation, "Aviso": Exit Sub
If Combo3.Text = "" Then MsgBox "Seleccione la Cantidad a Imprimir", vbInformation, "Aviso": Exit Sub
If Combo1.Text = "" Then MsgBox "Desea Aplicar Descuento", vbInformation, "Aviso": Exit Sub
If txtentrega.Text = "" Then MsgBox "Seleccione Fecha de Entrega", vbInformation, "Aviso": Exit Sub
'------------------------------validar que la info del detalle de la venta no sea igual----
var1 = txtmaterial.Text + txtancho.Text + Combo2.Text
Dim Registros As Integer
Registros = ListView1.ListItems.Count

For x = 1 To Registros
With ListView1
    var2 = ListView1.ListItems.item(x) & ListView1.ListItems.item(x).ListSubItems(1) & ListView1.ListItems.item(x).ListSubItems(2) & " mts"
End With
If var1 = var2 Then MsgBox "Esta Información ya ha sido agregado a esta compra anteriormente", vbInformation, "Aviso": limpiar: Exit Sub
Next

'grabar en TemporalFacturaPlotter
With RsTemporalFacturaPlotter
    .Requery
    .AddNew
    !material = txtmaterial.Text
    !medidaancho = CDbl(txtancho.Text)
    !medidalargo = CDbl(txtlargo.Text)
    !cantidad = txtcantidad.Text
    !descuento = CDbl(txtdescuento.Text)
    !importe = CDbl(txtimporte.Text)
    !semana = lblsemana.Caption
    !Hora = lblhora.Caption
    .Update
End With
agregar                     'llena el listview1 con los datos que meti
'calcular los totales
txtsubtotal.Text = Sumar    'suma toda la lista de precios del campo precio del listview1
txtiva.Text = txtsubtotal.Text * 0.1
txttotal.Text = txtsubtotal.Text + txtsubtotal.Text * 0.1
limpiar         'limpia todo el pedo
End Sub
'End Function
Private Function Sumar() As Double
   
    Dim i As Integer
    'Recorre todos los items y para sumar los SubItems
    For i = 1 To ListView1.ListItems.Count
        Sumar = Sumar + CDbl(ListView1.ListItems.item(i).ListSubItems(7))
    Next i
       
End Function


En línea

There is some fiction in you truth, and some truth in you fiction
cassiani


Desconectado Desconectado

Mensajes: 978


« Anterior | Próximo »


Ver Perfil WWW
Re: Ayuda con Listview (evitar duplicados en lista de facturación) plis!!!
« Respuesta #2 en: 25 Septiembre 2009, 16:46 pm »

recuerda las etiquetas GeShi

me llamo la atensión este bloque:
Código:
With ListView1
    var2 = ListView1.ListItems.item(x) & ListView1.ListItems.item(x).ListSubItems(1) & _
ListView1.ListItems.item(x).ListSubItems(2) & " mts"
End With

usas el With ... End With, pero sigues haciendo referencia al objeto, en este caso el ListView1, recuerda que le usas para ejecutar una serie de declaraciones que hagan referencia repetida a un solo objeto.

Código:
With ListView1
    var2 = .ListItems.item(x) & .ListItems.item(x).ListSubItems(1) & .ListItems.item(x).ListSubItems(2) & " mts"
End With

Código:
*http://msdn.microsoft.com/en-us/library/wc500chb(VS.71).aspx

ah que abajo si lo usaste .. o.O
« Última modificación: 25 Septiembre 2009, 17:22 pm por cΔssiΔnі » En línea

GhostLT

Desconectado Desconectado

Mensajes: 82


To know the truth,you must risk everything


Ver Perfil
Re: Ayuda con Listview (evitar duplicados en lista de facturación) plis!!!
« Respuesta #3 en: 29 Septiembre 2009, 05:40 am »

Primero que nada GRACIAS!!! por mencionar las etiquetas geSHI no tenia idea como le hacian, apartir de ahora las voy a implementar para una mejor comprensión y con respecto a la info del with es cierto intentaré poner mas cuidado.   :D
En línea

There is some fiction in you truth, and some truth in you fiction
Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines