コード例 #1
0
        private void LoadUserInfo()
        {
            if (Context.Session[SessionInfo.USER_INFO] == null)
            {
                string     cookieName = FormsAuthentication.FormsCookieName;
                HttpCookie authCookie = Context.Request.Cookies[cookieName];
                if (authCookie == null)
                {
                    Response.Redirect("Login.aspx");
                }

                FormsAuthenticationTicket authTicket = null;

                authTicket = FormsAuthentication.Decrypt(authCookie.Value);

                FormsIdentity identity = new FormsIdentity(authTicket);

                string username = identity.Name;
                eChartProject.BLL.eChart.accounts_users bll = new eChartProject.BLL.eChart.accounts_users();
                string strWhere = "username='******'";
                List <eChartProject.Model.eChart.accounts_users> user = bll.GetModelList(strWhere);

                if (user != null && user.Count > 0)
                {
                    UserInfo userInfo = new UserInfo();
                    userInfo.Email      = user[0].Email;
                    userInfo.Password   = user[0].Password;
                    userInfo.UserId     = user[0].UserID;
                    userInfo.Age        = (int)user[0].Age;
                    userInfo.City       = user[0].City;
                    userInfo.Country    = user[0].Country;
                    userInfo.UserName   = username;
                    userInfo.UserStatus = (int)user[0].UserStatus;

                    SessionInfo.UserInfo = userInfo;
                }
                else
                {
                    Response.Redirect("Login.aspx");
                }
            }
            if (SessionInfo.UserInfo != null)
            {
                if (!string.IsNullOrEmpty(SessionInfo.UserInfo.Email) & !string.IsNullOrEmpty(SessionInfo.UserInfo.Password))
                {
                    if (this.Master != null)
                    {
                        (this.Master.FindControl("email") as HtmlInputControl).Value = SessionInfo.UserInfo.Email;
                        (this.Master.FindControl("pswd") as HtmlInputControl).Value  = SessionInfo.UserInfo.Password;
                        (this.Master.FindControl("lblName") as Label).Text           = SessionInfo.UserInfo.UserName;
                    }
                }
            }
            else
            {
                Response.Redirect("Login.aspx");
            }
        }
コード例 #2
0
ファイル: Login.aspx.cs プロジェクト: wwkkww1983/Csharp
        protected void Page_Load(object sender, EventArgs e)
        {
            string     cookieName = FormsAuthentication.FormsCookieName;
            HttpCookie authCookie = Context.Request.Cookies[cookieName];

            if (authCookie != null)
            {
                FormsAuthenticationTicket authTicket = null;

                authTicket = FormsAuthentication.Decrypt(authCookie.Value);

                FormsIdentity identity = new FormsIdentity(authTicket);



                string username = identity.Name;

                eChartProject.BLL.eChart.accounts_users bll = new eChartProject.BLL.eChart.accounts_users();
                string strWhere = "username='******'";
                List <eChartProject.Model.eChart.accounts_users> user = bll.GetModelList(strWhere);



                if (user != null && user.Count > 0)
                {
                    UserInfo userInfo = new UserInfo();
                    userInfo.Email      = user[0].Email;
                    userInfo.Password   = user[0].Password;
                    userInfo.UserId     = user[0].UserID;
                    userInfo.Age        = (int)user[0].Age;
                    userInfo.City       = user[0].City;
                    userInfo.Country    = user[0].Country;
                    userInfo.UserName   = username;
                    userInfo.UserStatus = (int)user[0].UserStatus;

                    SessionInfo.UserInfo = userInfo;


                    Maticsoft.Common.MessageBox.Redirect(this, "Welcome.aspx");

                    txtPassword.Disabled = true;
                    txtEmail.Disabled    = true;
                }
            }
        }
コード例 #3
0
ファイル: Login.aspx.cs プロジェクト: wwkkww1983/Csharp
        /// <summary>
        /// Login
        /// </summary>
        /// <param name="username"></param>
        /// <param name="pswd"></param>
        private void DoLogin(string username, string pswd)
        {
            string errMsg = string.Empty;

            eChartProject.BLL.eChart.accounts_users bll = new eChartProject.BLL.eChart.accounts_users();
            string strWhere = "username='******' and password = '******'";
            List <eChartProject.Model.eChart.accounts_users> user = bll.GetModelList(strWhere);


            if (user != null && user.Count > 0)
            {
                UserInfo userInfo = new UserInfo();
                userInfo.Email      = user[0].Email;
                userInfo.Password   = pswd;
                userInfo.UserId     = user[0].UserID;
                userInfo.Age        = (int)user[0].Age;
                userInfo.City       = user[0].City;
                userInfo.Country    = user[0].Country;
                userInfo.UserName   = username;
                userInfo.UserStatus = (int)user[0].UserStatus;

                SessionInfo.UserInfo = userInfo;

                if (userInfo.UserStatus == (int)EnumUserStatus.Blocked)
                {
                    errMsg = "Please activate your account in the email sent to you.";
                }
                FormsAuthentication.RedirectFromLoginPage(username, cbRemember.Checked);
            }
            else
            {
                errMsg = "The email or the password is invalid.";
            }

            ValidationSummary.InnerText        = errMsg;
            ValidationSummary.Style["display"] = "inline";
            txtPassword.Value = "";
        }
