Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Data.OleDb;
- using System.Configuration;
- namespace WebApplication1
- {
- public partial class login : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- }
- protected void Button1_Click(object sender, EventArgs e)
- {
- int result = 0;
- OleDbConnection cn = new OleDbConnection();
- cn.ConnectionString = ConfigurationManager.ConnectionStrings["smConnectionString"].ToString();
- cn.Open();
- OleDbCommand cmd = new OleDbCommand("SELECT login_ID, utype FROM employee WHERE login_ID = @loginid AND pass_word= @password",cn);
- cmd.Parameters.AddWithValue("@loginid", TextBox1.Text);
- cmd.Parameters.AddWithValue("@password", TextBox2.Text);
- try
- {
- result = (int)cmd.ExecuteScalar();
- if (result > 0)
- {
- OleDbDataReader reader = cmd.ExecuteReader();
- while (reader.Read())
- {
- string ulevel = reader["utype"].ToString();
- Session["empID"] = reader["login_ID"].ToString();
- Label1.Text = ulevel;
- }
- if (Label1.Text == "admin")
- {
- Response.RedirectPermanent("emp_viewsl.aspx?='" + Session["empID"] + "'");
- Label1.Text = "Admin";
- }
- else if (Label1.Text == "accountant")
- {
- //Response.RedirectPermanent("");
- Label1.Text = "accountat";
- }
- else
- {
- //Response.RedirectPermanent("");
- Label1.Text = "user";
- }
- }
- else
- {
- Label2.Text = "Invalid credentials";
- }
- }
- catch (Exception ex)
- {
- Label2.Text = ex.Message;
- Label2.Visible = true;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement