Imports System.Data.SqlClient
Public Class frmCustomerRequirement
Dim con As New SqlConnection
Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
If CheckBox1.Checked = True Then
TextBox2.Enabled = True
Else
TextBox2.Enabled = False
End If
End Sub
Private Sub CheckBox2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox2.CheckedChanged
If CheckBox2.Checked = True Then
TextBox3.Enabled = True
Else
TextBox3.Enabled = False
End If
End Sub
Private Sub CheckBox3_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox3.CheckedChanged
If CheckBox3.Checked = True Then
TextBox4.Enabled = True
Else
TextBox4.Enabled = False
End If
End Sub
Private Sub CheckBox4_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox4.CheckedChanged
If CheckBox4.Checked = True Then
TextBox5.Enabled = True
Else
TextBox5.Enabled = False
End If
End Sub
Private Sub CheckBox5_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox5.CheckedChanged
If CheckBox5.Checked = True Then
TextBox6.Enabled = True
Else
TextBox6.Enabled = False
End If
End Sub
Private Sub CheckBox6_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox6.CheckedChanged
If CheckBox6.Checked = True Then
TextBox7.Enabled = True
Else
TextBox7.Enabled = False
End If
End Sub
Private Sub CheckBox7_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox7.CheckedChanged
If CheckBox7.Checked = True Then
TextBox8.Enabled = True
Else
TextBox8.Enabled = False
End If
End Sub
Private Sub frmCustomerRequirement_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
con.ConnectionString = "Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Testdb.mdf;Integrated Security=True;User Instance=True"
'for product
Dim abc As String = "SELECT * FROM Productdb "
Dim cmd As New SqlCommand(abc, con)
cmd.CommandType = CommandType.Text
Dim da As New SqlDataAdapter(cmd)
Dim dt As New DataTable
da.Fill(dt)
If dt.Rows.Count = 0 Then
MsgBox("PLEASE SELECT ADMIN", Microsoft.VisualBasic.MsgBoxStyle.Critical, "Eror")
Else
For i = 0 To dt.Rows.Count - 1
ComboBox2.Items.Add(dt.Rows(i).Item("Product_ID"))
Next
End If
'for customer
Dim abc1 As String = "SELECT * FROM Customersdb "
Dim cmd1 As New SqlCommand(abc1, con)
cmd1.CommandType = CommandType.Text
Dim da1 As New SqlDataAdapter(cmd1)
Dim dt1 As New DataTable
da1.Fill(dt1)
If dt1.Rows.Count = 0 Then
MsgBox("PLEASE SELECT ADMIN", Microsoft.VisualBasic.MsgBoxStyle.Critical, "Eror")
Else
For i = 0 To dt1.Rows.Count - 1
ComboBox1.Items.Add(dt1.Rows(i).Item("Customer_ID"))
Next
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub ComboBox2_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox2.SelectedIndexChanged
Try
Dim abc As String = "SELECT Product_Name FROM Productdb Where Product_ID='" + ComboBox2.Text + "'"
Dim cmd As New SqlCommand(abc, con)
con.Open()
Dim dr As SqlDataReader = cmd.ExecuteReader()
If dr.Read() Then
TextBox9.Text = dr(0).ToString()
End If
con.Close()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
Me.Close()
End Sub
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
Try
Dim abc As String = "SELECT Customer_Name FROM Customersdb Where Customer_ID='" + ComboBox1.Text + "'"
Dim cmd As New SqlCommand(abc, con)
con.Open()
Dim dr As SqlDataReader = cmd.ExecuteReader()
If dr.Read() Then
TextBox1.Text = dr(0).ToString()
End If
con.Close()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim ab As String = " INSERT INTO CustomerRequirementdb (Customer_ID,Product_ID,CName,Product_Name,Mon_Copies,Tue_Copies,Wed_Copies,Thur_Copies,Fri_Copies,Sat_Copies,Sun_Copies) VALUES ('" & ComboBox1.Text & "','" & ComboBox2.Text & "','" & TextBox1.Text & "','" & TextBox9.Text & "','" & TextBox2.Text & "','" & TextBox3.Text & "','" & TextBox4.Text & "','" & TextBox5.Text & "','" & TextBox6.Text & "','" & TextBox7.Text & "','" & TextBox8.Text & "');"
Dim db As New SqlDataAdapter(ab, con)
Dim dc As New DataSet
db.Fill(dc)
MsgBox("Record updated")
End Sub
End Class