I don't like to admit it but I am building a vb.net winform that requires the use of reading text fields, check boxes or radio buttons to build a sql query and return results. the sql query part works fantastically however the select case statements don't seem to be evaluating the checkbox or radio checkstate correctly.
Select Case True
Case txtFirstName.Text.Length > 0 & chkActive.CheckState
dgvEmployees.DataSource = employess.FindEmployee(txtFirstName.Text)
dgvEmployees.Visible = True
Case txtFirstName.Text.Length > 0 & chkActive.CheckState
dgvEmployees.DataSource = employess.FindEmployee(txtFirstName.Text, , , "Active")
chkInactive.Enabled = False
dgvEmployees.Visible = True
Case txtFirstName.Text.Length > 0 & chkInactive.CheckState
dgvEmployees.DataSource = employess.FindEmployee(txtFirstName.Text, , , "Inactive")
chkActive.Enabled = False
dgvEmployees.Visible = True
Case txtLastName.Text.Length > 0 & chkActive.CheckState
dgvEmployees.DataSource = employess.FindEmployee(, txtLastName.Text)
dgvEmployees.Visible = True
Case txtLastName.Text.Length > 0 & chkActive.CheckState
dgvEmployees.DataSource = employess.FindEmployee(, txtLastName.Text, , "Active")
chkInactive.Enabled = False
dgvEmployees.Visible = True
Case txtLastName.Text.Length > 0 & chkInactive.CheckState
dgvEmployees.DataSource = employess.FindEmployee(, txtLastName.Text, , "Inactive")
chkActive.Enabled = False
dgvEmployees.Visible = True
Case txtEmpCode.Text.Length > 0 & rdbActive.Checked
dgvEmployees.DataSource = employess.FindEmployee(, , txtEmpCode.Text)
dgvEmployees.Visible = True
Case txtEmpCode.Text.Length > 0 & chkActive.Checked
dgvEmployees.DataSource = employess.FindEmployee(, , txtEmpCode.Text, "Active")
chkInactive.Enabled = False
dgvEmployees.Visible = True
Case txtEmpCode.Text.Length > 0 & chkInactive.CheckState = CheckState.Checked
dgvEmployees.DataSource = employess.FindEmployee(, , txtEmpCode.Text, "Inactive")
chkActive.Enabled = False
dgvEmployees.Visible = True
Case Else
MessageBox.Show("please enter an employee code, firstname or lastname")
End Select
Every time I debug i get an invalid cast exception for the radio button or check box, am I missing something?
Aucun commentaire:
Enregistrer un commentaire