public void ProcessRequest(HttpContext context)
        {
            //string action = context.Request.Params["key"];
            string email = context.Request.Form["emal"];
            string name  = context.Request.Form["name"];
            string pass  = context.Request.Form["pass"];

            string status = "1";
            string error  = "null";

            try
            {
                using (var db = new TestTryEntities())
                {
                    //数据操作
                    var getGser = db.User.Where(x => x.Name == name || x.Email == email).Take(1).ToList();
                    if (getGser.Count > 0)
                    {
                        status = "0";
                        error  = "该用户名或邮箱已存在,请重试";
                    }
                    User user = new User()
                    {
                        Name     = pass,
                        Email    = email,
                        Password = pass
                    };
                    db.User.Add(user);
                    db.SaveChanges();
                    //var user = (from v in db.Student
                    //            where v.Name == "51aspx"
                    //            select v).Single();
                    //user.Password = "******";
                    //db.SaveChanges();
                }
            }
            catch (Exception e)
            {
                status = "0";
                error  = e.ToString();
            }

            StringBuilder json = new StringBuilder();

            json.Append("[");
            json.Append("{");
            json.Append("\"status\":" + "\"" + status + "\",");
            json.Append("\"error\":" + "\"" + error + "\"");
            json.Append("}");
            json.Append("]");
            //CreateXmlFile createXml = new CreateXmlFile();
            //TestTryEntities Db = new TestTryEntities();
            // int total = Db.Student.Count();
            string returnStr = json.ToString();

            context.Response.Write(returnStr);
        }
Exemplo n.º 2
0
 public void InserProject(string Pname, string PjCity, string MachineNum, string IsNow, string PjXSName, string IsDealer, string Phone, string Other)
 {
     using (var db = new TestTryEntities())
     {
         //数据操作
         //var getGser = db.User.Where(x => x.Name == name || x.Email == email).Take(1).ToList();
         //if (getGser.Count > 0)
         //{
         //}
         ProjectInfo pro = new ProjectInfo()
         {
             pname      = Pname,
             pjCity     = PjCity,
             machineNum = MachineNum,
             isNow      = Convert.ToInt32(IsNow),
             pjXSName   = PjXSName,
             isDealer   = Convert.ToInt32(IsDealer),
             phone      = Phone,
             other      = Other
         };
         db.ProjectInfo.Add(pro);
         db.SaveChanges();
     }
 }