Beispiel #1
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";

            string json = "{'info':'增加数据失败'}";
            //获取动作的类型
            string action = context.Request.Form["Action"];

            if (action == "add")
            {
                //获取GET方法传递参数:Request.QueryString["参数名称"];
                //获取POST方法传递参数:Request.Form["参数名称"];
                string txtuname      = context.Request.Form["uname"]; //保存文本框对象,提高效率
                string txtupassword  = context.Request.Form["upassword"];
                string txtuemail     = context.Request.Form["uemail"];
                string adminSex      = context.Request.Form["usex"];
                string txtubirthday  = context.Request.Form["ubirthday"];
                string txtustatement = context.Request.Form["ustatement"];


                BBS.Model.BBSUsers model = new BBS.Model.BBSUsers();
                model.Uname     = txtuname;     //用户姓名
                model.UPassword = txtupassword; //用户密码
                model.UEmail    = txtuemail;    //用户邮箱
                //用户生日
                string y = txtubirthday.Substring(0, 4);
                string m = txtubirthday.Substring(4, 2);
                string d = txtubirthday.Substring(6, 2);
                txtubirthday     = y + "-" + m + "-" + d;
                model.UBirthday  = DateTime.Parse(txtubirthday); //用户生日
                model.UStatement = txtustatement;                //签名档



                model.Usex = false;//用户性别
                if (adminSex == "true")
                {
                    model.Usex = true;
                }

                BBS.BLL.BBSUsers bll = new BBS.BLL.BBSUsers();
                int n = bll.Add(model);
                //返回单个文字信息
                if (n > 0)
                {
                    json = "{'info':'增加数据成功,编号是:" + n + "'}";
                }
            }
            else if (action == "Load")
            {
                if (context.Session["uid"] == null)
                {
                    json = "{'info':'no'}";
                }
            }
            context.Response.Write(json);
        }
Beispiel #2
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";

            string json = "{'info':'增加数据失败'}";

            //获取GET方法传递参数:Request.QueryString["参数名称"];
            //获取POST方法传递参数:Request.Form["参数名称"];

            string action = context.Request.Form["Action"];

            if (action == "Add")
            {
                string uname      = context.Request.Form["uname"]; //保存文本框对象,提高效率
                string upassword  = context.Request.Form["upassword"];
                string uemail     = context.Request.Form["uemail"];
                string ubirthday  = context.Request.Form["ubirthday"];
                string ustatement = context.Request.Form["ustatement"];
                string usex       = context.Request.Form["usex"];



                BBS.Model.BBSUsers model = new BBS.Model.BBSUsers();
                model.Uname      = uname;
                model.UPassword  = upassword;
                model.UEmail     = uemail;
                model.UBirthday  = DateTime.Parse(ubirthday);
                model.UStatement = ustatement;
                model.Usex       = false;
                if (usex == "true")
                {
                    model.Usex = true;
                }

                BBS.BLL.BBSUsers bll = new BBS.BLL.BBSUsers();
                int n = bll.Add(model);
                //返回单个文字信息
                if (n > 0)
                {
                    json = "{'info':'增加数据成功,编号是:" + n + "'}";
                    context.Session["ID"]   = n;
                    context.Session["Name"] = uname;
                }
            }


            context.Response.Write(json);
        }
Beispiel #3
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (this.txtUname.Text.Trim().Length == 0)
            {
                strErr += "Uname不能为空!\\n";
            }
            if (this.txtUPassword.Text.Trim().Length == 0)
            {
                strErr += "UPassword不能为空!\\n";
            }
            if (this.txtUEmail.Text.Trim().Length == 0)
            {
                strErr += "UEmail不能为空!\\n";
            }
            if (!PageValidate.IsDateTime(txtUBirthday.Text))
            {
                strErr += "UBirthday格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txtUClass.Text))
            {
                strErr += "UClass格式错误!\\n";
            }
            if (this.txtUStatement.Text.Trim().Length == 0)
            {
                strErr += "UStatement不能为空!\\n";
            }
            if (!PageValidate.IsDateTime(txtURegDate.Text))
            {
                strErr += "URegDate格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txtUState.Text))
            {
                strErr += "UState格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txtUPoint.Text))
            {
                strErr += "UPoint格式错误!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            string   Uname      = this.txtUname.Text;
            string   UPassword  = this.txtUPassword.Text;
            string   UEmail     = this.txtUEmail.Text;
            DateTime UBirthday  = DateTime.Parse(this.txtUBirthday.Text);
            bool     Usex       = this.chkUsex.Checked;
            int      UClass     = int.Parse(this.txtUClass.Text);
            string   UStatement = this.txtUStatement.Text;
            DateTime URegDate   = DateTime.Parse(this.txtURegDate.Text);
            int      UState     = int.Parse(this.txtUState.Text);
            int      UPoint     = int.Parse(this.txtUPoint.Text);

            BBS.Model.BBSUsers model = new BBS.Model.BBSUsers();
            model.Uname      = Uname;
            model.UPassword  = UPassword;
            model.UEmail     = UEmail;
            model.UBirthday  = UBirthday;
            model.Usex       = Usex;
            model.UClass     = UClass;
            model.UStatement = UStatement;
            model.URegDate   = URegDate;
            model.UState     = UState;
            model.UPoint     = UPoint;

            BBS.BLL.BBSUsers bll = new BBS.BLL.BBSUsers();
            bll.Add(model);
            Common.MessageBox.ShowAndRedirect(this, "保存成功!", "add.aspx");
        }