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

.net编程

开发平台:

Others

  1. using System;
  2. using System.Data;
  3. using System.Data.SqlClient;
  4. using System.Web.UI.WebControls;
  5. using System.Web.UI.HtmlControls;
  6. using qminoa.DA.Schedule;
  7. namespace qminoa.Webs.Schedule
  8. {
  9. public class SchedByDay : qminoa.Webs.PageBase
  10. {
  11. protected System.Web.UI.WebControls.Label lblUName;
  12. protected System.Web.UI.WebControls.TextBox txtYear;
  13. protected System.Web.UI.WebControls.DropDownList dropMonth;
  14. protected System.Web.UI.WebControls.DropDownList dropDay;
  15. protected System.Web.UI.WebControls.ImageButton cmdQuery;
  16. protected System.Web.UI.WebControls.Label lblErr;
  17. protected System.Web.UI.WebControls.Label lblYear;
  18. protected System.Web.UI.WebControls.Label lblDate;
  19. protected System.Web.UI.WebControls.LinkButton cmdToday;
  20. protected System.Web.UI.WebControls.LinkButton cmdMonth;
  21. protected System.Web.UI.WebControls.LinkButton cmdWeek;
  22. protected System.Web.UI.WebControls.LinkButton cmdDay;
  23. protected System.Web.UI.WebControls.LinkButton cmdLastDay;
  24. protected System.Web.UI.WebControls.Label lblHeader;
  25. protected System.Web.UI.WebControls.LinkButton cmdNextDay;
  26. protected System.Web.UI.WebControls.ImageButton cmdAddNew;
  27.     private static DateTime date = new DateTime();
  28. private void Page_Load(object sender, System.EventArgs e)
  29. {
  30. this.PageBegin("我的日程",false);
  31. if(!IsPostBack)
  32. {
  33. if(Request.QueryString["date"] != null)
  34. {
  35. date =DateTime.Parse(Request.QueryString["date"]);
  36. DisplayDate(date);
  37. }
  38. else
  39. {
  40. date= DateTime.Now;
  41. DisplayDate(DateTime.Now);
  42. }
  43. }
  44. }
  45. void DisplayDate(DateTime date)
  46. {
  47. string Day = "";
  48. switch(date.DayOfWeek.ToString())
  49. {
  50. case "Sunday":
  51. Day="星期日";
  52. break;
  53. case "Monday":
  54. Day="星期一";
  55. break;
  56. case "Tuesday":
  57. Day="星期二";
  58. break;
  59. case "Wednesday":
  60. Day="星期三";
  61. break;
  62. case "Thursday":
  63. Day="星期四";
  64. break;
  65. case "Friday":
  66. Day="星期五";
  67. break;
  68. case "Saturday":
  69. Day="星期六";
  70. break;
  71. }
  72. lblHeader.Text = date.Year +"年"+ date.Month +"月"+ date.Day +"日"+" "+" "+" "+Day;
  73. txtYear.Text = date.Year.ToString();
  74. dropMonth.SelectedIndex = date.Month - 1;
  75. dropDay.SelectedIndex = date.Day - 1;
  76. }
  77. #region Web Form Designer generated code
  78. override protected void OnInit(EventArgs e)
  79. {
  80. //
  81. // CODEGEN:该调用是 ASP.NET Web 窗体设计器所必需的。
  82. //
  83. InitializeComponent();
  84. base.OnInit(e);
  85. }
  86. /// <summary>
  87. /// 设计器支持所需的方法 - 不要使用代码编辑器修改
  88. /// 此方法的内容。
  89. /// </summary>
  90. private void InitializeComponent()
  91. {    
  92. this.dropMonth.SelectedIndexChanged += new System.EventHandler(this.dropMonth_SelectedIndexChanged);
  93. this.dropDay.SelectedIndexChanged += new System.EventHandler(this.dropDay_SelectedIndexChanged);
  94. this.cmdQuery.Click += new System.Web.UI.ImageClickEventHandler(this.cmdQuery_Click);
  95. this.cmdMonth.Click += new System.EventHandler(this.cmdMonth_Click);
  96. this.cmdWeek.Click += new System.EventHandler(this.cmdWeek_Click);
  97. this.cmdLastDay.Click += new System.EventHandler(this.cmdLastDay_Click);
  98. this.cmdNextDay.Click += new System.EventHandler(this.cmdNextDay_Click);
  99. this.cmdAddNew.Click += new System.Web.UI.ImageClickEventHandler(this.cmdAddNew_Click);
  100. this.Load += new System.EventHandler(this.Page_Load);
  101. }
  102. #endregion
  103. private void cmdMonth_Click(object sender, System.EventArgs e)
  104. {
  105. Response.Redirect("Schedule.aspx?date="+date);
  106. }
  107. private void cmdWeek_Click(object sender, System.EventArgs e)
  108. {
  109. Response.Redirect("SchedByWeek.aspx?date="+date);
  110. }
  111. private void cmdLastDay_Click(object sender, System.EventArgs e)
  112. {
  113. System.TimeSpan duration = new System.TimeSpan(1, 0, 0, 0);
  114. date=date.Subtract(duration);
  115. DisplayDate(date);
  116. }
  117. private void cmdNextDay_Click(object sender, System.EventArgs e)
  118. {
  119. System.TimeSpan duration = new System.TimeSpan(1, 0, 0, 0);
  120. date=date.Add(duration);
  121. DisplayDate(date);
  122. }
  123.         
  124. private void cmdQuery_Click(object sender, System.Web.UI.ImageClickEventArgs e)
  125. {
  126. if(!(txtYear.Text==""))
  127. {
  128. int year,month,day;
  129. year=Int32.Parse(txtYear.Text);
  130. month=dropMonth.SelectedIndex + 1;
  131. day=Int32.Parse(dropDay.SelectedItem.Text);
  132.     date = new DateTime(year,month,day);
  133. DisplayDate(date);
  134. }
  135. }
  136. private void dropDay_SelectedIndexChanged(object sender, System.EventArgs e)
  137. {
  138. int numday = DateTime.DaysInMonth(Int32.Parse(txtYear.Text),dropMonth.SelectedIndex + 1);
  139. if(dropDay.SelectedIndex + 1 > numday)
  140. {
  141. lblErr.Visible = true;
  142. lblErr.Text = "日期错误";
  143. dropDay.SelectedIndex = numday - 1;
  144. }
  145. }
  146. private void dropMonth_SelectedIndexChanged(object sender, System.EventArgs e)
  147. {
  148. int numday = DateTime.DaysInMonth(Int32.Parse(txtYear.Text),dropMonth.SelectedIndex + 1);
  149. if(dropDay.SelectedIndex + 1 > numday)
  150. {
  151. lblErr.Visible = true;
  152. lblErr.Text = "日期错误";
  153. dropDay.SelectedIndex = numday - 1;
  154. }
  155. }
  156. public string ssubject()
  157. {
  158. string strDisInfo="";
  159. DateTime FDate = new DateTime();
  160. DateTime Date = new DateTime();
  161. Date = date;
  162. SqlCommand objcommand = new SqlCommand();
  163. SqlDataReader objdatareader;  
  164. ScheduleDA objschdule = new ScheduleDA();
  165.             objcommand = objschdule.SchRead(Convert.ToInt16(this.Empid),Date);
  166. objcommand.Connection.Open();
  167. objdatareader=objcommand.ExecuteReader();
  168. try
  169. {
  170. while(objdatareader.Read())
  171. {
  172. int ID = Int32.Parse(objdatareader.GetInt32(1).ToString());
  173. FDate = DateTime.Parse(objdatareader.GetSqlDateTime(2).ToString());
  174. string FDate_hour = FDate.Hour.ToString();
  175. string FDate_Minute = FDate.Minute.ToString();
  176. if(FDate_Minute == "0")
  177. {
  178. FDate_Minute = "00";
  179. }
  180. string Subject = objdatareader.GetValue(0).ToString();
  181. if(Subject.Length > 4)
  182. {
  183. Subject = Subject.Substring(0,4);
  184. Subject += ".."; 
  185. }
  186. 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>";
  187. }
  188. objdatareader.Close();
  189. objcommand.Connection.Close();
  190. return strDisInfo;
  191. }
  192. catch
  193. {
  194. return strDisInfo;
  195. }
  196. }
  197. public void cmdAddNew_Click(object sender, System.Web.UI.ImageClickEventArgs e)
  198. {
  199.     Response.Redirect("SchAddUp.aspx?day="+date.ToShortDateString());
  200. }
  201. }
  202. }