Título: Ayuda con Listview (evitar duplicados en lista de facturación) plis!!! Publicado por: GhostLT 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 Título: Re: Ayuda con Listview (evitar duplicados en lista de facturación) plis!!! Publicado por: GhostLT 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 Título: Re: Ayuda con Listview (evitar duplicados en lista de facturación) plis!!! Publicado por: cassiani en 25 Septiembre 2009, 16:46 pm recuerda las etiquetas GeShi
me llamo la atensión este bloque: Código: With ListView1 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 Código: *http://msdn.microsoft.com/en-us/library/wc500chb(VS.71).aspx ah que abajo si lo usaste .. o.O Título: Re: Ayuda con Listview (evitar duplicados en lista de facturación) plis!!! Publicado por: GhostLT 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
|