Exemplo n.º 1
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            UploadImage ui        = new UploadImage();
            var         PhoneName = this.FileUpload1.FileName;
            UsersModels u         = new UsersModels()
            {
                Email    = this.textEmail.Text.Trim(),
                Password = this.textPassword.Text.Trim(),
                NickName = this.textNickName.Text.Trim(),
                Photo    = ui.UpFileName(this.FileUpload1, "~/User_folder/"),
            };

            if (ub.Add_User(u))
            {
                Response.Write("<script>alert('注册成功');</script>");
            }
            else
            {
                Response.Write("<script>alert('注册失败');</script>");
            }
        }
Exemplo n.º 2
0
        private void register()
        {
            string username = "";

            if (!string.IsNullOrEmpty(HttpContext.Current.Request["username"]))
            {
                username = InText.SafeSql(InText.SafeStr(HttpContext.Current.Request["username"]));
            }
            string pwd = "";

            if (!string.IsNullOrEmpty(HttpContext.Current.Request["pwd"]))
            {
                pwd = Utils.Encrypt(InText.SafeSql(InText.SafeStr(HttpContext.Current.Request["pwd"])));
            }
            string email = "";

            if (!string.IsNullOrEmpty(HttpContext.Current.Request["email"]))
            {
                email = InText.SafeSql(InText.SafeStr(HttpContext.Current.Request["email"]));
            }
            int sex = 2;

            if (!string.IsNullOrEmpty(HttpContext.Current.Request["sex"]))
            {
                sex = Utils.CheckInt(HttpContext.Current.Request["sex"]);
            }
            int baby = 2;

            if (!string.IsNullOrEmpty(HttpContext.Current.Request["baby"]))
            {
                baby = Utils.CheckInt(HttpContext.Current.Request["baby"]);
            }
            DateTime baby_date = DateTime.Now;

            if (!string.IsNullOrEmpty(HttpContext.Current.Request["baby_date"]))
            {
                baby_date = Convert.ToDateTime(HttpContext.Current.Request["baby_date"]);
            }
            string remark = "";

            if (!string.IsNullOrEmpty(HttpContext.Current.Request["remark"]))
            {
                remark = InText.SafeSql(InText.SafeStr(HttpContext.Current.Request["remark"]));
            }

            int result = userBll.Add_User(username, pwd, email, sex, baby, baby_date, remark);

            StringWriter sw = new StringWriter();

            Newtonsoft.Json.JsonWriter writer = new Newtonsoft.Json.JsonTextWriter(sw);

            if (result > 0)
            {
                writer.WriteStartObject();
                writer.WritePropertyName("status");
                writer.WriteValue("200");
                writer.WritePropertyName("newid");
                writer.WriteValue(result.ToString());
                writer.WriteEndObject();
                writer.Flush();
            }
            else
            {
                writer.WriteStartObject();
                writer.WritePropertyName("status");
                writer.WriteValue("500");
                writer.WriteEndObject();
                writer.Flush();
            }
            string jsonText = sw.GetStringBuilder().ToString();

            Response.Write(jsonText);
        }