/
CompanyLogin.aspx.cs
75 lines (49 loc) · 1.74 KB
/
CompanyLogin.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.IO;
using System.Data;
using System.Configuration;
public partial class CompanyLogin : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
private bool YourValidationFunction(string UserName, string Password, int Active)
{
DataAccess dataaccess = new DataAccess();
SqlConnection Sqlcon = dataaccess.OpenConnection();
bool boolReturnValue = false;
String SQLQuery = "SELECT CompanyId, CompanyEmail, Password, Active FROM CompanyMaster where CompanyEmail='"+Login1.UserName+"' and Password='"+Login1.Password+"' and Active='"+Active+"'";
SqlCommand command = new SqlCommand(SQLQuery, Sqlcon);
SqlDataReader Dr;
Dr = command.ExecuteReader();
while (Dr.Read())
{
if ((UserName == Dr["CompanyEmail"].ToString()) & (Password == Dr["Password"].ToString()) )
{
Session["CompanyId"] = Dr["CompanyId"].ToString();
boolReturnValue = true;
}
Dr.Close();
return boolReturnValue;
}
return boolReturnValue;
}
protected void Login1_Authenticate1(object sender, AuthenticateEventArgs e)
{
int Active = 1;
if (YourValidationFunction(Login1.UserName, Login1.Password, Active))
{
Response.Redirect("~/Company/CompanyHome.aspx");
}
else
{
e.Authenticated = false;
}
}
}