protected void Btnword_Click(object sender, EventArgs e) { int rsid = Int32.Parse(Request.Cookies[LearnSite.Common.CookieHelp.stuCookieNname].Values["Sid"].ToString()); string rsnum = Request.Cookies[LearnSite.Common.CookieHelp.stuCookieNname].Values["Snum"].ToString(); string rip = Request.Cookies[LearnSite.Common.CookieHelp.stuCookieNname].Values["LoginIp"].ToString(); string rgrade = Request.Cookies[LearnSite.Common.CookieHelp.stuCookieNname].Values["Sgrade"].ToString(); string rclass = Request.Cookies[LearnSite.Common.CookieHelp.stuCookieNname].Values["Sclass"].ToString(); string ryear = Request.Cookies[LearnSite.Common.CookieHelp.stuCookieNname].Values["Syear"].ToString(); string rterm = Request.Cookies[LearnSite.Common.CookieHelp.stuCookieNname].Values["ThisTerm"].ToString(); int rtid = Int32.Parse(Request.QueryString["Tid"].ToString()); int rcid = Int32.Parse(Request.QueryString["Cid"].ToString()); string rwords = Request.Form["textareaWord"].Trim(); string tempcut = LearnSite.Common.WordProcess.DropHTML(rwords); int counts = tempcut.Length; int rscore = 0; bool rban = false; if (counts > 5 && counts < 500) { rwords = rwords.Replace("<br />", ""); rwords = rwords.Replace(",", ","); LearnSite.BLL.TopicReply rbll = new LearnSite.BLL.TopicReply(); LearnSite.Model.TopicReply rmodel = new LearnSite.Model.TopicReply(); rmodel.Rban = rban; rmodel.Rip = rip; rmodel.Rscore = rscore; rmodel.Rsnum = rsnum; rmodel.Rtid = rtid; rmodel.Rtime = DateTime.Now; rmodel.Rwords = HttpUtility.HtmlEncode(rwords); rmodel.Rgrade = Int32.Parse(rgrade); rmodel.Rterm = Int32.Parse(rterm); rmodel.Rcid = rcid; rmodel.Rclass = Int32.Parse(rclass); rmodel.Rsid = rsid; rmodel.Ryear = Int32.Parse(ryear); rmodel.Redit = false; rmodel.Ragree = 0; int myreply = rbll.ReplyCount(rtid, rsid);//获取该学号回复数 if (Btnword.Text == "老师总结") { if (myreply > 0) { rbll.UpdateTeacher(rtid, rsid, rwords);//更新老师总结 } else { rbll.Add(rmodel);//增加老师总结 } Labeldiscuss.Text = "总结成功!"; } else { bool historyban = rbll.Isban(rtid, rsid); if (!historyban) { if (myreply < 1) { rbll.Add(rmodel);//增加一条回复 Labeldiscuss.Text = "回复成功!"; } else { if (rbll.Isedit(rtid, rsid)) { rbll.UpdateOne(rmodel);//修改一条回复 Labeldiscuss.Text = "修改成功!"; } else { Labeldiscuss.Text = "默认回复最多为1次!"; } } } else { Labeldiscuss.Text = "你在回复中存在违纪言论已被老师禁言!"; } } System.Threading.Thread.Sleep(500); showtopic(); showreply(); } else { Labeldiscuss.Text = "回复不能少于6个汉字或超过300个汉字,谢谢!"; } }
/// <summary> /// 获得数据列表 /// </summary> public List <LearnSite.Model.TopicReply> DataTableToList(DataTable dt) { List <LearnSite.Model.TopicReply> modelList = new List <LearnSite.Model.TopicReply>(); int rowsCount = dt.Rows.Count; if (rowsCount > 0) { LearnSite.Model.TopicReply model; for (int n = 0; n < rowsCount; n++) { model = new LearnSite.Model.TopicReply(); if (dt.Rows[n]["Rid"].ToString() != "") { model.Rid = int.Parse(dt.Rows[n]["Rid"].ToString()); } if (dt.Rows[n]["Rtid"].ToString() != "") { model.Rtid = int.Parse(dt.Rows[n]["Rtid"].ToString()); } model.Rsnum = dt.Rows[n]["Rsnum"].ToString(); model.Rwords = dt.Rows[n]["Rwords"].ToString(); if (dt.Rows[n]["Rtime"].ToString() != "") { model.Rtime = DateTime.Parse(dt.Rows[n]["Rtime"].ToString()); } model.Rip = dt.Rows[n]["Rip"].ToString(); if (dt.Rows[n]["Rscore"].ToString() != "") { model.Rscore = int.Parse(dt.Rows[n]["Rscore"].ToString()); } if (dt.Rows[n]["Rban"].ToString() != "") { if ((dt.Rows[n]["Rban"].ToString() == "1") || (dt.Rows[n]["Rban"].ToString().ToLower() == "true")) { model.Rban = true; } else { model.Rban = false; } } if (dt.Rows[n]["Rgrade"].ToString() != "") { model.Rgrade = int.Parse(dt.Rows[n]["Rgrade"].ToString()); } if (dt.Rows[n]["Rterm"].ToString() != "") { model.Rterm = int.Parse(dt.Rows[n]["Rterm"].ToString()); } if (dt.Rows[n]["Rcid"].ToString() != "") { model.Rcid = int.Parse(dt.Rows[n]["Rcid"].ToString()); } if (dt.Rows[n]["Rclass"].ToString() != "") { model.Rclass = int.Parse(dt.Rows[n]["Rclass"].ToString()); } modelList.Add(model); } } return(modelList); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(LearnSite.Model.TopicReply model) { return(dal.Add(model)); }
/// <summary> ///Rid 更新一条数据Rwords Rtime Redit Ragree /// </summary> public bool UpdateOne(LearnSite.Model.TopicReply model) { return(dal.UpdateOne(model)); }