April 8, 2015

LAB EXAM

FORM 1


Imports System.Data.SqlClient
Public Class Form1
    Dim con As SqlConnection = New SqlConnection("Data Source=.\SqlExpress;Initial Catalog=LabExam;Integrated Security=True;Pooling=False")
    Dim cmd As SqlCommand
    Public Sub display()
        Dim abind As New BindingSource
        Dim ds As New DataSet
        Dim da As SqlDataAdapter
        cmd = New SqlCommand("Select * From PRODUCTtbl", con)
        con.Open()
        da = New SqlDataAdapter(cmd)
        da.Fill(ds)
        abind.DataSource = ds.Tables(0)
        DataGridView1.DataSource = abind
        ComboBox1.DataSource = abind
        ComboBox1.DisplayMember = "ProductName"
        da.Update(ds)
        con.Close()

    End Sub

    Private Sub ComboBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles ComboBox1.KeyPress
        e.Handled = True
        MessageBox.Show("User is not permitted to type in this feild")
    End Sub

    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
        If ComboBox1.Text = "Apple" Then
            PictureBox1.BackgroundImage = System.Drawing.Image.FromFile("C:\Users\Student\Downloads\images\download (1).jpg")
        ElseIf ComboBox1.Text = "Banana" Then
            PictureBox1.BackgroundImage = System.Drawing.Image.FromFile("C:\Users\Student\Downloads\images\download.jpg")
        ElseIf ComboBox1.Text = "Grapes" Then
            PictureBox1.BackgroundImage = System.Drawing.Image.FromFile("C:\Users\Student\Downloads\images\images (2).jpg")
        ElseIf ComboBox1.Text = "Buko" Then
            PictureBox1.BackgroundImage = System.Drawing.Image.FromFile("C:\Users\Student\Downloads\images\download (5).jpg")
        ElseIf ComboBox1.Text = "Santol" Then
            PictureBox1.BackgroundImage = System.Drawing.Image.FromFile("C:\Users\Student\Downloads\images\kraTon2.jpg")
        ElseIf ComboBox1.Text = "Pineapple" Then
            PictureBox1.BackgroundImage = System.Drawing.Image.FromFile("C:\Users\Student\Downloads\images\images (3).jpg")
        ElseIf ComboBox1.Text = "Melon" Then
            PictureBox1.BackgroundImage = System.Drawing.Image.FromFile("C:\Users\Student\Downloads\images\download (4).jpg")
        ElseIf ComboBox1.Text = "Mango" Then
            PictureBox1.BackgroundImage = System.Drawing.Image.FromFile("C:\Users\Student\Downloads\images\download (3).jpg")
        ElseIf ComboBox1.Text = "langka" Then
            PictureBox1.BackgroundImage = System.Drawing.Image.FromFile("C:\Users\Student\Downloads\images\download (6).jpg")
        ElseIf ComboBox1.Text = "Duhat" Then
            PictureBox1.BackgroundImage = System.Drawing.Image.FromFile("C:\Users\Student\Downloads\images\download (2).jpg")
        End If
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        cmd = New SqlCommand("insert into ORDERStbl values('" & TextBox3.Text & " ','" & TextBox4.Text & "','" & TextBox5.Text & "')", con)
        con.Open()
        cmd.ExecuteNonQuery()
        con.Close()

        MessageBox.Show("successfully added", "adding information", MessageBoxButtons.OK, MessageBoxIcon.Information)
        display()


    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        display()

    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        cmd = New SqlCommand("delete from ORDERStbl where OrdersID='" & TextBox2.Text & "'", con)
        con.Open()
        cmd.ExecuteNonQuery()
        con.Close()

        MessageBox.Show("Successfully deleted", "delete Information", MessageBoxButtons.OK, MessageBoxIcon.Information)
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        cmd = New SqlCommand("Update ORDERStbl set OrdersName='" & TextBox5.Text & "' where OrdersID='" & TextBox2.Text & "'", con)
        con.Open()
        cmd.ExecuteNonQuery()
        con.Close()
        MessageBox.Show("Successfully Updated", "Update Information", MessageBoxButtons.OK, MessageBoxIcon.Information)
        display()
    End Sub

    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        Form3.Show()
        Me.Hide()
    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        Dim ds As New DataSet
        Dim da As SqlDataAdapter
        cmd = New SqlCommand("select*FROM PRODUCTtbl where ProductName like'%" & TextBox1.Text & "%'", con)
        con.Open()
        da = New SqlDataAdapter(cmd)
        da.Fill(ds)
        DataGridView1.DataSource = ds.Tables(0)
        con.Close()
    End Sub
