-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlists.aspx.cs
83 lines (78 loc) · 2.74 KB
/
lists.aspx.cs
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
80
81
82
83
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace ASPWebApplication
{
public partial class WebForm1 : System.Web.UI.Page
{
static string connectName = "MS:SQL2019 Bağlantısı"; //web.config dosyasında yer alan bağlantıya atanmış isim/name
static SqlConnection connect = new SqlConnection(ConfigurationManager.ConnectionStrings[connectName].ConnectionString);
static string query;
protected void Page_Load(object sender, EventArgs e)
{
if (Session["SessionID"] != null)
{
if (!IsPostBack)
{
Clear();
}
}
else
{
login login = new login();
login.target = "lists.aspx";
Response.Redirect("login.aspx");
}
}
void Clear()
{
//ID.Text = "";
UserID.Text = "";
Password.Text = "";
EMail.Text = "";
Name.Text = "";
Surname.Text = "";
regSex.SelectedValue = null;
Phone.Text = "";
}
protected void ListsButton_Click(object sender, EventArgs e)
{
Clear();
if (ID.Text != "")
{
query = "SELECT * FROM DBO_TestTable WHERE ID=@ID";
SqlCommand command = new SqlCommand(query, connect);
connect.Open();
command.Parameters.AddWithValue("@ID", ID.Text);
SqlDataReader reader = command.ExecuteReader();
while (reader.Read())
{
ID.Text = reader["ID"].ToString();
UserID.Text = reader["UserID"].ToString();
Password.Text = reader["Password"].ToString();
EMail.Text = reader["EMail"].ToString();
Name.Text = reader["Name"].ToString();
Surname.Text = reader["Surname"].ToString();
regSex.SelectedValue = reader["Sex"].ToString();
Phone.Text = reader["Phone"].ToString();
}
connect.Close();
if(UserID.Text == "")
{
ID.Text = "";
Clear();
}
}
else
{
Response.Write("<script>alert('Alanı boş bırakmayınız.');</script>");
Clear();
}
}
}
}