123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- using DAL;
- using Models;
- using OA2014.publicCode;
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Linq;
- using System.Web;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- namespace OA2014.users
- {
- public partial class LeaveTimes:SessionCode
- {
- UsersService us = new UsersService();
- SetDataService sds = new SetDataService();
- YearMonthService yms = new YearMonthService();
- //分页设置
- int sumPage = 0;
- int totalRecord = 0;
- string url = "../users/LeaveTimes.aspx";
- protected void Page_Load(object sender, EventArgs e)
- {
- if (!IsPostBack)
- {
- bindDDL();
- bind();
- }
- }
- /// <summary>
- /// 绑定下拉列表
- /// </summary>
- private void bindDDL()
- {
- List<Users> uList = us.GetAll();
- if (uList != null)
- {
- ddlUsers.DataSource = uList;
- ddlUsers.DataValueField = "Id";
- ddlUsers.DataTextField = "CnName";
- ddlUsers.DataBind();
- }
- //绑定请假类型
- List<SetData> sdList = sds.GetAll(9);
- if (sdList != null)
- {
- ddlLeaveType.DataSource = sdList;
- ddlLeaveType.DataValueField = "Id";
- ddlLeaveType.DataTextField = "Name";
- ddlLeaveType.DataBind();
- }
- ddlLeaveType.Items.Insert(0, new ListItem("全部", "0"));
- ddlLeaveType.SelectedIndex = -1;
- ddlYearMonth.DataSource = yms.GetYearMonth();
- ddlYearMonth.DataTextField = "YearMonths";
- ddlYearMonth.DataValueField = "YearMonths";
- ddlYearMonth.DataBind();
- ddlYearMonth.SelectedIndex = -1;
- if (Request.QueryString["uid"] != null && !string.IsNullOrEmpty(Request.QueryString["uid"].ToString()))
- ddlUsers.Items.FindByValue(Request.QueryString["uid"].ToString()).Selected = true;
- if (Request.QueryString["LeaveType"] != null && !string.IsNullOrEmpty(Request.QueryString["LeaveType"].ToString()))
- ddlLeaveType.Items.FindByValue(Request.QueryString["LeaveType"].ToString()).Selected = true;
- if (Request.QueryString["YearMonth"] != null && !string.IsNullOrEmpty(Request.QueryString["YearMonth"].ToString()))
- ddlYearMonth.Items.FindByValue(Request.QueryString["YearMonth"].ToString()).Selected = true;
- }
- /// <summary>
- /// 绑定数据
- /// </summary>
- private void bind()
- {
- //url传递参数设置
- pageControl.Params = "&uid=" + ddlUsers.SelectedValue + "&YearMonth=" + ddlYearMonth.SelectedValue + "&LeaveType=" + ddlLeaveType.SelectedValue;
- //分页设置
- int pageIndex = pageControl.getPageIndex();
- AttendanceDataService adds = new AttendanceDataService();
- DataTable dt = adds.GetLeaveList(Convert.ToInt32(ddlUsers.SelectedValue), ddlYearMonth.Text, Convert.ToInt32(ddlLeaveType.SelectedValue), pageIndex, 10, out sumPage, out totalRecord);
- lblSumLeavelY.InnerText = adds.GetLeaveCountY(Convert.ToInt32(ddlUsers.SelectedValue), ddlYearMonth.Text, Convert.ToInt32(ddlLeaveType.SelectedValue));
- lblSumLeavelM.InnerText = totalRecord.ToString();
- if (dt != null && dt.Rows.Count>0)
- {
- rpData.DataSource = dt;
- rpData.DataBind();
- }
- //绑定分页用户控件
- pageControl.bind(pageIndex, sumPage, totalRecord, url);
- }
- protected void ddlUsers_TextChanged(object sender, EventArgs e)
- {
- Response.Redirect("LeaveTimes.aspx?Page=1&uid=" + ddlUsers.SelectedValue + "&YearMonth=" + ddlYearMonth.SelectedValue + "&LeaveType=" + ddlLeaveType.SelectedValue);
- }
- protected void ddlYearMonth_TextChanged(object sender, EventArgs e)
- {
- Response.Redirect("LeaveTimes.aspx?Page=1&uid=" + ddlUsers.SelectedValue + "&YearMonth=" + ddlYearMonth.SelectedValue + "&LeaveType=" + ddlLeaveType.SelectedValue);
- }
- protected void ddlLeaveType_TextChanged(object sender, EventArgs e)
- {
- Response.Redirect("LeaveTimes.aspx?Page=1&uid=" + ddlUsers.SelectedValue + "&YearMonth=" + ddlYearMonth.SelectedValue + "&LeaveType=" + ddlLeaveType.SelectedValue);
- }
- }
- }
|