End Class




FORM 2

Imports System.Data.SqlClient

Public Class Form2
    Dim con As SqlConnection = New SqlConnection("Data Source=.\SqlExpress;Initial Catalog=LabExam;Integrated Security=True;Pooling=False")
    Dim cmd As SqlCommand
    Public Sub display()
        Dim abind As New BindingSource
        Dim ds As New DataSet
        Dim da As SqlDataAdapter
        con.Open()
        da = New SqlDataAdapter(cmd)
        da.Fill(ds)
        abind.DataSource = ds.Tables(0)
        da.Update(ds)
        con.Close()

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If TextBox1.Text = "P" And TextBox2.Text = "grace" Then
        Else
            MsgBox("Sorry, username or password not found", MsgBoxStyle.OkOnly, "Invalid")
        End If
        Form3.Show()
        Me.Hide()
    End Sub

    Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub
End Class




FORM 3

Imports System.Data.SqlClient
Public Class Form3
    Dim con As SqlConnection = New SqlConnection("Data Source=.\SqlExpress;Initial Catalog=LabExam;Integrated Security=True;Pooling=False")
    Dim cmd As SqlCommand
    Public Sub display()
        Dim abind As New BindingSource
        Dim ds As New DataSet
        Dim da As SqlDataAdapter
        cmd = New SqlCommand("Select * From PRODUCTtbl", con)
        con.Open()
        da = New SqlDataAdapter(cmd)
        da.Fill(ds)
        abind.DataSource = ds.Tables(0)
        da.Update(ds)
        con.Close()

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim abind As New BindingSource
        Dim ds As New DataSet
        Dim da As SqlDataAdapter
        cmd = New SqlCommand("Select * From PRODUCTtbl", con)
        con.Open()
        da = New SqlDataAdapter(cmd)
        da.Fill(ds)
        abind.DataSource = ds.Tables(0)
        da.Update(ds)
        con.Close()
        Form4.Show()
        Me.Hide()

    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim abind As New BindingSource
        Dim ds As New DataSet
        Dim da As SqlDataAdapter
        cmd = New SqlCommand("Select * From ORDERStbl", con)
        con.Open()
        da = New SqlDataAdapter(cmd)
        da.Fill(ds)
        abind.DataSource = ds.Tables(0)
        da.Update(ds)
        con.Close()
        Form1.Show()
        Me.Hide()

    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Dim abind As New BindingSource
        Dim ds As New DataSet
        Dim da As SqlDataAdapter
        cmd = New SqlCommand("Select * From CUSTOMERtbl", con)
        con.Open()
        da = New SqlDataAdapter(cmd)
        da.Fill(ds)
        abind.DataSource = ds.Tables(0)
        da.Update(ds)
        con.Close()
        Form6.Show()
        Me.Hide()
    End Sub
End Class






FORM 4

Imports System.Data.SqlClient
Public Class Form4
    Dim con As SqlConnection = New SqlConnection("Data Source=.\SqlExpress;Initial Catalog=LabExam;Integrated Security=True;Pooling=False")
    Dim cmd As SqlCommand
    Public Sub display()
        Dim abind As New BindingSource
        Dim ds As New DataSet
        Dim da As SqlDataAdapter
        cmd = New SqlCommand("Select * From PRODUCTtbl", con)
        con.Open()
        da = New SqlDataAdapter(cmd)
        da.Fill(ds)
        abind.DataSource = ds.Tables(0)
        DataGridView1.DataSource = abind
        da.Update(ds)
        con.Close()
    End Sub

    Private Sub Form4_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        display()
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        cmd = New SqlCommand("insert into PRODUCTtbl values('" & TextBox3.Text & " ','" & TextBox4.Text & "','" & TextBox5.Text & "')", con)
        con.Open()
        cmd.ExecuteNonQuery()
        con.Close()

        MessageBox.Show("successfully added", "adding information", MessageBoxButtons.OK, MessageBoxIcon.Information)
        display()
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        cmd = New SqlCommand("delete from PRODUCTtbl where ProductsID='" & TextBox2.Text & "'", con)
        con.Open()
        cmd.ExecuteNonQuery()
        con.Close()

        MessageBox.Show("Successfully deleted", "delete Information", MessageBoxButtons.OK, MessageBoxIcon.Information)

    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        cmd = New SqlCommand("Update PRODUCTtbl set ProductName='" & TextBox3.Text & "'ProductQuantity='" & TextBox4.Text & "'ProductPrice='" & TextBox5.Text & "' where is ProductID='" & TextBox2.Text & "'", con)
        con.Open()
        cmd.ExecuteNonQuery()
        con.Close()
        MessageBox.Show("Successfully Updated", "Update Information", MessageBoxButtons.OK, MessageBoxIcon.Information)
        display()
    End Sub

    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        Form3.Show()
        Me.Hide()
    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        Dim ds As New DataSet
        Dim da As SqlDataAdapter
        cmd = New SqlCommand("select*FROM PRODUCTtbl where ProductName like'%" & TextBox1.Text & "%'", con)
        con.Open()
        da = New SqlDataAdapter(cmd)
        da.Fill(ds)
        DataGridView1.DataSource = ds.Tables(0)
        con.Close()
    End Sub

