Private Sub txtResult_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles txtResult.DragDrop
popAmount()
Dim strHolder As String
Dim strName As String
Dim strSSNsubstring As String
Dim strSeperator As String
Dim tb As TextBox = CType(sender, TextBox)
Dim strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & mdbPath
Dim strSQL, strSQLInsert As String
Dim rdr As OleDbDataReader
Dim cn As New OleDbConnection(strConn)
Dim cmd As OleDbCommand = cn.CreateCommand()
Dim intAmountLeft As Integer
Dim strSelected As String = lstApplicant.Items(lstApplicant.SelectedIndex).ToString()
strName = tb.Text()
strSSNsubstring = strName.Substring(5, 9)
intSSNnumb = CInt(strSSNsubstring)
strSeperator = "*************************************************"
'strHolder = e.Data.GetData(lstApplicant.Text().GetType.ToString())
strHolder = lstApplicant.Items(lstApplicant.SelectedIndex).ToString()
tb.Text = strName & vbCrLf & strSeperator & vbCrLf & "Awarded: " & strHolder & " scholarship" & _
vbCrLf & "SSN#: " & intSSNnumb & vbCrLf & "Amount Award: $" & strAmount
cn.Open()
strSQL = "SELECT COUNT(*) FROM Awarded WHERE awrdID=" & intSSNnumb
Dim cmdSQL As New OleDbCommand(strSQL, cn)
Try
Dim count As Integer = cmdSQL.ExecuteScalar
If count > 0 Then
'records found so update
cmd.CommandText = "UPDATE Awarded SET awrdName=" & "'" & strHolder & "'" & " awrdAmount =" & strAmount & " WHERE awrdID=" & intSSNnumb
cmd.ExecuteNonQuery()
Else
'records not found so add to database
strSQLInsert = "INSERT INTO Awarded (awrdID, awrdName, awrdAmount) VALUES(" & intSSNnumb & ", '" & strHolder & "', '" & strAmount & "')"
Dim cmdQuery As New OleDbCommand(strSQLInsert, cn)
cmdQuery.ExecuteNonQuery()
End If
intAmountLeft = intScholarshipAmount + CInt(strAmount)
'intAmountLeft = CInt(strAmount)
If intAmountLeft > 0 Then
cmd.CommandText = "UPDATE Scholarship SET AmntAwarded=" & intAmountLeft & " WHERE Scholarship LIKE " & "'" & strSelected & "'"
cmd.ExecuteNonQuery()
'blnSchlTF = True
blnQlfy = False
'txtResult.Clear()
ScholarshipLoad()
blnQlfy = True
End If
Catch dbException As Exception
MessageBox.Show(dbException.Message)
End Try
cn.Close()
End Sub