Public Class frm_Factura
Dim Random As New Random()
Dim numero As
Int64 = Random.Next(100000000, 999999999)
Private Sub
frm_Factura_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
MyBase.Load
Me.txtdia.Text =
Microsoft.VisualBasic.Day(DateTimePicker1.Value)
Me.txtmes.Text =
Microsoft.VisualBasic.Month(DateTimePicker1.Value)
Me.txtaño.Text = Microsoft.VisualBasic.Year(DateTimePicker1.Value)
cboariculos.Items.Add("Camisetas")
cboariculos.Items.Add("Short")
cboariculos.Items.Add("Buzos")
cboariculos.Items.Add("Medias")
cboariculos.Items.Add("Casacas")
cboariculos.Items.Add("Gorros")
cboariculos.Items.Add("Maletines")
lblruc.Text = "R.U.C :"
& numero
End Sub
Private Sub
cboariculos_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
cboariculos.SelectedIndexChanged
Select Case
cboariculos.SelectedIndex
Case
0
txtprecio.Text = 40
Case
1
txtprecio.Text = 25
Case
2
txtprecio.Text = 140
Case 3
txtprecio.Text = 15
Case
4
txtprecio.Text = 60
Case
5
txtprecio.Text = 35
Case
6
txtprecio.Text = 70
End Select
End Sub
Private Sub
btningresar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
btningresar.Click
Dim subtotal As
Integer
subtotal = NUDcantidad.Value * Val(txtprecio.Text)
lstcantidad.Items.Add(Val(NUDcantidad.Value))
lstdescripcion.Items.Add(cboariculos.SelectedItem)
lstpunitario.Items.Add(Val(txtprecio.Text))
lstptotal.Items.Add(subtotal)
End Sub
Private Sub
btncalcular_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
btncalcular.Click
Dim total As
Double
Dim Elementos_lista As Double
Elementos_lista = lstptotal.Items.Count - 1
total = SumarElementos(Elementos_lista)
txtigv.Text = total * 0.19
txttotal.Text = Val(total) + Val(txtigv.Text)
End Sub
Public Function
SumarElementos(ByVal Lista As Integer) As Integer
Dim i As
Integer
Dim Suma As
Integer
Suma = 0
For i = 0 To
lstptotal.Items.Count - 1
Suma = Suma + lstptotal.Items(i)
SumarElementos = Suma
Next
End Function
Private Sub
btneliminar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
btneliminar.Click
Dim m As
Integer = lstdescripcion.SelectedIndex
lstdescripcion.Items.RemoveAt(m)
lstcantidad.Items.RemoveAt(m)
lstptotal.Items.RemoveAt(m)
lstpunitario.Items.RemoveAt(m)
End Sub
Private Sub
Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Timer1.Tick
Eliminar(lstdescripcion)
End Sub
Function Eliminar(ByVal LB As ListBox) As Int32
Dim i As
Int32
Dim j As
Int32
Dim n As
Int32
For i = 0 To
LB.Items.Count - 2 ' Recorre los items (compara
empezando desde el primero , de abajo hacia arriba)
For
j = LB.Items.Count - 1 To i + 1 Step -1
If
LB.Items(i).ToString = LB.Items(j).ToString Then
' ... si es el mismo
LB.Items.RemoveAt(j) ' elimina el elemento indicando el índice
lstpunitario.Items.RemoveAt(j)
lstcantidad.Items.RemoveAt(j)
lstptotal.Items.RemoveAt(j)
End
If
Next
Next
Return n '
retorna los eliminados
End Function
Private Sub
txtnombre_Validating(ByVal sender As System.Object, ByVal e As
System.ComponentModel.CancelEventArgs) Handles txtnombre.Validating
If txtnombre.Text.Length = 0 Then
ErrorProvider1.SetError(Me.txtnombre, "Ingrese
Nombre")
Else
ErrorProvider1.SetError(Me.txtnombre, "")
End If
End Sub
Private Sub
txtdireccion_Validating(ByVal sender As System.Object, ByVal e As
System.ComponentModel.CancelEventArgs) Handles txtdireccion.Validating
If txtdireccion.Text.Length = 0 Then
ErrorProvider1.SetError(Me.txtdireccion, "Ingrese
Dirección")
Else
ErrorProvider1.SetError(Me.txtdireccion, "")
End If
End Sub
End Class
hola que componentes yeba esta factura como sellaman los componentes
ResponderEliminar