2025-06-04 10:04:20 +08:00
|
|
|
|
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)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.ProjectId = this.CurrUser.LoginProjectId;
|
2025-12-08 10:02:06 +08:00
|
|
|
|
Funs.DropDownPageSize(this.ddlPageSize);
|
|
|
|
|
|
UnitService.InitUnitDownList(this.drpUnit, this.ProjectId, true);
|
|
|
|
|
|
TeamGroupService.InitTeamGroupProjectUnitDropDownList(this.drpWorkTeam, this.ProjectId, null, true);
|
|
|
|
|
|
WorkPostService.InitWorkPostDropDownList(this.drpWorkPost, true);
|
2025-06-04 10:04:20 +08:00
|
|
|
|
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
|
2025-12-08 10:02:06 +08:00
|
|
|
|
group x by new { x.PersonId, x.ProjectId } into g
|
2025-06-04 10:04:20 +08:00
|
|
|
|
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
|
2025-12-05 17:46:23 +08:00
|
|
|
|
join u in db.Base_Unit on detail.UnitId equals u.UnitId
|
|
|
|
|
|
join tg in db.ProjectData_TeamGroup on y.TeamGroupId equals tg.TeamGroupId
|
2025-06-04 10:04:20 +08:00
|
|
|
|
where detail.IsIn == true
|
|
|
|
|
|
select new
|
|
|
|
|
|
{
|
|
|
|
|
|
PersonId = record.PersonId,
|
|
|
|
|
|
PersonName = y.PersonName,
|
2025-12-08 10:02:06 +08:00
|
|
|
|
WorkPostId = y.WorkPostId,
|
2025-06-04 10:04:20 +08:00
|
|
|
|
WorkPostName = z.WorkPostName,
|
2025-12-05 17:46:23 +08:00
|
|
|
|
IdentityCard = y.IdentityCard,
|
2025-12-08 10:02:06 +08:00
|
|
|
|
UnitId = y.UnitId,
|
2025-12-05 17:46:23 +08:00
|
|
|
|
UnitName = u.UnitName,
|
2025-12-08 10:02:06 +08:00
|
|
|
|
TeamGroupId = y.TeamGroupId,
|
|
|
|
|
|
TeamGroupName = tg.TeamGroupName,
|
2025-06-04 10:04:20 +08:00
|
|
|
|
ProjectId = record.ProjectId,
|
|
|
|
|
|
ChangeTime = record.MaxChangeTime,
|
|
|
|
|
|
PostType = z.PostType,
|
|
|
|
|
|
IsIn = true,
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
if (this.chManager.Checked)
|
|
|
|
|
|
{
|
|
|
|
|
|
finalQuery = finalQuery.Where(x => x.PostType == Const.PostType_1);
|
|
|
|
|
|
}
|
2025-12-08 10:02:06 +08:00
|
|
|
|
if (!string.IsNullOrWhiteSpace(this.txtPersonName.Text.Trim()))
|
|
|
|
|
|
{
|
|
|
|
|
|
finalQuery = finalQuery.Where(x => x.PersonName.Contains(this.txtPersonName.Text.Trim()));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (this.drpUnit.SelectedValue != Const._Null && !string.IsNullOrEmpty(this.drpUnit.SelectedValue))
|
|
|
|
|
|
{
|
|
|
|
|
|
finalQuery = finalQuery.Where(x => x.UnitId == this.drpUnit.SelectedValue);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (this.drpWorkPost.SelectedValue != Const._Null && !string.IsNullOrEmpty(this.drpWorkPost.SelectedValue))
|
|
|
|
|
|
{
|
|
|
|
|
|
finalQuery = finalQuery.Where(x => x.WorkPostId == this.drpWorkPost.SelectedValue);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (this.drpWorkTeam.SelectedValue != Const._Null && !string.IsNullOrEmpty(this.drpWorkTeam.SelectedValue))
|
|
|
|
|
|
{
|
|
|
|
|
|
finalQuery = finalQuery.Where(x => x.TeamGroupId == this.drpWorkTeam.SelectedValue);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-06-04 10:04:20 +08:00
|
|
|
|
|
2025-06-04 15:26:39 +08:00
|
|
|
|
DataTable tb = this.LINQToDataTable(finalQuery);
|
|
|
|
|
|
|
2025-06-04 10:04:20 +08:00
|
|
|
|
Grid1.RecordCount = tb.Rows.Count;
|
|
|
|
|
|
var table = this.GetPagedDataTable(Grid1, tb);
|
|
|
|
|
|
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
|
|
|
|
|
|
|
2025-12-05 17:46:23 +08:00
|
|
|
|
|
|
|
|
|
|
#region 导出
|
|
|
|
|
|
|
|
|
|
|
|
/// 导出按钮
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
|
protected void btnOut_Click(object sender, EventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
Response.ClearContent();
|
|
|
|
|
|
string filename = Funs.GetNewFileName();
|
2025-12-08 10:02:06 +08:00
|
|
|
|
Response.AddHeader("content-disposition", "attachment; filename=" + System.Web.HttpUtility.UrlEncode("项目当前现场" + filename + DateTime.Now.ToString("yyyyMMddHHmmss"), System.Text.Encoding.UTF8) + ".xls");
|
2025-12-05 17:46:23 +08:00
|
|
|
|
Response.ContentType = "application/excel";
|
|
|
|
|
|
Response.ContentEncoding = System.Text.Encoding.UTF8;
|
|
|
|
|
|
this.Grid1.PageSize = this.Grid1.RecordCount;
|
|
|
|
|
|
BindGrid();
|
|
|
|
|
|
Response.Write(GetGridTableHtml(Grid1));
|
|
|
|
|
|
Response.End();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
2025-06-04 10:04:20 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|