End Class





FORM 5


Imports System.Data.SqlClient
Public Class Form5
    Dim con As SqlConnection = New SqlConnection("Data Source=.\SqlExpress;Initial Catalog=LabExam;Integrated Security=True;Pooling=False")
    Dim cmd As SqlCommand
    Public Sub display()
        Dim abind As New BindingSource
        Dim ds As New DataSet
        Dim da As SqlDataAdapter
        cmd = New SqlCommand("Select OrdersName From ORDERStbl", con)
        con.Open()
        da = New SqlDataAdapter(cmd)
        da.Fill(ds)
        abind.DataSource = ds.Tables(0)
        ComboBox1.DataSource = abind
        ComboBox1.DisplayMember = "ProductName"
        DataGridView1.DataSource = abind
        da.Update(ds)
        con.Close()


    End Sub

    Private Sub ComboBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles ComboBox1.KeyPress
        e.Handled = True
        MessageBox.Show("User is not permitted to type in this feild")

    End Sub

    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
        If ComboBox1.Text = "Banana" Then
            PictureBox1.BackgroundImage = System.Drawing.Image.FromFile("C:\Users\Student\Downloads\images\download (1).jpg")
        ElseIf ComboBox1.Text = "Grapes" Then
            PictureBox1.BackgroundImage = System.Drawing.Image.FromFile("C:\Users\Student\Downloads\images\download.jpg")
        ElseIf ComboBox1.Text = "Apple" Then
            PictureBox1.BackgroundImage = System.Drawing.Image.FromFile("C:\Users\Student\Downloads\images\images (2).jpg")
        ElseIf ComboBox1.Text = "Buko" Then
            PictureBox1.BackgroundImage = System.Drawing.Image.FromFile("C:\Users\Student\Downloads\images\download (5).jpg")
        ElseIf ComboBox1.Text = "Santol" Then
            PictureBox1.BackgroundImage = System.Drawing.Image.FromFile("C:\Users\Student\Downloads\images\kraTon2.jpg")
        ElseIf ComboBox1.Text = "Pineapple" Then
            PictureBox1.BackgroundImage = System.Drawing.Image.FromFile("C:\Users\Student\Downloads\images\images (3).jpg")
        ElseIf ComboBox1.Text = "Melon" Then
            PictureBox1.BackgroundImage = System.Drawing.Image.FromFile("C:\Users\Student\Downloads\images\download (4).jpg")
        ElseIf ComboBox1.Text = "Mango" Then
            PictureBox1.BackgroundImage = System.Drawing.Image.FromFile("C:\Users\Student\Downloads\images\download (3).jpg")
        ElseIf ComboBox1.Text = "langka" Then
            PictureBox1.BackgroundImage = System.Drawing.Image.FromFile("C:\Users\Student\Downloads\images\download (6).jpg")
        ElseIf ComboBox1.Text = "Duhat" Then
            PictureBox1.BackgroundImage = System.Drawing.Image.FromFile("C:\Users\Student\Downloads\images\download (2).jpg")
        End If
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        MessageBox.Show(" You Ordered'" & ComboBox1.Text & "'")

    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        display()

    End Sub

    Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click

    End Sub

