0% found this document useful (0 votes)
40 views

Facultad de Ingeniería Escuela Profesional de Ingeniería de Sistemas

The document contains code for two programming exercises in Visual Basic .NET. The first exercise code defines classes and methods for a data table to manage book data such as code, name and publisher. The second exercise code defines classes and methods for a form to manage book sales data, including adding, removing and processing sales. Methods handle events like button clicks to perform these operations.

Uploaded by

sajsjasjasjajsa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
40 views

Facultad de Ingeniería Escuela Profesional de Ingeniería de Sistemas

The document contains code for two programming exercises in Visual Basic .NET. The first exercise code defines classes and methods for a data table to manage book data such as code, name and publisher. The second exercise code defines classes and methods for a form to manage book sales data, including adding, removing and processing sales. Methods handle events like button clicks to perform these operations.

Uploaded by

sajsjasjasjajsa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

FACULTAD DE INGENIERÍA

ESCUELA PROFESIONAL DE INGENIERÍA DE SISTEMAS

INTEGRANTES

 CARMEN ATOCHE ARNOL


 CARMEN HERRERA TANYA
 CHUMACERO ORDINOLA JUAN
 JIMENEZ RAMIREZ MARLON

DOCENTE
ING. JENNIFER SULLON CHINGA

ASIGNATURA
PROGRAMACIÓN NET

CICLO
V

TEMA
CASOS PRACTICOS

PIURA-PERÚ
2019
EJERCICIO 1
Public Class Form1
Public dt As New DataTable Public
cbCodigo(4) As Double Public
listNombre(4) As String
Public listEditorial(4) As String
Public cbDni(4) As Double
Public listNombre1(4) As String Public
listApellidos(4) As String

Private Sub Button4_Click(sender As Object, e As EventArgs) Handles


btnCancelarP.Click

Dim x As Integer
x = MessageBox.Show("Desea Salir", "Salir", MessageBoxButtons.YesNo,
MessageBoxIcon.Question)
If x = 6 Then
End
End If
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles
btnNuevoP.Click

Me.boxCodigo.Items.Clear()
Me.txtNombre.Text = ""
Me.txtEditorial.Text = ""
Me.boxDni.Items.Clear()
Me.txtNombre1.Text = ""
Me.txtApellidos.Text = ""
End Sub

Private Sub Button2_Click(sender As Object, e As EventArgs) Handles


btnEliminar.Click

Dim pos As Integer


pos = BindingContext(dataPres.DataSource).Position
dt.Rows.RemoveAt(pos)

Dim contar As Integer contar


= dt.Rows.Count
Me.txtTotal.Text = contar
End Sub

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles


btnAgregar.Click
dt.Rows.Add(cbCodigo.Text, txtNombre.Text, txtEditorial.Text)

Dim contar As Integer


contar = dt.Rows.Count Me.txtTotal.Text = contar End
Sub

Private Sub frmdatatable_Load(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles MyBase.Load

dt.Columns.Add("Código", GetType(String))
dt.Columns.Add("Nombre", GetType(String))
dt.Columns.Add("Editorial", GetType(String))
dataPres.DataSource = dt
End Sub
End Class
EJERCICIO 2

Public Class Form1


Public pos, nomb As Integer
Public boxCodigo(4) As Double
Public listNombreL(4) As String
Public listEdit(4) As String
Public listPrecioL(4) As Double
Public Monto, ST As Double
Private Sub ComboBox1_SelectedIndexChanged(sender As
Object, e As EventArgs)
Handles boxCod.SelectedIndexChanged
Me.txtNom.Text = listNombreL(Me.boxCod.SelectedIndex)
Me.txtEdit.Text = listEdit(Me.boxCod.SelectedIndex)
Me.txtCoste.Text = listPrecioL(Me.boxCod.SelectedIndex)
Me.txtMonto.Focus()
End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles MyBase.Load
boxCodigo(0) = 12345
boxCodigo(1) = 23456
boxCodigo(2) = 34567
boxCodigo(3) = 45678
listNombreL(0) = "Saga Harry Potter"
listNombreL(1) = "Saga Crepúsculo"
listNombreL(2) = "Saga 50 Sombras de Grey"
listNombreL(3) = "Saga The Maze Runner"
listEdit(0) = "Bloomsbury Publishing"
listEdit(1) = "Little, Brown And Company"
listEdit(2) = "Vintage Books "
listEdit(3) = "Dell Publishing"

listPrecioL(0) = 150
listPrecioL(1) = 120
listPrecioL(2) = 320
listPrecioL(3) = 100
Monto = 0
End Sub

Private Sub btnEliminar_Click(sender As Object, e As EventArgs)


Handles btnEliminar.Click

pos = Me.listNom.SelectedIndex
If pos >= 0 Then
Me.listNom.Items.RemoveAt(pos)
Me.listPrecio.Items.RemoveAt(pos)
Me.listCantidad.Items.RemoveAt(pos)
Me.listST.Items.RemoveAt(pos)

Else
MessageBox.Show("Seleccionar elemento a eliminar",
"Eliminar",
MessageBoxButtons.OK, MessageBoxIcon.Hand)

End If
End Sub
Private Sub btnCancelar_Click(sender As Object, e As EventArgs)
Handles btnCancelar.Click

Me.txtCantidad.Text = ""
Me.txtST.Text = ""
Me.txtMonto.Text = ""
Me.listNom.Items.Clear()
Me.listPrecio.Items.Clear()
Me.listCantidad.Items.Clear()
Me.listST.Items.Clear()

Dim x As Integer

x = MessageBox.Show("Desea Salir", "Salir",


MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If x = 6 Then
End
End If
End Sub

Private Sub btnProcesar_Click(sender As Object, e As EventArgs)


Handles btnProcesar.Click

Dim Procesar As Integer


Procesar = MessageBox.Show("¿Desea Pocesar la Venta?",
"Procesar",MessageBoxButtons.YesNo, MessageBoxIcon.Question)

If Procesar = 6 Then
MessageBox.Show("El monto total a pagar es: " + txtMonto.Text,
"Salir", MessageBoxButtons.OK, MessageBoxIcon.Information)

End If
Me.txtNom.Text = ""
Me.txtEdit.Text = ""
Me.txtCantidad.Text = ""
Me.txtCoste.Text = ""

Me.txtST.Text = ""
Me.txtMonto.Text = ""
Me.listNom.Items.RemoveAt(pos)
Me.listPrecio.Items.RemoveAt(pos)
Me.listCantidad.Items.RemoveAt(pos)
Me.listST.Items.RemoveAt(pos)

End Sub
Private Sub btnAgregar_Click(sender As Object, e As EventArgs)
Handles btnAgregar.Click

Dim can, pre, ST As Double


can = Me.txtCantidad.Text
pre = Me.txtCoste.Text
ST = can * pre
Me.txtST.Text = ST
Monto = Monto + ST
Do While nomb < 1
Me.listNom.Items.Add(Me.txtNom.Text)

nomb = nomb + 1
Exit Sub
Loop
MessageBox.Show("Solo se puede comprar un libro por codigo!",
"Atención", MessageBoxButtons.OK, MessageBoxIcon.Information)
Me.txtMonto.Text = Monto
Me.listPrecio.Items.Add(Me.txtCoste.Text)
Me.listCantidad.Items.Add(Me.txtCantidad.Text)
Me.listST.Items.Add(Me.txtST.Text)
End Sub
End Clas

You might also like