/// <summary> /// 删除回复信息 /// </summary> /// <param name="identify"></param> public void AnswerDelete(int identify) { MessageBoard mb = Gateway.Default.From <MessageBoard>().Where(MessageBoard._.Mb_Id == identify).ToFirst <MessageBoard>(); if (mb.Mb_IsTheme) { this.ThemeDelete(mb); } else { Song.Entities.MessageBoard theme = Gateway.Default.From <MessageBoard>().Where(MessageBoard._.Mb_IsTheme == true && MessageBoard._.Mb_UID == mb.Mb_UID).ToFirst <MessageBoard>(); using (DbTrans tran = Gateway.Default.BeginTrans()) try { theme.Mb_AnsTime = DateTime.Now; theme.Mb_ReplyNumber -= 1; tran.Save <MessageBoard>(theme); // tran.Delete <MessageBoard>(MessageBoard._.Mb_Id == identify); tran.Commit(); } catch (Exception ex) { tran.Rollback(); throw ex; } finally { tran.Close(); } } }
/// <summary> /// 添加回复留言信息 /// </summary> /// <param name="entity"></param> public void AnswerAdd(MessageBoard entity) { // Song.Entities.Organization org = Business.Do <IOrganization>().OrganCurrent(); if (org != null) { entity.Org_ID = org.Org_ID; entity.Org_Name = org.Org_Name; } Song.Entities.MessageBoard theme = Gateway.Default.From <MessageBoard>().Where(MessageBoard._.Mb_IsTheme == true && MessageBoard._.Mb_UID == entity.Mb_UID).ToFirst <MessageBoard>(); using (DbTrans tran = Gateway.Default.BeginTrans()) { try { theme.Mb_AnsTime = DateTime.Now; theme.Mb_ReplyNumber += 1; tran.Save <MessageBoard>(theme); // entity.Mb_IsTheme = false; entity.Mb_CrtTime = DateTime.Now; entity.Mb_IP = WeiSha.Common.Request.IP.IPAddress; tran.Save <MessageBoard>(entity); tran.Commit(); } catch (Exception ex) { tran.Rollback(); throw ex; } finally { tran.Close(); } } }
protected void Page_Load(object sender, EventArgs e) { mb = Business.Do <IMessageBoard>().ThemeSingle(id); if (!this.IsPostBack) { fill(); } }
/// <summary> /// 修改是否显示的状态 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void sbShow_Click(object sender, EventArgs e) { try { StateButton ub = (StateButton)sender; int index = ((GridViewRow)(ub.Parent.Parent)).RowIndex; int id = int.Parse(this.GridView1.DataKeys[index].Value.ToString()); // Song.Entities.MessageBoard entity = Business.Do <IMessageBoard>().ThemeSingle(id); entity.Mb_IsShow = !entity.Mb_IsShow; Business.Do <IMessageBoard>().ThemeSave(entity); BindData(null, null); } catch (Exception ex) { Message.ExceptionShow(ex); } }
public MessageBoard[] ListPager(string uid, int size, int index, out int countSum) { WhereClip wc = MessageBoard._.Mb_UID == uid; countSum = Gateway.Default.Count <MessageBoard>(wc); Song.Entities.MessageBoard[] msg = Gateway.Default.From <MessageBoard>().Where(wc).OrderBy(MessageBoard._.Mb_CrtTime.Asc).ToArray <MessageBoard>(size, (index - 1) * size); //把主题放到最前面 for (int i = 0; i < msg.Length; i++) { if (msg[i].Mb_IsTheme == true) { Song.Entities.MessageBoard tm = msg[0]; msg[0] = msg[i]; msg[i] = tm; break; } } return(msg); }
/// <summary> /// 获取列表 /// </summary> private void list() { //int couid = WeiSha.Common.Request.Form["couid"].Int32 ?? 0; int size = WeiSha.Common.Request.Form["size"].Int32 ?? 10; //每页多少条 int index = WeiSha.Common.Request.Form["index"].Int32 ?? 1; //第几页 int sumcount = 0; Song.Entities.MessageBoard[] msgBoards = Business.Do <IMessageBoard>().ThemePager(Organ.Org_ID, couid, false, true, "", size, index, out sumcount); //冒泡排序 Song.Entities.MessageBoard temp = null; for (int i = 0; i < msgBoards.Length; i++) { for (int j = i + 1; j < msgBoards.Length; j++) { if (msgBoards[j].Mb_CrtTime > msgBoards[i].Mb_CrtTime) { temp = msgBoards[j]; msgBoards[j] = msgBoards[i]; msgBoards[i] = temp; } } } string json = "{\"size\":" + size + ",\"index\":" + index + ",\"sumcount\":" + sumcount + ","; json += "\"items\":["; for (int n = 0; n < msgBoards.Length; n++) { Song.Entities.MessageBoard mb = msgBoards[n]; mb.Mb_Content = WeiSha.Common.HTML.ClearTag(mb.Mb_Content); if (string.IsNullOrWhiteSpace(mb.Mb_Answer)) { mb.Mb_IsAns = false; } if (!mb.Mb_IsAns || string.IsNullOrWhiteSpace(mb.Mb_Answer) || mb.Mb_Answer.Trim() == "") { json += mb.ToJson() + ","; continue; } //如果教师进行了回复,则增加教师相关输出 if (mb.Mb_IsAns) { //增加输出项 Dictionary <string, object> addParas = new Dictionary <string, object>(); Song.Entities.Teacher th = Business.Do <ITeacher>().TeacherSingle(mb.Th_ID); if (th != null) { addParas.Add("Th_Name", th.Th_Name); addParas.Add("Th_Photo", th.Th_Photo); json += mb.ToJson(null, null, addParas) + ","; } } } if (json.EndsWith(",")) { json = json.Substring(0, json.Length - 1); } json += "]}"; Response.Write(json); Response.End(); }
/// <summary> /// 删除,按主键ID; /// </summary> /// <param name="identify">实体的主键</param> public void ThemeDelete(int identify) { Song.Entities.MessageBoard tm = this.ThemeSingle(identify); Gateway.Default.Delete <MessageBoard>(MessageBoard._.Mb_UID == tm.Mb_UID); }