Exemple #1
0
        // GET: YjLihouT
        public ActionResult Index(string n, tb_users user)
        {
            tb_users new_user;
            tb_users n_user;

            if (n != null)
            {
                n_user          = db.tb_users.SqlQuery("select * from tb_users where user_name = '" + n + "'").FirstOrDefault();
                Handler.loginid = n_user.user_id;
                if (n_user != null)
                {
                    return(View(n_user));
                }
            }
            if (user.user_name != null)
            {
                new_user = db.tb_users.SqlQuery("select * from tb_users where user_name = '" + user.user_name + "'").FirstOrDefault();
                new_user.user_login_count++;
                db.Entry(new_user).State = EntityState.Modified;
                db.SaveChanges();
                new_user.user_ip = GetIPAndMac.ipTrue();
                return(View(new_user));
            }
            n_user = db.tb_users.SqlQuery("select * from tb_users where user_name = '游客'").FirstOrDefault();
            return(View(n_user));
        }
Exemple #2
0
 //初始化登录信息
 private void InitLogin(HttpContext context)
 {
     if (loginis)
     {
         if (loginid >= 1)
         {
             SqlParameter[] ID   = { new SqlParameter("@ID", loginid) };
             DataTable      dt   = DB.SqlQueryForDataTatable(db.Database, "select * from tb_users where user_id = @ID", ID);
             string         json = f.DtToJson(dt);
             json = json.Replace("\"", "\\\"");
             tb_users new_user = db.tb_users.SqlQuery("select * from tb_users where user_id = " + loginid).FirstOrDefault();
             new_user.user_login_time = DateTime.Now;
             new_user.user_ip         = GetIPAndMac.ipTrue();
             db.Entry(new_user).State = EntityState.Modified;
             db.SaveChanges();
             context.Response.Write("{\"status\":\"" + json + "\"}");
         }
         else
         {
             context.Response.Write("{\"status\":\"-1\"}");
         }
     }
     else
     {
         tb_users users = new tb_users();
         users.user_name     = "游客";
         users.user_nickname = "游客";
         context.Response.Write(f.StToJSON(users));
     }
 }