using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ResMangSys.DAL.UsersTableAdapters;

namespace ResMangSys.Account
{
    public partial class Login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            // 下载于www.51aspx.com
        }

        protected void LoginButton_Click(object sender, EventArgs e)
        {
            if (IsValid)
            {
                T_UsersTableAdapter adapter = new T_UsersTableAdapter();
                if (adapter.IsExist(UserName.Text.Trim(), Password.Text.Trim()) > 0)
                {
                    ResMangSys.DAL.Users.T_UsersRow row = adapter.GetUserDataByNamPwd(UserName.Text.Trim(), Password.Text.Trim()).Single();
                    Session["id"] = row.Id;
                    Session["role"] = row.Role.Trim();
                    Session["pwd"] = row.UserPwd.Trim();
                    Response.Redirect("SingleBaStaQuery.aspx");
                }
                else
                {
                    FailureText.Text = "用户名或密码错误";
                }
            }
        }
    }
}