-
Notifications
You must be signed in to change notification settings - Fork 1
/
Login.aspx.cs
39 lines (35 loc) · 2.73 KB
/
Login.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
using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class Login : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
clsDbConnection db = new clsDbConnection();
DataTable dt = new DataTable();
dt = db.dbSelect("SELECT UserID, UserName, UserTypeID, [NameCS] ,[SnameCS] FROM tblUsers WHERE (UserName = '" + TextBox1.Text.Trim() + "') AND (UsePassChar = '" + TextBox2.Text.Trim() + "')");
if (dt.Rows.Count <= 0)
{
Response.Write("<script>alert('نام کاربری و یا کلمه عبور صحیح وارد نشده است')</script>");
}
else
{
Session.Add("UserName", dt.Rows[0][1].ToString());
Session.Add("UserTypeID", dt.Rows[0][2].ToString().Trim());
Session.Add("UserID", dt.Rows[0][0].ToString());
Session.Add("UserTotalNameSname", dt.Rows[0][3].ToString() + " " + dt.Rows[0][4].ToString());
Response.Redirect("Default.aspx?ID=" + DateTime.Now.Ticks.ToString());
}
}
}