| 
									
										
										
										
											2021-08-30 21:49:56 +08:00
										 |  |  |  | using BLL; | 
					
						
							|  |  |  |  | using System; | 
					
						
							|  |  |  |  | using System.Linq; | 
					
						
							|  |  |  |  | using System.Text; | 
					
						
							|  |  |  |  | using AspNet = System.Web.UI.WebControls; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | namespace FineUIPro.Web.ZHGL.RealName | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |     public partial class OnPost : PageBase | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 加载 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="sender"></param> | 
					
						
							|  |  |  |  |         /// <param name="e"></param> | 
					
						
							|  |  |  |  |         protected void Page_Load(object sender, EventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             if (!IsPostBack) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 Funs.DropDownPageSize(this.ddlPageSize); | 
					
						
							|  |  |  |  |                 ProjectService.InitAllProjectShortNameDropDownList(this.drpProject, this.CurrUser.UserId, true); | 
					
						
							|  |  |  |  |                 if (!string.IsNullOrEmpty(this.CurrUser.LoginProjectId)) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     this.drpProject.SelectedValue = this.CurrUser.LoginProjectId; | 
					
						
							|  |  |  |  |                     this.drpProject.Readonly = true; | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |                 this.GridBind(); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 获取数据,合并相同行 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         private void GridBind() | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             var getData = OnPostService.getListData(this.drpProject.SelectedValue, this.txtName.Text.Trim(), this.txtIdentityCard.Text.Trim(), | 
					
						
							|  |  |  |  |                 this.rblStates.SelectedValue,this.rbInfo.SelectedValue,this.rbIDCardNo.SelectedValue,this.rbRealName.SelectedValue, | 
					
						
							|  |  |  |  |                 Grid1); | 
					
						
							|  |  |  |  |             Grid1.RecordCount = OnPostService.count; | 
					
						
							|  |  |  |  |             Grid1.DataSource = getData; | 
					
						
							|  |  |  |  |             Grid1.DataBind(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         protected void btnSearch_Click(object sender, EventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             this.GridBind(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         #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; | 
					
						
							|  |  |  |  |             this.GridBind(); | 
					
						
							|  |  |  |  |             Response.Write(GetGridTableHtml(Grid1)); | 
					
						
							|  |  |  |  |             Response.End(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 导出方法 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="grid"></param> | 
					
						
							|  |  |  |  |         /// <returns></returns> | 
					
						
							|  |  |  |  |         private string GetGridTableHtml(Grid grid) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             StringBuilder sb = new StringBuilder(); | 
					
						
							|  |  |  |  |             sb.Append("<meta http-equiv=\"content-type\" content=\"application/excel; charset=UTF-8\"/><html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">"); | 
					
						
							|  |  |  |  |             sb.Append("<table cellspacing=\"0\" rules=\"all\" border=\"1\" style=\"border-collapse:collapse;\">"); | 
					
						
							|  |  |  |  |             sb.Append("<tr>"); | 
					
						
							|  |  |  |  |             foreach (GridColumn column in grid.Columns) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 sb.AppendFormat("<td>{0}</td>", column.HeaderText); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             sb.Append("</tr>"); | 
					
						
							|  |  |  |  |             foreach (GridRow row in grid.Rows) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 sb.Append("<tr>"); | 
					
						
							|  |  |  |  |                 foreach (GridColumn column in grid.Columns) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     string html = row.Values[column.ColumnIndex].ToString(); | 
					
						
							|  |  |  |  |                     if (column.ColumnID == "tfNumber") | 
					
						
							|  |  |  |  |                     { | 
					
						
							|  |  |  |  |                         html = (row.FindControl("labNumber") as AspNet.Label).Text; | 
					
						
							|  |  |  |  |                     } | 
					
						
							| 
									
										
										
										
											2021-09-06 12:27:07 +08:00
										 |  |  |  |                     if (column.ColumnID == "tfShortName") | 
					
						
							|  |  |  |  |                     { | 
					
						
							|  |  |  |  |                         html = (row.FindControl("lblShortName") as AspNet.Label).Text; | 
					
						
							|  |  |  |  |                     } | 
					
						
							| 
									
										
										
										
											2021-08-30 21:49:56 +08:00
										 |  |  |  |                     if (column.ColumnID == "tfAge") | 
					
						
							|  |  |  |  |                     { | 
					
						
							|  |  |  |  |                         html = (row.FindControl("lblAge") as AspNet.Label).Text; | 
					
						
							|  |  |  |  |                     } | 
					
						
							|  |  |  |  |                     if (column.ColumnID == "tfProvince") | 
					
						
							|  |  |  |  |                     { | 
					
						
							|  |  |  |  |                         html = (row.FindControl("lblProvince") as AspNet.Label).Text; | 
					
						
							|  |  |  |  |                     } | 
					
						
							|  |  |  |  |                     sb.AppendFormat("<td x:str>{0}</td>", html); | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                 sb.Append("</tr>"); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             sb.Append("</table>"); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             return sb.ToString(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         #endregion | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         #region 分页 排序 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 改变索引事件 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="sender"></param> | 
					
						
							|  |  |  |  |         /// <param name="e"></param> | 
					
						
							|  |  |  |  |         protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             this.GridBind(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <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); | 
					
						
							|  |  |  |  |             this.GridBind(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         ///  | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="sender"></param> | 
					
						
							|  |  |  |  |         /// <param name="e"></param> | 
					
						
							|  |  |  |  |         protected void Grid1_Sort(object sender, GridSortEventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             this.GridBind(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         #endregion | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         #region 格式化字符串 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 年龄 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="compileMan"></param> | 
					
						
							|  |  |  |  |         /// <returns></returns> | 
					
						
							|  |  |  |  |         protected string ConvertAge(object rirthday) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             string age = string.Empty; | 
					
						
							|  |  |  |  |             if (rirthday != null) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 DateTime? bDate = Funs.GetNewDateTime(rirthday.ToString()); | 
					
						
							|  |  |  |  |                 if (bDate.HasValue) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     age = CommonService.CalculateAgeCorrect(bDate.Value).ToString(); | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             return age; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 籍贯 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="rirthday"></param> | 
					
						
							|  |  |  |  |         /// <returns></returns> | 
					
						
							|  |  |  |  |         protected string ConvertProvinceCode(object ProvinceCode) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             string name = string.Empty; | 
					
						
							|  |  |  |  |             if (ProvinceCode != null) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 var getCity = Funs.DB.RealName_City.FirstOrDefault(x => x.ProvinceCode == ProvinceCode.ToString()); | 
					
						
							|  |  |  |  |                 if (getCity != null) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     name = getCity.Cname; | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             return name; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         ///  | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="ProvinceCode"></param> | 
					
						
							|  |  |  |  |         /// <returns></returns> | 
					
						
							|  |  |  |  |         protected string ConvertShortName(object projectId) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             string name = string.Empty; | 
					
						
							|  |  |  |  |             if (projectId != null) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 var getproject = Funs.DB.Base_Project.FirstOrDefault(x => x.ProjectId == projectId.ToString()); | 
					
						
							|  |  |  |  |                 if (getproject != null) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     var getRP = Funs.DB.RealName_Project.FirstOrDefault(x => x.ProCode == getproject.JTProjectCode); | 
					
						
							|  |  |  |  |                     if (getRP != null) | 
					
						
							|  |  |  |  |                     { | 
					
						
							|  |  |  |  |                         name = getRP.ProShortName; | 
					
						
							|  |  |  |  |                     } | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             return name; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         #endregion | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         protected void btnIDCard_Click(object sender, EventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             var getPersons = from x in Funs.DB.SitePerson_Person where !x.IsCardNoOK.HasValue select x; | 
					
						
							|  |  |  |  |             foreach (var item in getPersons) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 item.IsCardNoOK = IDCardValid.CheckIDCard(item.IdentityCard); | 
					
						
							|  |  |  |  |                 Funs.DB.SubmitChanges(); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             ShowNotify("刷新完成!", MessageBoxIcon.Success); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | } |