sábado, 1 de febrero de 2014

Código Fuente del Programa Tienda de Computadores

Formulario en Diseño


Formulario en Ejecución


Código Fuente

Se crean variables y constantes

Public Class CompraInteractiva
    Dim path As String
    Dim suma_total As Long

    Const teclado = 17000
    Const Mouse = 12000
    Const Microfono = 15000
    Const Scanner = 198000
    Const WebCam = 65000
    Const LapizOptico = 150000
    Const Monitor = 250000
    Const Impresora = 350000
    Const Parlantes = 35000
    Const DiscoDuro = 215000
    Const CD = 125000
    Const DVD = 115000
    Const Memoria = 22000
 


    Public Sub LimpiarDisp_Entrada()
        PictureBox1.Image = Nothing
        PictureBox2.Image = Nothing
        PictureBox3.Image = Nothing
        PictureBox4.Image = Nothing
        PictureBox5.Image = Nothing
        PictureBox6.Image = Nothing
        lbPrecio1.Text = Nothing
        lbPrecio2.Text = Nothing
        lbPrecio3.Text = Nothing
        lbPrecio4.Text = Nothing
        lbPrecio5.Text = Nothing
        lbPrecio6.Text = Nothing
        CheckBox1.Checked = False
        CheckBox2.Checked = False
        CheckBox3.Checked = False
        CheckBox4.Checked = False
        CheckBox5.Checked = False
        CheckBox6.Checked = False
    End Sub


    Public Sub LimpiarDisp_salida()
        PictureBox1.Image = Nothing
        PictureBox2.Image = Nothing
        PictureBox3.Image = Nothing
        lbPrecio1.Text = Nothing
        lbPrecio2.Text = Nothing
        lbPrecio3.Text = Nothing
        CheckBox7.Checked = False
        CheckBox8.Checked = False
        CheckBox9.Checked = False
    End Sub

    Public Sub LimpiarDisp_Almacenamiento()
        PictureBox1.Image = Nothing
        PictureBox2.Image = Nothing
        PictureBox3.Image = Nothing
        PictureBox4.Image = Nothing
        lbPrecio1.Text = Nothing
        lbPrecio2.Text = Nothing
        lbPrecio3.Text = Nothing
        lbPrecio4.Text = Nothing
        CheckBox10.Checked = False
        CheckBox11.Checked = False
        CheckBox12.Checked = False
        CheckBox13.Checked = False
    End Sub

    Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged

        If RadioButton1.Checked Then
            GroupBox4.Enabled = True
            GroupBox5.Enabled = False
            GroupBox2.Enabled = False
            LimpiarDisp_salida()
            LimpiarDisp_Almacenamiento()
        Else
            GroupBox4.Enabled = False
        End If
    End Sub

    Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton2.CheckedChanged

        If RadioButton2.Checked Then
            GroupBox5.Enabled = True
            LimpiarDisp_Entrada()
            LimpiarDisp_Almacenamiento()
        Else
            GroupBox5.Enabled = False
        End If
    End Sub

    Private Sub RadioButton3_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton3.CheckedChanged

        If RadioButton3.Checked Then
            GroupBox2.Enabled = True
            LimpiarDisp_Entrada()
            LimpiarDisp_salida()
        Else
            GroupBox2.Enabled = False
        End If
    End Sub

    Private Sub CompraInteractiva_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        RadioButton1.Checked = Nothing
    End Sub

    Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged

        If CheckBox1.Checked Then
            PictureBox1.Image = Image.FromFile("c:\Imagenes\Teclado.gif")
            lbPrecio1.Text = teclado
            suma_total = suma_total + teclado
            TextBox1.Text = FormatCurrency(suma_total)
        Else
            PictureBox1.Image = Nothing
            lbPrecio1.Text = Nothing
            TextBox1.Text = Nothing
            suma_total = suma_total - teclado
            TextBox1.Text = FormatCurrency(suma_total)
        End If
    End Sub

    Private Sub CheckBox2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox2.CheckedChanged

        If CheckBox2.Checked Then
            PictureBox2.Image = Image.FromFile("c:\Imagenes\Mouse.png")
            lbPrecio2.Text = Mouse
            suma_total = suma_total + Mouse
            TextBox1.Text = FormatCurrency(suma_total)
        Else
            PictureBox2.Image = Nothing
            lbPrecio2.Text = Nothing
            suma_total = suma_total - Mouse
            TextBox1.Text = FormatCurrency(suma_total)
        End If
    End Sub

    Private Sub CheckBox3_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox3.CheckedChanged

        If CheckBox3.Checked Then
            PictureBox3.Image = Image.FromFile("c:\Imagenes\Microfono.jpg")
            lbPrecio3.Text = Microfono
            suma_total = suma_total + Microfono
            TextBox1.Text = FormatCurrency(suma_total)
        Else
            PictureBox3.Image = Nothing
            lbPrecio3.Text = Nothing
            suma_total = suma_total - Microfono
            TextBox1.Text = FormatCurrency(suma_total)
        End If
    End Sub

    Private Sub CheckBox4_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox4.CheckedChanged

        If CheckBox4.Checked Then
            PictureBox4.Image = Image.FromFile("c:\Imagenes\Scanner.jpg")
            lbPrecio4.Text = Scanner
            suma_total = suma_total + Scanner
            TextBox1.Text = FormatCurrency(suma_total)
        Else
            PictureBox4.Image = Nothing
            lbPrecio4.Text = Nothing
            suma_total = suma_total - Scanner
            TextBox1.Text = FormatCurrency(suma_total)
        End If
    End Sub

    Private Sub CheckBox5_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox5.CheckedChanged

        If CheckBox5.Checked Then
            PictureBox5.Image = Image.FromFile("c:\Imagenes\WebCam.png")
            lbPrecio5.Text = WebCam
            suma_total = suma_total + WebCam
            TextBox1.Text = FormatCurrency(suma_total)
        Else
            PictureBox5.Image = Nothing
            lbPrecio5.Text = Nothing
            suma_total = suma_total - WebCam
            TextBox1.Text = FormatCurrency(suma_total)
        End If
    End Sub

    Private Sub CheckBox6_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox6.CheckedChanged

        If CheckBox6.Checked Then
            PictureBox6.Image = Image.FromFile("c:\Imagenes\LapizOptico.jpg")
            lbPrecio6.Text = 150000
            suma_total = suma_total + LapizOptico
            TextBox1.Text = FormatCurrency(suma_total)
        Else
            PictureBox6.Image = Nothing
            lbPrecio6.Text = Nothing
            suma_total = suma_total - LapizOptico
            TextBox1.Text = FormatCurrency(suma_total)
        End If
    End Sub

    Private Sub CheckBox7_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox7.CheckedChanged
        If CheckBox7.Checked Then
            PictureBox1.Image = Image.FromFile("c:\Imagenes\Monitor.png")
            lbPrecio1.Text = Monitor
            suma_total = suma_total + Monitor
            TextBox1.Text = FormatCurrency(suma_total)
        Else
            PictureBox1.Image = Nothing
            lbPrecio1.Text = Nothing
            suma_total = suma_total - Monitor
            TextBox1.Text = FormatCurrency(suma_total)
        End If
    End Sub

    Private Sub CheckBox8_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox8.CheckedChanged

        If CheckBox8.Checked Then
            PictureBox2.Image = Image.FromFile("c:\Imagenes\Impresora.png")
            lbPrecio2.Text = Impresora
            suma_total = suma_total + Impresora
            TextBox1.Text = FormatCurrency(suma_total)
        Else
            PictureBox2.Image = Nothing
            lbPrecio2.Text = Nothing
            suma_total = suma_total - Impresora
            TextBox1.Text = FormatCurrency(suma_total)
        End If
    End Sub

    Private Sub CheckBox9_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox9.CheckedChanged

        If CheckBox9.Checked Then
            PictureBox3.Image = Image.FromFile("c:\Imagenes\Parlantes.jpg")
            lbPrecio3.Text = Parlantes
            suma_total = suma_total + Parlantes
            TextBox1.Text = FormatCurrency(suma_total)
        Else
            PictureBox3.Image = Nothing
            lbPrecio3.Text = Nothing
            suma_total = suma_total - Parlantes
            TextBox1.Text = FormatCurrency(suma_total)
        End If
    End Sub

    Private Sub CheckBox10_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox10.CheckedChanged

        If CheckBox10.Checked Then
            PictureBox1.Image = Image.FromFile("c:\Imagenes\DiscoDuro.jpg")
            lbPrecio1.Text = DiscoDuro
            suma_total = suma_total + DiscoDuro
            TextBox1.Text = FormatCurrency(suma_total)
        Else
            PictureBox1.Image = Nothing
            lbPrecio1.Text = Nothing
            suma_total = suma_total - DiscoDuro
            TextBox1.Text = FormatCurrency(suma_total)
        End If
    End Sub

    Private Sub CheckBox11_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox11.CheckedChanged

        If CheckBox11.Checked Then
            PictureBox2.Image = Image.FromFile("c:\Imagenes\UnidadCD.jpg")
            lbPrecio2.Text = CD
            suma_total = suma_total + CD
            TextBox1.Text = FormatCurrency(suma_total)
        Else
            PictureBox2.Image = Nothing
            lbPrecio2.Text = Nothing
            suma_total = suma_total - CD
            TextBox1.Text = FormatCurrency(suma_total)
        End If
    End Sub

    Private Sub CheckBox12_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox12.CheckedChanged

        If CheckBox12.Checked Then
            PictureBox3.Image = Image.FromFile("c:\Imagenes\UnidadDVD.png")
            lbPrecio3.Text = DVD
            suma_total = suma_total + DVD
            TextBox1.Text = FormatCurrency(suma_total)
        Else
            PictureBox3.Image = Nothing
            lbPrecio3.Text = Nothing
            suma_total = suma_total - DVD
            TextBox1.Text = FormatCurrency(suma_total)
        End If
    End Sub

    Private Sub CheckBox13_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox13.CheckedChanged

        If CheckBox13.Checked Then
            PictureBox4.Image = Image.FromFile("c:\Imagenes\Memoria.png")
            lbPrecio4.Text = Memoria
            suma_total = suma_total + Memoria
            TextBox1.Text = FormatCurrency(suma_total)
        Else
            PictureBox4.Image = Nothing
            lbPrecio4.Text = Nothing
            suma_total = suma_total - Memoria
            TextBox1.Text = FormatCurrency(suma_total)
        End If
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonPrintForm.Click

        With Me.PrintForm1
            .PrintAction = Printing.PrintAction.PrintToPreview
            Dim bLandscapeOriginal As Boolean = .PrinterSettings.DefaultPageSettings.Landscape
            .PrinterSettings.DefaultPageSettings.Landscape = True
            .PrinterSettings.DefaultPageSettings.Landscape = bLandscapeOriginal
            .Print(Me, PowerPacks.Printing.PrintForm.PrintOption.CompatibleModeClientAreaOnly)
        End With
    End Sub
End Class

No hay comentarios: