20220315 代码初始化上传
This commit is contained in:
@@ -0,0 +1,217 @@
|
||||
using BLL;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.Text;
|
||||
using AspNet = System.Web.UI.WebControls;
|
||||
|
||||
namespace FineUIPro.Web.Door
|
||||
{
|
||||
public partial class InOutList : PageBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 项目id
|
||||
/// </summary>
|
||||
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.ProjectId)
|
||||
//{
|
||||
// this.ProjectId = Request.Params["projectId"];
|
||||
//}
|
||||
Funs.DropDownPageSize(this.ddlPageSize);
|
||||
UnitService.InitUnitDropDownList(this.drpUnit, this.ProjectId, true);
|
||||
this.txtStartDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now);
|
||||
this.txtEndDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now);
|
||||
if (this.CurrUser != null && this.CurrUser.PageSize.HasValue)
|
||||
{
|
||||
Grid1.PageSize = this.CurrUser.PageSize.Value;
|
||||
}
|
||||
this.ddlPageSize.SelectedValue = Grid1.PageSize.ToString();
|
||||
GetPersonStatistic();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#region 删除
|
||||
/// <summary>
|
||||
/// 批量删除
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void btnMenuDel_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (CurrUser.UserId == Const.hfnbdId)
|
||||
{
|
||||
if (string.IsNullOrEmpty(Grid1.SelectedRowID))
|
||||
{
|
||||
Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
string sql = "delete from t_d_validcardevent where NewID = '" + Grid1.SelectedRowID + "' ";
|
||||
SQLHelper.GetIntValue(sql);
|
||||
string sql1 = "delete from t_d_facerecord where NewID = '" + Grid1.SelectedRowID + "' ";
|
||||
SQLHelper.GetIntValue(sql1);
|
||||
BLL.LogService.AddSys_Log(this.CurrUser, Grid1.SelectedRowID, Grid1.SelectedRowID, BLL.Const.CheckListMenuId, "删除出入记录");
|
||||
GetPersonStatistic();
|
||||
Alert.ShowInTop("删除数据成功!", MessageBoxIcon.Success);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
Alert.ShowInTop("您没权限删除!", MessageBoxIcon.Success);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// 获取数据,合并相同行
|
||||
/// </summary>
|
||||
private void GetPersonStatistic()
|
||||
{
|
||||
if (!string.IsNullOrEmpty(this.ProjectId))
|
||||
{
|
||||
string strSql = string.Empty;
|
||||
List<SqlParameter> listStr = new List<SqlParameter>();
|
||||
if (this.rbCheckType.SelectedValue == "1")
|
||||
{
|
||||
strSql = @"SELECT NEWID,ValidEventID AS ID,V.ProjectId,EmployName,DepartmentID,DepartmentName AS DepartName,AreaID,AreaName,EmployNO,V.CardNO AS CardID
|
||||
,RecordDateTime AS DateTimeRecord,RecordAll AS RecordDes,(CASE WHEN InOrOut=2 THEN '出门' ELSE '进门' END) AS InOrOut
|
||||
,P.UnitId,P.TeamGroupId
|
||||
FROM t_d_validcardevent V
|
||||
LEFT JOIN SitePerson_Person AS P ON V.IDCardNo=P.IdentityCard AND V.ProjectId=P.ProjectId
|
||||
where V.ProjectId = @ProjectId";
|
||||
if (!string.IsNullOrEmpty(this.txtStartDate.Text))
|
||||
{
|
||||
strSql += " AND RecordDateTime >= @StartDate";
|
||||
listStr.Add(new SqlParameter("@StartDate", this.txtStartDate.Text));
|
||||
}
|
||||
if (!string.IsNullOrEmpty(this.txtEndDate.Text))
|
||||
{
|
||||
strSql += " AND RecordDateTime < @EndDate";
|
||||
listStr.Add(new SqlParameter("@EndDate", Funs.GetNewDateTime(this.txtEndDate.Text).Value.AddDays(1)));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
strSql = @"SELECT NewID,ID,V.ProjectId,EmployName,DepartmentID,DepartName,AreaID,AreaName,EmployNO,CardID,RoleID
|
||||
,DateTimeRecord,RecordDes, InOrOut ,P.UnitId,P.TeamGroupId
|
||||
FROM dbo.t_d_facerecord V
|
||||
LEFT JOIN SitePerson_Person AS P ON V.EmployNO=P.IdentityCard AND V.ProjectId=P.ProjectId
|
||||
where V.ProjectId = @ProjectId";
|
||||
if (this.rbCheckType.SelectedValue == "2")
|
||||
{
|
||||
strSql += " AND RoleID = '微信端'";
|
||||
}
|
||||
else
|
||||
{
|
||||
strSql += " AND RoleID != '微信端'";
|
||||
}
|
||||
if (!string.IsNullOrEmpty(this.txtStartDate.Text))
|
||||
{
|
||||
strSql += " AND DateTimeRecord >= @StartDate";
|
||||
listStr.Add(new SqlParameter("@StartDate", this.txtStartDate.Text));
|
||||
}
|
||||
if (!string.IsNullOrEmpty(this.txtEndDate.Text))
|
||||
{
|
||||
strSql += " AND DateTimeRecord < @EndDate";
|
||||
listStr.Add(new SqlParameter("@EndDate", Funs.GetNewDateTime(this.txtEndDate.Text).Value.AddDays(1)));
|
||||
}
|
||||
}
|
||||
listStr.Add(new SqlParameter("@ProjectId", this.ProjectId));
|
||||
if (this.drpUnit.SelectedValue != BLL.Const._Null)
|
||||
{
|
||||
strSql += " AND UnitId = @UnitId ";
|
||||
listStr.Add(new SqlParameter("@UnitId", this.drpUnit.SelectedValue));
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(this.txtName.Text.Trim()))
|
||||
{
|
||||
strSql += " AND EmployName LIKE @EmployName";
|
||||
listStr.Add(new SqlParameter("@EmployName", "%" + this.txtName.Text.Trim() + "%"));
|
||||
}
|
||||
SqlParameter[] parameter = listStr.ToArray();
|
||||
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
||||
Grid1.RecordCount = tb.Rows.Count;
|
||||
var table = this.GetPagedDataTable(Grid1, tb);
|
||||
|
||||
Grid1.DataSource = table;
|
||||
Grid1.DataBind();
|
||||
}
|
||||
}
|
||||
|
||||
protected void btnSearch_Click(object sender, EventArgs e)
|
||||
{
|
||||
GetPersonStatistic();
|
||||
}
|
||||
|
||||
#region 导出按钮
|
||||
/// 导出按钮
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
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 = this.Grid1.RecordCount;
|
||||
GetPersonStatistic();
|
||||
Response.Write(GetGridTableHtml(Grid1));
|
||||
Response.End();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 分页 排序
|
||||
/// <summary>
|
||||
/// 改变索引事件
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
|
||||
{
|
||||
GetPersonStatistic();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 分页下拉选择事件
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
this.Grid1.PageSize = Convert.ToInt32(this.ddlPageSize.SelectedValue);
|
||||
GetPersonStatistic();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void Grid1_Sort(object sender, GridSortEventArgs e)
|
||||
{
|
||||
GetPersonStatistic();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user