public ActionResult NewsTalk_Edit(t_news_talk model) { string sql = string.Format("update t_news_talk t set t.adminid='{0}',t.answer='{1}',t.read=0 where t.id={2}", Common.getAdmin().id, model.answer, model.id); int count = DbHelperMySQL.ExecuteSql(sql); return(Json(Result.AutoResult(count), JsonRequestBehavior.AllowGet)); }
public ActionResult NewsTalk_Add(t_news_talk model, IEnumerable <HttpPostedFileBase> files) { string sql = string.Format("insert into t_news_talk(newsid,userid,time,question,del) values({0},{1},now(),'{2}',0);SELECT @@IDENTITY", model.newsid, Common.getUser().id, model.question); int talkid = Convert.ToInt32(DbHelperMySQL.GetSingle(sql)); try { Common.Count_User_News_Question(); } catch (Exception e) { } int result = 0; if (files != null && files.Count() != 0) { foreach (var f in files) { string fileName = DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss") + "." + Guid.NewGuid() + Path.GetExtension(f.FileName); string filePath = Path.Combine(Request.MapPath("~/Upload"), fileName); f.SaveAs(filePath); sql = string.Format("insert into t_files(filename,type,typekey,del) values('{0}',1,'{1}',0)", fileName, talkid); int count = DbHelperMySQL.ExecuteSql(sql); result += count; } return(Json(Result.AutoResult(result == files.Count() ? 1 : 0), JsonRequestBehavior.AllowGet)); } return(Json(Result.AutoResult(talkid == 0 ? 0 : 1), JsonRequestBehavior.AllowGet)); }