using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
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.Xml.Linq;
using Maticsoft.DBUtility;

public partial class Login : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    /// <summary>
    /// 登录事件
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnLogin_Click(object sender, ImageClickEventArgs e)
    {
        try
        {
            EnCode encode = new EnCode();
            string strMemberName = txtMemberName.Text.Trim();
            string strPassword = encode.md5(txtPassword.Text.Trim());

            JY.BLL.Member bll = new JY.BLL.Member();
            string strSql = " MemberName='" + strMemberName + "' and Password='" + strPassword + "' and isdelete=0";

            DataTable dt = bll.GetList(strSql).Tables[0];
            if (dt.Rows.Count > 0)
            {
                Session["MemberID"] = dt.Rows[0]["ID"].ToString();
                Session["MemberName"] = dt.Rows[0]["MemberName"].ToString();
                Session["MemberRankId"] = dt.Rows[0]["MemberRankId"].ToString();

                if (Request.QueryString["url"] != null && Request.QueryString["url"] != "")
                {
                    Response.Redirect(Server.UrlDecode(Request.QueryString["url"]));
                }
                else
                {
                    Response.Redirect("Member/MemberInfo.aspx");
                }
            }
            else
            {
                publicHandle.ShowMessage(this.Page, "用户名或密码不正确，请重新输入！");
            }
        }
        catch (Exception er)
        {
            publicHandle.ShowMessage(this, er.Message);
        }
    }
}
