Elaborar una aplicación que permita crear un objeto de la clase artículo al seleccionar “Alta” del menú Artículo y luego mostrar los artículos cargados en un cuadro combinado (Combo). Apenas el usuario seleccione un artículo se debe mostrar el precio del mismo, el interés es fijo para esta ocasión.
El diseño de la interfaz debe ser similar a la siguiente figura:
Al hacer click en el Menu de “Articulos”, y de nuevo en “Altas”, se agregaran los articulos al comboBox.
La venta a realizarse es a plazos, ello condiciona la cuota mensual a pagarse. Cuando se haga click sobre el botón Cuota mensual debe mostrarse un cuadro de diálogo con los datos propuestos:
De manera similar al hacer click sobre el botón Total nos debe mostrar la cantidad total a pagar.
Bueno pasemos al codigo del formulario.
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.Text = "Pedido de cotizaciones"
Me.Label1.Text = "Articulos"
Me.Label2.Text = "Precio en US$"
Me.Label3.Text = "Interes"
Me.GroupBox1.Text = "Plazo:"
Me.RadioButton1.Text = "6 meses"
Me.RadioButton2.Text = "12 meses"
Me.RadioButton3.Text = "24 meses"
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Me.TextBox1.Text = ""
Me.TextBox2.Text = ""
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
If MessageBox.Show("Desea Salir?", "Chau", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) = Windows.Forms.DialogResult.OK Then
MessageBox.Show("Ha decidido salir, chau!!!", "CHAU", MessageBoxButtons.OK, MessageBoxIcon.Information)
Me.Close()
Else
MessageBox.Show("Continua en la aplicacion", "Gracias", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
End Sub
Private Sub AltasToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AltasToolStripMenuItem.Click
Dim primerArt As String = "Televisor"
Dim segundoArt As String = "Heladera"
Dim tercerArt As String = "Computadora"
Dim cuartoArt As String = "Cocina"
Dim nuevoArticulo As New Articulo(primerArt, segundoArt, tercerArt, cuartoArt)
Me.ComboBox1.Items.Add(nuevoArticulo.Primer)
Me.ComboBox1.Items.Add(nuevoArticulo.Segundo)
Me.ComboBox1.Items.Add(nuevoArticulo.Tercer)
Me.ComboBox1.Items.Add(nuevoArticulo.Cuarto)
End Sub
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
Select Case (Me.ComboBox1.SelectedIndex)
Case 0 : Me.TextBox1.Text = 600.2 REM televisor
Case 1 : Me.TextBox1.Text = 900.5D REM heladera
Case 2 : Me.TextBox1.Text = 2600D REM computadora
Case 3 : Me.TextBox1.Text = 500.2D REM cocina
End Select
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim cuotaMensual As Single
Dim interes As Single
If RadioButton1.Checked = True Then
interes = Me.TextBox1.Text * 10 / 100
cuotaMensual = (Me.TextBox1.Text + interes) / 6
MessageBox.Show("Interes: $" & interes & "Cuota Mensual: $" & cuotaMensual, "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
End If
If RadioButton2.Checked = True Then
interes = Me.TextBox1.Text * 20 / 100
cuotaMensual = (Me.TextBox1.Text + interes) / 12
MessageBox.Show("Interes: $" & interes & "Cuota Mensual: $" & cuotaMensual, "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
End If
If RadioButton3.Checked = True Then
interes = Me.TextBox1.Text * 40 / 100
cuotaMensual = (Me.TextBox1.Text + interes) / 24
MessageBox.Show("Interes: $" & interes & "Cuota Mensual: $" & cuotaMensual, "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
End If
End Sub
Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged
Me.TextBox2.Text = "10%"
End Sub
Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton2.CheckedChanged
Me.TextBox2.Text = "20%"
End Sub
Private Sub RadioButton3_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton3.CheckedChanged
Me.TextBox2.Text = "40%"
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim interes As Single
Dim total As Single
If RadioButton1.Checked = True Then
interes = Me.TextBox1.Text * 10 / 100
total = Me.TextBox1.Text + interes
MessageBox.Show("El total es " & total, "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
If RadioButton2.Checked = True Then
interes = Me.TextBox1.Text * 20 / 100
total = Me.TextBox1.Text + interes
MessageBox.Show("El total es " & total, "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
If RadioButton3.Checked = True Then
interes = Me.TextBox1.Text * 40 / 100
total = Me.TextBox1.Text + interes
MessageBox.Show("El total es " & total, "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
End Sub
End Class
-----------------------------------------------------------------------------------------------------
Public Class Articulo
Private _primerArt As String
Private _segundoArt As String
Private _tercerArt As String
Private _cuartoArt As String
Private _interesArt As Single
Public Sub New()
End Sub
Public Sub New(ByVal primerArt As String, ByVal segundoArt As String, ByVal tercerArt As String, ByVal cuartoArt As String)
Me.Primer = primerArt
Me.Segundo = segundoArt
Me.Tercer = tercerArt
Me.Cuarto = cuartoArt
End Sub
Public Property Primer() As String
Get
Return _primerArt
End Get
Set(ByVal value As String)
_primerArt = value
End Set
End Property
Public Property Segundo() As String
Get
Return _segundoArt
End Get
Set(ByVal value As String)
_segundoArt = value
End Set
End Property
Public Property Tercer() As String
Get
Return _tercerArt
End Get
Set(ByVal value As String)
_tercerArt = value
End Set
End Property
Public Property Cuarto() As String
Get
Return _cuartoArt
End Get
Set(ByVal value As String)
_cuartoArt = value
End Set
End Property
End Class