using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using AVC.Business;
using AVC.DataEntity;
using AVC.Passport;
using AVC.Passport.DataEntity;
public partial class login : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            txtUserName.Attributes.Add("onmouseover", "this.select();");
            txtPwd.Attributes.Add("onmouseover", "this.select();");
            txtPwd.Attributes.Add("onfocus", "this.select();");
            ViewState["SourceUrl"] = Request.Url.AbsoluteUri;
        }
    }

    protected void btnLogin_Click(object sender, EventArgs e)
    {
        string strSubSystemID = System.Configuration.ConfigurationManager.AppSettings["SubSystemID"];
        UserMst objUserMst;
        int ResultCode;
        if (UserMstBiz.Login(strSubSystemID, this.txtUserName.Text.Trim(), txtPwd.Text, out objUserMst, out ResultCode))
        {
            UserTicket.UserID = objUserMst.UserID;
            UserTicket.UserName = objUserMst.UserName;
            string strSourceUrl = (string)ViewState["SourceUrl"];
            
                if (strSourceUrl.IndexOf("login.aspx", StringComparison.OrdinalIgnoreCase) >= 0)
                    strSourceUrl = "~/Index.aspx";
            Response.Redirect(strSourceUrl);
        }
    }
    protected void btnClear_Click(object sender, EventArgs e)
    {
        txtUserName.Text = "";
        txtPwd.Text = "";
    }
}
