Schedule.aspx.cs
上传用户:autodoor
上传日期:2022-08-04
资源大小:9973k
文件大小:8k
- using System;
- using System.Data;
- using System.Data.SqlClient;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Web.UI.HtmlControls;
- using qminoa.Common;
- using qminoa.DA.Schedule;
- namespace qminoa.Webs.Schedule
- {
- public class Schedule : qminoa.Webs.PageBase
- {
- protected string str_NoticeMsg ;
- private static DateTime date = new DateTime();
- protected System.Web.UI.WebControls.ImageButton cmdQuery;
- protected System.Web.UI.WebControls.Label lblErr;
- 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.Calendar calSchedule;
- protected System.Web.UI.WebControls.TextBox txtYear;
- protected System.Web.UI.WebControls.DropDownList dropMonth;
- protected System.Web.UI.WebControls.RangeValidator RangeValidator1;
- protected System.Web.UI.WebControls.ValidationSummary ValidationSummary1;
- private void Page_Load(object sender, System.EventArgs e)
- {
- this.PageBegin("我的日程",false);
- if(!IsPostBack)
- {
- DataTable tipTB = (new ScheduleDA()).cpScheduleTip(Convert.ToInt16(this.Empid)).Tables[0];
- if(tipTB.Rows.Count > 0 && Session["isScheduleNoticed"] == null)
- {
- str_NoticeMsg = "onload="javascript:window.open('ScheduleNotice.aspx','','top=1000,left=1000')"";
- Session["isScheduleNoticed"] = "1";
- }
- if(Request.QueryString["date"] != null)
- {
- date = DateTime.Parse(Request.QueryString["date"]);
- txtYear.Text = date.Year.ToString();
- dropMonth.SelectedIndex = date.Month - 1;
- }
- else
- {
- date = DateTime.Now;
- txtYear.Text = date.Year.ToString();
- dropMonth.SelectedIndex = date.Month - 1;
- }
- }
- }
- public void calSchedule_DayRender(object sender, DayRenderEventArgs e)
- {
- CalendarDay d = ((DayRenderEventArgs)e).Day;
- TableCell c = ((DayRenderEventArgs)e).Cell;
- CNDate dt = new CNDate(d.Date);
- if (d.IsOtherMonth)
- {
- c.Controls.Clear();
- }
- else
- {
- try
- {
- HyperLink aHyperLink = new HyperLink();
- aHyperLink.ImageUrl = "../img/add_small.gif";
- aHyperLink.ToolTip = "新增个人日程";
- aHyperLink.NavigateUrl = "schaddup.aspx?reurl=schedule.aspx&day="+d.Date.ToShortDateString();
- c.Controls.Add(new LiteralControl(" "+" "+" "+" "));
- c.Controls.Add(aHyperLink);
- c.Controls.Add(new LiteralControl("<br>"+dt.FormatLunarYear()));
- }
- catch (Exception exc)
- {
- Response.Write(exc.ToString());
- }
- DateTime FDate = new DateTime();
- string Subject;
- SqlCommand objcommand = new SqlCommand();
- SqlDataReader objdatareader;
- DateTime Date = new DateTime();
- Date = d.Date;
- ScheduleDA scheduleDadaAccess = new ScheduleDA();
- objcommand = scheduleDadaAccess.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";
- }
- Subject = objdatareader.GetValue(0).ToString();
- if(Subject.Length > 4)
- {
- Subject = Subject.Substring(0,4);
- Subject += "..";
- }
- HtmlAnchor a = new HtmlAnchor();
- a.HRef = "schaddup.aspx?reurl=schedule.aspx&id="+ID+"&day="+d.Date.ToShortDateString();
- a.InnerText = "☉"+FDate_hour+":"+FDate_Minute+" "+Subject+"";
- c.Controls.Add(new LiteralControl(" "+" "+" "+" "));
- c.Controls.Add(new LiteralControl("<br>"));
- c.Controls.Add(a);
- c.Controls.Add(new LiteralControl("<br>"));
- }
- objdatareader.Close();
- objcommand.Connection.Close();
- }
- catch(Exception exc)
- {
- Response.Write(exc.ToString());
- }
- }
- e.Cell.Attributes["onmouseover"] = "javascript:this.style.backgroundColor='#fff7ce';cursor='hand';";
- e.Cell.Attributes["onmouseout"] = "javascript:this.style.backgroundColor='#ffffff';";
- }
- private void cmdQuery_Click(object sender, System.Web.UI.ImageClickEventArgs e)
- {
- int year,month;
- year = Int32.Parse(txtYear.Text);
- month = dropMonth.SelectedIndex + 1;
- DateTime querydate = new DateTime(year,month,1);
- calSchedule.VisibleDate = querydate;
- }
- private void calSchedule_monthchanged(object sender, MonthChangedEventArgs e)
- {
- int year = Int16.Parse(e.PreviousDate.Year.ToString());
- int month = Int16.Parse(e.PreviousDate.Month.ToString());
-
- if (e.NewDate > e.PreviousDate)
- {
- if((year == 2050) && (month == 12))
- {
- lblErr.Visible = true;
- lblErr.Text = "请选择1900--2050年!";
- txtYear.Text = "2050";
- dropMonth.SelectedIndex = 11;
- calSchedule.VisibleDate = e.PreviousDate;
- }
- else
- {
- if(e.PreviousDate.Month == 12)
- {
- dropMonth.SelectedIndex = 0;
- txtYear.Text = (e.PreviousDate.Year + 1).ToString();
- }
- else
- {
- dropMonth.SelectedIndex = e.PreviousDate.Month - 1 + 1;
- txtYear.Text = e.PreviousDate.Year.ToString();
- }
- }
- }
- else
- {
- if((year == 1900) && (month == 1))
- {
- lblErr.Visible = true;
- lblErr.Text = "请选择1900--2050年!";
- txtYear.Text = "1900";
- dropMonth.SelectedIndex = 0;
- calSchedule.VisibleDate = e.PreviousDate;
- }
- else
- {
- if(e.PreviousDate.Month == 1)
- {
- dropMonth.SelectedIndex = 11;
- txtYear.Text = (e.PreviousDate.Year - 1).ToString();
- }
- else
- {
- dropMonth.SelectedIndex = e.PreviousDate.Month - 1 - 1;
- txtYear.Text = e.PreviousDate.Year.ToString();
- }
- }
- }
- }
- private void cmdWeek_Click(object sender, System.EventArgs e)
- {
- date = DateTime.Now;
- Response.Redirect("SchedByWeek.aspx?date="+date.ToShortDateString());
- }
- private void cmdDay_Click(object sender, System.EventArgs e)
- {
- date = DateTime.Now;
- Response.Redirect("SchedByDay.aspx?date="+date.ToShortDateString());
- }
- public DateTime GetDate()
- {
- return date;
- }
- #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.cmdQuery.Click += new System.Web.UI.ImageClickEventHandler(this.cmdQuery_Click);
- this.cmdWeek.Click += new System.EventHandler(this.cmdWeek_Click);
- this.cmdDay.Click += new System.EventHandler(this.cmdDay_Click);
- this.calSchedule.VisibleMonthChanged += new System.Web.UI.WebControls.MonthChangedEventHandler(this.calSchedule_monthchanged);
- this.calSchedule.SelectionChanged += new System.EventHandler(this.calSchedule_SelectionChanged);
- this.Load += new System.EventHandler(this.Page_Load);
- }
- #endregion
- private void calSchedule_SelectionChanged(object sender, System.EventArgs e)
- {
- date = calSchedule.SelectedDate;
- Response.Redirect("SchedByDay.aspx?date="+date.ToShortDateString());
- }
- }
- }