示例#1
0
    protected void ButtonLogin_Click(object sender, EventArgs e)
    {
        lblError.Text = "";
        DataSet dsUser = new DataSet();

        dsUser = this.CheckValidUser(txtMemberID.Text);
        if (dsUser != null)
        {
            string AccountStatus = dsUser.Tables["Account"].Rows[0]["UserStatus"].ToString();
            if (AccountStatus == "A")
            {
                string PassDB = dsUser.Tables["Account"].Rows[0]["password"].ToString();
                if (this.CheckPassword(txtPassword.Text, PassDB))
                {
                    Session["AccountId"] = dsUser.Tables["Account"].Rows[0]["Id"].ToString();
                    Session["USERNAME"]  = dsUser.Tables["Account"].Rows[0]["Title"].ToString() + " " + dsUser.Tables["Account"].Rows[0]["Firstname"].ToString() + " " + dsUser.Tables["Account"].Rows[0]["Lastname"].ToString();
                    Session["USEREMAIL"] = dsUser.Tables["Account"].Rows[0]["Email"].ToString();
                    Session["USERTYPE"]  = dsUser.Tables["Account"].Rows[0]["UserType"].ToString();
                    Session["USERLOGON"] = dsUser.Tables["Account"].Rows[0]["LoginDate"].ToString();

                    this.SaveLoginDate(Session["AccountId"].ToString());
                    //A.ActionLog(PageCode, "Logon System", "Logon success", Session["ACCOUNT_ID"].ToString());
                    A.ActionLog("Account", Session["AccountId"].ToString(), "Login-Success");

                    Response.Redirect("~/User_Search.aspx");

                    //if (string.IsNullOrEmpty(Request.QueryString["n"]) && string.IsNullOrEmpty(Request.QueryString["p"]))
                    //{
                    //    Response.Redirect("CD_MySummary.aspx");
                    //}
                    //else
                    //{
                    //    if (Request.QueryString["p"] == "acc")
                    //    {
                    //        Response.Redirect("CD_Account_Edit.aspx?AccountID=" + Request.QueryString["n"]);
                    //    }
                    //    else if (Request.QueryString["p"] == "product")
                    //    {
                    //        Response.Redirect("BW_Consumption.aspx?RID=" + Request.QueryString["n"]);
                    //    }
                    //}
                }
                else
                {
                    A.NotLogonLog("Account", dsUser.Tables["Account"].Rows[0]["Id"].ToString(), "Login-PassInvalid");
                    lblError.Text += "Password invalid.";
                }
            }
            else if (AccountStatus == "I")
            {
                A.NotLogonLog("Account", dsUser.Tables["Account"].Rows[0]["Id"].ToString(), "Login-Inactive");
                lblError.Text += "Your Accout is Inactive. Please contact your administrator.";
            }
        }
        else
        {
            A.NotLogonLog("Account", "", "Login-InvalidAccount");
            lblError.Text += "Account not found.";
        }
    }