Example #1
0
        public ActionResult Register()
        {
            User user = new User();
            if(null != user){
                user.UserName = Request.QueryString["uname"];
                user.Password = Request.QueryString["pwd"];
                user.Email = Request.QueryString["email"];
                user.sex = Request.QueryString["sex"];
                user.RegisterTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            }
            //非空判断
            if (string.IsNullOrWhiteSpace(user.UserName)) { return RedirectToAction("Login"); }
            if (string.IsNullOrWhiteSpace(user.Password)) { return RedirectToAction("Login"); }
            if (string.IsNullOrWhiteSpace(user.Email)) { return RedirectToAction("Login"); }
            if (string.IsNullOrWhiteSpace(user.RegisterTime)) { return RedirectToAction("Login"); }

            WeiBoDataServices services = new WeiBoDataServices();
            int result = services.getServices().Register(user);
            if (result > 0)
            {
                //注册成功自动登录
                int uid = services.getServices().Login(user.UserName, user.Password);
                Session["uid"] = uid;
                Session["uname"] = user.UserName;
                return RedirectToAction("../Detail/More");
            }
            else
            {
                return RedirectToAction("Login");
            }
        }
Example #2
0
 public int updateUser(User user)
 {
     return SqlHelper.ExecuteNonQuery("I_Update_UserInfo", new SqlParameter("@uid", user.ID)
         , new SqlParameter("@address", user.Address)
         , new SqlParameter("@sex", user.sex)
         , new SqlParameter("@introduce", user.Introduce));
 }
Example #3
0
 /// <summary>
 /// 用户注册
 /// </summary>
 /// <param name="user">用户对象</param>
 /// <returns>成功则返回1</returns>
 public int Register(User user)
 {
     int result = SqlHelper.ExecuteNonQuery("I_Add_NewUser",
         new SqlParameter("@uname", user.UserName),
         new SqlParameter("@pwd", user.Password),
         new SqlParameter("@email", user.Email),
         new SqlParameter("@sex",int.Parse(user.sex)),
         new SqlParameter("@registerTime", user.RegisterTime));
     return result;
 }
Example #4
0
 public User getUserById(int uid)
 {
     User u = new User();
     SqlDataReader dr = SqlHelper.ExecuteReader("S_Get_User_BY_Id", new SqlParameter("@uid", uid));
     if(dr.Read()){
         u.ID = uid;
         u.UserName = dr.GetString(1);
         if (dr.GetInt32(3) == 0) { u.sex = "男"; } else { u.sex = "女"; };
         u.UserImage = dr.GetString(4);
         u.Email = dr.GetString(5);
         u.Address = dr.GetString(6);
         u.EduInfo = dr.GetString(7);
         u.Introduce = dr.GetString(8);
         u.RegisterTime = dr.GetString(9);
     }
     dr.Close();
     return u;
 }
Example #5
0
 public int updateUser(User user)
 {
     IWeiBoDal dal = new WeiBoDAL();
     return dal.updateUser(user);
 }
Example #6
0
 public int Register(User user)
 {
     IWeiBoDal dal = getDal();
     return dal.Register(user);
 }
Example #7
0
 public void update()
 {
     WeiBoDataServices s = new WeiBoDataServices();
     com.weibo.entity.User u = new com.weibo.entity.User();
     string UrlReferrer = Request.UrlReferrer.ToString();
     int no_province = int.Parse(Request.QueryString["Provinces"]);
     int no_city = int.Parse(Request.QueryString["Cities"]);
     string no_sex = Request.QueryString["sex"];
     string introduce = Request.QueryString["introduce"];
     string[] pc = s.getServices().GetProvinceAndCityById(no_province, no_city);
     u.ID = (int)Session["uid"];
     u.Address = pc[0] + "," + pc[1];
     u.sex = no_sex;
     u.Introduce = introduce;
     int result = s.getServices().updateUser(u);
     if (result > 0)
     {
         Response.Redirect(UrlReferrer);
     }
     else
     {
         Response.Redirect(UrlReferrer);
     }
 }