예제 #1
0
 protected void btnlogin_Click(object sender, EventArgs e)
 {
     try
     {
         if (Page.IsValid)
         {
             Session["id"]        = objPrp.Pemp_email = login_username.Value;
             objPrp.Pemp_password = login_password.Value;
             int chk_user = obj.usr_authentication(objPrp);
             if (chk_user == 1) //admin user
             {
                 FormsAuthenticationTicket tkt = new FormsAuthenticationTicket(1, objPrp.Pemp_email, DateTime.Now, DateTime.Now.AddMinutes(20), false, "admin", FormsAuthentication.FormsCookiePath);
                 string     st = FormsAuthentication.Encrypt(tkt);
                 HttpCookie ck = new HttpCookie(FormsAuthentication.FormsCookieName, st);
                 Response.Cookies.Add(ck);
                 Response.Redirect("~/ADMIN/home.aspx");
             }
             else if (chk_user == 2) //emp or admin user
             {
                 FormsAuthenticationTicket tkt = new FormsAuthenticationTicket(1, objPrp.Pemp_email, DateTime.Now, DateTime.Now.AddMinutes(20), false, "emp", FormsAuthentication.FormsCookiePath);
                 string     st = FormsAuthentication.Encrypt(tkt);
                 HttpCookie ck = new HttpCookie(FormsAuthentication.FormsCookieName, st);
                 Response.Cookies.Add(ck);
                 Response.Redirect("~/EMPLOYEE/home.aspx");
             }
             else if (chk_user == -1) //invalid user
             {
                 Label_Error.Visible = true;
                 login_username.Style.Add("Border-Color", "red");
                 login_password.Style.Add("Border-Color", "red");
             }
         }
     }
     catch
     {
         //Response.Redirect("www.google.com");
     }
 }