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 InOutRecordItem : PageBase { /// /// 项目id /// public string ProjectId { get { return (string)ViewState["ProjectId"]; } set { ViewState["ProjectId"] = value; } } /// /// 项目id /// public string id { get { return (string)ViewState["id"]; } set { ViewState["id"] = value; } } protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { this.id = Request.Params["id"]; 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); if (this.CurrUser != null && this.CurrUser.PageSize.HasValue) { Grid1.PageSize = this.CurrUser.PageSize.Value; } this.ddlPageSize.SelectedValue = Grid1.PageSize.ToString(); GetPersonStatistic(); } } /// /// 获取数据,合并相同行 /// private void GetPersonStatistic() { var getRecord = DoorServerService.GetEmployInOutRecordById(id); if (getRecord != null) { var getPerson = PersonService.GetPersonByIdentityCard(getRecord.ProjectId, getRecord.IDCardNo); if (getPerson != null) { this.txtUnit.Text = UnitService.GetUnitNameByUnitId(getPerson.UnitId); this.txtTeamGroupName.Text = TeamGroupService.GetTeamGroupNameByTeamGroupId(getPerson.TeamGroupId); this.txtPersonName.Text = getPerson.PersonName; this.txtIdCardNo.Text = getPerson.IdentityCard; this.txtWorkPostName.Text = WorkPostService.getWorkPostNameById(getPerson.WorkPostId); this.txtNation.Text = BasicDataService.GetDictNameByDictCode(getPerson.Nation); this.txtInTime.Text = string.Format("{0:yyyy-MM-dd HH:mm:ss}", getPerson.InTime); this.txtOutTime.Text = string.Format("{0:yyyy-MM-dd HH:mm:ss}", getPerson.OutTime); } else { this.txtUnit.Text = getRecord.UnitName; this.txtTeamGroupName.Text = getRecord.DepartName; this.txtPersonName.Text = getRecord.EmployName; this.txtIdCardNo.Text = getRecord.IDCardNo; this.txtWorkPostName.Text = getRecord.PostName; this.txtNation.Text = getRecord.NationName; } string strSql = string.Empty; List listStr = new List(); 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 AND IDCardNo=@IDCardNo AND RecordDateTime>=@RecordDate AND RecordDateTime<@RecordDateE"; } 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 AND EmployNO=@IDCardNo AND DateTimeRecord>=@RecordDate AND DateTimeRecord<@RecordDateE"; } listStr.Add(new SqlParameter("@ProjectId", this.ProjectId)); listStr.Add(new SqlParameter("@IDCardNo", getRecord.IDCardNo)); listStr.Add(new SqlParameter("@RecordDate", getRecord.RecordDate)); listStr.Add(new SqlParameter("@RecordDateE", getRecord.RecordDate.Value.AddDays(1))); 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 导出按钮 /// 导出按钮 /// /// /// 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 分页 排序 /// /// 改变索引事件 /// /// /// protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e) { GetPersonStatistic(); } /// /// 分页下拉选择事件 /// /// /// protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e) { this.Grid1.PageSize = Convert.ToInt32(this.ddlPageSize.SelectedValue); GetPersonStatistic(); } /// /// /// /// /// protected void Grid1_Sort(object sender, GridSortEventArgs e) { GetPersonStatistic(); } #endregion } }