using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Data.SqlClient;

public partial class EmployeeLogin : System.Web.UI.Page
{
  
    protected void Page_Load(object sender, EventArgs e)
    {
        //SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings.Get("con"));

    }
    SqlConnection con = new SqlConnection(ConfigurationManager .AppSettings.Get("con"));
    protected void Button1_Click(object sender, EventArgs e)
    {
        try
        {
            if (con.State == ConnectionState.Closed)
                con.Open();
            SqlCommand cmd = new SqlCommand("select deptno,branchno,role from emp where empno=" + txtUserId.Text + " and pwd='" + txtPwd.Text + "' and role='" + ddlDesg.SelectedValue + "'", con);
            SqlDataReader dr;
            dr = cmd.ExecuteReader();

            if (dr.Read())
            {
                Session["eid"] = txtUserId.Text;
                Session["dno"] = dr.GetValue(0);
                Session["bno"] = dr.GetValue(1);
                Session["role"] = dr.GetValue(2);

                //if (dr.GetValue(2).ToString().ToLower() == "manager")
                //{
                //    Response.Redirect("ManagerHome.aspx");
                //}
                //else
                //{
                    Response.Redirect("EmpHome.aspx");
                //}
            }
            else
                lbltext.Text = "Insufficient Data. Plz give correct Data";

        }
        catch (Exception ex)
        {
            lbltext.Text = ex.Message;
        }
    }
    protected void Button2_Click(object sender, EventArgs e)
    {

    }
}
