163 lines
5.3 KiB
C#
163 lines
5.3 KiB
C#
|
using BLL;
|
|||
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Data;
|
|||
|
using System.Data.SqlClient;
|
|||
|
using System.Linq;
|
|||
|
|
|||
|
namespace FineUIPro.Web.DataShow
|
|||
|
{
|
|||
|
public partial class ProjectSitePerson : PageBase
|
|||
|
{
|
|||
|
#region 项目主键
|
|||
|
/// <summary>
|
|||
|
/// 项目主键
|
|||
|
/// </summary>
|
|||
|
public string ProjectId
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return (string)ViewState["ProjectId"];
|
|||
|
}
|
|||
|
set
|
|||
|
{
|
|||
|
ViewState["ProjectId"] = value;
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region 加载页面
|
|||
|
/// <summary>
|
|||
|
/// 加载页面
|
|||
|
/// </summary>
|
|||
|
/// <param name="sender"></param>
|
|||
|
/// <param name="e"></param>
|
|||
|
protected void Page_Load(object sender, EventArgs e)
|
|||
|
{
|
|||
|
if (!IsPostBack)
|
|||
|
{
|
|||
|
Funs.DropDownPageSize(this.ddlPageSize);
|
|||
|
this.ProjectId = this.CurrUser.LoginProjectId;
|
|||
|
this.Panel1.Title = $"项目当前现场人员({BLL.ProjectService.GetProjectNameByProjectId(this.ProjectId)})";
|
|||
|
ddlPageSize.SelectedValue = Grid1.PageSize.ToString();
|
|||
|
//BLL.ProjectService.InitProjectDropDownList(this.drpProject, true);
|
|||
|
// 绑定表格t
|
|||
|
BindGrid();
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 绑定数据
|
|||
|
/// </summary>
|
|||
|
private void BindGrid()
|
|||
|
{
|
|||
|
if (!string.IsNullOrWhiteSpace(this.ProjectId))
|
|||
|
{
|
|||
|
var db = Funs.DB;
|
|||
|
var startDate = DateTime.Now.Date;
|
|||
|
var endDate = startDate.AddDays(1);
|
|||
|
var query =
|
|||
|
from x in db.SitePerson_PersonInOutNow
|
|||
|
where x.ChangeTime >= startDate && x.ChangeTime < endDate && x.ProjectId == this.ProjectId
|
|||
|
group x by new { x.PersonId, x.ProjectId } into g
|
|||
|
select new
|
|||
|
{
|
|||
|
g.Key.PersonId,
|
|||
|
g.Key.ProjectId,
|
|||
|
MaxChangeTime = g.Max(x => x.ChangeTime)
|
|||
|
};
|
|||
|
var finalQuery =
|
|||
|
from record in query
|
|||
|
join detail in db.SitePerson_PersonInOutNow
|
|||
|
on new { record.PersonId, record.ProjectId, record.MaxChangeTime }
|
|||
|
equals new { detail.PersonId, detail.ProjectId, MaxChangeTime = detail.ChangeTime }
|
|||
|
join y in db.SitePerson_Person on record.PersonId equals y.PersonId
|
|||
|
join z in db.Base_WorkPost on y.WorkPostId equals z.WorkPostId
|
|||
|
where detail.IsIn == true
|
|||
|
select new
|
|||
|
{
|
|||
|
PersonId = record.PersonId,
|
|||
|
PersonName = y.PersonName,
|
|||
|
WorkPostName = z.WorkPostName,
|
|||
|
ProjectId = record.ProjectId,
|
|||
|
ChangeTime = record.MaxChangeTime,
|
|||
|
PostType = z.PostType,
|
|||
|
IsIn = true,
|
|||
|
};
|
|||
|
|
|||
|
if (this.chManager.Checked)
|
|||
|
{
|
|||
|
finalQuery = finalQuery.Where(x => x.PostType == Const.PostType_1);
|
|||
|
}
|
|||
|
var ssss = finalQuery.Count();
|
|||
|
|
|||
|
DataTable tb = this.GetPagedDataTable(Grid1, finalQuery);
|
|||
|
// 2.获取当前分页数据
|
|||
|
//var table = this.GetPagedDataTable(Grid1, tb1);
|
|||
|
Grid1.RecordCount = tb.Rows.Count;
|
|||
|
var table = this.GetPagedDataTable(Grid1, tb);
|
|||
|
//Grid1.RecordCount = finalQuery.Count();
|
|||
|
Grid1.DataSource = table;
|
|||
|
Grid1.DataBind();
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region 查询
|
|||
|
/// <summary>
|
|||
|
/// 查询
|
|||
|
/// </summary>
|
|||
|
/// <param name="sender"></param>
|
|||
|
/// <param name="e"></param>
|
|||
|
protected void TextBox_TextChanged(object sender, EventArgs e)
|
|||
|
{
|
|||
|
this.BindGrid();
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region 表排序、分页、关闭窗口
|
|||
|
/// <summary>
|
|||
|
/// 分页
|
|||
|
/// </summary>
|
|||
|
/// <param name="sender"></param>
|
|||
|
/// <param name="e"></param>
|
|||
|
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
|
|||
|
{
|
|||
|
BindGrid();
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 排序
|
|||
|
/// </summary>
|
|||
|
/// <param name="sender"></param>
|
|||
|
/// <param name="e"></param>
|
|||
|
protected void Grid1_Sort(object sender, GridSortEventArgs e)
|
|||
|
{
|
|||
|
BindGrid();
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 分页显示条数下拉框
|
|||
|
/// </summary>
|
|||
|
/// <param name="sender"></param>
|
|||
|
/// <param name="e"></param>
|
|||
|
protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
|
|||
|
{
|
|||
|
Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue);
|
|||
|
BindGrid();
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 关闭弹出窗
|
|||
|
/// </summary>
|
|||
|
/// <param name="sender"></param>
|
|||
|
/// <param name="e"></param>
|
|||
|
protected void Window1_Close(object sender, WindowCloseEventArgs e)
|
|||
|
{
|
|||
|
BindGrid();
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
}
|
|||
|
}
|