Example #1
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            if (TextBox1.Text.Length == 0
                || TextBox2.Text.Length == 0
                || TextBox3.Text.Length == 0
                || TextBox4.Text.Length == 0
                || TextBox2.Text != TextBox3.Text)
            {
                Response.Write("<script> alert( '注册失败') </script> ");
                return;
            }
            else
            {
                //检查用户名是否存在
                using (LiBoClothesShopEntities context = new LiBoClothesShopEntities())
                {
                    var query = from userInfo in context.UserInfoes
                                where userInfo.UserName == TextBox1.Text
                                select userInfo;
                    if (query.Count() != 0)
                    {
                        Response.Write("<script> alert( '注册失败') </script> ");
                        return;
                    }
                    else
                    {
                        UserInfo newUser = new UserInfo();
                        newUser.UserName = TextBox1.Text;
                        newUser.Password = TextBox2.Text;
                        newUser.Phone = TextBox3.Text;
                        if (Convert.ToInt32(Request.QueryString["Type"]) == 2)
                        {
                            newUser.IsAdmin = true;
                        }
                        else
                        {
                            newUser.IsAdmin = false;
                        }

                        context.AddToUserInfoes(newUser);
                        context.SaveChanges();
                        Response.Write("<script> alert( '注册成功');window.location.href = 'Default.aspx';</script>");
                    }
                }
            }
        }
Example #2
0
 /// <summary>
 /// Deprecated Method for adding a new object to the UserInfoes EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToUserInfoes(UserInfo userInfo)
 {
     base.AddObject("UserInfoes", userInfo);
 }
Example #3
0
 /// <summary>
 /// Create a new UserInfo object.
 /// </summary>
 /// <param name="userName">Initial value of the UserName property.</param>
 /// <param name="password">Initial value of the Password property.</param>
 /// <param name="phone">Initial value of the Phone property.</param>
 /// <param name="isAdmin">Initial value of the IsAdmin property.</param>
 public static UserInfo CreateUserInfo(global::System.String userName, global::System.String password, global::System.String phone, global::System.Boolean isAdmin)
 {
     UserInfo userInfo = new UserInfo();
     userInfo.UserName = userName;
     userInfo.Password = password;
     userInfo.Phone = phone;
     userInfo.IsAdmin = isAdmin;
     return userInfo;
 }