السلام عليكم و رحمة الله
انا عندي كنترول ريتينق
وعندي جدول ابي اخزن فيه عدد النجوم اللي اختارها اليوزر كتقييم للموضوع
الموضوع هو LOID
LOID + UserID= primary key
فهذا معناته مايسمح لليوزر يقيم الموضوع اكثر من مره
المشكله لما يكون اليوزر ماقيم الموضوع يطلع له مسج "عفوا..لقد قمت بالتقييم مسبقا"
وفي نفس الوقت يخزن القيمه في الداتا بيس
وانا ابيه يطلع له مسج" شكرا لمشاركتك معنا في التقييم"
انا مو عارفه ليش اذا تنفذت الكويري يدخل في هذي الـ if
If (myTransaction.Equals(Nothing) = False)
هو قاعد يدخل فيها سواء تنفذت الكويري او ماتنفذت
مع انه المفروض مايدخل فيها الا في حال ان الكويري ماتنفذت
اليكم الكود
Protected Sub Rating1_Changed(ByVal sender As Object, ByVal e As AjaxControlToolkit.RatingEventArgs) Handles Rating1.Changed
Dim user As MembershipUser = Membership.GetUser
Dim LO As String = CType(FormView1.FindControl("LOIDLabel"), Label).Text
Dim myConnection As SqlConnection
Dim myTransaction As SqlTransaction = Nothing
Dim test As Boolean = True
Dim cmd As String = "INSERT INTO Rating(UserId,LOID,NoStars) Values (@UserID, @LOID,@NoStars)"
Try
myConnection = New SqlConnection(ConfigurationManager.ConnectionStrings("DBConnectionString1").ToString())
myConnection.Open()
myTransaction = myConnection.BeginTransaction()
Dim myCommand As SqlCommand = New SqlCommand(cmd, myConnection, myTransaction)
myCommand.Parameters.AddWithValue("UserId", user.ProviderUserKey.ToString())
myCommand.Parameters.AddWithValue("LOID", LO)
myCommand.Parameters.AddWithValue("NoStars", Rating1.CurrentRating)
myCommand.ExecuteNonQuery()
myTransaction.Commit()
Catch ex As Exception
If (myTransaction.Equals(Nothing) = False) Then
myTransaction.Rollback()
If Not (My.User.IsAuthenticated) Then
Rating1.ReadOnly = True
labelValue1.Text = "عفواً..لم تقم بتسجيل الدخول"
test = False
Else
Rating1.ReadOnly = True
labelValue1.Text = "عفواً..لقد قمت بالتقييم مسبقاً"
test = False
End If
End If
Finally
myConnection.Dispose()
End Try
If (test = True) Then
Rating1.ReadOnly = True
labelValue1.Text = "شكرا..لمشاركتك في التقييم"
End If
End Sub