protected void Repeater_Notes_ItemCommand(object source, RepeaterCommandEventArgs e) { if (e.CommandArgument.Equals("save")) { Label labMid = (Label)e.Item.FindControl("labMid"); Label labCid = (Label)e.Item.FindControl("labCid"); HtmlTextArea txtContent = (HtmlTextArea)e.Item.FindControl("notesTarea"); if (labMid == null || labCid == null || txtContent == null) { return; } Model.Tao.CourseNotes noteModel = new Model.Tao.CourseNotes(); BLL.Tao.CourseNotes noteBll = new BLL.Tao.CourseNotes(); int cid = int.Parse(labCid.Text); int Mid = int.Parse(labMid.Text); noteModel.CourseID = cid; noteModel.ModuleID = Mid; noteModel.UserID = CurrentUser.UserID; string contentStr = txtContent.Value; Label labNid = (Label)e.Item.FindControl("labNid"); if (labNid != null && labNid.Text != "") { noteModel.NoteID = int.Parse(labNid.Text); noteModel.Contents = contentStr; noteModel.Updatetime = DateTime.Now; if (noteBll.Update(noteModel)) { Maticsoft.Common.MessageBox.Show(this, "修改成功!"); } else { Maticsoft.Common.MessageBox.Show(this, "修改失败!"); } } else { noteModel.Contents = contentStr; noteModel.Updatetime = DateTime.Now; if (noteBll.Add(noteModel) > 0) { Maticsoft.Common.MessageBox.Show(this, "保存成功!"); } else { Maticsoft.Common.MessageBox.Show(this, "保存失败!"); } } } }
protected void btnAddCourseNotes_Click(object sender, ImageClickEventArgs e) { if (CurrentUser == null) { Maticsoft.Common.MessageBox.Show(this, "对不起,您尚未登录,无法进行添加笔记操作,请登录后再进行操作!"); return; } if (string.IsNullOrEmpty(this.NotebookArea.Value)) { Maticsoft.Common.MessageBox.Show(this, "请输入笔记内容!"); return; } if (!string.IsNullOrEmpty(this.labNID.Text)) { int nid = int.Parse(labNID.Text); Model.Tao.CourseNotes model = courseNotesBLL.GetModel(nid); model.Contents = this.NotebookArea.Value; if (courseNotesBLL.Update(model)) { ShowCourseNotes(CurrentUser.UserID, int.Parse(this.hfCourseID.Value), int.Parse(this.hfModuleID.Value)); } } else { if (!string.IsNullOrEmpty(this.hfCourseID.Value) && PageValidate.IsNumber(this.hfCourseID.Value)) { Model.Tao.CourseNotes model = new Model.Tao.CourseNotes(); model.CourseID = int.Parse(this.hfCourseID.Value); model.ModuleID = courseModuleBLL.GetFirstModuleID(int.Parse(this.hfCourseID.Value)); if (!string.IsNullOrEmpty(this.hfModuleID.Value) && PageValidate.IsNumber(this.hfModuleID.Value)) { model.ModuleID = int.Parse(this.hfModuleID.Value); } model.Contents = this.NotebookArea.Value; model.Updatetime = DateTime.Now; model.UserID = CurrentUser.UserID; if (courseNotesBLL.Add(model) > 0) { ShowCourseNotes(CurrentUser.UserID, int.Parse(this.hfCourseID.Value), int.Parse(this.hfModuleID.Value)); } } } this.labNID.Text = string.Empty; this.NotebookArea.Value = string.Empty; }