End Class






FORM 6

Imports System.Data.SqlClient
Public Class Form6
    Dim con As SqlConnection = New SqlConnection("Data Source=.\SqlExpress;Initial Catalog=LabExam;Integrated Security=True;Pooling=False")
    Dim cmd As SqlCommand
    Public Sub display()
        Dim abind As New BindingSource
        Dim ds As New DataSet
        Dim da As SqlDataAdapter
        cmd = New SqlCommand("Select * From CUSTOMERtbl", con)
        con.Open()
        da = New SqlDataAdapter(cmd)
        da.Fill(ds)
        abind.DataSource = ds.Tables(0)
        DataGridView1.DataSource = abind
        da.Update(ds)
        con.Close()
    End Sub

    Private Sub Form6_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        display()

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        cmd = New SqlCommand("insert into CUSTOMERtbl values('" & TextBox2.Text & " ','" & TextBox3.Text & "')", con)
        con.Open()
        cmd.ExecuteNonQuery()
        con.Close()

        MessageBox.Show("successfully added", "adding information", MessageBoxButtons.OK, MessageBoxIcon.Information)
        display()
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        cmd = New SqlCommand("delete from CUSTOMERtbl where CustomerID='" & TextBox2.Text & "'", con)
        con.Open()
        cmd.ExecuteNonQuery()
        con.Close()

        MessageBox.Show("Successfully deleted", "delete Information", MessageBoxButtons.OK, MessageBoxIcon.Information)
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        cmd = New SqlCommand("Update CUSTOMERtbl set CustomerName='" & TextBox2.Text & "'CustomerAddress='" & TextBox3.Text & "' where OrdersID='" & TextBox1.Text & "'", con)
        con.Open()
        cmd.ExecuteNonQuery()
        con.Close()
        MessageBox.Show("Successfully Updated", "Update Information", MessageBoxButtons.OK, MessageBoxIcon.Information)
        display()
    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        Form3.Show()
        Me.Hide()
    End Sub

    Private Sub TextBox4_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox4.TextChanged

    End Sub

    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        Dim ds As New DataSet
        Dim da As SqlDataAdapter
        cmd = New SqlCommand("select*FROM CUSTOMERtbl where CustomerName like'%" & TextBox4.Text & "%'", con)
        con.Open()
        da = New SqlDataAdapter(cmd)
        da.Fill(ds)
        DataGridView1.DataSource = ds.Tables(0)
        con.Close()
    End Sub

    Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
        Form2.Show()
        Me.Hide()
    End Sub
End Class







SPLASH SCREEN


Public NotInheritable Class SplashScreen1

    'TODO: This form can easily be set as the splash screen for the application by going to the "Application" tab
    '  of the Project Designer ("Properties" under the "Project" menu).


    Private Sub SplashScreen1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        'Set up the dialog text at runtime according to the application's assembly information.

        'TODO: Customize the application's assembly information in the "Application" pane of the project
        '  properties dialog (under the "Project" menu).

        'Application title
        'If My.Application.Info.Title <> "" Then
        '    ApplicationTitle.Text = My.Application.Info.Title
        'Else
        '    'If the application title is missing, use the application name, without the extension
        '    ApplicationTitle.Text = System.IO.Path.GetFileNameWithoutExtension(My.Application.Info.AssemblyName)
        'End If

        ''Format the version information using the text set into the Version control at design time as the
        ''  formatting string.  This allows for effective localization if desired.
        ''  Build and revision information could be included by using the following code and changing the
        ''  Version control's designtime text to "Version {0}.{1:00}.{2}.{3}" or something similar.  See
        ''  String.Format() in Help for more information.
        ''
        ''    Version.Text = System.String.Format(Version.Text, My.Application.Info.Version.Major, My.Application.Info.Version.Minor, My.Application.Info.Version.Build, My.Application.Info.Version.Revision)

        'Version.Text = System.String.Format(Version.Text, My.Application.Info.Version.Major, My.Application.Info.Version.Minor)

        ''Copyright info
        'Copyright.Text = My.Application.Info.Copyright
    End Sub

    Private Sub MainLayoutPanel_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MainLayoutPanel.Paint

    End Sub

    Private Sub ApplicationTitle_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ApplicationTitle.Click
        Form2.Show()
        Me.Hide()


    End Sub
End Class



No comments: