تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
عدم تكرار الاسم
#1
مرحباً بالجميع، هذا الموقع يبيع الوجبات للطلاب. ويشترط على الطالب إبراز بطاقته الجامعية أو بطاقة الهوية لشراء الوجبة. أريد من الطالب ألا يشتري الوجبة بشكل متكرر لأنه لديه البطاقة الجامعية وبطاقة الهوية والرقمين مختلفين. أريد البحث بالاسم إذا كان الاسم موجود في قاعدة البيانات وقت الوجبة فلن يتكرر إذا كان مع الرقم الجامعي أو رقم الهوية

هذا الكود .......

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
الرد }}}
تم الشكر بواسطة:


المواضيع المحتمل أن تكون متشابهة .
الموضوع : الكاتب الردود : المشاهدات : آخر رد
  معرفة عدد مرات تكرار الاسم في الداتاقريدفيو صالح عبدالله 8 473 05-02-24, 04:39 PM
آخر رد: صالح عبدالله
  [VB.NET] منع تكرار البيانات في عند الادخال مبرمج صغير 1 2 314 24-01-24, 05:18 PM
آخر رد: مبرمج صغير 1
  كود لعدم تكرار الرقم في قاعدة البيانات yossefsaad370 1 366 28-10-23, 10:29 AM
آخر رد: atefkhalf2004
  تكرار الرقم القومى salah525 1 290 02-10-23, 10:14 PM
آخر رد: سالم العنزي
Rainbow مشكلة تكرار القيم في الكريستال ريبورت devpos 1 368 07-09-23, 11:48 PM
آخر رد: Asem2
  منع تكرار البيانات المدخلة على قاعدة البيانات الرائد 14 7,248 18-08-23, 08:10 PM
آخر رد: ahmed_king2023
  مساعدة في تكرار صفحات الطبع Reportview نيمو 0 421 20-06-23, 09:14 PM
آخر رد: نيمو
  تكرار البيانات من زر تعديل البيانات ( في البيانات المحفوظة ) خليل احمد المراني 8 1,006 26-05-23, 11:00 PM
آخر رد: خليل احمد المراني
  في الداتا جريد فيو تجميع الاسم الاول والثاني والثالث yosif 2 396 16-04-23, 07:08 AM
آخر رد: yosif
  تقسيم الاسم الكامل الى اجزاء في الداتا جريد فيو yosif 4 538 13-04-23, 11:15 PM
آخر رد: yosif

التنقل السريع :


يقوم بقرائة الموضوع: بالاضافة الى ( 1 ) ضيف كريم