TaskList.aspx.cs
上传用户:jdb8708888
上传日期:2013-05-29
资源大小:19971k
文件大小:32k
源码类别:

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. /// TaskList 的摘要说明。
  17. /// </summary>
  18. public class TaskList : System.Web.UI.Page
  19. {
  20. protected System.Web.UI.WebControls.DataGrid dgList;
  21. public  string Username="",ActualUsername="";
  22. protected string Action;
  23. protected System.Web.UI.HtmlControls.HtmlTable  tblContainer;
  24. protected System.Web.UI.WebControls.LinkButton lnkbtnToday;
  25. protected System.Web.UI.WebControls.LinkButton lnkbtnHistory;
  26. protected System.Web.UI.WebControls.LinkButton lnkbtnFinished;
  27. protected System.Web.UI.WebControls.Button btnNew;
  28. protected System.Web.UI.WebControls.Button btnAccept;
  29. protected System.Web.UI.WebControls.Button btnCancel;
  30. protected System.Web.UI.WebControls.DropDownList listStaff;
  31. protected System.Web.UI.WebControls.Button btnSubscribe;
  32. protected System.Web.UI.WebControls.LinkButton Linkbutton1;
  33. protected System.Web.UI.WebControls.Table Table1;
  34. protected System.Web.UI.WebControls.Button btnWeeklyView;
  35. protected System.Web.UI.WebControls.Label lblInstru;
  36. public static int displayType;
  37. protected System.Web.UI.WebControls.Button btnCancelSubscription;
  38. protected System.Web.UI.WebControls.LinkButton lnkbtnArranged;
  39. public static string SchBeginDate;
  40. private void Page_Load(object sender, System.EventArgs e)
  41. {
  42. if(!Page.IsPostBack)
  43. {
  44. HttpCookie UserCookie = Request.Cookies["Username"];
  45. if(Session["Username"]==null)
  46. {
  47. Session["Username"] = UserCookie.Value.ToString();
  48. }
  49. ActualUsername = UserCookie.Value.ToString();
  50. Session["ActualUsername"] = ActualUsername;
  51. Username = (string)Session["Username"];
  52. populateData();
  53. SetStatus();
  54. displayType  = Request.QueryString["displayType"]!=null?Int32.Parse(Request.QueryString["displayType"]):1;
  55. SchBeginDate = Request.QueryString["SchBeginDate"]!=null?Request.QueryString["SchBeginDate"]:DateTime.Today.AddDays(-(Convert.ToInt32(DateTime.Today.DayOfWeek))+1).ToShortDateString();
  56. if(Request.QueryString["SchBeginDate"]!=null)
  57. {
  58. this.lnkbtnFinished .Enabled = false;
  59. this.lnkbtnHistory .Enabled  = false;
  60. this.lnkbtnToday .Enabled  = false;
  61. this.Linkbutton1.Enabled  = false;
  62. this.btnAccept .Enabled  = false;
  63. this.btnCancel.Enabled      = false;
  64. this.btnNew .Enabled  = false;
  65. this.lnkbtnArranged .Enabled = false;
  66. this.btnWeeklyView .Text  = "返回";
  67. PopulateWeeklyData();
  68. }
  69. else
  70. {
  71. InitData();
  72. }
  73. //Response.Write(DateTime.Today.AddDays(-(Convert.ToInt32(DateTime.Today.DayOfWeek))+1).ToShortDateString()); 
  74. }
  75. else
  76. {
  77. // if(Page.FindControl("Table1").ID=="")
  78. //PopulateDateToTable(Calendar1.SelectedDate ,Calendar1.SelectedDates .Count);
  79. }
  80. //Response.Write(Session["Username"].ToString());
  81. }
  82. private void InitData()
  83. {
  84. Username = (string)Session["Username"];
  85. this.tblContainer.Rows[0].Cells[0].Attributes.Add("background","../../images/maillistbutton2.gif");
  86. this.btnNew.Attributes["onclick"]= "var newwin=window.open('Manage.aspx','newtask','toolbar=yes,scrollbars=yes,width=800,height=600,resizable=yes');newwin.moveTo(0,0);newwin.focus();";
  87. Task task = new Task();
  88. this.dgList.Visible = true;
  89. this.btnAccept .Visible = true;
  90. this.btnCancel.Visible = true;
  91. //this.lnkbtnAdd.Attributes.Add("onclick","return dialwinprocess('"+DateTime.Today.ToShortDateString()+"','8','1','0')");
  92. //this.lnkbtnAdd.Attributes.Add("onclick","self.location='CalendarView.aspx?Action=1';return true;");
  93. DataTable mydb = Tools.ConvertDataReaderToDataTable(task.GetAllTaskBySomeone(DateTime.Today.ToShortDateString(),Username,displayType));
  94. this.dgList .DataSource = mydb.DefaultView;
  95. this.dgList.DataBind();
  96. setgrid();
  97. mydb.Dispose();
  98. for(int t=0;t<4;t++)
  99. {
  100. if(t==displayType-1)
  101. this.tblContainer.Rows[0].Cells[t].Attributes.Add("background","../../images/maillistbutton2.gif");
  102. else
  103. this.tblContainer.Rows[0].Cells[t].Attributes.Add("background","../../images/maillistbutton1.gif");
  104. }
  105. }
  106. private void PopulateWeeklyData()
  107. {
  108. this.dgList .Visible = false;
  109. this.lblInstru .Visible = false;
  110. this.Table1 .Visible = true;
  111. this.Table1.Rows.Clear();
  112. //Response.Write("<table width="49%" border="1" align="center" class="top"><tr><td width="2%"  bgcolor="#A692F5">&nbsp;</td> <td width="18%">未确认任务</td> <td width="2%" bgcolor="BlanchedAlmond">&nbsp;</td> <td width="18%">已确认任务</td></tr></table>");
  113. //System.Globalization.DateTimeFormatInfo.CurrentInfo.FirstDayOfWeek = System.DayOfWeek.Monday;
  114. //System.Globalization.DateTimeFormatInfo.CurrentInfo.DayNames=new String[]{"七","一","二","三","四","五","六"};
  115. PopulateDateToTable(DateTime.Parse(SchBeginDate),6);
  116. }
  117. #region 绑定数据至表格
  118. public void PopulateDateToTable(DateTime sDate,int dayCount)
  119. {
  120. string Username = (string)Session["Username"];
  121. string[] UnameStr = System.Text.RegularExpressions.Regex.Split(Username,",");
  122. Task task = new Task();
  123. #region 初始化日程数据
  124. int[][] TaskData = new int[1][];
  125. Hashtable htcolorlist = new Hashtable();
  126. // 初始化天数据至ArrayList
  127. // ArrayList demoDayData = new ArrayList();
  128. // demoDayData.Add(9);
  129. // demoDayData.Add(10);
  130. // demoDayData.Add(11);
  131. // demoDayData.Add(12);
  132. // int[][] TaskData = new int[5][];  //每日的任务数据
  133. // TaskData[0] = new int[]{0,0,0,0,0,13,14,15,16,17,18};
  134. // TaskData[1] = new int[]{8,9,10,11,0,0,0,0,0,0,0};
  135. // TaskData[2] = new int[]{0,9,10,11,12,13,0,0,0,0,0};
  136. // TaskData[3] = new int[]{8,9,10,11,12,13,14,15,0,0,0};
  137. // TaskData[4] = new int[]{0,0,0,0,0,0,0,0,0,17,18};
  138. // demoData[5] = new int[]{0,0,0,0,0,0,0,0};
  139. // demoData[6] = new int[]{0,0,0,0,0,0,0,0};
  140. // demoData[7] = new int[]{0,0,0,0,0,0,0,0};
  141. // 生成行和单元格
  142. ArrayList DaySch = new ArrayList(dayCount+1);//根据选择的天数生成数组 加1是因为会增加一信息列
  143. ArrayList DayTask = new ArrayList(dayCount+1); //记录每天的前五条任务ID
  144. DaySch.Add(new int[5][]);  //加入一个废列
  145. DayTask.Add(new String[5]);
  146. for(int p=0;p<dayCount;p++)
  147. {
  148. TaskData = new int[5][];
  149. string tmpDate = sDate.AddDays(p).ToString();
  150. String[] a = new String[5];
  151. a = task.GetTop5DayTaskList(tmpDate,UnameStr[0].ToString());
  152. // TaskData[0] = new int[]{0,0,0,0,0,13,14,15,16,17,18};
  153. // TaskData[1] = new int[]{8,9,10,11,0,0,0,0,0,0,0};
  154. // TaskData[2] = new int[]{0,9,10,11,12,13,0,0,0,0,0};
  155. // TaskData[3] = new int[]{8,9,10,11,12,13,14,15,0,0,0};
  156. // TaskData[4] = new int[]{0,0,0,0,0,0,0,0,0,17,18};
  157. for(int k=0;k<a.Length;k++)
  158. {
  159. TaskData[k] = task.GetTaskPeriod(tmpDate,UnameStr[0],Int32.Parse(a[k].ToString()));
  160. }
  161. DaySch.Add(TaskData);
  162. DayTask.Add(a);
  163. }
  164. #endregion
  165. int numcells = dayCount;
  166. // int startTimeNo = 8;
  167. SqlDataReader dataReader = null;
  168. dataReader =  task.GetPeriodInfo();
  169. ArrayList period = new ArrayList();
  170. while(dataReader.Read())
  171. period.Add(dataReader[1].ToString());
  172. int numrows = period.Count;
  173. //  初始化表头
  174. TableRow r = new TableRow();
  175. // 生成一个第一列,列头为时间
  176. TableCell c = null;
  177. if(Username!="")
  178. {
  179. for (int i=0; i<numcells+1; i++) 
  180. {
  181. string s = sDate.AddDays(i-1).ToShortDateString()==DateTime.Today.ToShortDateString()?"<font color=white><b>"+DateTime.Today.ToShortDateString()+"</b></font>":sDate.AddDays(i-1).ToShortDateString();
  182. LiteralControl lc = new LiteralControl((i==0)?"<font color=white>&nbsp;&nbsp; 时段&nbsp;&nbsp;&nbsp;    ":"<font color=white>"+s+"&nbsp;&nbsp;&nbsp;"+UDS.Components.Tools.ConvertDayOfWeekToZh(sDate.AddDays(i-1).DayOfWeek)+"</font>");
  183. if(i==numcells)
  184. lc.Text +="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=tasklist.aspx?SchBeginDate="+DateTime.Parse(SchBeginDate).AddDays(-7).ToShortDateString()+"><font color=white size=3><</font></a>&nbsp;&nbsp;&nbsp; <a href=tasklist.aspx?SchBeginDate="+DateTime.Parse(SchBeginDate).AddDays(7).ToShortDateString()+"><font color=white size=3>></font></a>";
  185. c = new TableCell();
  186. c.CssClass = "top";
  187. c.BackColor = Color.FromName("#337FB2");
  188. c.Controls.Add(lc);
  189. r.Cells.Add(c);
  190. }
  191. Table1.Rows.Add(r);
  192. // 初始化表头结束
  193. // 根据时间段共生成8行
  194. for (int j=0; j<numrows; j++) 
  195. {
  196.             
  197. r = new TableRow();
  198.                 
  199. // 每行根据选择的天数生成列
  200. for (int i=0; i<dayCount+1; i++) 
  201. {
  202. c = new TableCell();
  203. Table newtable = new Table();
  204. if (i==0)
  205. if(j%2==0)
  206. {
  207. string []a = period[j].ToString().Split('-');
  208. c.Controls.Add(new LiteralControl("<div style='position:absolute; width:86px; height:76px; z-index:1'><font size=3>"+a[0].ToString()+"</font></div>"));
  209. }
  210. else
  211. c.Controls.Add(new LiteralControl("-"));
  212. else
  213. { //如果不是第一列
  214. // newtable.BorderWidth = 0;
  215. //newtable.GridLines = System.Web.UI.WebControls .GridLines.Vertical;
  216. // 在某列中新table设置开始
  217. newtable = new Table();
  218. TableRow nr = new TableRow();
  219. for(int q=0;q<TaskData.Length;q++)
  220. {
  221. int[][] tmp =  (int[][])DaySch[i];
  222. String[] a = (String[])DayTask[i];
  223. TableCell nc = new TableCell();
  224. bool flag=false;
  225. // string col = "";
  226. string taskid = "";
  227. // 遍历五个任务时间数组,看有没有被占
  228. for(int co=0;co<TaskData.Length;co++)
  229. {
  230. if(Int32.Parse(tmp[co][j].ToString())!=0)
  231. {
  232. flag = true;
  233. taskid = a[co].ToString();
  234. }
  235. }
  236. if(flag)
  237. {
  238. nc.Controls.Add(new LiteralControl("<font color=#C597DD>0"+"</font>"));
  239. nc.BackColor=Color.FromName("#C597DD");
  240. nc.Style.Add("cursor","hand");
  241. nc.Attributes.Add("onclick","return dialwinprocess('"+sDate.AddDays(i-1).ToShortDateString()+"','"+(8+j).ToString()+"','2','"+taskid+"')");
  242. }
  243. else
  244. {
  245. nc.Controls.Add(new LiteralControl("<font color=#FFFFFF>0</font>"));
  246. }
  247. nr.Cells.Add(nc);
  248. }
  249. newtable.CellPadding = 0;
  250. newtable.CellSpacing = 0;
  251. newtable.GridLines = System.Web.UI.WebControls .GridLines.Both;
  252. newtable.BorderWidth = 0;
  253. newtable.Rows.Add(nr);
  254. // 新table设置结束
  255. c.Controls.Add(newtable);
  256. }
  257. r.Cells.Add(c);
  258. }
  259. Table1.CellPadding = 0;
  260. Table1.CellSpacing = 0;
  261. Table1.GridLines = System.Web.UI.WebControls .GridLines.Horizontal;
  262. Table1.BorderWidth = 1;
  263. Table1.Rows.Add(r);
  264. }
  265. }
  266. }
  267. #endregion
  268. public void SetStatus()
  269. {
  270. string Username = (string)Session["Username"];
  271. string ActualUsername = (string)Session["ActualUsername"];
  272. this.btnAccept.Enabled = (Username.ToLower()==ActualUsername.ToLower());
  273. this.btnCancel.Enabled = (Username.ToLower()==ActualUsername.ToLower());
  274. this.btnNew.Enabled    = (Username.ToLower()==ActualUsername.ToLower());
  275. this.btnSubscribe.Visible = (Username.ToLower()!=ActualUsername.ToLower());
  276. this.btnSubscribe.Enabled = (Username.ToLower()!=ActualUsername.ToLower());
  277. }
  278. public void populateData()
  279. {
  280. #region 协同人员列表初始化
  281. string Username = (string)Session["Username"];
  282. UDS.Components .Staff staff = new UDS.Components .Staff();
  283. try
  284. {
  285. listStaff.DataTextField = "RealName";
  286. listStaff.DataValueField = "Staff_Name";
  287. listStaff.DataSource =  staff.GetStaffFromPosition(ActualUsername);
  288. listStaff.DataBind();
  289. foreach(ListItem li in listStaff.Items)
  290. {
  291. if(li.Value.ToLower() ==Username.ToLower())
  292. {
  293. li.Selected =true;
  294. }
  295. }
  296. // listStaff.SelectedItem .Value = Username;
  297. // listStaff.SelectedItem .Text = UDS.Components .Staff.GetRealNameByUsername(Username);
  298. }
  299. catch(Exception e)
  300. {
  301. UDS.Components.Error.Log(e.ToString());
  302. Server.Transfer("../Error.aspx");
  303. }
  304. finally
  305. {
  306. staff = null;
  307. }
  308. #endregion
  309. }
  310. public class demodat
  311. {
  312. private int m_StartTime;
  313. private int m_EndTime;
  314. public int StartTime 
  315. {
  316. //文件ID
  317. get { return m_StartTime; }
  318. set { m_StartTime = value; }
  319. }
  320. public int EndTime 
  321. {
  322. //文档ID
  323. get { return m_EndTime; }
  324. set { m_EndTime = value; }
  325. }
  326. }
  327. #region Web Form Designer generated code
  328. override protected void OnInit(EventArgs e)
  329. {
  330. //
  331. // CODEGEN:该调用是 ASP.NET Web 窗体设计器所必需的。
  332. //
  333. InitializeComponent();
  334. base.OnInit(e);
  335. }
  336. /// <summary>
  337. /// 设计器支持所需的方法 - 不要使用代码编辑器修改
  338. /// 此方法的内容。
  339. /// </summary>
  340. private void InitializeComponent()
  341. {    
  342. this.btnAccept.Click += new System.EventHandler(this.btnAccept_Click);
  343. this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
  344. this.btnSubscribe.Click += new System.EventHandler(this.btnSubscribe_Click);
  345. this.listStaff.SelectedIndexChanged += new System.EventHandler(this.listStaff_SelectedIndexChanged);
  346. this.lnkbtnToday.Click += new System.EventHandler(this.lnkbtnToday_Click);
  347. this.lnkbtnHistory.Click += new System.EventHandler(this.lnkbtnHistory_Click);
  348. this.lnkbtnFinished.Click += new System.EventHandler(this.lnkbtnFinished_Click);
  349. this.Linkbutton1.Click += new System.EventHandler(this.Linkbutton1_Click);
  350. this.lnkbtnArranged.Click += new System.EventHandler(this.lnkbtnArranged_Click);
  351. this.btnWeeklyView.Click += new System.EventHandler(this.btnWeeklyView_Click);
  352. this.btnCancelSubscription.Click += new System.EventHandler(this.btnCancelSubscription_Click);
  353. this.Load += new System.EventHandler(this.Page_Load);
  354. }
  355. #endregion
  356. public string GetStatus(string str)
  357. {
  358. switch (str) 
  359. {
  360. case "0":
  361. return "?"; // 待定
  362. case "1":
  363. return "!"; // 待办
  364. case "2":
  365. return "√"; // 完成
  366. default:
  367. return "";
  368. }
  369. }
  370. public string GetPeriodByPeriodID(string EndTime,string begintime,string endtime)
  371. {
  372. if(begintime=="0"&&endtime=="0")
  373. {
  374. return DateTime.Parse(EndTime).ToShortTimeString()+"(截止)";
  375. }
  376. else if(begintime=="1"&&endtime=="20")
  377. {
  378. return "(全天)";
  379. }
  380. else
  381. {
  382. int b = Int32.Parse(begintime);
  383. int e = Int32.Parse(endtime);
  384. DateTime dt = new DateTime(1999,1,1,8,0,0,0);
  385. TimeSpan ts = new TimeSpan(0,0,(b-1)*30,0,0);
  386. DateTime bt = dt.Add(ts);
  387. DateTime et = bt.Add(new TimeSpan(0,0,(e-b+1)*30,0,0));
  388. return bt.ToShortTimeString()+"-"+et.ToShortTimeString();
  389. }
  390. }
  391. public string GetRealName(string Username)
  392. {
  393. if(Username!="")
  394. return UDS.Components.Staff.GetRealNameByUsername(Username);
  395. else
  396. return "";
  397. }
  398. public string GetRealNameStr(string Username)
  399. {
  400. if(Username!="")
  401. return UDS.Components.Staff.GetRealNameStrByUsernameStr(Username,3);
  402. else
  403. return "";
  404. }
  405. public string GetType(string type)
  406. {
  407. string Type="";
  408. if(type!="")
  409. {
  410. switch (Int32.Parse(type)) 
  411. {
  412. case 1:
  413. Type="会议";
  414. break;
  415. case 2:
  416. Type="文案";
  417. break;
  418. case 3:
  419. Type="来访";
  420. break;
  421. case 4:
  422. Type="电话";
  423. break;
  424. case 5:
  425. Type="走访";
  426. break;
  427. case 6:
  428. Type="外出";
  429. break;
  430. case 7:
  431. Type="假期";
  432. break;
  433. case 8:
  434. Type="出差";
  435. break;
  436. }
  437. return Type;
  438. }
  439. else
  440. return "";
  441. }
  442. public string GetProjectName(string project)
  443. {
  444. if(project!="")
  445. return UDS.Components .ProjectClass .GetProjectName (Int32.Parse(project));
  446. else
  447. return "";
  448. }
  449. private void setgrid()
  450. {
  451. foreach(DataGridItem dgi in this.dgList .Items)
  452. {
  453. Label lb=(Label)(dgi.Cells[3].Controls[1]);
  454. if(lb.Text=="?") dgi.BackColor=Color.AliceBlue ;
  455. }
  456. }
  457. #region 翻页事件
  458. public void DataGrid_PageChanged(object sender,DataGridPageChangedEventArgs e)
  459. {
  460. Username = (string)Session["Username"];
  461. this.dgList .CurrentPageIndex = e.NewPageIndex;
  462. Task task = new Task();
  463. DataTable mydb = Tools.ConvertDataReaderToDataTable(task.GetAllTaskBySomeone(DateTime.Today.ToShortDateString(),Username,displayType));
  464. this.dgList .DataSource = mydb.DefaultView;
  465. this.dgList.DataBind();
  466. setgrid();
  467. }
  468. #endregion
  469. private void btnList_Click(object sender, System.EventArgs e)
  470. {
  471. string Username = (string)Session["Username"];
  472. Task task = new Task();
  473. this.dgList.Visible = true;
  474. this.btnCancel .Visible = true;
  475. this.btnAccept .Visible = true;
  476. DataTable mydb = Tools.ConvertDataReaderToDataTable(task.GetTodayTaskBySomeone(DateTime.Today.ToShortDateString(),Username,1));
  477. this.dgList .DataSource = mydb.DefaultView;
  478. this.dgList.DataBind();
  479. setgrid();
  480. mydb.Dispose();
  481. }
  482. private void lnkbtnAccept_Click(object sender, System.EventArgs e)
  483. {
  484. string Username = (string)Session["Username"];
  485. string ids = "";
  486. foreach(DataGridItem dgi in this.dgList .Items)
  487. {
  488. CheckBox cb=(CheckBox)(dgi.Cells[0].Controls[1]);
  489. if (cb.Checked==true)
  490. {
  491. ids += dgList.DataKeys[dgi.ItemIndex].ToString()+",";
  492. }
  493. }
  494. if(ids!="")
  495. {
  496. ids = ids.Substring(0,ids.Length-1);
  497. Task task = new Task();
  498. try
  499. {
  500. task.DealTask(ids,1,Username,DateTime.Today.ToShortDateString());
  501. Response.Write("<script language=javascript>alert('操作成功!');window.location='TaskList.aspx';</script>");
  502. //Response.AddHeader("Refresh","1");
  503. }
  504. catch(Exception ex)
  505. {
  506. UDS.Components .Error.Log(ex.ToString());
  507. Server.Transfer("../Error.aspx");
  508. }
  509. }
  510. }
  511. private void lnkbtnCancel_Click(object sender, System.EventArgs e)
  512. {
  513. string Username = (string)Session["Username"];
  514. string ids = "";
  515. foreach(DataGridItem dgi in this.dgList .Items)
  516. {
  517. CheckBox cb=(CheckBox)(dgi.Cells[0].Controls[1]);
  518. if (cb.Checked==true)
  519. {
  520. ids += dgList.DataKeys[dgi.ItemIndex].ToString()+",";
  521. }
  522. }
  523. if(ids!="")
  524. {
  525. ids = ids.Substring(0,ids.Length-1);
  526. Task task = new Task();
  527. try
  528. {
  529. task.DealTask(ids,0,Username,DateTime.Today .ToShortDateString());
  530. Response.Write("<script language=javascript>alert('操作成功!');window.location='TaskList.aspx';</script>");
  531. //Response.AddHeader("Refresh","1");
  532. }
  533. catch(Exception ex)
  534. {
  535. UDS.Components .Error.Log(ex.ToString());
  536. Server.Transfer("../Error.aspx");
  537. }
  538. }
  539. }
  540. private void lnkbtnFinish_Click(object sender, System.EventArgs e)
  541. {
  542. string Username = (string)Session["Username"];
  543. string ids = "";
  544. foreach(DataGridItem dgi in this.dgList .Items)
  545. {
  546. CheckBox cb=(CheckBox)(dgi.Cells[0].Controls[1]);
  547. if (cb.Checked==true)
  548. {
  549. ids += dgList.DataKeys[dgi.ItemIndex].ToString()+",";
  550. }
  551. }
  552. if(ids!="")
  553. {
  554. ids = ids.Substring(0,ids.Length-1);
  555. Task task = new Task();
  556. try
  557. {
  558. task.DealTask(ids,2,Username,DateTime.Today.ToShortDateString());
  559. Response.Write("<script language=javascript>alert('操作成功!');window.location='TaskList.aspx';</script>");
  560. //Response.AddHeader("Refresh","1");
  561. }
  562. catch(Exception ex)
  563. {
  564. UDS.Components .Error.Log(ex.ToString());
  565. Server.Transfer("../Error.aspx");
  566. }
  567. }
  568. }
  569. private void lnkbtnToday_Click(object sender, System.EventArgs e)
  570. {
  571. string Username = (string)Session["Username"];
  572. this.btnCancelSubscription.Visible = false;
  573. this.btnCancel.Visible = true;
  574. displayType = 1;
  575. this.tblContainer.Rows[0].Cells[0].Attributes.Add("background","../../images/maillistbutton2.gif");
  576. this.tblContainer.Rows[0].Cells[1].Attributes.Add("background","../../images/maillistbutton1.gif");
  577. this.tblContainer.Rows[0].Cells[2].Attributes.Add("background","../../images/maillistbutton1.gif");
  578. this.tblContainer.Rows[0].Cells[3].Attributes.Add("background","../../images/maillistbutton1.gif");
  579. this.tblContainer.Rows[0].Cells[4].Attributes.Add("background","../../images/maillistbutton1.gif");
  580. Task task = new Task();
  581. DataTable mydb = Tools.ConvertDataReaderToDataTable(task.GetAllTaskBySomeone(DateTime.Today.ToShortDateString(),Username,displayType));
  582. this.dgList .DataSource = mydb.DefaultView;
  583. this.dgList.DataBind();
  584. setgrid();
  585. mydb.Dispose();
  586. }
  587. private void lnkbtnHistory_Click(object sender, System.EventArgs e)
  588. {
  589. string Username = (string)Session["Username"];
  590. this.btnCancelSubscription.Visible = false;
  591. this.btnCancel.Visible = true;
  592. displayType = 2;
  593. this.tblContainer.Rows[0].Cells[1].Attributes.Add("background","../../images/maillistbutton2.gif");
  594. this.tblContainer.Rows[0].Cells[0].Attributes.Add("background","../../images/maillistbutton1.gif");
  595. this.tblContainer.Rows[0].Cells[2].Attributes.Add("background","../../images/maillistbutton1.gif");
  596. this.tblContainer.Rows[0].Cells[3].Attributes.Add("background","../../images/maillistbutton1.gif");
  597. this.tblContainer.Rows[0].Cells[4].Attributes.Add("background","../../images/maillistbutton1.gif");
  598. Task task = new Task();
  599. DataTable mydb = Tools.ConvertDataReaderToDataTable(task.GetAllTaskBySomeone(DateTime.Today.ToShortDateString(),Username,displayType));
  600. this.dgList .DataSource = mydb.DefaultView;
  601. this.dgList.DataBind();
  602. setgrid();
  603. mydb.Dispose();
  604. }
  605. private void lnkbtnFinished_Click(object sender, System.EventArgs e)
  606. {
  607. string Username = (string)Session["Username"];
  608. this.btnCancelSubscription.Visible = false;
  609. this.btnCancel.Visible = false;
  610. displayType = 3;
  611. this.tblContainer.Rows[0].Cells[2].Attributes.Add("background","../../images/maillistbutton2.gif");
  612. this.tblContainer.Rows[0].Cells[0].Attributes.Add("background","../../images/maillistbutton1.gif");
  613. this.tblContainer.Rows[0].Cells[1].Attributes.Add("background","../../images/maillistbutton1.gif");
  614. this.tblContainer.Rows[0].Cells[3].Attributes.Add("background","../../images/maillistbutton1.gif");
  615. this.tblContainer.Rows[0].Cells[4].Attributes.Add("background","../../images/maillistbutton1.gif");
  616. Task task = new Task();
  617. DataTable mydb = Tools.ConvertDataReaderToDataTable(task.GetAllTaskBySomeone(DateTime.Today.ToShortDateString(),Username,displayType));
  618. this.dgList .DataSource = mydb.DefaultView;
  619. this.dgList.DataBind();
  620. // setgrid();
  621. mydb.Dispose();
  622. }
  623. private void btnAccept_Click(object sender, System.EventArgs e)
  624. {
  625. string Username = (string)Session["Username"];
  626. string ids = "";
  627. foreach(DataGridItem dgi in this.dgList .Items)
  628. {
  629. CheckBox cb=(CheckBox)(dgi.Cells[0].Controls[1]);
  630. if (cb.Checked==true)
  631. {
  632. ids += dgList.DataKeys[dgi.ItemIndex].ToString()+",";
  633. }
  634. }
  635. if(ids!="")
  636. {
  637. ids = ids.Substring(0,ids.Length-1);
  638. Task task = new Task();
  639. try
  640. {
  641. task.DealTask(ids,1,Username,DateTime.Today.ToShortDateString());
  642. Response.Write("<script language=javascript>alert('操作成功!');window.location='TaskList.aspx';</script>");
  643. //Response.AddHeader("Refresh","1");
  644. }
  645. catch(Exception ex)
  646. {
  647. UDS.Components .Error.Log(ex.ToString());
  648. Server.Transfer("../Error.aspx");
  649. }
  650. }
  651. }
  652. private void btnCancel_Click(object sender, System.EventArgs e)
  653. {
  654. string Username = (string)Session["Username"];
  655. string ids = "";
  656. foreach(DataGridItem dgi in this.dgList .Items)
  657. {
  658. CheckBox cb=(CheckBox)(dgi.Cells[0].Controls[1]);
  659. if (cb.Checked==true)
  660. {
  661. ids += dgList.DataKeys[dgi.ItemIndex].ToString()+",";
  662. }
  663. }
  664. if(ids!="")
  665. {
  666. ids = ids.Substring(0,ids.Length-1);
  667. Task task = new Task();
  668. try
  669. {
  670. task.DealTask(ids,0,Username,DateTime.Today .ToShortDateString());
  671. Response.Write("<script language=javascript>alert('操作成功!');window.location='TaskList.aspx';</script>");
  672. //Response.AddHeader("Refresh","1");
  673. }
  674. catch(Exception ex)
  675. {
  676. UDS.Components .Error.Log(ex.ToString());
  677. Server.Transfer("../Error.aspx");
  678. }
  679. }
  680. }
  681. private void btnFinish_Click(object sender, System.EventArgs e)
  682. {
  683. string Username = (string)Session["Username"];
  684. string ids = "";
  685. foreach(DataGridItem dgi in this.dgList .Items)
  686. {
  687. CheckBox cb=(CheckBox)(dgi.Cells[0].Controls[1]);
  688. if (cb.Checked==true)
  689. {
  690. ids += dgList.DataKeys[dgi.ItemIndex].ToString()+",";
  691. }
  692. }
  693. if(ids!="")
  694. {
  695. ids = ids.Substring(0,ids.Length-1);
  696. Task task = new Task();
  697. try
  698. {
  699. task.DealTask(ids,2,Username,DateTime.Today.ToShortDateString());
  700. Response.Write("<script language=javascript>alert('操作成功!');window.location='TaskList.aspx';</script>");
  701. //Response.AddHeader("Refresh","1");
  702. }
  703. catch(Exception ex)
  704. {
  705. UDS.Components .Error.Log(ex.ToString());
  706. Server.Transfer("../Error.aspx");
  707. }
  708. }
  709. }
  710. public void listStaff_SelectedIndexChanged(object sender, System.EventArgs e)
  711. {
  712. Session["Username"]=this.listStaff.SelectedItem .Value.ToString();
  713. string Username = (string)Session["Username"];
  714. string ActualUsername = (string)Session["ActualUsername"];
  715. if(this.btnWeeklyView.Text == "周览")
  716. {
  717. Response.Redirect("TaskList.aspx?displayType=1");
  718. }
  719. else
  720. {
  721. this.lnkbtnFinished .Enabled = false;
  722. this.lnkbtnHistory .Enabled  = false;
  723. this.lnkbtnToday .Enabled  = false;
  724. this.Linkbutton1.Enabled  = false;
  725. this.btnAccept .Enabled  = false;
  726. this.btnCancel.Enabled      = false;
  727. this.btnNew .Enabled  = false;
  728. this.btnWeeklyView .Text = "返回";
  729. PopulateWeeklyData();
  730. SetStatus();
  731. this.btnSubscribe .Enabled  = false;
  732. }
  733. }
  734. private void btnSubscribe_Click(object sender, System.EventArgs e)
  735. {
  736. string Username = (string)Session["Username"];
  737. string ActualUsername = (string)Session["ActualUsername"];
  738. string ids = "";
  739. Task task = new Task();
  740. foreach(DataGridItem dgi in this.dgList .Items)
  741. {
  742. CheckBox cb=(CheckBox)(dgi.Cells[0].Controls[1]);
  743. Label  lb=(Label)(dgi.Cells[1].Controls[3]);
  744. if (cb.Checked==true)
  745. {
  746. try
  747. {
  748. ids = dgList.DataKeys[dgi.ItemIndex].ToString();
  749. if(task.AddTaskSubscription(ActualUsername,Username,Int32.Parse(ids),Convert.ToDateTime(lb.Text.ToString()).ToShortDateString()))
  750. Response.Write("<script language=javascript>alert('订阅成功!');window.location='TaskList.aspx?displayType="+displayType.ToString()+"';</script>");
  751. }
  752. catch(Exception dbex)
  753. {
  754. UDS.Components .Error.Log(dbex.ToString());
  755. Server.Transfer("../Error.aspx");
  756. }
  757. }
  758. }
  759. }
  760. private void Linkbutton1_Click(object sender, System.EventArgs e)
  761. {
  762. string ActualUsername = (string)Session["ActualUsername"];
  763. string Username = (string)Session["Username"];
  764. this.btnCancelSubscription.Visible = (ActualUsername.ToLower()==Username.ToLower());
  765. displayType = 4;
  766. this.tblContainer.Rows[0].Cells[3].Attributes.Add("background","../../images/maillistbutton2.gif");
  767. this.tblContainer.Rows[0].Cells[0].Attributes.Add("background","../../images/maillistbutton1.gif");
  768. this.tblContainer.Rows[0].Cells[1].Attributes.Add("background","../../images/maillistbutton1.gif");
  769. this.tblContainer.Rows[0].Cells[2].Attributes.Add("background","../../images/maillistbutton1.gif");
  770. this.tblContainer.Rows[0].Cells[4].Attributes.Add("background","../../images/maillistbutton1.gif");
  771. Task task = new Task();
  772. DataTable mydb = Tools.ConvertDataReaderToDataTable(task.GetAllTaskBySomeone(DateTime.Today.ToShortDateString(),Username,displayType));
  773. this.dgList .DataSource = mydb.DefaultView;
  774. this.dgList.DataBind();
  775. // setgrid();
  776. mydb.Dispose();
  777. }
  778. private void btnWeeklyView_Click(object sender, System.EventArgs e)
  779. {
  780. if(this.btnWeeklyView .Text == "周览")
  781. {
  782. this.lnkbtnFinished .Enabled = false;
  783. this.lnkbtnHistory .Enabled  = false;
  784. this.lnkbtnToday .Enabled  = false;
  785. this.Linkbutton1.Enabled  = false;
  786. this.btnAccept .Enabled  = false;
  787. this.btnCancel.Enabled      = false;
  788. this.btnNew .Enabled  = false;
  789. this.lnkbtnArranged.Enabled  = false;
  790. this.btnWeeklyView .Text  = "返回";
  791. PopulateWeeklyData();
  792. }
  793. else if(this.btnWeeklyView .Text == "返回")
  794. {
  795. this.lnkbtnFinished .Enabled = true;
  796. this.lnkbtnHistory .Enabled  = true;
  797. this.lnkbtnToday .Enabled  = true;
  798. this.Linkbutton1.Enabled  = true;
  799. this.lnkbtnArranged .Enabled = true;
  800. this.btnAccept .Enabled  = true;
  801. this.btnCancel.Enabled      = true;
  802. this.btnNew .Enabled  = true;
  803. this.lblInstru .Visible      = true;
  804. this.btnWeeklyView .Text  = "周览";
  805. InitData();
  806. }
  807. SetStatus();
  808. }
  809. private void btnCancelSubscription_Click(object sender, System.EventArgs e)
  810. {
  811. string ActualUsername = (string)Session["ActualUsername"];
  812. string ids = "";
  813. foreach(DataGridItem dgi in this.dgList .Items)
  814. {
  815. CheckBox cb=(CheckBox)(dgi.Cells[0].Controls[1]);
  816. if (cb.Checked==true)
  817. {
  818. ids += dgList.DataKeys[dgi.ItemIndex].ToString()+",";
  819. }
  820. }
  821. if(ids!="")
  822. {
  823. ids = ids.Substring(0,ids.Length-1);
  824. Task task = new Task();
  825. try
  826. {
  827. task.DeleteTaskSubscription(ActualUsername,ids);
  828. Response.Write("<script language=javascript>alert('操作成功!');window.location='TaskList.aspx?displayType="+displayType+"';</script>");
  829. //Response.AddHeader("Refresh","1");
  830. }
  831. catch(Exception ex)
  832. {
  833. UDS.Components .Error.Log(ex.ToString());
  834. Server.Transfer("../Error.aspx");
  835. }
  836. }
  837. }
  838. private void lnkbtnArranged_Click(object sender, System.EventArgs e)
  839. {
  840. string ActualUsername = (string)Session["ActualUsername"];
  841. string Username = (string)Session["Username"];
  842. //this.btnCancelSubscription.Visible = (ActualUsername.ToLower()==Username.ToLower());
  843. this.btnCancelSubscription.Visible = false;
  844. this.btnCancel.Visible = false;
  845. displayType = 5;
  846. this.tblContainer.Rows[0].Cells[3].Attributes.Add("background","../../images/maillistbutton1.gif");
  847. this.tblContainer.Rows[0].Cells[0].Attributes.Add("background","../../images/maillistbutton1.gif");
  848. this.tblContainer.Rows[0].Cells[1].Attributes.Add("background","../../images/maillistbutton1.gif");
  849. this.tblContainer.Rows[0].Cells[2].Attributes.Add("background","../../images/maillistbutton1.gif");
  850. this.tblContainer.Rows[0].Cells[4].Attributes.Add("background","../../images/maillistbutton2.gif");
  851. Task task = new Task();
  852. DataTable mydb = Tools.ConvertDataReaderToDataTable(task.GetAllTaskBySomeone(DateTime.Today.ToShortDateString(),Username,displayType));
  853. this.dgList .DataSource = mydb.DefaultView;
  854. this.dgList.DataBind();
  855. // setgrid();
  856. mydb.Dispose();
  857. }
  858. }
  859. }