TaskDetail.aspx.cs
上传用户:xuming1973
上传日期:2014-02-27
资源大小:17511k
文件大小:9k
源码类别:

WEB源码(ASP,PHP,...)

开发平台:

C#

  1. using System;
  2. using System.Collections;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Data.SqlClient;
  6. using System.Drawing;
  7. using System.Web;
  8. using System.Web.SessionState;
  9. using System.Web.UI;
  10. using System.Web.UI.WebControls;
  11. using System.Web.UI.HtmlControls;
  12. using UDS.Components;
  13. namespace UDS.SubModule.Schedule
  14. {
  15. /// <summary>
  16. /// TaskDetail 的摘要说明。
  17. /// </summary>
  18. public class TaskDetail : System.Web.UI.Page
  19. {
  20. protected System.Web.UI.WebControls.Label lblTaskDetailTitle;
  21. protected System.Web.UI.WebControls.Button btnDelete;
  22. protected System.Web.UI.WebControls.Label lblArrangedBy;
  23. protected System.Web.UI.WebControls.Label lblStartTime;
  24. protected System.Web.UI.WebControls.Label lblEndTime;
  25. protected System.Web.UI.WebControls.Label lblProjectID;
  26. protected System.Web.UI.WebControls.Label lblSubject;
  27. protected System.Web.UI.WebControls.Label lblDetail;
  28. protected System.Web.UI.WebControls.Label lblType;
  29. protected System.Web.UI.WebControls.Label lblAttribute;
  30. protected System.Web.UI.WebControls.Label lblCooperator;
  31. protected System.Web.UI.WebControls.Button btnCancel;
  32. protected System.Web.UI.WebControls.Button btnAccept;
  33. protected System.Web.UI.WebControls.Button btnFinish;
  34. protected static string TaskID,Username,Date;
  35. protected System.Web.UI.WebControls.TextBox txtComment;
  36. protected System.Web.UI.WebControls.Button btnAddCom;
  37. protected System.Web.UI.HtmlControls.HtmlGenericControl TaskCommentFrm;
  38. private void Page_Load(object sender, System.EventArgs e)
  39. {
  40. Task task   = new Task();
  41. if(!Page.IsPostBack)
  42. {
  43. HttpCookie UserCookie = Request.Cookies["Username"];
  44. Username = UserCookie.Value.ToString();
  45. TaskID   = (Request.QueryString["TaskID"]!=null)?Request.QueryString["TaskID"].ToString():"0";
  46. Date   = (Request.QueryString["Date"]!=null)?Request.QueryString["Date"].ToString():DateTime.Today.ToShortDateString();
  47. TaskClass tsk = task.GetTaskDetail(Int32.Parse(TaskID)); 
  48. if(tsk.ArrangedBy==Username) 
  49. {
  50. this.btnDelete .Visible = true;
  51. this.btnFinish .Visible = true;
  52. this.btnCancel.Visible = false;
  53. this.btnAccept.Visible = false;
  54. }
  55. PopulateData(tsk);
  56. tsk = null;
  57. TaskCommentFrm.Attributes["src"] = "TaskComment.aspx?TaskID="+TaskID;
  58. this.btnFinish .Attributes["onclick"] = "javascript:return confirm('您确认吗?')";
  59. this.btnDelete.Attributes["onclick"] = "javascript:return confirm('您确认要删除此任务吗?')";
  60. }
  61. SetStatus();
  62. int status = task.GetTaskStatusBySomeone(Int32.Parse(TaskID),Username);
  63. if(status==2)
  64. {
  65. this.btnAccept.Enabled = false;
  66. this.btnCancel .Enabled = false;
  67. this.btnFinish .Enabled = false;
  68. }
  69. }
  70. private void SetStatus()
  71. {
  72. string Username="",ActualUsername="";
  73. if(Session["Username"]!=null)
  74. {
  75. Username = Session["Username"].ToString();
  76. ActualUsername = Session["ActualUsername"].ToString();
  77. }
  78. else
  79. {
  80. HttpCookie UserCookie = Request.Cookies["Username"];
  81. Username = UserCookie.Value.ToString();
  82. ActualUsername = UserCookie.Value.ToString();
  83. }
  84. this.txtComment.Enabled = (ActualUsername.ToLower() ==Username.ToLower());
  85. this.btnAccept.Enabled = (ActualUsername.ToLower() ==Username.ToLower());
  86. this.btnCancel.Enabled = (ActualUsername.ToLower() ==Username.ToLower());
  87. this.btnFinish.Enabled = (ActualUsername.ToLower() ==Username.ToLower());
  88. this.btnDelete.Enabled = (ActualUsername.ToLower() ==Username.ToLower());
  89. this.btnAddCom.Enabled = (ActualUsername.ToLower() ==Username.ToLower());
  90. }
  91. private void PopulateData(TaskClass tsk)
  92. {
  93. string ClassName = "",Type="";
  94. switch (tsk.Type) {
  95. case 1:
  96. Type="会议";
  97. break;
  98. case 2:
  99. Type="文案";
  100. break;
  101. case 3:
  102. Type="来访";
  103. break;
  104. case 4:
  105. Type="电话";
  106. break;
  107. case 5:
  108. Type="走访";
  109. break;
  110. case 6:
  111. Type="外出";
  112. break;
  113. case 7:
  114. Type="假期";
  115. break;
  116. case 8:
  117. Type="出差";
  118. break;
  119. }
  120. this.lblSubject .Text = tsk.Subject ;
  121. this.lblDetail .Text = tsk.Detail ;
  122. this.lblStartTime .Text = (DateTime.Parse(tsk.StartTime).ToShortTimeString()=="0:00")?DateTime.Parse(tsk.StartTime).ToShortDateString()+" 8:00":tsk.StartTime;
  123. this.lblEndTime .Text = (DateTime.Parse(tsk.EndTime).ToShortTimeString()=="0:00")?DateTime.Parse(tsk.EndTime).ToShortDateString()+" 18:00":tsk.EndTime;
  124. this.lblArrangedBy .Text = UDS.Components .Staff.GetRealNameByUsername(tsk.ArrangedBy) ;
  125. this.lblCooperator .Text    = UDS.Components .Staff.GetRealNameStrByUsernameStr(tsk.CooperatorList,0) ;
  126. this.lblType.Text = Type;
  127. this.lblAttribute.Text = tsk.Attribute.ToString()=="1"?"独占任务":"限时任务";
  128. if(tsk.ProjectID!=0)
  129. {
  130. ProjectClass prj = new ProjectClass();
  131. SqlDataReader dataReader =  prj.GetProjectDetail(tsk.ProjectID);
  132. if(dataReader.Read())
  133. ClassName = dataReader["ClassName"].ToString();
  134. dataReader.Close();
  135. prj = null;
  136. }
  137.             this.lblProjectID .Text = (tsk.ProjectID ==0)?"无":"<a href='#' onclick=javascript:window.close();window.dialogArguments.location='../UnitiveDocument/Project.aspx?classID="+tsk.ProjectID .ToString()+"'>"+ClassName+"</a>";
  138. }
  139. #region Web Form Designer generated code
  140. override protected void OnInit(EventArgs e)
  141. {
  142. //
  143. // CODEGEN:该调用是 ASP.NET Web 窗体设计器所必需的。
  144. //
  145. InitializeComponent();
  146. base.OnInit(e);
  147. }
  148. /// <summary>
  149. /// 设计器支持所需的方法 - 不要使用代码编辑器修改
  150. /// 此方法的内容。
  151. /// </summary>
  152. private void InitializeComponent()
  153. {    
  154. this.btnAddCom.Click += new System.EventHandler(this.btnAddCom_Click);
  155. this.btnDelete.Click += new System.EventHandler(this.btnDelete_Click);
  156. this.btnAccept.Click += new System.EventHandler(this.btnAccept_Click);
  157. this.btnFinish.Click += new System.EventHandler(this.btnFinish_Click);
  158. this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
  159. this.Load += new System.EventHandler(this.Page_Load);
  160. }
  161. #endregion
  162. private void btnDelete_Click(object sender, System.EventArgs e)
  163. {
  164. Task task   = new Task();
  165. try
  166. {
  167. task.DeleteTask(Int32.Parse(TaskID));
  168. task = null;
  169. Response.Write("<script language=javascript>alert('删除成功!');window.dialogArguments.location='TaskList.aspx?displayType="+UDS.SubModule .Schedule.TaskList.displayType.ToString()+"';window.close();</script>");
  170. }
  171. catch(Exception ex)
  172. {
  173. UDS.Components.Error .Log(ex.ToString());
  174. Server.Transfer("../Error.aspx");
  175. }
  176. }
  177. private void btnFinish_Click(object sender, System.EventArgs e)
  178. {
  179. Task task   = new Task();
  180. try
  181. {
  182. task.DealTask(TaskID,2,Username,Date);
  183. task = null;
  184. Response.Write("<script language=javascript>alert('任务完成操作成功!');window.dialogArguments.location='TaskList.aspx?displayType="+UDS.SubModule .Schedule.TaskList.displayType.ToString()+"';window.close();</script>");
  185. }
  186. catch(Exception ex)
  187. {
  188. UDS.Components.Error .Log(ex.ToString());
  189. Server.Transfer("../Error.aspx");
  190. }
  191. }
  192. private void btnAccept_Click(object sender, System.EventArgs e)
  193. {
  194. Task task   = new Task();
  195. try
  196. {
  197. task.DealTask(TaskID,1,Username,Date);
  198. task = null;
  199. Response.Write("<script language=javascript>alert('任务接受操作成功!');window.dialogArguments.location='TaskList.aspx?displayType="+UDS.SubModule .Schedule.TaskList.displayType.ToString()+"';window.close();</script>");
  200. }
  201. catch(Exception ex)
  202. {
  203. UDS.Components.Error .Log(ex.ToString());
  204. Server.Transfer("../Error.aspx");
  205. }
  206. }
  207. private void btnCancel_Click(object sender, System.EventArgs e)
  208. {
  209. Task task   = new Task();
  210. try
  211. {
  212. task.DealTask(TaskID,0,Username,Date);
  213. task = null;
  214. Response.Write("<script language=javascript>alert('任务取消操作成功!');window.dialogArguments.location='TaskList.aspx?displayType="+UDS.SubModule .Schedule.TaskList.displayType.ToString()+"';window.close();</script>");
  215. }
  216. catch(Exception ex)
  217. {
  218. UDS.Components.Error .Log(ex.ToString());
  219. Server.Transfer("../Error.aspx");
  220. }
  221. }
  222. private void btnAddCom_Click(object sender, System.EventArgs e)
  223. {
  224. HttpCookie UserCookie = Request.Cookies["Username"];
  225. string Username = UserCookie.Value.ToString();
  226. Task task   = new Task();
  227. try
  228. {
  229. task.AddTaskComment(Username,this.txtComment .Text,Int32.Parse(TaskID));
  230. task = null;
  231. Response.Write("<script language=javascript>alert('评论添加成功!');</script>");
  232. TaskCommentFrm.Attributes["src"] = "TaskComment.aspx?TaskID="+TaskID;
  233. }
  234. catch(Exception ex)
  235. {
  236. UDS.Components.Error .Log(ex.ToString());
  237. Server.Transfer("../Error.aspx");
  238. }
  239. }
  240. }
  241. }