Schedule.aspx.cs
上传用户:autodoor
上传日期:2022-08-04
资源大小:9973k
文件大小:8k
源码类别:

.net编程

开发平台:

Others

  1. using System;
  2. using System.Data;
  3. using System.Data.SqlClient;
  4. using System.Web.UI;
  5. using System.Web.UI.WebControls;
  6. using System.Web.UI.HtmlControls;
  7. using qminoa.Common;
  8. using qminoa.DA.Schedule;
  9. namespace qminoa.Webs.Schedule
  10. {
  11. public class Schedule : qminoa.Webs.PageBase
  12. {
  13. protected string str_NoticeMsg ;
  14. private static DateTime date = new DateTime();
  15. protected System.Web.UI.WebControls.ImageButton cmdQuery;
  16. protected System.Web.UI.WebControls.Label lblErr;
  17. protected System.Web.UI.WebControls.LinkButton cmdToday;
  18. protected System.Web.UI.WebControls.LinkButton cmdMonth;
  19. protected System.Web.UI.WebControls.LinkButton cmdWeek;
  20. protected System.Web.UI.WebControls.LinkButton cmdDay;
  21. protected System.Web.UI.WebControls.Calendar calSchedule;
  22. protected System.Web.UI.WebControls.TextBox txtYear;
  23. protected System.Web.UI.WebControls.DropDownList dropMonth;
  24. protected System.Web.UI.WebControls.RangeValidator RangeValidator1;
  25. protected System.Web.UI.WebControls.ValidationSummary ValidationSummary1;
  26. private void Page_Load(object sender, System.EventArgs e)
  27. {
  28. this.PageBegin("我的日程",false);
  29. if(!IsPostBack)
  30. {
  31. DataTable tipTB = (new ScheduleDA()).cpScheduleTip(Convert.ToInt16(this.Empid)).Tables[0];
  32. if(tipTB.Rows.Count > 0 && Session["isScheduleNoticed"] == null)
  33. {
  34. str_NoticeMsg = "onload="javascript:window.open('ScheduleNotice.aspx','','top=1000,left=1000')"";
  35. Session["isScheduleNoticed"] = "1";
  36. }
  37. if(Request.QueryString["date"] != null)
  38. {
  39. date = DateTime.Parse(Request.QueryString["date"]);
  40. txtYear.Text = date.Year.ToString();
  41. dropMonth.SelectedIndex = date.Month - 1;
  42. }
  43. else
  44. {
  45. date = DateTime.Now;
  46. txtYear.Text = date.Year.ToString();
  47. dropMonth.SelectedIndex = date.Month - 1;
  48. }
  49. }
  50. }
  51. public void calSchedule_DayRender(object sender, DayRenderEventArgs e) 
  52. {
  53. CalendarDay d = ((DayRenderEventArgs)e).Day;
  54. TableCell c = ((DayRenderEventArgs)e).Cell;
  55. CNDate dt = new CNDate(d.Date); 
  56. if (d.IsOtherMonth) 
  57. {
  58. c.Controls.Clear();
  59. }
  60. else 
  61. {
  62. try
  63. {
  64. HyperLink aHyperLink = new HyperLink();
  65. aHyperLink.ImageUrl = "../img/add_small.gif";
  66. aHyperLink.ToolTip = "新增个人日程";
  67. aHyperLink.NavigateUrl = "schaddup.aspx?reurl=schedule.aspx&day="+d.Date.ToShortDateString();
  68. c.Controls.Add(new LiteralControl(" "+" "+" "+" ")); 
  69. c.Controls.Add(aHyperLink); 
  70. c.Controls.Add(new LiteralControl("<br>"+dt.FormatLunarYear()));
  71. }
  72. catch (Exception exc) 
  73. {
  74. Response.Write(exc.ToString());
  75. }
  76. DateTime FDate = new DateTime();
  77. string Subject;
  78. SqlCommand objcommand = new SqlCommand();
  79. SqlDataReader objdatareader;  
  80. DateTime Date = new DateTime();
  81. Date = d.Date;
  82. ScheduleDA scheduleDadaAccess = new ScheduleDA();
  83. objcommand = scheduleDadaAccess.SchRead(Convert.ToInt16(this.Empid),Date);
  84. objcommand.Connection.Open();
  85. objdatareader=objcommand.ExecuteReader();
  86. try
  87. {
  88. while(objdatareader.Read())
  89. {
  90. int ID = Int32.Parse(objdatareader.GetInt32(1).ToString());
  91. FDate = DateTime.Parse(objdatareader.GetSqlDateTime(2).ToString());
  92. string FDate_hour = FDate.Hour.ToString();
  93.                         string FDate_Minute = FDate.Minute.ToString();
  94. if(FDate_Minute == "0")
  95. {
  96. FDate_Minute = "00";
  97. }
  98. Subject = objdatareader.GetValue(0).ToString();
  99. if(Subject.Length > 4)
  100. {
  101. Subject = Subject.Substring(0,4);
  102. Subject += ".."; 
  103. }
  104. HtmlAnchor a = new HtmlAnchor();
  105. a.HRef = "schaddup.aspx?reurl=schedule.aspx&id="+ID+"&day="+d.Date.ToShortDateString();
  106. a.InnerText = "☉"+FDate_hour+":"+FDate_Minute+" "+Subject+"";
  107. c.Controls.Add(new LiteralControl("&nbsp;"+"&nbsp;"+"&nbsp;"+"&nbsp;")); 
  108. c.Controls.Add(new LiteralControl("<br>")); 
  109. c.Controls.Add(a); 
  110. c.Controls.Add(new LiteralControl("<br>")); 
  111. }
  112. objdatareader.Close();
  113. objcommand.Connection.Close();
  114. }
  115. catch(Exception exc) 
  116. {
  117. Response.Write(exc.ToString());
  118. }
  119. }
  120. e.Cell.Attributes["onmouseover"] = "javascript:this.style.backgroundColor='#fff7ce';cursor='hand';";
  121. e.Cell.Attributes["onmouseout"] = "javascript:this.style.backgroundColor='#ffffff';";
  122. }
  123. private void cmdQuery_Click(object sender, System.Web.UI.ImageClickEventArgs e)
  124. {
  125. int year,month;
  126. year = Int32.Parse(txtYear.Text);
  127. month = dropMonth.SelectedIndex + 1;
  128. DateTime querydate = new DateTime(year,month,1);
  129. calSchedule.VisibleDate = querydate;
  130. }
  131. private void calSchedule_monthchanged(object sender, MonthChangedEventArgs  e)
  132. {
  133. int year = Int16.Parse(e.PreviousDate.Year.ToString());
  134. int month = Int16.Parse(e.PreviousDate.Month.ToString());
  135. if (e.NewDate > e.PreviousDate) 
  136. {
  137. if((year == 2050) && (month == 12))
  138. {
  139. lblErr.Visible = true;
  140. lblErr.Text = "请选择1900--2050年!";
  141. txtYear.Text = "2050";
  142. dropMonth.SelectedIndex = 11;
  143. calSchedule.VisibleDate = e.PreviousDate;
  144. }
  145. else
  146. {
  147. if(e.PreviousDate.Month == 12)
  148. {
  149. dropMonth.SelectedIndex = 0;
  150. txtYear.Text = (e.PreviousDate.Year + 1).ToString();
  151. }
  152. else
  153. {
  154. dropMonth.SelectedIndex = e.PreviousDate.Month - 1 + 1;
  155. txtYear.Text = e.PreviousDate.Year.ToString();
  156. }
  157. }
  158. }
  159. else
  160. {
  161. if((year == 1900) && (month == 1))
  162. {
  163. lblErr.Visible = true;
  164. lblErr.Text = "请选择1900--2050年!";
  165. txtYear.Text = "1900";
  166. dropMonth.SelectedIndex = 0;
  167. calSchedule.VisibleDate = e.PreviousDate; 
  168. }
  169. else
  170. {
  171. if(e.PreviousDate.Month == 1)
  172. {
  173. dropMonth.SelectedIndex = 11;
  174. txtYear.Text = (e.PreviousDate.Year - 1).ToString();
  175. }
  176. else
  177. {
  178. dropMonth.SelectedIndex = e.PreviousDate.Month - 1 - 1;
  179. txtYear.Text = e.PreviousDate.Year.ToString();
  180. }
  181. }
  182. }
  183. }
  184. private void cmdWeek_Click(object sender, System.EventArgs e)
  185. {
  186. date = DateTime.Now;
  187. Response.Redirect("SchedByWeek.aspx?date="+date.ToShortDateString());
  188. }
  189. private void cmdDay_Click(object sender, System.EventArgs e)
  190. {
  191. date = DateTime.Now;
  192. Response.Redirect("SchedByDay.aspx?date="+date.ToShortDateString());
  193. }
  194. public DateTime GetDate()
  195. {
  196. return date;
  197. }
  198. #region Web Form Designer generated code
  199. override protected void OnInit(EventArgs e)
  200. {
  201. //
  202. // CODEGEN:该调用是 ASP.NET Web 窗体设计器所必需的。
  203. //
  204. InitializeComponent();
  205. base.OnInit(e);
  206. }
  207. /// <summary>
  208. /// 设计器支持所需的方法 - 不要使用代码编辑器修改
  209. /// 此方法的内容。
  210. /// </summary>
  211. private void InitializeComponent()
  212. {   
  213. this.cmdQuery.Click += new System.Web.UI.ImageClickEventHandler(this.cmdQuery_Click);
  214. this.cmdWeek.Click += new System.EventHandler(this.cmdWeek_Click);
  215. this.cmdDay.Click += new System.EventHandler(this.cmdDay_Click);
  216. this.calSchedule.VisibleMonthChanged += new System.Web.UI.WebControls.MonthChangedEventHandler(this.calSchedule_monthchanged);
  217. this.calSchedule.SelectionChanged += new System.EventHandler(this.calSchedule_SelectionChanged);
  218. this.Load += new System.EventHandler(this.Page_Load);
  219. }
  220. #endregion
  221. private void calSchedule_SelectionChanged(object sender, System.EventArgs e)
  222. {
  223. date = calSchedule.SelectedDate;
  224. Response.Redirect("SchedByDay.aspx?date="+date.ToShortDateString());
  225. }
  226. }
  227. }