예제 #1
0
 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 + ")'> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a></td><td style='font-size:20px;'><a href='javascript:void(0)' class='btn_delete' onclick='showDeleteNote(" + m.Id + ")'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a></td>";
         return Content(content);
     }
     catch (Exception e)
     {
         return Content("fail" + e.Message);
     }
 }
예제 #2
0
        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 + ")'> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a></td><td style='style='font-size:20px;'><a href='javascript:void(0)' class='btn_delete' onclick='showDeleteNote(" + nid + ")'><span style='font-size:24px'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a></td></tr>";
                return Content(content);
            }
            catch (Exception e)
            {
                return Content("fail" + e.Message);
            }
        }
예제 #3
0
 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;
 }
예제 #4
0
 public void updateNote(Note mes)
 {
     executeNonQuery("UPDATE Note SET UserId=" + mes.UserId + ", Name='" + mes.Name
                                  + "', Content='" + mes.Content + "' WHERE Id=" + mes.Id);
 }
예제 #5
0
 public void insertNote(Note mes)
 {
     executeNonQuery("INSERT INTO Note (UserId, Name, Content, SubmitTime) VALUES ("
                                  + mes.UserId + ", '" + mes.Name + "', '" + mes.Content + "', '" + mes.SubmitTime + "')");
 }