public ActionResult ListEssay() { DBHelper tmpDBHelper = new DBHelper(); List<Essay> EssayList = tmpDBHelper.GetEssayList(); ViewBag.list = EssayList; return View(); }
// GET: Comment public ActionResult Index() { DBHelper db = new DBHelper(); var uid = Session["UserId"].ToString(); ViewBag.CommentList = db.GetCommentListByUid(uid); return View(); }
public ActionResult DeleteEssay(string uid, string title) { DBHelper tmpDBHelper = new DBHelper(); tmpDBHelper.SqlExcute("delete from Essay where UserID = '" + uid + "'and EssayTitle = '" + title + "'"); return Redirect("ManageEssay"); }
public ActionResult Delete(string uid, string title, string content) { // TODO: Add delete logic here DBHelper db = new DBHelper(); var DelStr = CommentDelStr(uid, title, content); db.SqlExcute(DelStr); return RedirectToAction("Index"); }
public ActionResult Create(string uid, string title) { DBHelper db = new DBHelper(); ViewBag.Essay = db.GetEssyByUid_Title(uid, title); ViewBag.CommentList = db.GetCommentListByTitle(title); essay_uid = uid; essay_title = title; return View(); //************************************************************** }
public ActionResult CreateEssay(Essay model) { DBHelper tmpDBHelper = new DBHelper(); var title = model.Title; var content = model.Content; var userID = Session["UserId"].ToString(); tmpDBHelper.SqlExcute("insert into Essay(UserId,EssayTitle,EssayContent) values('" + userID + "','" + title + "','" + content + "')"); return Redirect("ListEssay"); }
public ActionResult UpdateEssay(Essay model) { DBHelper tmpDBHelper = new DBHelper(); var uid = Session["UserId"].ToString(); var new_title = model.Title; var new_content = model.Content; string old_title = (string)Session["CurrentTitle"]; string old_content = (string)Session["CurrentContent"]; tmpDBHelper.UpdateEssay(uid, old_title, old_content, new_title, new_content); return Redirect("ManageEssay"); }
public ActionResult Create(string content) { DBHelper db = new DBHelper(); var uid = Session["UserId"].ToString(); ViewBag.Essay = db.GetEssyByUid_Title(essay_uid, essay_title); //************************************************************** try { // TODO: Add insert logic here db.SqlExcute(CommentCreateSql(essay_title, content)); ViewBag.CommentList = db.GetCommentListByTitle(essay_title); Response.Write("<script>alert('评论成功!')</script>"); return View(); } catch { return View(); } }
//判断用户名是否被注册~~~ private bool ExistAccount(string uid,string pwd=null) { bool Exist = false; DBHelper db = new DBHelper(); var n = 0; if (pwd == null) { n = db.SqlReader("select * from UserAccount where UserId = '" + uid + "'"); } else { n = db.SqlReader("select * from UserAccount where UserId = '" + uid + "' and Pwd = '" + pwd + "'"); } Exist = (n > 0) ? true : false; return Exist; }
public ActionResult Register(RegisterViewModel model) { if (ModelState.IsValid) { if (!ExistAccount(model.UserId)) { DBHelper db = new DBHelper(); db.SqlExcute(StoreAccountText(model.UserId, model.Pwd)); return Redirect("~/Essay/ListEssay"); } else { Response.Write("<script>alert('该手机号码已被注册')</script>"); return View(model); } } // 如果我们进行到这一步时某个地方出错,则重新显示表单 return View(model); }
public List<Essay> GetEssayList(string uid) { DBHelper db = new DBHelper(); return db.GetEssayList(uid); /////// }