📄 addpersonnote.aspx.cs
字号:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections.Generic;
using Office.DAL;
using Office.Model;
using Office.BLL;
public partial class ScheduleManage_PersonNote_AddPersonNote : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.lab_creater.Text = ((UserInfo)Session["User"]).UserId;
this.GetNote();
if (Request.QueryString["Nid"] == null)
{
this.Button2.Enabled = false;
}
}
}
//添加数据
public void InsertNote()
{
String title = this.txt_title.Text;
String content = this.txt_content.Text;
String name = this.lab_creater.Text;
String time = this.txt_time.Text;
MyNote note = new MyNote();
note.NoteTitle = title;
note.NoteContent = content;
note.CreateUser = UserInfoManager.GetUserInfoByUserId(name);
note.CreateTime = DateTime.Parse(time);
MyNoteManager.AddMyNote(note);
Response.Redirect("PersonNote.aspx");
}
//获得数据
public void GetNote()
{
MyNote note = new MyNote();
int noteid = Convert.ToInt32(Request.QueryString["Nid"]);
note = MyNoteManager.GetMyNoteByNoteId(noteid);
if (note != null)
{
this.txt_title.Text = note.NoteTitle;
this.txt_content.Text = note.NoteContent.ToString();
this.lab_creater.Text = note.CreateUser.UserName;
this.lab_creater.Enabled = false;
this.txt_time.Text = note.CreateTime.ToString();
this.txt_time.Enabled = false;
}
}
//修改数据
public void UpdateNote()
{
this.Button2.Enabled = true;
MyNote note = new MyNote();
note.NoteId = Convert.ToInt32(Request.QueryString["Nid"]);
note.NoteTitle = this.txt_title.Text;
note.NoteContent = this.txt_content.Text;
note.CreateUser = UserInfoManager.GetUserInfoByUserId(((UserInfo)Session["User"]).UserId);
note.CreateTime = DateTime.Parse(this.txt_time.Text);
MyNoteManager.ModifyMyNote(note);
Response.Redirect("PersonNote.aspx");
}
//删除数据
public void DeleteNote()
{
MyNoteManager.DeleteMyNoteById(Int32.Parse(Request.QueryString["Nid"].ToString()));
Response.Redirect("PersonNote.aspx");
}
//添加和修改
protected void Button1_Click(object sender, EventArgs e)
{
if(Request.QueryString["Nid"] != null)
{
this.UpdateNote();
}
else
{
this.InsertNote();
}
}
//删除
protected void Button2_Click(object sender, EventArgs e)
{
this.DeleteNote();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -