02-11-23, 12:28 PM
مرحباً بالجميع، هذا الموقع يبيع الوجبات للطلاب. ويشترط على الطالب إبراز بطاقته الجامعية أو بطاقة الهوية لشراء الوجبة. أريد من الطالب ألا يشتري الوجبة بشكل متكرر لأنه لديه البطاقة الجامعية وبطاقة الهوية والرقمين مختلفين. أريد البحث بالاسم إذا كان الاسم موجود في قاعدة البيانات وقت الوجبة فلن يتكرر إذا كان مع الرقم الجامعي أو رقم الهوية
هذا الكود .......
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim aid = Trim(txtUserName.Text)
Dim Connection As New SqlConnection()
If Trim(txtUserName.Text) = "111" Then
Dim adapter As New SqlDataAdapter("SELECT Aid, sname, location from student where ltrim(rtrim(aid))='" & Trim(txtUserName.Text) & "'", Connection)
Dim ds As New DataSet()
adapter.Fill(ds, "head")
Label6.Text = ds.Tables("head").Rows(0).Item("sname") & "(" & ds.Tables("head").Rows(0).Item("Aid") & ")"
Label9.Text = ds.Tables("head").Rows(0).Item("location")
Label10.Text = "STATUS : " & Label9.Text
stype = ds.Tables("head").Rows(0).Item("location")
Textbox5.Text = ds.Tables("head").Rows(0).Item("location")
Label10.BackColor = Drawing.Color.White
Label10.ForeColor = Drawing.Color.Green
Label5.Visible = True
Label6.Visible = True
Label7.Visible = True
Label8.Visible = True
Label9.Visible = True
Label10.Visible = True
Label14.Visible = True
Label15.Visible = True
Label16.Visible = True
'Textbox4.Visible = True
'Textbox10.Visible = True
Textbox11.Visible = True
'Textbox12.Visible = True
BindCheck()
Else
'BindCheck()
ServicePointManager.ServerCertificateValidationCallback = AddressOf RemoteCertificateValidate
Dim StudentOutputData As New BarCodeApps.ServiceReference1.Student2Data
Dim StudentInputData As New BarCodeApps.ServiceReference1.UserInput
Dim StudentSSOClient As New BarCodeApps.ServiceReference1.StudentsServiceClient
'StudentInputData.StudentId = aid
StudentInputData.NationalId = aid
StudentInputData.ConsumerApplication = "BarCodeApps"
'StudentOutputData = StudentSSOClient.GetStudent2Info(StudentInputData)
If StudentOutputData.IsDataFound = False Then
StudentInputData.StudentId = aid
StudentInputData.NationalId = Nothing
'StudentOutputData = StudentSSOClient.GetStudent2Info(StudentInputData)
End If
Fname = StudentOutputData.FIRST_NAME_ENG
MNAME = StudentOutputData.MIDDLE_NAME_ENG
lNAME = StudentOutputData.LAST_NAME_ENG
Label6.Text = Fname & " " & MNAME & " " & lNAME & "(" & StudentOutputData.STUDENT_ID & ")"
Textbox9.Text = Fname & " " & MNAME & " " & lNAME
' Label7.Text = StudentOutputData.STUDENT_ID
Label9.Text = StudentOutputData.DEPARTMENT_NAME & " " & StudentOutputData.DEPARTMENT_NAME_ENG
Label10.Text = "STATUS : " & StudentOutputData.STATUS_DESC
scode = StudentOutputData.STATUS_CODE
Label13.Text = StudentOutputData.DEPARTMENT_NAME
Label11.Text = StudentOutputData.STATUS_DESC
Label12.Text = StudentOutputData.STATUS_CODE
stype = "KSU Student"
Textbox5.Text = "KSU Student"
Textbox6.Text = StudentOutputData.STATUS_CODE
' Else
' GoTo Line313
' End If
If CStr(Textbox6.Text) = "" Then
Textbox6.Text = 99
End If
lblOutput.Visible = True
Label5.Visible = True
Label6.Visible = True
'Label7.Visible = True
Label8.Visible = True
Label9.Visible = True
Label10.Visible = True
'Label14.Visible = True
'Label15.Visible = True
'Label16.Visible = True
'Textbox4.Visible = True
'Textbox10.Visible = True
'Textbox11.Visible = True
'Textbox12.Visible = True
If scode = "1" Then
'If scode = "1" Or scode = "7" Then
BindBlockStudent()
Label10.BackColor = Drawing.Color.White
Label10.ForeColor = Drawing.Color.Green
image2.Visible = True
Label10.Text = "STATUS : " & StudentOutputData.STATUS_DESC
Textbox8.Text = "Normal"
' ElseIf CStr(Textbox6.Text) <> "1" And CStr(Textbox6.Text) <> "7" And CStr(Textbox6.Text) <> "99" Then
ElseIf CStr(Textbox6.Text) <> "1" And CStr(Textbox6.Text) <> "99" Then
Label10.ForeColor = Drawing.Color.Red
Label10.BackColor = Drawing.Color.Yellow
Label10.Text = "STATUS : " & StudentOutputData.STATUS_DESC
ElseIf CStr(Textbox6.Text) = "99" Then
Label10.Text = "STATUS : " & "Student Not Registered in KSU List..!"
Line313:
Dim cmdAddType As SqlCommand = New SqlCommand("chkID", conn)
cmdAddType.CommandType = CommandType.StoredProcedure
cmdAddType.Parameters.Add(New SqlParameter("@IDNO", SqlDbType.NVarChar, 255))
'cmdAddType.Parameters.Add(New SqlParameter("@sname", SqlDbType.NVarChar, 255))
Dim OParm As SqlParameter = cmdAddType.Parameters.Add("@OReturn", SqlDbType.Int)
OParm.Direction = ParameterDirection.Output
cmdAddType.Parameters("@IDNO").Value = Trim(txtUserName.Text)
'cmdAddType.Parameters("@sname").Value = Trim(txtUserName.Text)
conn.Open()
cmdAddType.ExecuteNonQuery()
conn.Close()
Dim OReturn As String = cmdAddType.Parameters("@OReturn").Value.ToString
If CStr(OReturn) = "1" Then
Dim adapter As New SqlDataAdapter("SELECT Aid, sname,building, location,mealtype from student where ltrim(rtrim(aid))='" & Trim(txtUserName.Text) & "' and starttime <getdate() and="" endtime=""> GETDATE()", Connection)
'and (CONVERT(varchar, STARTTIME, 113) < CONVERT(varchar, GETDATE(), 113)) AND (CONVERT(varchar, ENDTIME, 113) > CONVERT(varchar, GETDATE(),113))
Dim ds As New DataSet()
adapter.Fill(ds, "head")
If ds.Tables("head").Rows.Count <> 0 Then
Label6.Text = ds.Tables("head").Rows(0).Item("sname") & "(" & ds.Tables("head").Rows(0).Item("Aid") & ")"
Textbox9.Text = ds.Tables("head").Rows(0).Item("sname")
Label9.Text = ds.Tables("head").Rows(0).Item("building")
Label10.Text = "STATUS : " & Label9.Text
'stype = "NON-KSU Student"
'Textbox5.Text = "NON-KSU Student"
stype = ds.Tables("head").Rows(0).Item("location")
Textbox5.Text = ds.Tables("head").Rows(0).Item("location")
Textbox8.Text = ds.Tables("head").Rows(0).Item("mealtype")
Textbox6.Text = 2
BindBlockStudent()
Label10.BackColor = Drawing.Color.White
Label10.ForeColor = Drawing.Color.Green
image2.Visible = True
Else
Label10.Text = "STATUS : " & "Student Meal Time Expired/Not Available..!"
Label10.BackColor = Drawing.Color.Yellow
Label10.ForeColor = Drawing.Color.Red
End If
ElseIf CStr(OReturn) = "3" Then
Dim adapter As New SqlDataAdapter("SELECT Aid, sname,building, location,mealtype from student where ltrim(rtrim(aid))='" & Trim(txtUserName.Text) & "' and mobile is not null", conn)
'and (CONVERT(varchar, STARTTIME, 113) < CONVERT(varchar, GETDATE(), 113)) AND (CONVERT(varchar, ENDTIME, 113) > CONVERT(varchar, GETDATE(),113))
Dim ds As New DataSet()
adapter.Fill(ds, "head")
If ds.Tables("head").Rows.Count <> 0 Then
Label6.Text = ds.Tables("head").Rows(0).Item("sname") & "(" & ds.Tables("head").Rows(0).Item("Aid") & ")"
Textbox9.Text = ds.Tables("head").Rows(0).Item("sname")
Label9.Text = ds.Tables("head").Rows(0).Item("building")
Label10.Text = "STATUS : " & Label9.Text
stype = "KSU Student"
Textbox5.Text = "KSU Student"
Textbox8.Text = ds.Tables("head").Rows(0).Item("mealtype")
Textbox6.Text = 2
BindBlockStudent()
Label10.BackColor = Drawing.Color.White
Label10.ForeColor = Drawing.Color.Green
image2.Visible = True
End If
Else
Label10.Text = "STATUS : " & "Student Not Registered in KSU & Non KSU List..!" & "*" & StudentOutputData.STATUS_DESC & "*" & StudentOutputData.STATUS_CODE
Label10.BackColor = Drawing.Color.Yellow
Label10.ForeColor = Drawing.Color.Red
'Response.Write("")
'Response.Write("window.open('AddStudent.aspx?prompt0=" & Trim(txtUserName.Text) & "','AddStudent','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=820,height=620')" & vbCrLf)
'Response.Write("")
'Response.Write("")
'Response.Write("alert('Student Status is Inactive... ')")
'Response.Write("")
End If
End If
End If
End Sub
هذا الكود .......
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim aid = Trim(txtUserName.Text)
Dim Connection As New SqlConnection()
If Trim(txtUserName.Text) = "111" Then
Dim adapter As New SqlDataAdapter("SELECT Aid, sname, location from student where ltrim(rtrim(aid))='" & Trim(txtUserName.Text) & "'", Connection)
Dim ds As New DataSet()
adapter.Fill(ds, "head")
Label6.Text = ds.Tables("head").Rows(0).Item("sname") & "(" & ds.Tables("head").Rows(0).Item("Aid") & ")"
Label9.Text = ds.Tables("head").Rows(0).Item("location")
Label10.Text = "STATUS : " & Label9.Text
stype = ds.Tables("head").Rows(0).Item("location")
Textbox5.Text = ds.Tables("head").Rows(0).Item("location")
Label10.BackColor = Drawing.Color.White
Label10.ForeColor = Drawing.Color.Green
Label5.Visible = True
Label6.Visible = True
Label7.Visible = True
Label8.Visible = True
Label9.Visible = True
Label10.Visible = True
Label14.Visible = True
Label15.Visible = True
Label16.Visible = True
'Textbox4.Visible = True
'Textbox10.Visible = True
Textbox11.Visible = True
'Textbox12.Visible = True
BindCheck()
Else
'BindCheck()
ServicePointManager.ServerCertificateValidationCallback = AddressOf RemoteCertificateValidate
Dim StudentOutputData As New BarCodeApps.ServiceReference1.Student2Data
Dim StudentInputData As New BarCodeApps.ServiceReference1.UserInput
Dim StudentSSOClient As New BarCodeApps.ServiceReference1.StudentsServiceClient
'StudentInputData.StudentId = aid
StudentInputData.NationalId = aid
StudentInputData.ConsumerApplication = "BarCodeApps"
'StudentOutputData = StudentSSOClient.GetStudent2Info(StudentInputData)
If StudentOutputData.IsDataFound = False Then
StudentInputData.StudentId = aid
StudentInputData.NationalId = Nothing
'StudentOutputData = StudentSSOClient.GetStudent2Info(StudentInputData)
End If
Fname = StudentOutputData.FIRST_NAME_ENG
MNAME = StudentOutputData.MIDDLE_NAME_ENG
lNAME = StudentOutputData.LAST_NAME_ENG
Label6.Text = Fname & " " & MNAME & " " & lNAME & "(" & StudentOutputData.STUDENT_ID & ")"
Textbox9.Text = Fname & " " & MNAME & " " & lNAME
' Label7.Text = StudentOutputData.STUDENT_ID
Label9.Text = StudentOutputData.DEPARTMENT_NAME & " " & StudentOutputData.DEPARTMENT_NAME_ENG
Label10.Text = "STATUS : " & StudentOutputData.STATUS_DESC
scode = StudentOutputData.STATUS_CODE
Label13.Text = StudentOutputData.DEPARTMENT_NAME
Label11.Text = StudentOutputData.STATUS_DESC
Label12.Text = StudentOutputData.STATUS_CODE
stype = "KSU Student"
Textbox5.Text = "KSU Student"
Textbox6.Text = StudentOutputData.STATUS_CODE
' Else
' GoTo Line313
' End If
If CStr(Textbox6.Text) = "" Then
Textbox6.Text = 99
End If
lblOutput.Visible = True
Label5.Visible = True
Label6.Visible = True
'Label7.Visible = True
Label8.Visible = True
Label9.Visible = True
Label10.Visible = True
'Label14.Visible = True
'Label15.Visible = True
'Label16.Visible = True
'Textbox4.Visible = True
'Textbox10.Visible = True
'Textbox11.Visible = True
'Textbox12.Visible = True
If scode = "1" Then
'If scode = "1" Or scode = "7" Then
BindBlockStudent()
Label10.BackColor = Drawing.Color.White
Label10.ForeColor = Drawing.Color.Green
image2.Visible = True
Label10.Text = "STATUS : " & StudentOutputData.STATUS_DESC
Textbox8.Text = "Normal"
' ElseIf CStr(Textbox6.Text) <> "1" And CStr(Textbox6.Text) <> "7" And CStr(Textbox6.Text) <> "99" Then
ElseIf CStr(Textbox6.Text) <> "1" And CStr(Textbox6.Text) <> "99" Then
Label10.ForeColor = Drawing.Color.Red
Label10.BackColor = Drawing.Color.Yellow
Label10.Text = "STATUS : " & StudentOutputData.STATUS_DESC
ElseIf CStr(Textbox6.Text) = "99" Then
Label10.Text = "STATUS : " & "Student Not Registered in KSU List..!"
Line313:
Dim cmdAddType As SqlCommand = New SqlCommand("chkID", conn)
cmdAddType.CommandType = CommandType.StoredProcedure
cmdAddType.Parameters.Add(New SqlParameter("@IDNO", SqlDbType.NVarChar, 255))
'cmdAddType.Parameters.Add(New SqlParameter("@sname", SqlDbType.NVarChar, 255))
Dim OParm As SqlParameter = cmdAddType.Parameters.Add("@OReturn", SqlDbType.Int)
OParm.Direction = ParameterDirection.Output
cmdAddType.Parameters("@IDNO").Value = Trim(txtUserName.Text)
'cmdAddType.Parameters("@sname").Value = Trim(txtUserName.Text)
conn.Open()
cmdAddType.ExecuteNonQuery()
conn.Close()
Dim OReturn As String = cmdAddType.Parameters("@OReturn").Value.ToString
If CStr(OReturn) = "1" Then
Dim adapter As New SqlDataAdapter("SELECT Aid, sname,building, location,mealtype from student where ltrim(rtrim(aid))='" & Trim(txtUserName.Text) & "' and starttime <getdate() and="" endtime=""> GETDATE()", Connection)
'and (CONVERT(varchar, STARTTIME, 113) < CONVERT(varchar, GETDATE(), 113)) AND (CONVERT(varchar, ENDTIME, 113) > CONVERT(varchar, GETDATE(),113))
Dim ds As New DataSet()
adapter.Fill(ds, "head")
If ds.Tables("head").Rows.Count <> 0 Then
Label6.Text = ds.Tables("head").Rows(0).Item("sname") & "(" & ds.Tables("head").Rows(0).Item("Aid") & ")"
Textbox9.Text = ds.Tables("head").Rows(0).Item("sname")
Label9.Text = ds.Tables("head").Rows(0).Item("building")
Label10.Text = "STATUS : " & Label9.Text
'stype = "NON-KSU Student"
'Textbox5.Text = "NON-KSU Student"
stype = ds.Tables("head").Rows(0).Item("location")
Textbox5.Text = ds.Tables("head").Rows(0).Item("location")
Textbox8.Text = ds.Tables("head").Rows(0).Item("mealtype")
Textbox6.Text = 2
BindBlockStudent()
Label10.BackColor = Drawing.Color.White
Label10.ForeColor = Drawing.Color.Green
image2.Visible = True
Else
Label10.Text = "STATUS : " & "Student Meal Time Expired/Not Available..!"
Label10.BackColor = Drawing.Color.Yellow
Label10.ForeColor = Drawing.Color.Red
End If
ElseIf CStr(OReturn) = "3" Then
Dim adapter As New SqlDataAdapter("SELECT Aid, sname,building, location,mealtype from student where ltrim(rtrim(aid))='" & Trim(txtUserName.Text) & "' and mobile is not null", conn)
'and (CONVERT(varchar, STARTTIME, 113) < CONVERT(varchar, GETDATE(), 113)) AND (CONVERT(varchar, ENDTIME, 113) > CONVERT(varchar, GETDATE(),113))
Dim ds As New DataSet()
adapter.Fill(ds, "head")
If ds.Tables("head").Rows.Count <> 0 Then
Label6.Text = ds.Tables("head").Rows(0).Item("sname") & "(" & ds.Tables("head").Rows(0).Item("Aid") & ")"
Textbox9.Text = ds.Tables("head").Rows(0).Item("sname")
Label9.Text = ds.Tables("head").Rows(0).Item("building")
Label10.Text = "STATUS : " & Label9.Text
stype = "KSU Student"
Textbox5.Text = "KSU Student"
Textbox8.Text = ds.Tables("head").Rows(0).Item("mealtype")
Textbox6.Text = 2
BindBlockStudent()
Label10.BackColor = Drawing.Color.White
Label10.ForeColor = Drawing.Color.Green
image2.Visible = True
End If
Else
Label10.Text = "STATUS : " & "Student Not Registered in KSU & Non KSU List..!" & "*" & StudentOutputData.STATUS_DESC & "*" & StudentOutputData.STATUS_CODE
Label10.BackColor = Drawing.Color.Yellow
Label10.ForeColor = Drawing.Color.Red
'Response.Write("")
'Response.Write("window.open('AddStudent.aspx?prompt0=" & Trim(txtUserName.Text) & "','AddStudent','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=820,height=620')" & vbCrLf)
'Response.Write("")
'Response.Write("")
'Response.Write("alert('Student Status is Inactive... ')")
'Response.Write("")
End If
End If
End If
End Sub