📄 planlist.aspx.cs
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using MyOA.BusinessLogicLayer;
using MyOA.DataAccessHelper;
namespace MyOA.Web
{
/// <summary>
/// CalendarList 的摘要说明。
/// </summary>
public partial class PlanList : System.Web.UI.Page
{
/// <summary>
/// 页面加载事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load(object sender, System.EventArgs e)
{
if(!IsPostBack)
{
ImageButtonUpdate.Visible=false;
ImageButtonAdd.Visible=false;
InitData();
GetPlan(DateTime.Today);
}
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.ImageButtonAdd.Click += new System.Web.UI.ImageClickEventHandler(this.ImageButtonAdd_Click);
this.ImageButtonUpdate.Click += new System.Web.UI.ImageClickEventHandler(this.ImageButtonUpdate_Click);
}
#endregion
/// <summary>
/// 初始化日历控件为当前日期
/// </summary>
private void InitData()
{
Calendar.SelectedDate=DateTime.Today;
}
/// <summary>
/// 获取计划信息,并通过TextBoxPlan显示出来
/// </summary>
/// <param name="day"></param>
private void GetPlan(DateTime day)
{
TextBoxPlan.Text="";
TextBoxPlan.ReadOnly=false;
Plan plan=new Plan();
plan.LoadData(Session["login_name"].ToString(),day);
if(plan.PlanContent!=null && plan.PlanContent!=System.String.Empty)
{
TextBoxPlan.Text=plan.PlanContent;
ImageButtonUpdate.Visible=true;
ImageButtonAdd.Visible=false;
}
else
{
TextBoxPlan.Text="[无计划]";
ImageButtonAdd.Visible=true;
ImageButtonUpdate.Visible=false;
}
if(day<DateTime.Today)
{
TextBoxPlan.ReadOnly=true;
ImageButtonUpdate.Visible=false;
ImageButtonAdd.Visible=false;
}
}
/// <summary>
/// 日历控件单击事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Calendar_SelectionChanged(object sender, System.EventArgs e)
{
GetPlan(Calendar.SelectedDate);
}
/// <summary>
/// 添加新计划
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ImageButtonAdd_Click(object sender, System.Web.UI.ImageClickEventArgs e)
{
Hashtable ht=new Hashtable();
ht.Add("LoginName",SqlStringConstructor.GetQuotedString(Session["login_name"].ToString()));
ht.Add("PlanDate",SqlStringConstructor.GetQuotedString(Calendar.SelectedDate.ToString()));
ht.Add("PlanContent",SqlStringConstructor.GetQuotedString(TextBoxPlan.Text));
Plan.Add(ht);
}
/// <summary>
/// 修改计划
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ImageButtonUpdate_Click(object sender, System.Web.UI.ImageClickEventArgs e)
{
Plan plan=new Plan();
plan.LoadData(Session["login_name"].ToString(),Calendar.SelectedDate);
plan.PlanContent=TextBoxPlan.Text;
plan.Update();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -