Quote:
Public Sub ScholarshipLoad()
'Dim txtResult As New TextBox()
Dim strSelected As String = lstApplicant.Items(lstApplicant.SelectedIndex).ToString()
Dim plcHolder, strStanding, strSndStanding As String
Dim strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & mdbPath
Dim strSQL As String = "SELECT * FROM Scholarship WHERE Scholarship.Scholarship=" & "'" & strSelected & "'"
Dim shlDataAdapter As New OleDbDataAdapter(strSQL, strConn)
shlDataAdapter.TableMappings.Add("Table", "Scholarship")
Dim schlDataSet As New DataSet()
shlDataAdapter.Fill(schlDataSet)
Dim schlRow As DataRow
Dim intScholarAmount As Integer
Dim tblScholar As DataTable = schlDataSet.Tables(0)
For Each schlRow In tblScholar.Rows
strStanding = schlRow("Standing")
strSndStanding = schlRow("sndstanding")
If strStanding = "N" Then
strStanding = "Not Require"
End If
If strSndStanding = "N" Then
strSndStanding = "Not Require"
ElseIf strSndStanding = "Above" Then
strSndStanding = "Senior"
End If
If IsDBNull(schlRow("AmntAwarded")) = False Then
intScholarshipAmount = CInt(schlRow("AmntAwarded"))
intScholarAmount = CInt(schlRow("Amount")) - CInt(schlRow("AmntAwarded"))
Else
intScholarAmount = schlRow("Amount")
End If
plcHolder = "Require GPA: " & schlRow("GPA") & vbCrLf & "Require Major: " & schlRow("Major") & vbCrLf & "Must be: " & _
strStanding & " to: " & strSndStanding & vbCrLf & "Total Amount: $" & intScholarAmount
Next schlRow
mtplResult(plcHolder)
End Sub
Public Sub mtplResult(ByRef plcHolder As String)
Dim txtResult As New TextBox()
Dim txtAward As New TextBox()
Dim lblAmount As New Label()
Dim strTextBoxInc As String
Dim strTextBoxResult As String
x = 8
n += 1
If blnSchlTF = True And blnQlfy = False Then
h = 60 'from 50 to 60
x = 8
y = 8
strTextBoxResult = "txtBoxScholarship"
ElseIf blnSchlTF = True And blnQlfy = True Then
If h = 60 AndAlso y = 8 Then
h = 165
x = 8
y = 90 'from 80 to 90
Else
y += 175
End If
strTextBoxResult = "txtQualifiedApplicant"
End If
pnlAppResult.SuspendLayout()
With txtResult
.Name = strTextBoxResult
.Width = 264
.Height = h
.AllowDrop = True
.Location = New Point(x, y)
.AutoSize = True
.Multiline = True
.ScrollBars = ScrollBars.Vertical
.Text = plcHolder
.BackColor = System.Drawing.Color.White
.ReadOnly = True
.Visible = True
.Show()
End With
AddHandler txtResult.DragEnter, AddressOf txtResult_DragEnter
AddHandler txtResult.DragDrop, AddressOf txtResult_DragDrop
pnlAppResult.Controls.Add(txtResult)
pnlAppResult.ResumeLayout(True)
End Sub
And here is the routine for updating and calling the ScholarshipLoad() to re-display the textbox.name = "txtBoxScholarship" again and refresh this textbox.
Quote:
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
Thanks for trying to help!