コード例 #1
0
ファイル: isUpdate.ashx.cs プロジェクト: dmer175/ASP.NET-
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            BLL.User_Service userSer = new BLL.User_Service();
            int id = Convert.ToInt32(context.Request.Form["hiddenId"]);

            Model.User_Model usermodel = userSer.GetUser(id);
            if (usermodel != null)
            {
                usermodel.LoginPwd = context.Request.Form["txtpwd"];
                usermodel.NickName = context.Request.Form["txtnick"];
                usermodel.Sex      = context.Request.Form["txtsex"];
                usermodel.Age      = Convert.ToInt32(context.Request.Form["txtage"]);
                usermodel.FaceId   = Convert.ToInt32(context.Request.Form["txtface"]);
                usermodel.Friend   = Convert.ToInt32(context.Request.Form["txtfriend"]);
                usermodel.Name     = context.Request.Form["txtname"];
                usermodel.StarId   = Convert.ToInt32(context.Request.Form["txtstar"]);
                usermodel.BloodId  = Convert.ToInt32(context.Request.Form["txtblood"]);
                usermodel.Id       = id;
                if (userSer.UpdateUser(usermodel))
                {
                    context.Response.Redirect("Index.ashx");
                }
                else
                {
                    context.Response.Redirect("Error.html");
                }
            }
        }
コード例 #2
0
ファイル: Update.ashx.cs プロジェクト: dmer175/ASP.NET-
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/html";
            int id;

            if (int.TryParse(context.Request.QueryString["id"], out id))
            {
                BLL.User_Service userSer     = new BLL.User_Service();
                Model.User_Model usermodel   = userSer.GetUser(id);
                string           filePath    = context.Request.MapPath("Update.html");
                string           fileContent = File.ReadAllText(filePath);
                fileContent = fileContent.Replace("$pwd", usermodel.LoginPwd).Replace("$nick", usermodel.NickName)
                              .Replace("$sex", usermodel.Sex).Replace("$age", usermodel.Age.ToString()).Replace("$face", usermodel.FaceId.ToString())
                              .Replace("$friend", usermodel.Friend.ToString()).Replace("$name", usermodel.Name).Replace("$star", usermodel.StarId.ToString())
                              .Replace("$blood", usermodel.BloodId.ToString()).Replace("$id", usermodel.Id.ToString());
                context.Response.Write(fileContent);
            }
        }