LeaveTimes.aspx.cs 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. using DAL;
  2. using Models;
  3. using OA2014.publicCode;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Data;
  7. using System.Linq;
  8. using System.Web;
  9. using System.Web.UI;
  10. using System.Web.UI.WebControls;
  11. namespace OA2014.users
  12. {
  13. public partial class LeaveTimes:SessionCode
  14. {
  15. UsersService us = new UsersService();
  16. SetDataService sds = new SetDataService();
  17. YearMonthService yms = new YearMonthService();
  18. //分页设置
  19. int sumPage = 0;
  20. int totalRecord = 0;
  21. string url = "../users/LeaveTimes.aspx";
  22. protected void Page_Load(object sender, EventArgs e)
  23. {
  24. if (!IsPostBack)
  25. {
  26. bindDDL();
  27. bind();
  28. }
  29. }
  30. /// <summary>
  31. /// 绑定下拉列表
  32. /// </summary>
  33. private void bindDDL()
  34. {
  35. List<Users> uList = us.GetAll();
  36. if (uList != null)
  37. {
  38. ddlUsers.DataSource = uList;
  39. ddlUsers.DataValueField = "Id";
  40. ddlUsers.DataTextField = "CnName";
  41. ddlUsers.DataBind();
  42. }
  43. //绑定请假类型
  44. List<SetData> sdList = sds.GetAll(9);
  45. if (sdList != null)
  46. {
  47. ddlLeaveType.DataSource = sdList;
  48. ddlLeaveType.DataValueField = "Id";
  49. ddlLeaveType.DataTextField = "Name";
  50. ddlLeaveType.DataBind();
  51. }
  52. ddlLeaveType.Items.Insert(0, new ListItem("全部", "0"));
  53. ddlLeaveType.SelectedIndex = -1;
  54. ddlYearMonth.DataSource = yms.GetYearMonth();
  55. ddlYearMonth.DataTextField = "YearMonths";
  56. ddlYearMonth.DataValueField = "YearMonths";
  57. ddlYearMonth.DataBind();
  58. ddlYearMonth.SelectedIndex = -1;
  59. if (Request.QueryString["uid"] != null && !string.IsNullOrEmpty(Request.QueryString["uid"].ToString()))
  60. ddlUsers.Items.FindByValue(Request.QueryString["uid"].ToString()).Selected = true;
  61. if (Request.QueryString["LeaveType"] != null && !string.IsNullOrEmpty(Request.QueryString["LeaveType"].ToString()))
  62. ddlLeaveType.Items.FindByValue(Request.QueryString["LeaveType"].ToString()).Selected = true;
  63. if (Request.QueryString["YearMonth"] != null && !string.IsNullOrEmpty(Request.QueryString["YearMonth"].ToString()))
  64. ddlYearMonth.Items.FindByValue(Request.QueryString["YearMonth"].ToString()).Selected = true;
  65. }
  66. /// <summary>
  67. /// 绑定数据
  68. /// </summary>
  69. private void bind()
  70. {
  71. //url传递参数设置
  72. pageControl.Params = "&uid=" + ddlUsers.SelectedValue + "&YearMonth=" + ddlYearMonth.SelectedValue + "&LeaveType=" + ddlLeaveType.SelectedValue;
  73. //分页设置
  74. int pageIndex = pageControl.getPageIndex();
  75. AttendanceDataService adds = new AttendanceDataService();
  76. DataTable dt = adds.GetLeaveList(Convert.ToInt32(ddlUsers.SelectedValue), ddlYearMonth.Text, Convert.ToInt32(ddlLeaveType.SelectedValue), pageIndex, 10, out sumPage, out totalRecord);
  77. lblSumLeavelY.InnerText = adds.GetLeaveCountY(Convert.ToInt32(ddlUsers.SelectedValue), ddlYearMonth.Text, Convert.ToInt32(ddlLeaveType.SelectedValue));
  78. lblSumLeavelM.InnerText = totalRecord.ToString();
  79. if (dt != null && dt.Rows.Count>0)
  80. {
  81. rpData.DataSource = dt;
  82. rpData.DataBind();
  83. }
  84. //绑定分页用户控件
  85. pageControl.bind(pageIndex, sumPage, totalRecord, url);
  86. }
  87. protected void ddlUsers_TextChanged(object sender, EventArgs e)
  88. {
  89. Response.Redirect("LeaveTimes.aspx?Page=1&uid=" + ddlUsers.SelectedValue + "&YearMonth=" + ddlYearMonth.SelectedValue + "&LeaveType=" + ddlLeaveType.SelectedValue);
  90. }
  91. protected void ddlYearMonth_TextChanged(object sender, EventArgs e)
  92. {
  93. Response.Redirect("LeaveTimes.aspx?Page=1&uid=" + ddlUsers.SelectedValue + "&YearMonth=" + ddlYearMonth.SelectedValue + "&LeaveType=" + ddlLeaveType.SelectedValue);
  94. }
  95. protected void ddlLeaveType_TextChanged(object sender, EventArgs e)
  96. {
  97. Response.Redirect("LeaveTimes.aspx?Page=1&uid=" + ddlUsers.SelectedValue + "&YearMonth=" + ddlYearMonth.SelectedValue + "&LeaveType=" + ddlLeaveType.SelectedValue);
  98. }
  99. }
  100. }