using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BLL;
using System.Data;
namespace ComResProSystem
{
    public partial class Login:System.Web.UI.Page
    {
        BLL.BaseBLL basebll = new BaseBLL();
        BLL.UserBll bll = new UserBll();
        protected void Page_Load(object sender, EventArgs e)
        {

        }

       

        protected void IBt_Submit_Click(object sender, ImageClickEventArgs e)
        {
            if (Tb_Password.Text != "" && Tb_UserName.Text != "")
            {
                int Login = basebll.CheckLogin("SELECT COUNT(ID) FROM Users WHERE UserName=@username AND [PassWord]=@password", Tb_UserName.Text, Tb_Password.Text);
                if (Login > 0)
                {
                    DataTable dt = bll.gettable("SELECT ID FROM Users WHERE UserName='" + Tb_UserName.Text + "' AND [PassWord]='"+Tb_Password.Text+"'");
                    Session["UserID"] = dt.Rows[0]["ID"].ToString();
                    Session["UserName"] = Tb_UserName.Text;
                    Response.Redirect("Index.aspx");
                }
                else
                {
                    Response.Write("<script>alert('用户名或密码错误！')</script>");
                }
            }
            else
            {
                Response.Write("<script>alert('请输入用户名和密码！')</script>");
            }

        }
    }
}