public async Task <IActionResult> JJUpdate(string datas) { JJProject myJJProject = JsonConvert.DeserializeObject <JJProject>(datas); //先查询要修改的原数据 JJProject customer = _context.JJProjects.Find(myJJProject.ID); //设置修改后的值 //customer.ID = myJJProject.ID; //customer.MC = myJJProject.MC; customer.XMDD = myJJProject.XMDD; customer.SGDW = myJJProject.SGDW; customer.FZR = myJJProject.FZR; customer.LXDH = myJJProject.LXDH; customer.JSZT = myJJProject.JSZT; customer.JSXZ = myJJProject.JSXZ; customer.KGRQ = myJJProject.KGRQ; customer.WGRQ = myJJProject.WGRQ; customer.YSZJ = myJJProject.YSZJ; customer.SYZJ = myJJProject.SYZJ; customer.XMMS = myJJProject.XMMS; customer.BZ = myJJProject.BZ; //更新到数据库 _context.SaveChanges(); var jjProjects = await _context.JJProjects.ToListAsync(); string jjProject = Newtonsoft.Json.JsonConvert.SerializeObject(jjProjects); return(Json(jjProject)); }
// public async Task<HttpResponse> Post(string row,string column,string scale) // { // byte[] result = getTile(int.Parse(scale),int.Parse(row),int.Parse(column),"satellite"); // Response.ContentType = "image/png"; // await Response.Body.WriteAsync(result, 0, result.Length); // return Response; // } public async Task <IActionResult> Post() { //身份标识 string ID = Request.Form["身份标识"]; //开工日期 string startTime = Request.Form["开工日期"]; //完工日期 string endTime = Request.Form["完工日期"]; //建设状态 string status = Request.Form["建设状态"]; //建设性质 string type = Request.Form["建设性质"]; //update //1先查询要修改的原数据 JJProject customer = _context.JJProjects.Find(ID); //2设置修改后的值 customer.ID = ID; customer.JSZT = status; customer.JSXZ = type; customer.KGRQ = startTime; customer.WGRQ = endTime; //3更新到数据库 _context.SaveChanges(); return(Json($"{ID}:更改成功")); }
public async Task <IActionResult> JJSave(string datas) { JJProject myJJProject = JsonConvert.DeserializeObject <JJProject>(datas); _context.JJProjects.Add(myJJProject); _context.SaveChanges(); var jjProjects = await _context.JJProjects.ToListAsync(); string jjProject = Newtonsoft.Json.JsonConvert.SerializeObject(jjProjects); return(Json(jjProject)); }
public async Task <IActionResult> JJDelete(string id) { try { //创建删除对象 JJProject project = _context.JJProjects.Find(id); _context.JJProjects.Remove(project); //更新到数据库 _context.SaveChanges(); } catch (Exception ex) { } var jjProjects = await _context.JJProjects.ToListAsync(); string jjProject = Newtonsoft.Json.JsonConvert.SerializeObject(jjProjects); return(Json(jjProject)); }