
Imports System.Data.SqlClient
Public Class frm_100Block
    Dim conn As New SqlConnection(System.Configuration.ConfigurationSettings.AppSettings("SO_Conn"))
    Dim conn1 As New SqlConnection(System.Configuration.ConfigurationSettings.AppSettings("SO_Conn"))
    Dim cmd As SqlCommand = Nothing

    Private Sub frm_100Block_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'Fill_ComboFields(cmb_loccd_1, "SO_FrmqafillCombo")
        Fill_All_ComboBoxes()
    End Sub
    Private Sub Fill_All_ComboBoxes()
        'If cmb_100b_add2.Items.Count = 0 Then
        Fill_ComboFields(cmb_100b_add3, "SO_frmQaGetcombovalue")
        Fill_ComboFields(cmb_100b_add2, "SO_FrmQaADDR_PREFIX_1")
        Fill_ComboFields(cmb_100b_add2_1, "SO_FrmQaADDR_PREFIX_2")
        Fill_ComboFields(cmb_100b_add4_1, "SO_FrmQaADDR_SUFFIX_CD")
        Fill_ComboFields(cmb_100b_add4, "SO_FrmQaSTREET_SUFFIX_CD")

        'Fill_ComboFields(cmb_100b_pipesize, "SO_frmQaGetcombovalue")
        'Fill_ComboFields(cmb_100b_pipekind, "SO_frmQaGetcombovalue")

        Fill_ComboFields(cmb_100b_main2bld_size, "SO_frmQaGetcombovalue")
        Fill_ComboFields(cmb_100b_main2prop_size, "SO_frmQaGetcombovalue")
        Fill_ComboFields(cmb_100b_prop2bldg_size, "SO_frmQaGetcombovalue")
        Fill_ComboFields(cmb_100b_main2bld_type, "SO_frmQaGetcombovalue")
        Fill_ComboFields(cmb_100b_main2prop_type, "SO_frmQaGetcombovalue")
        Fill_ComboFields(cmb_100b_prop2bldg_type, "SO_frmQaGetcombovalue")

        Fill_ComboFields(cmb_100b_tapsize, "SO_frmQaGetcombovalue")
        Fill_ComboFields(cmb_100b_pressure, "SO_frmQaGetcombovalue")
        Fill_ComboFields(cmb_100b_testedto, "SO_frmQaGetcombovalue")

        Fill_ComboFields(cmb_100b_mainsize, "SO_frmQaGetcombovalue")
        Fill_ComboFields(cmb_100b_maintype, "SO_frmQaGetcombovalue")
        
        'End If
    End Sub
    Private Sub Fill_ComboFields(ByVal comboField As ComboBox, ByVal cmdText As String)
        'comboField.Items.Clear()
        cmd = Nothing
        Try
            cmd = New SqlCommand(cmdText, conn1)
            cmd.CommandType = CommandType.StoredProcedure
            If cmdText = "SO_frmQaGetcombovalue" Then
                If comboField.Name = "cmb_100b_city" Or comboField.Name = "cmb_y_city" Or comboField.Name = "cmb_l_city" Or comboField.Name = "cmb_q_city" Or comboField.Name = "cmb_r_city" Or comboField.Name = "cmb_a_city" Or comboField.Name = "cmb_x_city" Or comboField.Name = "cmb_9_city" Or comboField.Name = "cmb_8_city" Or comboField.Name = "cmb_7_city" Or comboField.Name = "cmb_6_city" Or comboField.Name = "cmb_w_city" Or comboField.Name = "cmb_3_city" Or comboField.Name = "cmb_4_city" Or comboField.Name = "cmb_5_city" Then
                    cmd.Parameters.AddWithValue("@stypes", "CITY")
                End If
               
                If comboField.Name = "cmb_100b_main2bld_size" Or comboField.Name = "cmb_100b_main2prop_size" Or comboField.Name = "cmb_100b_prop2main_size" Or comboField.Name = "cmb_100b_mainsize" Or comboField.Name = "cmb_y_mainsize" Or comboField.Name = "cmb_q_mainsize" Or comboField.Name = "cmb_r_mainsize" Or comboField.Name = "cmb_a_mainsize" Or comboField.Name = "cmb_x_mainsize" Or comboField.Name = "cmb_9_mainsize" Or comboField.Name = "cmb_8_mainsize" Or comboField.Name = "cmb_7_mainsize" Or comboField.Name = "cmb_6_mainsize" Or comboField.Name = "cmb_w_mainsize" Or comboField.Name = "cmb_3_mainsize" Or comboField.Name = "cmb_4_mainsize" Then
                    cmd.Parameters.AddWithValue("@stypes", "MAIN SIZE")
                End If
                If comboField.Name = "cmb_100b_main2bld_type" Or comboField.Name = "cmb_100b_main2prop_type" Or comboField.Name = "cmb_100b_prop2main_type" Or comboField.Name = "cmb_100b_maintype" Or comboField.Name = "cmb_y_maintype" Or comboField.Name = "cmb_q_maintype" Or comboField.Name = "cmb_r_maintype" Or comboField.Name = "cmb_a_maintype" Or comboField.Name = "cmb_x_maintype" Or comboField.Name = "cmb_9_maintype" Or comboField.Name = "cmb_8_maintype" Or comboField.Name = "cmb_7_maintype" Or comboField.Name = "cmb_6_maintype" Or comboField.Name = "cmb_w_maintype" Or comboField.Name = "cmb_3_maintype" Or comboField.Name = "cmb_4_maintype" Then
                    cmd.Parameters.AddWithValue("@stypes", "MAIN TYPE")
                End If
               
                If comboField.Name = "cmb_100b_tapsize" Or comboField.Name = "cmb_y_tapzize" Or comboField.Name = "cmb_9_tapzize" Or comboField.Name = "cmb_7_tapzize" Or comboField.Name = "cmb_w_tapzize" Or comboField.Name = "cmb_3_tapzize" Then
                    cmd.Parameters.AddWithValue("@stypes", "TAP SIZE")
                End If
                If comboField.Name = "cmb_100b_pressure" Or comboField.Name = "cmb_y_pressure" Or comboField.Name = "cmb_w_pressure" Or comboField.Name = "cmb_3_pressure" Or comboField.Name = "cmb_4_pressure" Then
                    cmd.Parameters.AddWithValue("@stypes", "PRESSURE")
                End If
                If comboField.Name = "cmb_100b_testedto" Or comboField.Name = "cmb_y_testedto" Or comboField.Name = "cmb_q_testedto" Or comboField.Name = "cmb_r_testedto" Or comboField.Name = "cmb_x_testedto" Or comboField.Name = "cmb_6_testedto" Or comboField.Name = "cmb_w_testedto" Or comboField.Name = "cmb_4_testedto" Then
                    cmd.Parameters.AddWithValue("@stypes", "TESTED TO")
                End If
            End If

            'If cmdText = "SO_FrmQagettownname" Then
            '    Dim house_no As String = ""
            '    Dim ADDR_PREFIX_1 As String = ""
            '    Dim ADDR_PREFIX_2 As String = ""
            '    Dim STREET_NM As String = ""
            '    Dim ADDR_SUFFIX_CD As String = ""
            '    Dim STREET_SUFFIX_CD As String = ""
            '    Dim cities As String = ""

            '    house_no = txt_100b_add.Text
            '    ADDR_PREFIX_1 = cmb_100b_add2.Text
            '    ADDR_PREFIX_2 = cmb_100b_add2_1.Text
            '    STREET_NM = cmb_100b_add3.Text
            '    ADDR_SUFFIX_CD = cmb_100b_add4_1.Text
            '    STREET_SUFFIX_CD = cmb_100b_add4.Text
            '    'cities = txt_div.Text

            '    cmd.Parameters.AddWithValue("@HOUSE_NO", house_no)
            '    cmd.Parameters.AddWithValue("@ADDR_PREFIX_1", ADDR_PREFIX_1)
            '    cmd.Parameters.AddWithValue("@ADDR_PREFIX_2", ADDR_PREFIX_2)
            '    cmd.Parameters.AddWithValue("@STREET_NM", STREET_NM)
            '    cmd.Parameters.AddWithValue("@STREET_SUFFIX_CD", ADDR_SUFFIX_CD)
            '    cmd.Parameters.AddWithValue("@divison", cities)
            'End If
            If (conn1.State = ConnectionState.Closed) Then
                conn1.Open()
            End If
            Dim ds As New DataSet()
            ds.Tables.Clear()
            Dim da As New SqlDataAdapter(cmd)
            da.Fill(ds)
            comboField.DataSource = ds.Tables(0)
            comboField.DisplayMember = "t_values"
            comboField.ValueMember = "t_values"
            comboField.SelectedIndex = -1

        Catch ex As Exception
            MessageBox.Show(ex.Message, Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Stop)
        Finally
            conn1.Close()
            cmd = Nothing
        End Try
    End Sub
End Class
