示例#1
0
        protected LoginRecordInfo PopulateLoginRecord(IDataReader reader)
        {
            LoginRecordInfo entity = new LoginRecordInfo()
            {
                ID          = (int)reader["ID"],
                AdminID     = (int)reader["AdminID"],
                LastLoginIP = reader["LastLoginIP"] as string,
                LoginTime   = DataConvert.SafeDate(reader["LoginTime"]),
                UserName    = reader["UserName"] as string
            };

            return(entity);
        }
示例#2
0
        /// <summary>
        /// 用户登录
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btSave_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                string userName = StrHelper.Trim(txtUserName.Value);
                string password = StrHelper.Trim(txtUserPwd.Value);

                ///用户名,密码,验证码不允许为空
                if (!string.IsNullOrEmpty(userName) && !string.IsNullOrEmpty(password))
                {
                    int id = Admins.Instance.ValiUser(userName, EncryptString.MD5(password));//验证用户

                    if (id > 0)
                    {
                        AdminInfo admin = Admins.Instance.GetAdmin(id);
                        if (admin.State == "1")
                        {
                            admin.LastLoginIP = WebHelper.GetClientsIP();
                            admin.LastLoginTime = DateTime.Now;
                            admin.LoginTimes++;
                            Admins.Instance.UpdateAdmin(admin);
                            LoginRecordInfo lr = new LoginRecordInfo()
                            {
                                AdminID = admin.ID,
                                LastLoginIP = admin.LastLoginIP,
                                LoginTime = DateTime.Now,
                                UserName = admin.UserName
                            };
                            Admins.Instance.AddLoginRecord(lr);
                            Session[GlobalKey.SESSION_ADMIN] = admin;
                            ManageCookies.CreateCookie(GlobalKey.SESSION_ADMIN, id.ToString(), true, DateTime.Today.AddDays(1), HXContext.Current.CookieDomain);
                            Response.Redirect("index.aspx");
                        }
                        else
                            lblMsg.Text = "用户状态异常,请联系管理员";
                    }
                    else
                        lblMsg.Text = "用户名或密码错误";
                    Session[GlobalKey.SESSION_ADMIN] = null;
                }
            }
        }
示例#3
0
 public void AddLoginRecord(LoginRecordInfo lr)
 {
     CommonDataProvider.Instance().AddLoginRecord(lr);
 }
示例#4
0
 public abstract void AddLoginRecord(LoginRecordInfo lr);
示例#5
0
 public void AddLoginRecord(LoginRecordInfo lr)
 {
     CommonDataProvider.Instance().AddLoginRecord(lr);
 }
示例#6
0
 public override void AddLoginRecord(LoginRecordInfo lr)
 {
     string sql = @"
     INSERT INTO ComOpp_LoginRecord(
         [AdminID]
         ,[UserName]
         ,[LastLoginIP]
         ,[LoginTime]
     ) VALUES (
         @AdminID
         ,@UserName
         ,@LastLoginIP
         ,@LoginTime
     )";
     SqlParameter[] p =
     {
         new SqlParameter("@AdminID",lr.AdminID),
         new SqlParameter("@UserName",lr.UserName),
         new SqlParameter("@LastLoginIP",lr.LastLoginIP),
         new SqlParameter("@LoginTime",lr.LoginTime)
     };
     SqlHelper.ExecuteNonQuery(_con, CommandType.Text, sql, p);
 }
示例#7
0
        protected LoginRecordInfo PopulateLoginRecord(IDataReader reader)
        {
            LoginRecordInfo entity = new LoginRecordInfo()
            {
                ID = (int)reader["ID"],
                AdminID = (int)reader["AdminID"],
                LastLoginIP = reader["LastLoginIP"] as string,
                LoginTime = DataConvert.SafeDate(reader["LoginTime"]),
                UserName = reader["UserName"] as string
            };

            return entity;
        }
示例#8
0
 public abstract void AddLoginRecord(LoginRecordInfo lr);