예제 #1
0
        protected void LogIn(object sender, EventArgs e)
        {
            if (IsValid)
            {
                String _userName, _password;
                _userName = UserName.Text.ToString();
                _password = Password.Text.ToString();
                String    sql;
                DataTable dt;
                sql = "Select * from account where username='******' AND password='******'";
                clsDB conn = new clsDB();
                dt = conn.ExecuteDataTable(sql);
                if (dt.Rows.Count > 0)
                {
                    Session["TITLE"]     = dt.Rows[0]["title"].ToString();
                    Session["NAME"]      = dt.Rows[0]["name"].ToString();
                    Session["SURNAME"]   = dt.Rows[0]["surname"].ToString();
                    Session["LEVEL"]     = dt.Rows[0]["level"].ToString();
                    Session["EMAIL"]     = dt.Rows[0]["email"].ToString();
                    Session["SIGNATURE"] = dt.Rows[0]["signature"].ToString();

                    Model.Log      L   = new Model.Log();
                    Helper.Utility Log = new Helper.Utility();

                    L.content   = "Log in success.";
                    L.create_by = Session["EMAIL"].ToString();
                    Log.WriteLog(L);


                    Response.Redirect("../DataDocument.aspx");
                }
                else
                {
                    Model.Log      L   = new Model.Log();
                    Helper.Utility Log = new Helper.Utility();

                    L.content   = "Log in fail.";
                    L.create_by = _userName;
                    Log.WriteLog(L);
                }



                //    // Validate the user password
                //    var manager = new UserManager();
                //    ApplicationUser user = manager.Find(UserName.Text, Password.Text);
                //    if (user != null)
                //    {
                //        IdentityHelper.SignIn(manager, user, RememberMe.Checked);
                //        IdentityHelper.RedirectToReturnUrl(Request.QueryString["ReturnUrl"], Response);
                //    }
                //    else
                //    {
                //        FailureText.Text = "Invalid username or password.";
                //        ErrorMessage.Visible = true;
                //    }
            }
        }
예제 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            clsDB     conn = new clsDB();
            DataTable dt;
            String    sql;

            sql = "Select * from Account";
            dt  = conn.ExecuteDataTable(sql);
            GridView1.DataSource = dt;
            GridView1.DataBind();
        }