SchedByDay.aspx.cs
上传用户:autodoor
上传日期:2022-08-04
资源大小:9973k
文件大小:7k
- using System;
- using System.Data;
- using System.Data.SqlClient;
- using System.Web.UI.WebControls;
- using System.Web.UI.HtmlControls;
- using qminoa.DA.Schedule;
- namespace qminoa.Webs.Schedule
- {
- public class SchedByDay : qminoa.Webs.PageBase
- {
- protected System.Web.UI.WebControls.Label lblUName;
- protected System.Web.UI.WebControls.TextBox txtYear;
- protected System.Web.UI.WebControls.DropDownList dropMonth;
- protected System.Web.UI.WebControls.DropDownList dropDay;
- protected System.Web.UI.WebControls.ImageButton cmdQuery;
- protected System.Web.UI.WebControls.Label lblErr;
- protected System.Web.UI.WebControls.Label lblYear;
- protected System.Web.UI.WebControls.Label lblDate;
- protected System.Web.UI.WebControls.LinkButton cmdToday;
- protected System.Web.UI.WebControls.LinkButton cmdMonth;
- protected System.Web.UI.WebControls.LinkButton cmdWeek;
- protected System.Web.UI.WebControls.LinkButton cmdDay;
- protected System.Web.UI.WebControls.LinkButton cmdLastDay;
- protected System.Web.UI.WebControls.Label lblHeader;
- protected System.Web.UI.WebControls.LinkButton cmdNextDay;
- protected System.Web.UI.WebControls.ImageButton cmdAddNew;
- private static DateTime date = new DateTime();
- private void Page_Load(object sender, System.EventArgs e)
- {
- this.PageBegin("我的日程",false);
- if(!IsPostBack)
- {
- if(Request.QueryString["date"] != null)
- {
- date =DateTime.Parse(Request.QueryString["date"]);
- DisplayDate(date);
- }
- else
- {
- date= DateTime.Now;
- DisplayDate(DateTime.Now);
- }
- }
- }
-
- void DisplayDate(DateTime date)
- {
- string Day = "";
- switch(date.DayOfWeek.ToString())
- {
- case "Sunday":
- Day="星期日";
- break;
- case "Monday":
- Day="星期一";
- break;
- case "Tuesday":
- Day="星期二";
- break;
- case "Wednesday":
- Day="星期三";
- break;
- case "Thursday":
- Day="星期四";
- break;
- case "Friday":
- Day="星期五";
- break;
- case "Saturday":
- Day="星期六";
- break;
- }
- lblHeader.Text = date.Year +"年"+ date.Month +"月"+ date.Day +"日"+" "+" "+" "+Day;
- txtYear.Text = date.Year.ToString();
- dropMonth.SelectedIndex = date.Month - 1;
- dropDay.SelectedIndex = date.Day - 1;
- }
- #region Web Form Designer generated code
- override protected void OnInit(EventArgs e)
- {
- //
- // CODEGEN:该调用是 ASP.NET Web 窗体设计器所必需的。
- //
- InitializeComponent();
- base.OnInit(e);
- }
-
- /// <summary>
- /// 设计器支持所需的方法 - 不要使用代码编辑器修改
- /// 此方法的内容。
- /// </summary>
- private void InitializeComponent()
- {
- this.dropMonth.SelectedIndexChanged += new System.EventHandler(this.dropMonth_SelectedIndexChanged);
- this.dropDay.SelectedIndexChanged += new System.EventHandler(this.dropDay_SelectedIndexChanged);
- this.cmdQuery.Click += new System.Web.UI.ImageClickEventHandler(this.cmdQuery_Click);
- this.cmdMonth.Click += new System.EventHandler(this.cmdMonth_Click);
- this.cmdWeek.Click += new System.EventHandler(this.cmdWeek_Click);
- this.cmdLastDay.Click += new System.EventHandler(this.cmdLastDay_Click);
- this.cmdNextDay.Click += new System.EventHandler(this.cmdNextDay_Click);
- this.cmdAddNew.Click += new System.Web.UI.ImageClickEventHandler(this.cmdAddNew_Click);
- this.Load += new System.EventHandler(this.Page_Load);
- }
- #endregion
- private void cmdMonth_Click(object sender, System.EventArgs e)
- {
- Response.Redirect("Schedule.aspx?date="+date);
- }
- private void cmdWeek_Click(object sender, System.EventArgs e)
- {
- Response.Redirect("SchedByWeek.aspx?date="+date);
- }
- private void cmdLastDay_Click(object sender, System.EventArgs e)
- {
- System.TimeSpan duration = new System.TimeSpan(1, 0, 0, 0);
- date=date.Subtract(duration);
- DisplayDate(date);
- }
- private void cmdNextDay_Click(object sender, System.EventArgs e)
- {
- System.TimeSpan duration = new System.TimeSpan(1, 0, 0, 0);
- date=date.Add(duration);
- DisplayDate(date);
- }
-
- private void cmdQuery_Click(object sender, System.Web.UI.ImageClickEventArgs e)
- {
- if(!(txtYear.Text==""))
- {
- int year,month,day;
- year=Int32.Parse(txtYear.Text);
- month=dropMonth.SelectedIndex + 1;
- day=Int32.Parse(dropDay.SelectedItem.Text);
- date = new DateTime(year,month,day);
- DisplayDate(date);
- }
- }
- private void dropDay_SelectedIndexChanged(object sender, System.EventArgs e)
- {
- int numday = DateTime.DaysInMonth(Int32.Parse(txtYear.Text),dropMonth.SelectedIndex + 1);
- if(dropDay.SelectedIndex + 1 > numday)
- {
- lblErr.Visible = true;
- lblErr.Text = "日期错误";
- dropDay.SelectedIndex = numday - 1;
- }
- }
- private void dropMonth_SelectedIndexChanged(object sender, System.EventArgs e)
- {
- int numday = DateTime.DaysInMonth(Int32.Parse(txtYear.Text),dropMonth.SelectedIndex + 1);
- if(dropDay.SelectedIndex + 1 > numday)
- {
- lblErr.Visible = true;
- lblErr.Text = "日期错误";
- dropDay.SelectedIndex = numday - 1;
- }
- }
- public string ssubject()
- {
- string strDisInfo="";
- DateTime FDate = new DateTime();
- DateTime Date = new DateTime();
- Date = date;
- SqlCommand objcommand = new SqlCommand();
- SqlDataReader objdatareader;
- ScheduleDA objschdule = new ScheduleDA();
- objcommand = objschdule.SchRead(Convert.ToInt16(this.Empid),Date);
- objcommand.Connection.Open();
- objdatareader=objcommand.ExecuteReader();
-
- try
- {
- while(objdatareader.Read())
- {
- int ID = Int32.Parse(objdatareader.GetInt32(1).ToString());
- FDate = DateTime.Parse(objdatareader.GetSqlDateTime(2).ToString());
- string FDate_hour = FDate.Hour.ToString();
- string FDate_Minute = FDate.Minute.ToString();
- if(FDate_Minute == "0")
- {
- FDate_Minute = "00";
- }
- string Subject = objdatareader.GetValue(0).ToString();
- if(Subject.Length > 4)
- {
- Subject = Subject.Substring(0,4);
- Subject += "..";
- }
- strDisInfo+="<br>"+"<A href=schaddup.aspx?reurl=schedbyday.aspx&id="+ID+"&day="+date+" class=td style='FONT-WEIGHT: 400'>☉"+FDate_hour+":"+FDate_Minute+" "+Subject+"</A>";
- }
- objdatareader.Close();
- objcommand.Connection.Close();
- return strDisInfo;
- }
- catch
- {
- return strDisInfo;
- }
- }
- public void cmdAddNew_Click(object sender, System.Web.UI.ImageClickEventArgs e)
- {
- Response.Redirect("SchAddUp.aspx?day="+date.ToShortDateString());
- }
- }
- }