using BLL; using System; using System.Collections.Generic; using System.Configuration; using System.Data; using System.Data.SqlClient; using System.Linq; using System.Text; using AspNet = System.Web.UI.WebControls; namespace FineUIPro.Web.HSSE.SitePerson { public partial class OnePersonPerFile : PageBase { #region 定义项 /// /// 人员主键 /// public string PersonId { get { return (string)ViewState["PersonId"]; } set { ViewState["PersonId"] = value; } } /// /// 人员主键 /// public string UserId { get { return (string)ViewState["UserId"]; } set { ViewState["UserId"] = value; } } /// /// 项目id /// public string ProjectId { get { return (string)ViewState["ProjectId"]; } set { ViewState["ProjectId"] = value; } } /// /// 单位id /// public string UnitId { get { return (string)ViewState["UnitId"]; } set { ViewState["UnitId"] = value; } } /// /// 人员身份证 /// public string IdentityCard { get { return (string)ViewState["IdentityCard"]; } set { ViewState["IdentityCard"] = value; } } #endregion #region 加载页面 /// /// 加载页面 /// /// /// 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"]; } //加载树 this.InitTreeMenu(); /// TAB1加载页面方法 this.LoadTab1Data(); /// TAB2加载页面方法 this.LoadTab2Data(); /// TAB2加载页面方法 this.LoadTab3Data(); } } /// /// 绑定数据 /// private void BindGrid() { BindGrid1(); BindGrid2(); BindGrid3(); } private void BindGrid1() { if (!string.IsNullOrEmpty(this.PersonId) && this.PersonId != "") { string strSql = @"SELECT NEWID() AS ID, CardNo,PersonName,ProjectId,UnitId,UnitName,WorkPostName,TrainTitle ,TrainStartDate,TrainEndDate,TrainTypeId,TeachHour,TrainTypeName,CheckScore,CheckResult,TeachMan,UnitType,TrainLevelName" + @" FROM dbo.View_EduTrain_TrainFind" + @" WHERE 1=1"; List listStr = new List(); strSql += " AND ProjectId = @ProjectId"; listStr.Add(new SqlParameter("@ProjectId", this.ProjectId)); // strSql += " AND UnitId = @UnitId"; // listStr.Add(new SqlParameter("@UnitId", this.UnitId)); strSql += " AND PersonId = @PersonId"; listStr.Add(new SqlParameter("@PersonId", this.PersonId)); if (this.drpTrainType.SelectedValue != BLL.Const._Null) { strSql += " AND TrainTypeId = @TrainTypeId"; listStr.Add(new SqlParameter("@TrainTypeId", this.drpTrainType.SelectedValue.Trim())); } if (!string.IsNullOrEmpty(this.txtTeachMan.Text.Trim())) { strSql += " AND TeachMan LIKE @TeachMan"; listStr.Add(new SqlParameter("@TeachMan", "%" + this.txtTeachMan.Text.Trim() + "%")); } if (this.cbIssue.SelectedValueArray.Length == 1) { ///是否通过 string selectValue = String.Join(", ", this.cbIssue.SelectedValueArray); if (selectValue == "1") { strSql += " AND CheckResult = 1 "; } else { strSql += " AND (CheckResult = 0 OR CheckResult IS NULL) "; } } 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(); } else { Grid1.RecordCount = 0; var table = this.GetPagedDataTable(Grid1, new DataTable()); Grid1.DataSource = table; Grid1.DataBind(); } } private void BindGrid2() { if (!string.IsNullOrEmpty(this.UnitId) && this.UnitId != "") { string strSql = "SELECT * FROM View_Hazard_HazardRegister WHERE ProblemTypes in ('1' ,'2') "; List listStr = new List(); strSql += " AND ProjectId = @ProjectId"; listStr.Add(new SqlParameter("@ProjectId", this.ProjectId)); strSql += " AND (CheckManId = @UserId OR ResponsibilityManId = @UserId)"; listStr.Add(new SqlParameter("@UserId", this.UserId)); if (!string.IsNullOrEmpty(this.txtType.Text.Trim())) { strSql += " AND RegisterTypesName LIKE @Type"; listStr.Add(new SqlParameter("@Type", "%" + this.txtType.Text.Trim() + "%")); } if (!string.IsNullOrEmpty(this.txtWorkAreaName.Text.Trim())) { strSql += " AND WorkAreaName LIKE @WorkAreaName"; listStr.Add(new SqlParameter("@WorkAreaName", "%" + this.txtWorkAreaName.Text.Trim() + "%")); } if (!string.IsNullOrEmpty(this.dpRiskLevel.SelectedValue.Trim())) { strSql += " AND Risk_Level = @Risk_Level"; listStr.Add(new SqlParameter("@Risk_Level", this.dpRiskLevel.SelectedText)); } if (!string.IsNullOrEmpty(this.txtResponsibilityUnitName.Text.Trim())) { strSql += " AND ResponsibilityUnitName LIKE @ResponsibilityUnitName"; listStr.Add(new SqlParameter("@ResponsibilityUnitName", "%" + this.txtResponsibilityUnitName.Text.Trim() + "%")); } if (!string.IsNullOrEmpty(txtStartTime.Text.Trim())) { strSql += " AND CheckTime >= @StartTime"; listStr.Add(new SqlParameter("@StartTime", this.txtStartTime.Text.Trim())); } if (!string.IsNullOrEmpty(this.txtEndTime.Text.Trim())) { strSql += " AND CheckTime <= @EndTime"; listStr.Add(new SqlParameter("@EndTime", this.txtEndTime.Text.Trim())); } if (!string.IsNullOrEmpty(txtStartRectificationTime.Text.Trim())) { strSql += " AND RectificationTime >= @StartRectificationTime"; listStr.Add(new SqlParameter("@StartRectificationTime", this.txtStartRectificationTime.Text.Trim())); } if (!string.IsNullOrEmpty(this.txtEndRectificationTime.Text.Trim())) { strSql += " AND RectificationTime <= @EndRectificationTime"; listStr.Add(new SqlParameter("@EndRectificationTime", this.txtEndRectificationTime.Text.Trim())); } if (this.drpProblemTypes.SelectedValue != BLL.Const._Null) { strSql += " and ProblemTypes ='" + this.drpProblemTypes.SelectedValue + "' "; } if (this.drpStates.SelectedValue != BLL.Const._Null) { strSql += " AND States LIKE @States"; listStr.Add(new SqlParameter("@States", "%" + this.drpStates.SelectedValue + "%")); } if (!CommonService.IsMainUnitOrAdmin(this.CurrUser.UserId)) { strSql += " AND (ResponsibleUnit =@ResponsibleUnit OR SendUnitId=@SendUnitId)"; listStr.Add(new SqlParameter("@ResponsibleUnit", this.CurrUser.UnitId)); listStr.Add(new SqlParameter("@SendUnitId", this.CurrUser.UnitId)); } SqlParameter[] parameter = listStr.ToArray(); DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter); Grid2.RecordCount = tb.Rows.Count; var table = this.GetPagedDataTable(Grid2, tb); Grid2.DataSource = table; Grid2.DataBind(); } else { Grid2.RecordCount = 0; var table = this.GetPagedDataTable(Grid2, new DataTable()); Grid2.DataSource = table; Grid2.DataBind(); } } private void BindGrid3() { if (!string.IsNullOrEmpty(this.PersonId) && this.PersonId != "") { string strSql = @"SELECT PersonPerfomance.PersonPerfomanceId," + @"PersonPerfomance.ProjectId," + @"CodeRecords.Code AS PersonPerfomanceCode," + @"PersonPerfomance.UnitId," + @"PersonPerfomance.TeamGroupId," + @"PersonPerfomance.PersonId," + @"PersonPerfomance.SubContractNum," + @"PersonPerfomance.EvaluationDate," + @"PersonPerfomance.CompileMan," + @"PersonPerfomance.CompileDate," + @"PersonPerfomance.States," + @"Unit.UnitName," + @"TeamGroup.TeamGroupName," + @"Person.PersonName," + @"(CASE WHEN PersonPerfomance.States = " + BLL.Const.State_0 + " OR PersonPerfomance.States IS NULL THEN '待['+OperateUser.UserName+']提交' WHEN PersonPerfomance.States = " + BLL.Const.State_2 + " THEN '审核/审批完成' ELSE '待['+OperateUser.UserName+']办理' END) AS FlowOperateName" + @" FROM Perfomance_PersonPerfomance AS PersonPerfomance " + @" LEFT JOIN Sys_CodeRecords AS CodeRecords ON PersonPerfomance.PersonPerfomanceId = CodeRecords.DataId " + @" LEFT JOIN Sys_FlowOperate AS FlowOperate ON PersonPerfomance.PersonPerfomanceId = FlowOperate.DataId AND FlowOperate.IsClosed <> 1" + @" LEFT JOIN Sys_User AS OperateUser ON FlowOperate.OperaterId = OperateUser.UserId" + @" LEFT JOIN Base_Unit AS Unit ON Unit.UnitId = PersonPerfomance.UnitId " + @" LEFT JOIN ProjectData_TeamGroup AS TeamGroup ON TeamGroup.TeamGroupId = PersonPerfomance.TeamGroupId " + @" LEFT JOIN SitePerson_Person AS Person ON Person.PersonId = PersonPerfomance.PersonId " + @" LEFT JOIN Sys_User AS Users ON PersonPerfomance.CompileMan = Users.UserId WHERE 1=1 "; List listStr = new List(); strSql += " AND PersonPerfomance.ProjectId = @ProjectId"; listStr.Add(new SqlParameter("@ProjectId", this.ProjectId)); // strSql += " AND PersonPerfomance.UnitId = @UnitId"; // listStr.Add(new SqlParameter("@UnitId", this.UnitId)); strSql += " AND Person.PersonId = @PersonId"; listStr.Add(new SqlParameter("@PersonId", this.PersonId)); if (!string.IsNullOrEmpty(Request.Params["projectId"])) ///是否文件柜查看页面传项目值 { strSql += " AND PersonPerfomance.States = @States"; ///状态为已完成 listStr.Add(new SqlParameter("@States", BLL.Const.State_2)); } if (!string.IsNullOrEmpty(this.txtPersonPerfomanceCode.Text.Trim())) { strSql += " AND PersonPerfomance.PersonPerfomanceCode LIKE @PersonPerfomanceCode"; listStr.Add(new SqlParameter("@PersonPerfomanceCode", "%" + this.txtPersonPerfomanceCode.Text.Trim() + "%")); } if (!string.IsNullOrEmpty(this.txtStartDate.Text.Trim())) { strSql += " AND PersonPerfomance.EvaluationDate >= @StartDate"; listStr.Add(new SqlParameter("@StartDate", this.txtStartDate.Text.Trim())); } if (!string.IsNullOrEmpty(this.txtEndDate.Text.Trim())) { strSql += " AND PersonPerfomance.EvaluationDate <= @EndDate"; listStr.Add(new SqlParameter("@EndDate", this.txtEndDate.Text.Trim())); } SqlParameter[] parameter = listStr.ToArray(); DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter); Grid3.RecordCount = tb.Rows.Count; tb = GetFilteredTable(Grid3.FilteredData, tb); var table = this.GetPagedDataTable(Grid3, tb); Grid3.DataSource = table; Grid3.DataBind(); } else { Grid3.RecordCount = 0; var table = this.GetPagedDataTable(Grid3, new DataTable()); Grid3.DataSource = table; Grid3.DataBind(); } } #endregion #region TAB1加载页面方法 /// /// 加载页面方法 /// private void LoadTab1Data() { Funs.DropDownPageSize(this.ddlPageSize1); ddlPageSize1.SelectedValue = Grid1.PageSize.ToString(); //培训类型 BLL.TrainTypeService.InitTrainTypeDropDownList(this.drpTrainType, true); } #endregion #region TAB2加载页面方法 /// /// 加载页面方法 /// private void LoadTab2Data() { Funs.DropDownPageSize(this.ddlPageSize2); ddlPageSize2.SelectedValue = Grid2.PageSize.ToString(); this.drpStates.DataValueField = "Id"; this.drpStates.DataTextField = "Name"; List handleSteps = new List(); Model.HandleStep handleStep1 = new Model.HandleStep(); handleStep1.Id = "1"; handleStep1.Name = "待整改"; handleSteps.Add(handleStep1); Model.HandleStep handleStep2 = new Model.HandleStep(); handleStep2.Id = "2"; handleStep2.Name = "已整改-待复查验收"; handleSteps.Add(handleStep2); Model.HandleStep handleStep3 = new Model.HandleStep(); handleStep3.Id = "3"; handleStep3.Name = "已闭环"; handleSteps.Add(handleStep3); //Model.HandleStep handleStep4 = new Model.HandleStep(); //handleStep4.Id = "4"; //handleStep4.Name = "已作废"; //handleSteps.Add(handleStep4); this.drpStates.DataSource = handleSteps; ; this.drpStates.DataBind(); Funs.FineUIPleaseSelect(this.drpStates); ListItem[] ProblemTypes = new ListItem[2]; ProblemTypes[0] = new ListItem("日常巡检", "1"); ProblemTypes[1] = new ListItem("专项巡检", "2"); this.drpProblemTypes.DataValueField = "Value"; this.drpProblemTypes.DataTextField = "Text"; this.drpProblemTypes.DataSource = ProblemTypes; this.drpProblemTypes.DataBind(); Funs.FineUIPleaseSelect(this.drpProblemTypes); } /// /// 查看按钮 /// /// /// protected void btnMenuSee_Click(object sender, EventArgs e) { if (Grid2.SelectedRowIndexArray.Length == 0) { Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning); return; } string RegistrationId = Grid2.SelectedRowID; var registration = BLL.HSSE_Hazard_HazardRegisterService.GetHazardRegisterByHazardRegisterId(RegistrationId); if (registration != null) { PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("../HiddenInspection/HiddenRectificationView.aspx?HazardRegisterId={0}", RegistrationId, "查看 - "))); } } /// /// 关闭弹出窗 /// /// /// protected void Window2_Close(object sender, WindowCloseEventArgs e) { BindGrid2(); } #endregion #region TAB3加载页面方法 /// /// 加载页面方法 /// private void LoadTab3Data() { Funs.DropDownPageSize(this.ddlPageSize3); ddlPageSize3.SelectedValue = Grid3.PageSize.ToString(); } #endregion #region 树事件 /// /// 加载树 /// private void InitTreeMenu() { this.tvProjectAndUnitAndPerson.Nodes.Clear(); this.tvProjectAndUnitAndPerson.ShowBorder = false; this.tvProjectAndUnitAndPerson.ShowHeader = false; this.tvProjectAndUnitAndPerson.EnableIcons = true; this.tvProjectAndUnitAndPerson.AutoScroll = true; this.tvProjectAndUnitAndPerson.EnableSingleClickExpand = true; var project = BLL.ProjectService.GetProjectByProjectId(this.ProjectId); if (project != null) { TreeNode newNode = new TreeNode(); newNode.Text = project.ProjectName; newNode.NodeID = project.ProjectId; newNode.CommandName = "UnitWork"; newNode.EnableExpandEvent = true; newNode.EnableClickEvent = true; this.tvProjectAndUnitAndPerson.Nodes.Add(newNode); TreeNode emptyNode = new TreeNode(); emptyNode.Text = ""; emptyNode.NodeID = ""; newNode.Nodes.Add(emptyNode); } } /// /// 点击树节点事件 加载单位人员数据 /// protected void tvPerson_NodeExpand(object sender, TreeNodeEventArgs e) { e.Node.Nodes.Clear(); if (e.Node.CommandName == "UnitWork") //展开单位节点 { List unitLists = BLL.UnitService.GetUnitByProjectIdList(e.NodeID); if (unitLists.Count() > 0) { if (BLL.ProjectUnitService.GetProjectUnitTypeByProjectIdUnitId(e.NodeID, this.CurrUser.UnitId)) { unitLists = unitLists.Where(x => x.UnitId == this.CurrUser.UnitId).ToList(); } //添加其他单位/无单位人员 Model.Base_Unit otherUnit = new Model.Base_Unit { UnitId = "0", UnitName = "其他" }; unitLists.Add(otherUnit); TreeNode newNode = null; foreach (var q in unitLists) { TreeNode newCNProfessionalNode = new TreeNode(); newCNProfessionalNode.Text = q.UnitName; newCNProfessionalNode.NodeID = e.NodeID + "|" + q.UnitId; newCNProfessionalNode.CommandName = "Person"; newCNProfessionalNode.EnableExpandEvent = true; newCNProfessionalNode.EnableClickEvent = true; e.Node.Nodes.Add(newCNProfessionalNode); TreeNode tempNode = new TreeNode(); tempNode.NodeID = ""; tempNode.Text = ""; tempNode.EnableExpandEvent = true; tempNode.EnableClickEvent = true; newCNProfessionalNode.Nodes.Add(tempNode); } } } if (e.Node.CommandName == "Person") //展开人员节点 { var str = e.NodeID.Split('|'); if (str.Count() > 1) { var projectId = str[0]; var unitId = str[1]; String strSql1 = @"select PersonName as UserName,IdentityCard from SitePerson_Person where ProjectId='" + projectId + "' and UnitId='" + unitId + "' and IsUsed = 1"; String strSql2 = @"select y.UserName,y.IdentityCard from Project_ProjectUser x,Sys_User y where x.ProjectId='" + projectId + "' and x.UnitId='" + unitId + "' and x.UserId=y.UserId "; DataTable dt1 = SQLHelper.GetDataTableRunText(strSql1, null); DataTable dt2 = SQLHelper.GetDataTableRunText(strSql2, null); DataTable dtCombined = dt1.Clone(); // 将dt1的数据添加到dtCombined中 foreach (DataRow row in dt1.Rows) { dtCombined.ImportRow(row); } // 将dt2的数据添加到dtCombined中,但要先检查是否已存在以避免重复 foreach (DataRow row in dt2.Rows) { bool isDuplicate = false; foreach (DataRow existingRow in dtCombined.Rows) { // 这里假设UserName和IdentityCard是共同的关键列 if (existingRow["UserName"].Equals(row["UserName"]) && existingRow["IdentityCard"].Equals(row["IdentityCard"])) { isDuplicate = true; break; } } if (!isDuplicate) { dtCombined.ImportRow(row); } } //查询项目用户 if (dtCombined.Rows.Count > 0) { for (var i = 0; i < dtCombined.Rows.Count; i++) { TreeNode newNode = new TreeNode(); newNode.Text = dtCombined.Rows[i]["UserName"].ToString(); newNode.NodeID = projectId + "|" + unitId + "|" + dtCombined.Rows[i]["IdentityCard"]; newNode.CommandName = "end"; newNode.EnableExpandEvent = true; newNode.EnableClickEvent = true; e.Node.Nodes.Add(newNode); } } } } } /// /// 点击TreeView /// /// /// protected void tvProjectAndUnitAndPerson_NodeCommand(object sender, TreeCommandEventArgs e) { if (e.Node.CommandName == "end") { //此处为点击人员节点事件 进行数据绑定 var str = e.NodeID.Split('|'); if (str.Count() > 1) { this.ProjectId = str[0].Trim(); this.UnitId = str[1].Trim(); this.IdentityCard = str[2].Trim(); //通过身份证获取personid和userid String strSql1 = @"select * from [dbo].[SitePerson_Person] where ProjectId='" + this.ProjectId + "' and UnitId='" + this.UnitId + "' and IsUsed = 1 and IdentityCard='" + this.IdentityCard + "'"; String strSql2 = @"select y.UserId, y.UserName,y.IdentityCard from [dbo].[Project_ProjectUser] x,[dbo].[Sys_User] y where x.ProjectId='" + this.ProjectId + "' and x.UnitId='" + this.UnitId + "' and x.UserId=y.UserId and y.IdentityCard='" + this.IdentityCard + "'"; DataTable dt1 = SQLHelper.GetDataTableRunText(strSql1, null); DataTable dt2 = SQLHelper.GetDataTableRunText(strSql2, null); if (dt1.Rows.Count > 0) { this.PersonId = dt1.Rows[0]["PersonId"].ToString(); } else { this.PersonId = string.Empty; } if (dt2.Rows.Count > 0) { this.UserId = dt2.Rows[0]["UserId"].ToString(); } else { this.UserId = string.Empty; } } BindGrid(); } } #endregion #region 页索引改变事件 /// /// 页索引改变事件 /// /// /// protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e) { Grid1.PageIndex = e.NewPageIndex; BindGrid1(); } protected void Grid2_PageIndexChange(object sender, GridPageEventArgs e) { Grid2.PageIndex = e.NewPageIndex; BindGrid2(); } protected void Grid3_PageIndexChange(object sender, GridPageEventArgs e) { Grid3.PageIndex = e.NewPageIndex; BindGrid3(); } #endregion #region 排序 /// /// 排序 /// /// /// protected void Grid1_Sort(object sender, GridSortEventArgs e) { Grid1.SortDirection = e.SortDirection; Grid1.SortField = e.SortField; BindGrid1(); } protected void Grid2_Sort(object sender, GridSortEventArgs e) { Grid2.SortDirection = e.SortDirection; Grid2.SortField = e.SortField; BindGrid2(); } protected void Grid3_Sort(object sender, GridSortEventArgs e) { Grid3.SortDirection = e.SortDirection; Grid3.SortField = e.SortField; BindGrid3(); } #endregion #region 分页选择下拉改变事件 /// /// 分页选择下拉改变事件 /// /// /// protected void ddlPageSize_SelectedIndexChanged1(object sender, EventArgs e) { Grid1.PageSize = Convert.ToInt32(ddlPageSize1.SelectedValue); BindGrid1(); } protected void ddlPageSize_SelectedIndexChanged2(object sender, EventArgs e) { Grid2.PageSize = Convert.ToInt32(ddlPageSize2.SelectedValue); BindGrid2(); } protected void ddlPageSize_SelectedIndexChanged3(object sender, EventArgs e) { Grid3.PageSize = Convert.ToInt32(ddlPageSize3.SelectedValue); BindGrid3(); } #endregion #region 查询 /// /// 查询 /// /// /// protected void TextBox_TextChanged1(object sender, EventArgs e) { this.BindGrid1(); } protected void TextBox_TextChanged2(object sender, EventArgs e) { this.BindGrid2(); } protected void TextBox_TextChanged3(object sender, EventArgs e) { this.BindGrid3(); } #endregion #region 导出 /// /// 导出按钮 /// /// /// protected void btnOut_Click1(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 = 500; BindGrid1(); Response.Write(GetGridTableHtml1(Grid1)); Response.End(); } #pragma warning disable CS0108 // “TrainFind.GetGridTableHtml(Grid)”隐藏继承的成员“PageBase.GetGridTableHtml(Grid)”。如果是有意隐藏,请使用关键字 new。 /// /// 导出方法 /// /// /// private string GetGridTableHtml1(Grid grid) #pragma warning restore CS0108 // “TrainFind.GetGridTableHtml(Grid)”隐藏继承的成员“PageBase.GetGridTableHtml(Grid)”。如果是有意隐藏,请使用关键字 new。 { StringBuilder sb = new StringBuilder(); sb.Append(""); sb.Append(""); sb.Append(""); foreach (GridColumn column in grid.Columns) { sb.AppendFormat("", column.HeaderText); } sb.Append(""); foreach (GridRow row in grid.Rows) { sb.Append(""); 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; } if (column.ColumnID == "tfUnitName") { html = (row.FindControl("lbUnitName") as AspNet.Label).Text; } if (column.ColumnID == "tfWorkPostName") { html = (row.FindControl("lbWorkPostName") as AspNet.Label).Text; } if (column.ColumnID == "tfTrainTypeName") { html = (row.FindControl("lbTrainTypeName") as AspNet.Label).Text; } if (column.ColumnID == "tfTrainLevelName") { html = (row.FindControl("lbTrainLevelName") as AspNet.Label).Text; } if (column.ColumnID == "tfTrainTitle") { html = (row.FindControl("lbTrainTitle") as AspNet.Label).Text; } if (column.ColumnID == "tfCheckResult") { html = (row.FindControl("lbCheckResult") as AspNet.Label).Text; } if (column.ColumnID == "tfI") { html = "'" + (row.FindControl("lbI") as AspNet.Label).Text; } sb.AppendFormat("", html); } sb.Append(""); } sb.Append("
{0}
{0}
"); return sb.ToString(); } protected void btnOut_Click2(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.Grid2.PageSize = 100000; this.BindGrid2(); Response.Write(GetGridTableHtml2(Grid2)); Response.End(); } #pragma warning disable CS0108 // “HiddenRectificationList.GetGridTableHtml(Grid)”隐藏继承的成员“PageBase.GetGridTableHtml(Grid)”。如果是有意隐藏,请使用关键字 new。 /// /// 导出方法 /// /// /// private string GetGridTableHtml2(Grid grid) #pragma warning restore CS0108 // “HiddenRectificationList.GetGridTableHtml(Grid)”隐藏继承的成员“PageBase.GetGridTableHtml(Grid)”。如果是有意隐藏,请使用关键字 new。 { StringBuilder sb = new StringBuilder(); sb.Append(""); sb.Append(""); sb.Append(""); foreach (GridColumn column in grid.Columns) { if (column.ColumnID != "ckbIsSelected" && column.ColumnID != "Punish" && column.ColumnID != "Del") { sb.AppendFormat("", column.HeaderText); } } sb.Append(""); foreach (GridRow row in grid.Rows) { sb.Append(""); foreach (GridColumn column in grid.Columns) { if (column.ColumnID != "ckbIsSelected" && column.ColumnID != "Punish" && column.ColumnID != "Del") { string html = row.Values[column.ColumnIndex].ToString(); if (column.ColumnID == "tfPageIndex") { html = (row.FindControl("lblPageIndex") as AspNet.Label).Text; } if (column.ColumnID == "tfImageUrl") { html = (row.FindControl("lbtnImageUrl") as AspNet.LinkButton).Text; } if (column.ColumnID == "tfRectificationImageUrl") { html = (row.FindControl("lbtnRectificationImageUrl") as AspNet.LinkButton).Text; } if (column.ColumnID == "ProblemTypes") { html = (row.FindControl("lbProblemTypes") as AspNet.Label).Text; } if (column.ColumnID == "CheckItemName") { html = (row.FindControl("lbCheckItemName") as AspNet.Label).Text; } if (column.ColumnID == "tfImageUrl1") { if (rbOutType.SelectedValue == "1") { html = (row.FindControl("lbImageUrl1") as AspNet.Label).Text; } else { html = ""; } } if (column.ColumnID == "tfImageUrl2") { if (rbOutType.SelectedValue == "1") { html = (row.FindControl("lbImageUrl2") as AspNet.Label).Text; } else { html = ""; } } //if (column.ColumnID == "tfCutPayment") //{ // html = (row.FindControl("lbtnCutPayment") as AspNet.LinkButton).Text; //} sb.AppendFormat("", html); } } sb.Append(""); } sb.Append("
{0}
{0}
"); return sb.ToString(); } #endregion #region 转换字符串 /// /// 考核结果 /// /// /// protected string ConvertCheckResult(object checkResult) { if (checkResult != null) { if (checkResult.ToString() == "True") { return "合格"; } else { return "不合格"; } } return ""; } #endregion protected string ConvertProblemTypes(object registrationId) { string url = string.Empty; if (registrationId != null) { if (registrationId.ToString() == "1") { return "日常巡检"; }else if (registrationId.ToString() == "2") { return "专项检查"; } } return url; } protected string ConvertCheckItemName(object CheckItemDetailId) { if (CheckItemDetailId != null&&!string.IsNullOrEmpty(CheckItemDetailId.ToString())) { var detail = Funs.DB.Check_CheckSpecialDetail.FirstOrDefault(xx => xx.CheckSpecialDetailId == CheckItemDetailId.ToString()); if (detail != null) { var special = Funs.DB.Check_CheckSpecial.FirstOrDefault(x => x.CheckSpecialId == detail.CheckSpecialId); if (special != null) { var checkItemSet = Funs.DB.Technique_CheckItemSet.FirstOrDefault(x => x.CheckItemSetId == special.CheckItemSetId); if (checkItemSet != null) { return checkItemSet.CheckItemName; } } } } return ""; } /// /// 获取整改前图片(放于Img中) /// /// /// protected string ConvertImageUrlByImage(object registrationId) { string url = string.Empty; if (registrationId != null) { var registration = BLL.HSSE_Hazard_HazardRegisterService.GetHazardRegisterByHazardRegisterId(registrationId.ToString()); if (registration != null) { url = BLL.UploadAttachmentService.ShowImage(ConfigurationManager.AppSettings["CEMS_IMG_URL"], registration.ImageUrl); } } return url; } /// /// 获取整改后图片(放于Img中) /// /// /// protected string ConvertImgUrlByImage(object registrationId) { string url = string.Empty; if (registrationId != null) { var registration = BLL.HSSE_Hazard_HazardRegisterService.GetHazardRegisterByHazardRegisterId(registrationId.ToString()); if (registration != null) { url = BLL.UploadAttachmentService.ShowImage(ConfigurationManager.AppSettings["CEMS_IMG_URL"], registration.RectificationImageUrl); } } return url; } } }