|
-
Apr 7th, 2009, 10:50 AM
#1
Thread Starter
Frenzied Member
Re: SelectedIndexChanged
Hallo,
I have a combobox called CmbPaymethod which is built up of 2 fields either BACS or Cheque. Therefore when a user selects either on the form the respective oracle number in textbox called TxtOracleNo changes to reflect that payment method. For example for a specific practice the payment method for BACS = 32 and Cheque = 40. Note: Each practice have unique oracle number.
Now, if a payment method is not available in the database there wont be an oracle number for it. I have this code below which changes when ever BACS /Cheque is selected by reading the Oracle_no from the table.
Dim cmd As New SqlCommand
Dim conn As SqlConnection = GetDbConnection()
Try
Dim Oracle_num As New System.Data.SqlClient.SqlCommand(("SELECT Oracle_no FROM gprdsql.TblOracleNos WHERE Prac_no='" & _
Me.TxtPracNo.Text & "' and Prac_eid = '" & _
Me.TxtPracEid.Text & "' and Pay_method = '" & _
Me.CmbPayMethod.Text & "' "), conn)
Using reader As System.Data.SqlClient.SqlDataReader = Oracle_num.ExecuteReader()
While reader.Read()
Dim Oracle_no As String = FixNull(reader.GetValue(0))
TxtOracleNo.Text = Oracle_no
TextBox6.Text = Oracle_no
End While
End Using
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Information, "GCPM")
End Try
What I want to do now is, when Payment method is selected (i.e., either BACS or Cheque and the oracle number is not available and hence TxtOracleNo.Text doesn't change a msgbox pops saying,
MsgBox("No Oracle number for this Payment Method. Enter Oracle number.", MsgBoxStyle.Information, "GCPM")
Thanks for your help
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|