/// <summary> /// 当前试题的笔记 /// </summary> /// <returns></returns> protected object GetNote(object[] id) { int qid = 0; if (id.Length > 0) { int.TryParse(id[0].ToString(), out qid); } if (!Extend.LoginState.Accounts.IsLogin) { return(null); } Song.Entities.Accounts st = Extend.LoginState.Accounts.CurrentUser; //笔记 Song.Entities.Student_Notes note = Business.Do <IStudent>().NotesSingle(qid, st.Ac_ID); return(note); }
/// <summary> /// 获取当前试题的笔记 /// </summary> /// <param name="objs"></param> /// <returns></returns> protected string GetNote(object[] objs) { //当前试题 Song.Entities.Questions qus = null; if (objs.Length > 0) { qus = objs[0] as Song.Entities.Questions; } if (qus == null) { return(""); } // Song.Entities.Student_Notes note = null; int acid = Extend.LoginState.Accounts.CurrentUserId; note = Business.Do <IStudent>().NotesSingle(qus.Qus_ID, acid); if (note == null) { return(""); } return(note.Stn_Context); }
int stnid = WeiSha.Common.Request.QueryString["stnid"].Int32 ?? 0; //笔记id protected override void InitPageTemplate(HttpContext context) { //如果没有提交 if (Request.ServerVariables["REQUEST_METHOD"] == "GET") { Song.Entities.Student_Notes note = null; note = Business.Do <IStudent>().NotesSingle(stnid); if (note == null && qid > 0 && Extend.LoginState.Accounts.IsLogin) { Song.Entities.Accounts st = Extend.LoginState.Accounts.CurrentUser; note = Business.Do <IStudent>().NotesSingle(qid, st.Ac_ID); } this.Document.SetValue("note", note); return; } if (Request.ServerVariables["REQUEST_METHOD"] == "POST") { if (!Extend.LoginState.Accounts.IsLogin) { return; } //提交的信息 string tbNote = WeiSha.Common.Request.Form["tbNote"].String; Song.Entities.Accounts st = Extend.LoginState.Accounts.CurrentUser; Song.Entities.Student_Notes note = null; note = Business.Do <IStudent>().NotesSingle(stnid); //如果笔记id取不到记录,用试题id取 if (note == null && qid > 0) { note = Business.Do <IStudent>().NotesSingle(qid, st.Ac_ID); } //如果提交信息为空,则为删除 if (string.IsNullOrWhiteSpace(tbNote)) { if (note != null) { Business.Do <IStudent>().NotesDelete(note.Stn_ID); } return; } Song.Entities.Student_Notes sn = note != null ? note : new Entities.Student_Notes(); sn.Stn_Context = tbNote; sn.Qus_ID = qid; sn.Ac_ID = st.Ac_ID; sn.Org_ID = this.Organ.Org_ID; try { if (stnid > 0) { Business.Do <IStudent>().NotesSave(sn); } else { Business.Do <IStudent>().NotesAdd(sn); } this.Document.SetValue("isSuccess", true); } catch { this.Document.SetValue("isSuccess", false); } } }