using BLL;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace FineUIPro.Web.Door
{
public partial class InOutRecordProjectStatistics : PageBase
{///
/// 项目id
///
public string ProjectId
{
get
{
return (string)ViewState["ProjectId"];
}
set
{
ViewState["ProjectId"] = value;
}
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.ProjectId = this.CurrUser.LoginProjectId;
if (!string.IsNullOrEmpty(Request.Params["projectId"]) && Request.Params["projectId"] != this.CurrUser.LoginProjectId)
{
this.ProjectId = Request.Params["projectId"];
}
Funs.DropDownPageSize(this.ddlPageSize);
this.GetButtonPower();
this.ddlPageSize.SelectedValue = this.Grid1.PageSize.ToString();
this.BindGrid();
}
}
protected void btSearch_Click(object sender, EventArgs e)
{
this.BindGrid();
}
#region 绑定数据
///
/// 绑定数据
///
private void BindGrid()
{
if (txtStartDate.SelectedDate != null)
{
var tb = BLL.InOutRecordProjectStatisticsService.GetStatistics(txtStartDate.SelectedDate.Value);
Grid1.RecordCount = tb.Count;
//tb = GetFilteredTable(Grid1.FilteredData, tb);
Grid1.DataSource = tb;
Grid1.DataBind();
}
}
#endregion
#region GV 数据操作
///
/// 过滤表头
///
///
///
//protected void Grid1_FilterChange(object sender, EventArgs e)
//{
// this.BindGrid();
//}
///
/// 分页
///
///
///
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
{
this.Grid1.PageIndex = e.NewPageIndex;
this.BindGrid();
}
///
/// 排序
///
///
///
protected void Grid1_Sort(object sender, GridSortEventArgs e)
{
this.Grid1.SortDirection = e.SortDirection;
this.Grid1.SortField = e.SortField;
this.BindGrid();
}
///
/// 分页显示条数下拉框
///
///
///
protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
{
this.Grid1.PageSize = Convert.ToInt32(this.ddlPageSize.SelectedValue);
this.BindGrid();
}
#endregion
#region 关闭弹出窗
///
/// 关闭弹出窗
///
///
///
protected void Window1_Close(object sender, WindowCloseEventArgs e)
{
BindGrid();
}
#endregion
#region 获取权限按钮
///
/// 获取按钮权限
///
///
///
private void GetButtonPower()
{
/*var buttonList = BLL.CommonService.GetAllButtonList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.SitePerson_PersonLeaveMenuId);
if (buttonList.Count > 0)
{
if (buttonList.Contains(BLL.Const.BtnAdd))
{
this.btnNew.Hidden = false;
}
if (buttonList.Contains(BLL.Const.BtnModify))
{
this.btnMenuEdit.Hidden = false;
}
if (buttonList.Contains(BLL.Const.BtnDelete))
{
this.btnMenuDelete.Hidden = false;
}
}*/
}
#endregion
#region 导出按钮
/// 导出按钮
///
///
///
protected void btnOut_Click(object sender, EventArgs e)
{
Response.ClearContent();
string filename = Funs.GetNewFileName();
Response.AddHeader("content-disposition", "attachment; filename=" + System.Web.HttpUtility.UrlEncode("人员请假表" + filename, System.Text.Encoding.UTF8) + ".xls");
Response.ContentType = "application/excel";
Response.ContentEncoding = System.Text.Encoding.UTF8;
this.Grid1.PageSize = 500;
this.BindGrid();
Response.Write(GetGridTableHtml(Grid1));
Response.End();
}
///
/// 导出方法
///
///
///
private string GetGridTableHtml(Grid grid)
{
StringBuilder sb = new StringBuilder();
sb.Append("");
sb.Append("
");
sb.Append("");
foreach (GridColumn column in grid.Columns)
{
sb.AppendFormat("{0} | ", column.HeaderText);
}
sb.Append("
");
foreach (GridRow row in grid.Rows)
{
sb.Append("");
foreach (GridColumn column in grid.Columns)
{
string html = row.Values[column.ColumnIndex].ToString();
if (column.ColumnID == "tfNumber")
{
html = (row.FindControl("lblNumber") as System.Web.UI.WebControls.Label).Text;
}
sb.AppendFormat("{0} | ", html);
}
sb.Append("
");
}
sb.Append("
");
return sb.ToString();
}
#endregion
protected void Grid1_RowDataBound(object sender, GridRowEventArgs e)
{
Model.InOutRecordProjectStatisticsOutput row = e.Row.DataItem as Model.InOutRecordProjectStatisticsOutput;
int type = row.type;
BoundField bftype = Grid1.FindColumn("bftype") as BoundField;
if (type ==0)
{
e.RowCssClass = "color1";
}
}
}
}