コード例 #4
0
ファイル: SaveSetting.aspx.cs プロジェクト: wwkkww1983/Csharp
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                try
                {
                    string username = Request.Form["username"];
                    string pass     = Request.Form["password"];
                    string country  = Request.Form["country"];
                    string city     = Request.Form["city"];
                    string email    = Request.Form["email"];
                    string gender   = Request.Form["gender"];
                    string age      = Request.Form["age"];

                    eChartProject.Model.eChart.accounts_users model = new eChartProject.Model.eChart.accounts_users();

                    model.FundID     = 1;
                    model.Username   = username;
                    model.Password   = Utils.MD5(pass.Trim());
                    model.Age        = int.Parse(age);
                    model.City       = city;
                    model.Country    = country;
                    model.Email      = email;
                    model.Gender     = int.Parse(gender);
                    model.UserStatus = 1;

                    eChartProject.BLL.eChart.accounts_users bll = new eChartProject.BLL.eChart.accounts_users();
                    bll.Add(model);

                    Response.Write("success");
                    Response.End();
                }
                catch
                {
                }
            }
        }
コード例 #5
0
ファイル: Default.aspx.cs プロジェクト: wwkkww1983/Csharp
        protected void Page_Load(object sender, EventArgs e)
        {
            //display the Supporter's info
            eChartProject.BLL.eChart.accounts_users bll = new eChartProject.BLL.eChart.accounts_users();
            string strWhere = " 1=1 order by UserID desc";
            List <eChartProject.Model.eChart.accounts_users> user = bll.GetModelList(strWhere);

            if (user != null && user.Count > 0)
            {
                UserInfo userInfo = new UserInfo();
                userInfo.Email      = user[0].Email;
                userInfo.Password   = user[0].Password;
                userInfo.UserId     = user[0].UserID;
                userInfo.Age        = (int)user[0].Age;
                userInfo.City       = user[0].City;
                userInfo.Country    = user[0].Country;
                userInfo.UserName   = user[0].Username;
                userInfo.UserStatus = (int)user[0].UserStatus;

                SessionInfo.UserInfo = userInfo;

                this.txtName.Value    = userInfo.UserName;
                this.txtGender.Value  = userInfo.Gender == "true"?"F":"M";
                this.txtCountry.Value = userInfo.Country;
                this.txtCity.Value    = userInfo.City;
                this.txtAge.Value     = userInfo.Age.ToString() + " yrs";
                TextName.InnerText    = userInfo.UserName;
            }
            //GET CLIENT USER'S COOKIE INFORMATION
            string     cookieName = FormsAuthentication.FormsCookieName;
            HttpCookie authCookie = Context.Request.Cookies[cookieName];

            if (authCookie != null)
            {
                FormsAuthenticationTicket authTicket = null;

                authTicket = FormsAuthentication.Decrypt(authCookie.Value);

                FormsIdentity identity = new FormsIdentity(authTicket);

                string fundID = identity.Name;
                int    outresult;
                if (int.TryParse(fundID, out outresult))
                {
                    strWhere = " ID=" + fundID;
                    List <eChartProject.Model.eChart.fund> user2 = FundBll.GetModelList(strWhere);


                    if (user != null && user.Count > 0)
                    {
                        ClientUserInfo clientUserInfo = new ClientUserInfo();
                        clientUserInfo.Email  = user2[0].EmailAddress;
                        clientUserInfo.FundID = user2[0].ID;

                        strWhere = " FundID=" + clientUserInfo.FundID + " and isclientadded=0  ";
                        List <eChartProject.Model.eChart.fundbankaccount> fundbank = FundBankAccountBll.GetModelList(strWhere);

                        if (fundbank != null && fundbank.Count > 0)
                        {
                            clientUserInfo.Pswd        = fundbank[0].FundBankAccountNo;
                            SessionInfo.ClientUserInfo = clientUserInfo;

                            txtEmail.Value = clientUserInfo.Email;
                            txtPassword.Attributes.Add("value ", clientUserInfo.Pswd);
                            btnLogin.Style["display"]   = "none";
                            ddRemember.Style["display"] = "none";

                            lbtnLogout.Style["display"]        = "inline";
                            ValidationSummary.Style["display"] = "none";
                            PrivateValidation.Style["display"] = "inline";
                        }
                        else
                        {
                            lbtnLogout.Style["display"] = "none";
                        }
                    }
                    else
                    {
                        lbtnLogout.Style["display"] = "none";
                    }
                }
                else
                {
                    lbtnLogout.Style["display"] = "none";
                }
            }
            else
            {
                lbtnLogout.Style["display"] = "none";
            }

            InitializeLearnMORE();
        }