public ActionResult edit(Note m) { try { Provider db = new Provider(); db.updateNote(m); string content = "<td>" + m.Name + "</td><td>" + m.Content + "</td><td>" + m.SubmitTime.ToString("yyyy-MM-dd") + "</td><td style='font-size:20px;'><a href='javascript:void(0)' class='btn_edit' onclick='showEditNote(" + m.Id + ")'> </a></td><td style='font-size:20px;'><a href='javascript:void(0)' class='btn_delete' onclick='showDeleteNote(" + m.Id + ")'> </a></td>"; return Content(content); } catch (Exception e) { return Content("fail" + e.Message); } }
public ActionResult add(Note m) { if (!isLogin()) return RedirectToAction("login", "auth"); User user = getCurrentUser(); m.UserId = user.Id; m.SubmitTime = DateTime.Now; Provider db = new Provider(); try { db.insertNote(m); int nid = (int)db.getDataRow("SELECT Id FROM Note ORDER BY Id DESC")["Id"]; string content = "<tr id='note_item_" + nid + "'><td>" + m.Name+ "</td><td>" +m.Content + "</td><td>" + m.SubmitTime.ToString("yyyy-MM-dd") + "</td><td style='font-size:20px;'><a href='javascript:void(0)' class='btn_edit' onclick='showEditNote(" + nid + ")'> </a></td><td style='style='font-size:20px;'><a href='javascript:void(0)' class='btn_delete' onclick='showDeleteNote(" + nid + ")'><span style='font-size:24px'> </a></td></tr>"; return Content(content); } catch (Exception e) { return Content("fail" + e.Message); } }
public Note toNote(DataRow data) { if (data == null) return null; Note mes = new Note(); mes.Id = (int)data["Id"]; mes.Name = (string)data["Name"]; mes.Content = (string)data["Content"]; mes.SubmitTime = (DateTime)data["SubmitTime"]; mes.UserId = (int)data["UserId"]; return mes; }
public void updateNote(Note mes) { executeNonQuery("UPDATE Note SET UserId=" + mes.UserId + ", Name='" + mes.Name + "', Content='" + mes.Content + "' WHERE Id=" + mes.Id); }
public void insertNote(Note mes) { executeNonQuery("INSERT INTO Note (UserId, Name, Content, SubmitTime) VALUES (" + mes.UserId + ", '" + mes.Name + "', '" + mes.Content + "', '" + mes.SubmitTime + "')"); }