planlist.aspx.cs

来自「一个简单的办公自动化系统」· CS 代码 · 共 119 行

CS
119
字号
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);
			}
		}

		/// <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>
        protected 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>
        protected 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 + =
减小字号Ctrl + -
显示快捷键?