How to login from mention code
Dear Sir,
Please help me to solve mention code to login
HTML
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Login.aspx.cs" Inherits="Employee_Rank.Login" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>
<style type="text/css">
body {background: #4298f4;color: white;font-family: 'Ubuntu Mono', sans-serif;text-transform: uppercase; }
.box {width: 100%;max-width: 450px;height: auto;margin: 0 auto;margin-top: 100px;background: white;border-radius: 7px;box-shadow: 0px 3px 10px 1px rgba(0, 0, 0, 0.9); }
.content {width: 75%;height: auto;position:;margin: 0 auto;padding: 30px 0px;background:;text-align: center;}
.content h1 {font-size: 24px;font-weight: 400;color: #4298f4;letter-spacing: 0.125em;text-align: center;}
.field {width: 100%;margin: 10px auto;padding: 10px;background: #4298f4;border: none;box-shadow: 0px 1px 0px 0px #111;border-radius: 3px;outline: none;color: white;font-weight: 700;letter-spacing: 0.125em;text-align: center;}
::-webkit-input-placeholder { /* WebKit browsers */
color: whitesmoke;
}
:-moz-placeholder { /* Mozilla Firefox 4 to 18 */
color: whitesmoke;
}
::-moz-placeholder { /* Mozilla Firefox 19+ */
color: whitesmoke;
}
:-ms-input-placeholder { /* Internet Explorer 10+ */
color: whitesmoke;
}
.btn {width: 100%;margin: 10px auto;padding: 10px;background: #4298f4;border: none;box-shadow: 0px 1px 0px 0px #111;border-radius: 3px;outline: none;color: white;font-weight: 700;letter-spacing: 0.125em;text-align: center;text-transform: uppercase;}
.btn:hover {background: #ff0c0c;color: white;}
.btn:active {background: #048202; color: white;}
.newStyle4 {font-family: CALIbri;font-size: larger;text-align: right;}
.auto-style1 {width: 75%;height: auto;position: ;}
margin: 0 auto;padding: 30px 0px;background: ;text-align: left;}
}
.auto-style2 {text-align: left;}
p.MsoNormal{mso-style-parent:"";margin:0in;font-size:11.0pt;font-family:"Calibri",sans-serif;}
</style>
</head>
<body>
<form id="form1" runat="server">
<br />
<br />
<h1 style="color: white; text-align: center">
FEEDBACK CAPTURING SYSTEM</h1>
<hr />
<div class="box">
<div class="auto-style1">
<div class="auto-style2">
<asp:TextBox class="field" placeholder="Employee ID" ID="UserName" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="UserNameRequired" runat="server" ControlToValidate="UserName"
ErrorMessage="User Name is required." ToolTip="User Name is required." ValidationGroup="Login1">*</asp:RequiredFieldValidator>
<br>
<asp:TextBox class="field" placeholder="Enter your Password" ID="Password" runat="server"
TextMode="Password"></asp:TextBox>
<asp:RequiredFieldValidator ID="PasswordRequired" runat="server" ControlToValidate="Password"
ErrorMessage="Password is required." ToolTip="Password is required." ValidationGroup="Login1">*</asp:RequiredFieldValidator>
<br>
<asp:Button class="btn" ID="LoginButton" runat="server" Text="Log In" OnClick="LoginButton_Click">
</asp:Button>
<br>
<asp:Label ID="Label1" runat="server" Style="font-weight: 700; color: #FF0000"></asp:Label>
<br>
<br>
</div>
</div>
</div>
</form>
<p class="MsoNormal">
<font size="3">Feedback System is open for all HODs (HODs including GMs): </font>
</p>
<p class="MsoNormal">
<font size="3">1)All HODs are requested to provide honest and professional feedback on the scale of 1 to 10.</font>
</p>
<p class="MsoNormal">
<font size="3">2) Your identity will not be disclosed. The feedbacks shall be used as additional information for team building and excellence.</font>
</p>
<p class="MsoNormal">
<font size="3">3) Your feedback should be majorly based on the performance of the individual on the assigned roles.</font>
</p>
<p class="MsoNormal">
<font size="3">3) You may be asked to provide the reasons if the score given is full 10 or very low(less than 5).</font>
</p>
<p class="MsoNormal">
<font size="3">4) E1 to E6 will be evaluated by HODs of respective divisions like for O&M executives by O&M HODs, Project executives by Project HODs AND For Services department executives by CUSTOMER department HODs(aLL HODS).</font>
</p>
<p class="MsoNormal">
<font size="3">5) E7 and E8(AGM) feedback shall be taken from all HODs.</font>
</p>
<p class="MsoNormal">
<font size="3">6) In case you don’t know someone, you may skip the feedback of that person instead of giving random feedback.</font>
</p>
<p class="MsoNormal">
<font size="3">7) All HODs and GMs are requested to provide the feedback by TOmorrow 09:00hrs.</font>
</p>
<p class="MsoNormal">
<font size="3">7) You may provide your feedback in multiple sessions also, your feedback is being saved and is available in
“already done” tab once you press the submit button.</font>
</p>
<p class="MsoNormal">
<font size="3">8) In case of any IT related support, please call 4052 or 4043.</font>
</p>
<p class="MsoNormal">
<font size="3">9) In the scale of 1-10, '10' is the best rated, and '1' is the least rated. select 'Not Known'', if the executive is not known. </font>
</p>
<p class="MsoNormal">
</p>
</body>
</html>
Code
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace Employee_Rank
{
public partial class Login : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void LoginButton_Click(object sender, EventArgs e)
{
int itest = 0;
if (UserName.Text.Trim() != "")
{
if (Password.Text.Trim() != "")
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["hrConnectionString"].ConnectionString);
try
{
string _respassword = encrpass(Password.Text.Trim());
con.Open();
using (SqlCommand command = new SqlCommand("SELECT EMP_NUM,emp_name,grade_code+grade_level as Grade,i.dept_cd FROM intranet_users i,estt_emp_mast e inner join cms.dbo.hod_dept b on e.empno=b.hod_no,dept_codes d where i.emp_num=e.empno and i.dept_cd=d.dept_code and emp_num = '" + UserName.Text.Trim() + "' and pwd = '" + _respassword.ToString().Trim() + "' group by EMP_NUM,emp_name,grade_code+grade_level,i.dept_cd", con))
// using (SqlCommand command = new SqlCommand("SELECT EMP_NUM,emp_name,grade_code+grade_level as Grade FROM intranet_users where emp_num = '" + UserName.Text.Trim() + "' and pwd = '" + _respassword.ToString().Trim() + "' group by EMP_NUM,emp_name,grade_code+grade_level", con))
using (SqlDataReader reader = command.ExecuteReader())
{
while (reader.Read())
{
itest = 1;
Session["emp_num"] = reader["emp_num"].ToString().Trim();
Session["name"] = reader["emp_name"].ToString().Trim();
Session["dept"] = reader["dept_cd"].ToString().Trim();
Session["Grd"] = reader["Grade"].ToString().Trim();
}
}
}
finally
{
con.Close();
}
if (itest == 0)
{
Label1.Text = "Wrong Password / User Id";
return;
}
else
{
if (Session["emp_num"].ToString() == "035001" || Session["emp_num"].ToString() == "003868" || Session["emp_num"].ToString() == "005382")
{
Response.Redirect("Home.aspx");
}
else
{
Label1.Text = " Form Closed. Not taking any inputs";
return;
}
}
}
else
{
UserName.Focus();
Label1.Text = "Enter Password";
}
}
else
{
UserName.Focus();
Label1.Text = "Enter User Name";
}
Label1.Text = "You Are Not Authorized User.";
}
protected string encrpass(string passerwd)
{
string asd;
//int k = 0;
string pas = ""; ;
long newstr = 0;
string newpass = "";
//int inter = 0;
//int teger = 0;
for (int i = 10 - passerwd.Length; i > 0; i--)
{
passerwd = passerwd + " ";
}
passerwd = passerwd.ToUpper();
passerwd = passerwd.Substring(0, 10);
for (int i = 0; i < 10; i++)
{
asd = passerwd.Substring(i, 1);
newstr = Convert.ToInt16(Convert.ToChar(asd));
pas = pas + String.Format("{0:X2}", (uint)System.Convert.ToUInt32(newstr.ToString()));
}
int index = 0;
while (index < pas.Length)
{
if (char.IsNumber(Convert.ToChar(pas.Substring(index, 1))))
{
newpass = newpass.Trim() + pas.Substring(index, 1);
}
index += 1;
}
newpass = newpass.Trim();
for (int k1 = newpass.Length + 1; k1 <= 20; k1++)
{
newpass = newpass + " ";
}
//MessageBox.Show(newpass);
// inter = 0;
//teger = 0;
long d = (Convert.ToInt32(newpass.Substring(0, 8)) * 3) / 13;
long d1 = (Convert.ToInt32(newpass.Substring(newpass.Length - 8, 8)) * 7) / 17;
long res = d + d1;
//MessageBox.Show(res.ToString());
return res.ToString();
}
}
}
home.aspx
<%@ Page Title="" Language="C#" MasterPageFile="~/Main.Master" AutoEventWireup="true" CodeBehind="Home.aspx.cs" Inherits="Employee_Rank.Home" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
</asp:Content>
.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace Employee_Rank
{
public partial class Home : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (Session["emp_num"] == null)
{
ClientScript.RegisterStartupScript(Page.GetType(), "alert", "alert('Session Time out. Login Again.');window.location='login.aspx';", true);
}
}
}
}