-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQuizVerification.aspx.cs
More file actions
79 lines (55 loc) · 2.35 KB
/
Copy pathQuizVerification.aspx.cs
File metadata and controls
79 lines (55 loc) · 2.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Web.Security;
namespace QUtopiaProject
{
public partial class QuizVerification : System.Web.UI.Page
{
SqlConnection SQLConn = new SqlConnection("Data Source=DESKTOP-1M38HSH; Initial Catalog=Login; Integrated Security=True");
protected void Page_Load(object sender, EventArgs e)
{
}
protected void VerifyButton_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["dbconnection"].ConnectionString);
con.Open();
//Kullanıcı var mı? Yok mu?
SqlCommand cmd = new SqlCommand("select * from QuizTable where Quiz_ID=@Quiz_ID and Password=@Password", con);
cmd.Parameters.AddWithValue("@Quiz_ID", QVQuizIDTextBox.Text);
cmd.Parameters.AddWithValue("@Password", QVQuizPassTextBox.Text);
//cmd.ExecuteNonQuery();
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);
if (dt.Rows.Count > 0)
{
String QID = QVQuizIDTextBox.Text;
String QuizPass = QVQuizPassTextBox.Text;
Int32 QuizID = Convert.ToInt32(QID);
//Int32 QuizPass = Convert.ToInt32(QPass);
Session.Add("QuizID", QuizID);
Session.Add("QuizPass", QuizPass);
if (QuizID != 0) //ID'ler 0'dan büyük hep
{
SqlCommand cmd1 = new SqlCommand("INSERT INTO TakeTable (User_ID, Quiz_ID, Total_Score) VALUES (@UserID, @QuizID, 0)", con);
cmd1.Parameters.AddWithValue("@UserID", Session["UserID"]);
cmd1.Parameters.AddWithValue("@QuizID", Session["QuizID"]);
cmd1.ExecuteNonQuery();
Response.Redirect("~/TakeTheQuiz.aspx");
}
//else Label1.Text = "olmadı";
}//if sonu
}
protected void Button1_Click(object sender, EventArgs e)
{
Response.Redirect("~/Profile.aspx");
}
}
}