649 lines
		
	
	
		
			30 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			649 lines
		
	
	
		
			30 KiB
		
	
	
	
		
			C#
		
	
	
	
using BLL;
 | 
						|
using Newtonsoft.Json.Linq;
 | 
						|
using NPOI.SS.UserModel;
 | 
						|
using NPOI.SS.Util;
 | 
						|
using NPOI.XSSF.UserModel;
 | 
						|
using System;
 | 
						|
using System.Collections.Generic;
 | 
						|
using System.IO;
 | 
						|
using System.Linq;
 | 
						|
using System.Web;
 | 
						|
using System.Web.UI;
 | 
						|
 | 
						|
namespace FineUIPro.Web.TestRun.Produce
 | 
						|
{
 | 
						|
    public partial class InspectWanderAboutConfirm : PageBase
 | 
						|
    {
 | 
						|
        /// <summary>
 | 
						|
        /// 检查表主键
 | 
						|
        /// </summary>
 | 
						|
        public string SubInspectId
 | 
						|
        {
 | 
						|
            get { return (string)ViewState["SubInspectId"]; }
 | 
						|
            set { ViewState["SubInspectId"] = value; }
 | 
						|
        }
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// 类型
 | 
						|
        /// </summary>
 | 
						|
        public int ConfirmType
 | 
						|
        {
 | 
						|
            get { return (int)ViewState["ConfirmType"]; }
 | 
						|
            set { ViewState["ConfirmType"] = value; }
 | 
						|
        }
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// 类型名称
 | 
						|
        /// </summary>
 | 
						|
        public string ConfirmTypeName
 | 
						|
        {
 | 
						|
            get { return (string)ViewState["ConfirmTypeName"]; }
 | 
						|
            set { ViewState["ConfirmTypeName"] = value; }
 | 
						|
        }
 | 
						|
 | 
						|
        protected void Page_Load(object sender, EventArgs e)
 | 
						|
        {
 | 
						|
            if (!IsPostBack)
 | 
						|
            {
 | 
						|
                this.SubInspectId = Request.Params["SubInspectId"];
 | 
						|
                this.ConfirmType = int.Parse(Request.Params["ConfirmType"]);
 | 
						|
 | 
						|
                if (this.ConfirmType == 1)
 | 
						|
                {
 | 
						|
                    this.ConfirmTypeName = "承包商";
 | 
						|
                }
 | 
						|
                if (this.ConfirmType == 2)
 | 
						|
                {
 | 
						|
                    this.ConfirmTypeName = "业主";
 | 
						|
                }
 | 
						|
                if (this.ConfirmType == 3)
 | 
						|
                {
 | 
						|
                    this.ConfirmTypeName = "工艺专利商";
 | 
						|
                }
 | 
						|
                this.BindGrid();
 | 
						|
            }
 | 
						|
        }
 | 
						|
 | 
						|
 | 
						|
        #region 数据绑定
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// 绑定数据
 | 
						|
        /// </summary>
 | 
						|
        public void BindGrid(int isPass = -1)
 | 
						|
        {
 | 
						|
            var term = Funs.DB.ProduceRun_SubInspectTerm.FirstOrDefault(x => x.SubInspectId == this.SubInspectId);
 | 
						|
            if (term != null)
 | 
						|
            {
 | 
						|
                lblIsUnifyWanderAbout.Text = term.IsUnifyWanderAbout == 1 ? "是" : "否";
 | 
						|
                lblUnifyWanderAboutData.Text = term.UnifyWanderAboutData != null ? term.UnifyWanderAboutData.Value.ToString("yyyy-MM-dd") : string.Empty;
 | 
						|
                unifyfile.Hidden = term.IsUnifyWanderAbout == 1 ? false : true;
 | 
						|
            }
 | 
						|
            var data = new List<ConfirmIsPass>();
 | 
						|
            var queryData = from a in Funs.DB.ProduceRun_SubInspectTermItem
 | 
						|
                            join b in Funs.DB.Sys_User on a.InspectedUser equals b.UserId
 | 
						|
                            where a.SubInspectId == this.SubInspectId
 | 
						|
                            select new { a, b };
 | 
						|
            if (queryData.Count() > 0)
 | 
						|
            {
 | 
						|
                var list = queryData.ToList();
 | 
						|
                foreach (var item in list)
 | 
						|
                {
 | 
						|
                    var model = new ConfirmIsPass();
 | 
						|
                    model.TermItemId = item.a.TermItemId;
 | 
						|
                    model.SubInspectId = item.a.SubInspectId;
 | 
						|
                    model.WorkInspectName = item.a.WorkInspectName;
 | 
						|
                    model.ConfirmType = this.ConfirmType;
 | 
						|
                    model.ConfirmTypeName = this.ConfirmTypeName;
 | 
						|
                    model.InspectedUser = item.a.InspectedUser;
 | 
						|
                    model.InspectedUserName = item.b.UserName;
 | 
						|
                    model.InspectionResults = item.a.InspectionResults.Value;
 | 
						|
                    //1=承包商=业主=工艺专利商
 | 
						|
                    if (this.ConfirmType == 1)
 | 
						|
                    {
 | 
						|
                        model.IsPass = isPass != -1 ? isPass : item.a.ContractorIsPass;
 | 
						|
                        model.Remark = item.a.ContractorRemark;
 | 
						|
                    }
 | 
						|
                    if (this.ConfirmType == 2)
 | 
						|
                    {
 | 
						|
                        model.IsPass = isPass != -1 ? isPass : item.a.OwnerIsPass;
 | 
						|
                        model.Remark = item.a.OwnerRemark;
 | 
						|
                    }
 | 
						|
                    if (this.ConfirmType == 3)
 | 
						|
                    {
 | 
						|
                        model.IsPass = isPass != -1 ? isPass : item.a.ProcessPatentIsPass;
 | 
						|
                        model.Remark = item.a.ProcessPatentRemark;
 | 
						|
                    }
 | 
						|
                    data.Add(model);
 | 
						|
                }
 | 
						|
            }
 | 
						|
            Grid1.DataSource = data;
 | 
						|
            Grid1.DataBind();
 | 
						|
            titleName.Title = this.ConfirmType == 1 ? "承包商确认签字" : this.ConfirmType == 2 ? "业主确认签字" : this.ConfirmType == 3 ? "工艺专利商确认签字" : "";
 | 
						|
        }
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// 排序
 | 
						|
        /// </summary>
 | 
						|
        protected void Grid1_Sort(object sender, GridSortEventArgs e)
 | 
						|
        {
 | 
						|
            Grid1.SortDirection = e.SortDirection;
 | 
						|
            Grid1.SortField = e.SortField;
 | 
						|
            BindGrid();
 | 
						|
        }
 | 
						|
 | 
						|
        #endregion
 | 
						|
 | 
						|
        #region 按钮和事件
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// 保存
 | 
						|
        /// </summary>
 | 
						|
        protected void btnSave_Click(object sender, EventArgs e)
 | 
						|
        {
 | 
						|
            try
 | 
						|
            {
 | 
						|
                JArray mergedData = Grid1.GetMergedData();
 | 
						|
                foreach (JObject mergedRow in mergedData)
 | 
						|
                {
 | 
						|
                    string status = mergedRow.Value<string>("status");
 | 
						|
                    JObject values = mergedRow.Value<JObject>("values");
 | 
						|
                    int i = mergedRow.Value<int>("index");
 | 
						|
                    GridRow row = Grid1.Rows[i];
 | 
						|
                    System.Web.UI.WebControls.RadioButtonList rblIsPass = (System.Web.UI.WebControls.RadioButtonList)row.FindControl("rblIsPass");
 | 
						|
                    var termItemId = this.Grid1.Rows[i].DataKeys[0].ToString();
 | 
						|
                    var inspectedUser = this.Grid1.Rows[i].DataKeys[1].ToString();
 | 
						|
                    var model = Funs.DB.ProduceRun_SubInspectTermItem.FirstOrDefault(x => x.TermItemId == termItemId && x.InspectedUser == inspectedUser);
 | 
						|
                    if (model != null)
 | 
						|
                    {
 | 
						|
                        if (!string.IsNullOrWhiteSpace(rblIsPass.SelectedValue))
 | 
						|
                        {
 | 
						|
                            //1=承包商=业主=工艺专利商
 | 
						|
                            if (this.ConfirmType == 1)
 | 
						|
                            {
 | 
						|
                                model.ContractorIsPass = int.Parse(rblIsPass.SelectedValue);
 | 
						|
                                model.ContractorRemark = values.Value<string>("Remark");
 | 
						|
                            }
 | 
						|
                            else if (this.ConfirmType == 2)
 | 
						|
                            {
 | 
						|
                                model.OwnerIsPass = int.Parse(rblIsPass.SelectedValue);
 | 
						|
                                model.OwnerRemark = values.Value<string>("Remark");
 | 
						|
                            }
 | 
						|
                            else if (this.ConfirmType == 3)
 | 
						|
                            {
 | 
						|
                                model.ProcessPatentIsPass = int.Parse(rblIsPass.SelectedValue);
 | 
						|
                                model.ProcessPatentRemark = values.Value<string>("Remark");
 | 
						|
                            }
 | 
						|
                        }
 | 
						|
                        Funs.DB.SubmitChanges();
 | 
						|
                    }
 | 
						|
                }
 | 
						|
                var subInspectId = this.Grid1.Rows[0].DataKeys[3].ToString();
 | 
						|
                var subModel = Funs.DB.ProduceRun_SubInspectTerm.FirstOrDefault(x => x.SubInspectId == subInspectId);
 | 
						|
                if (subModel != null)
 | 
						|
                {
 | 
						|
                    //1=承包商=业主=工艺专利商
 | 
						|
                    if (this.ConfirmType == 1)
 | 
						|
                    {
 | 
						|
                        if (Funs.DB.ProduceRun_SubInspectTermItem.Count(x => x.SubInspectId == subInspectId && x.ContractorIsPass.GetValueOrDefault() != 1) == 0)
 | 
						|
                        {
 | 
						|
                            subModel.ContractorIsAllPass = 1;
 | 
						|
                            subModel.ContractorAllPassData = DateTime.Now;
 | 
						|
                        }
 | 
						|
                        else
 | 
						|
                        {
 | 
						|
                            subModel.ContractorIsAllPass = 0;
 | 
						|
                            subModel.ContractorAllPassData = null;
 | 
						|
                        }
 | 
						|
                    }
 | 
						|
                    else if (this.ConfirmType == 2)
 | 
						|
                    {
 | 
						|
                        if (Funs.DB.ProduceRun_SubInspectTermItem.Count(x => x.SubInspectId == subInspectId && x.OwnerIsPass.GetValueOrDefault() != 1) == 0)
 | 
						|
                        {
 | 
						|
                            subModel.OwnerIsAllPass = 1;
 | 
						|
                            subModel.OwnerAllPassData = DateTime.Now;
 | 
						|
                        }
 | 
						|
                        else
 | 
						|
                        {
 | 
						|
                            subModel.OwnerIsAllPass = 0;
 | 
						|
                            subModel.OwnerAllPassData = null;
 | 
						|
                        }
 | 
						|
                    }
 | 
						|
                    else if (this.ConfirmType == 3)
 | 
						|
                    {
 | 
						|
                        if (Funs.DB.ProduceRun_SubInspectTermItem.Count(x => x.SubInspectId == subInspectId && x.ProcessPatentIsPass.GetValueOrDefault() != 1) == 0)
 | 
						|
                        {
 | 
						|
                            subModel.ProcessPatentIsAllPass = 1;
 | 
						|
                            subModel.ProcessPatentAllPassData = DateTime.Now;
 | 
						|
                        }
 | 
						|
                        else
 | 
						|
                        {
 | 
						|
                            subModel.ProcessPatentIsAllPass = 0;
 | 
						|
                            subModel.ProcessPatentAllPassData = null;
 | 
						|
                        }
 | 
						|
                    }
 | 
						|
                    //判断是否全部通过
 | 
						|
                    if (subModel.ContractorIsAllPass == 1 && subModel.OwnerIsAllPass == 1 && subModel.ProcessPatentIsAllPass == 1)
 | 
						|
                    {
 | 
						|
                        subModel.InspectIsClose = 1;
 | 
						|
                        subModel.InspectCloseData = DateTime.Now;
 | 
						|
                        subModel.WanderIsComplete = 1;
 | 
						|
                        subModel.WanderCompleteData = DateTime.Now;
 | 
						|
                    }
 | 
						|
                    else
 | 
						|
                    {
 | 
						|
                        subModel.InspectIsClose = 0;
 | 
						|
                        subModel.InspectCloseData = null;
 | 
						|
                        subModel.WanderIsComplete = 0;
 | 
						|
                        subModel.WanderCompleteData = null;
 | 
						|
                    }
 | 
						|
                }
 | 
						|
                Funs.DB.SubmitChanges();
 | 
						|
                BindGrid();
 | 
						|
                ShowNotify("保存成功!");
 | 
						|
            }
 | 
						|
            catch (Exception ex)
 | 
						|
            {
 | 
						|
                ShowNotify(ex.Message, MessageBoxIcon.Error);
 | 
						|
            }
 | 
						|
        }
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// 导出
 | 
						|
        /// </summary>
 | 
						|
        protected void btnExport_Click(object sender, EventArgs e)
 | 
						|
        {
 | 
						|
            string rootPath = Server.MapPath("~/") + Const.ExcelUrl;
 | 
						|
            //导出文件
 | 
						|
            string filePath = rootPath + DateTime.Now.ToString("yyyyMMddhhmmss") + "\\";
 | 
						|
            if (!Directory.Exists(filePath))
 | 
						|
            {
 | 
						|
                Directory.CreateDirectory(filePath);
 | 
						|
            }
 | 
						|
            string ReportFileName = filePath + this.ConfirmTypeName + "确认签字.xlsx";
 | 
						|
            //获取工作包检查表
 | 
						|
            var termData = from a in Funs.DB.ProduceRun_SubInspectTerm
 | 
						|
                           join b in Funs.DB.Base_Project on a.ProjectId equals b.ProjectId
 | 
						|
                           select new { a.SubInspectId, a.ProjectId, b.ProjectName, b.ShortName, b.ProjectCode, a.Contractor, a.Owner, a.ProcessPatent, a.InspectionIsAllPass, a.ContractorIsAllPass, a.OwnerIsAllPass, a.ProcessPatentIsAllPass, a.InspectTime, a.AddUser, a.AddTime };
 | 
						|
            if (termData != null)
 | 
						|
            {
 | 
						|
                var termModel = termData.FirstOrDefault();
 | 
						|
                //获取工作包检查项表
 | 
						|
                var termItems = Funs.DB.ProduceRun_SubInspectTermItem.Where(x => x.SubInspectId == this.SubInspectId).OrderBy(x => x.Sort).ToList();
 | 
						|
                int rowIndex = 0;
 | 
						|
                XSSFWorkbook hssfworkbook = new XSSFWorkbook();
 | 
						|
                XSSFSheet ws = (XSSFSheet)hssfworkbook.CreateSheet(this.ConfirmTypeName + "确认签字");
 | 
						|
 | 
						|
                #region 列宽
 | 
						|
 | 
						|
                ws.SetColumnWidth(0, (7 * 256));
 | 
						|
                ws.SetColumnWidth(1, (4 * 256));
 | 
						|
                ws.SetColumnWidth(2, (4 * 256));
 | 
						|
                ws.SetColumnWidth(3, (4 * 256));
 | 
						|
                ws.SetColumnWidth(4, (10 * 256));
 | 
						|
                ws.SetColumnWidth(5, (10 * 256));
 | 
						|
                ws.SetColumnWidth(6, (10 * 256));
 | 
						|
                ws.SetColumnWidth(7, (10 * 256));
 | 
						|
                ws.SetColumnWidth(8, (3 * 256));
 | 
						|
                ws.SetColumnWidth(9, (3 * 256));
 | 
						|
                ws.SetColumnWidth(10, (3 * 256));
 | 
						|
                ws.SetColumnWidth(11, (3 * 256));
 | 
						|
                ws.SetColumnWidth(12, (3 * 256));
 | 
						|
                ws.SetColumnWidth(13, (3 * 256));
 | 
						|
                ws.SetColumnWidth(14, (3 * 256));
 | 
						|
                ws.SetColumnWidth(15, (3 * 256));
 | 
						|
                ws.SetColumnWidth(16, (3 * 256));
 | 
						|
                ws.SetColumnWidth(17, (3 * 256));
 | 
						|
 | 
						|
                #endregion
 | 
						|
 | 
						|
                #region 样式
 | 
						|
                //头部样式居中
 | 
						|
                ICellStyle titleStyle = SetExcelStyle(hssfworkbook, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, VerticalAlignment.Center, HorizontalAlignment.Center, 14, true, true);
 | 
						|
                //头部样式靠左
 | 
						|
                ICellStyle leftTitleStyle = SetExcelStyle(hssfworkbook, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, VerticalAlignment.Center, HorizontalAlignment.Left, 14, true, true);
 | 
						|
                //公共样式
 | 
						|
                ICellStyle style = SetExcelStyle(hssfworkbook, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, VerticalAlignment.Center, HorizontalAlignment.Center, 10.5, true);
 | 
						|
                //公共样式靠左
 | 
						|
                ICellStyle leftStyle = SetExcelStyle(hssfworkbook, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, VerticalAlignment.Center, HorizontalAlignment.Left, 10.5, true);
 | 
						|
                //公共样式靠左上对其
 | 
						|
                ICellStyle leftTopStyle = SetExcelStyle(hssfworkbook, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, VerticalAlignment.Top, HorizontalAlignment.Left, 10.5, true);
 | 
						|
                //公共样式加粗
 | 
						|
                ICellStyle styleBold = SetExcelStyle(hssfworkbook, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, VerticalAlignment.Center, HorizontalAlignment.Center, 10.5, true, true);
 | 
						|
 | 
						|
                #endregion
 | 
						|
 | 
						|
                #region 头部
 | 
						|
 | 
						|
                ws = ExcelCreateRowTitle(ws, hssfworkbook, style, rowIndex, rowIndex + 5, 0, 17);
 | 
						|
                //行1
 | 
						|
                var region = new CellRangeAddress(rowIndex, rowIndex + 2, 0, 0);
 | 
						|
                ws.AddMergedRegion(region);
 | 
						|
                byte[] bytes = File.ReadAllBytes(Server.MapPath("~/") + "Images\\Template.png");
 | 
						|
                int pictureIdx = hssfworkbook.AddPicture(bytes, PictureType.JPEG);
 | 
						|
                IDrawing patriarch = ws.CreateDrawingPatriarch();
 | 
						|
                IClientAnchor anchor = patriarch.CreateAnchor(0, 0, 0, 0, 0, rowIndex, 1, rowIndex + 2);
 | 
						|
                IPicture pict = patriarch.CreatePicture(anchor, pictureIdx);
 | 
						|
                //pict.Resize();
 | 
						|
                region = new CellRangeAddress(rowIndex, rowIndex + 2, 1, 3);
 | 
						|
                ws.AddMergedRegion(region);
 | 
						|
                ws.GetRow(rowIndex).GetCell(1).SetCellValue("中国五环工程有限公司");
 | 
						|
                ws.GetRow(rowIndex).GetCell(1).CellStyle =
 | 
						|
                ws.GetRow(rowIndex).GetCell(2).CellStyle =
 | 
						|
                ws.GetRow(rowIndex).GetCell(3).CellStyle = leftTitleStyle;
 | 
						|
                region = new CellRangeAddress(rowIndex, rowIndex, 4, 7);
 | 
						|
                ws.AddMergedRegion(region);
 | 
						|
                ws.GetRow(rowIndex).GetCell(4).SetCellValue(termModel.ProjectName);
 | 
						|
                ws.GetRow(rowIndex).GetCell(4).CellStyle = style;
 | 
						|
                region = new CellRangeAddress(rowIndex, rowIndex, 8, 12);
 | 
						|
                ws.AddMergedRegion(region);
 | 
						|
                ws.GetRow(rowIndex).GetCell(8).SetCellValue("项目号");
 | 
						|
                ws.GetRow(rowIndex).GetCell(8).CellStyle = style;
 | 
						|
                region = new CellRangeAddress(rowIndex, rowIndex, 13, 17);
 | 
						|
                ws.AddMergedRegion(region);
 | 
						|
                ws.GetRow(rowIndex).GetCell(13).SetCellValue(termModel.ProjectCode);
 | 
						|
                ws.GetRow(rowIndex).GetCell(13).CellStyle = style;
 | 
						|
                region = new CellRangeAddress(rowIndex + 1, rowIndex + 1, 4, 7);
 | 
						|
                ws.AddMergedRegion(region);
 | 
						|
                ws.GetRow(rowIndex + 1).GetCell(4).SetCellValue("");
 | 
						|
                ws.GetRow(rowIndex + 1).GetCell(4).CellStyle = style;
 | 
						|
                region = new CellRangeAddress(rowIndex + 1, rowIndex + 1, 8, 12);
 | 
						|
                ws.AddMergedRegion(region);
 | 
						|
                ws.GetRow(rowIndex + 1).GetCell(8).SetCellValue("(文件号)");
 | 
						|
                ws.GetRow(rowIndex + 1).GetCell(8).CellStyle = style;
 | 
						|
                region = new CellRangeAddress(rowIndex + 1, rowIndex + 1, 13, 17);
 | 
						|
                ws.AddMergedRegion(region);
 | 
						|
                ws.GetRow(rowIndex + 1).GetCell(13).SetCellValue("");
 | 
						|
                ws.GetRow(rowIndex + 1).GetCell(13).CellStyle = style;
 | 
						|
                region = new CellRangeAddress(rowIndex + 2, rowIndex + 2, 4, 7);
 | 
						|
                ws.AddMergedRegion(region);
 | 
						|
                ws.GetRow(rowIndex + 2).GetCell(4).SetCellValue($"生产性能考核检查表");
 | 
						|
                ws.GetRow(rowIndex + 2).GetCell(4).CellStyle = titleStyle;
 | 
						|
                region = new CellRangeAddress(rowIndex + 2, rowIndex + 2, 8, 12);
 | 
						|
                ws.AddMergedRegion(region);
 | 
						|
                ws.GetRow(rowIndex + 2).GetCell(8).SetCellValue("第   1    页");
 | 
						|
                ws.GetRow(rowIndex + 2).GetCell(8).CellStyle = style;
 | 
						|
                region = new CellRangeAddress(rowIndex + 2, rowIndex + 2, 13, 17);
 | 
						|
                ws.AddMergedRegion(region);
 | 
						|
                ws.GetRow(rowIndex + 2).GetCell(13).SetCellValue("共    1     页");
 | 
						|
                ws.GetRow(rowIndex + 2).GetCell(13).CellStyle = style;
 | 
						|
                //行4,行5
 | 
						|
                region = new CellRangeAddress(rowIndex + 3, rowIndex + 4, 0, 2);
 | 
						|
                ws.AddMergedRegion(region);
 | 
						|
                ws.GetRow(rowIndex + 3).GetCell(0).CellStyle = style;
 | 
						|
                ws.GetRow(rowIndex + 3).GetCell(0).SetCellValue("");
 | 
						|
                region = new CellRangeAddress(rowIndex + 3, rowIndex + 4, 3, 11);
 | 
						|
                ws.AddMergedRegion(region);
 | 
						|
                ws.GetRow(rowIndex + 3).GetCell(3).CellStyle = leftStyle;
 | 
						|
                ws.GetRow(rowIndex + 3).GetCell(3).SetCellValue("");
 | 
						|
                region = new CellRangeAddress(rowIndex + 3, rowIndex + 3, 12, 17);
 | 
						|
                ws.AddMergedRegion(region);
 | 
						|
                ws.GetRow(rowIndex + 3).GetCell(12).CellStyle = style;
 | 
						|
                ws.GetRow(rowIndex + 3).GetCell(12).SetCellValue("检查日期");
 | 
						|
                region = new CellRangeAddress(rowIndex + 4, rowIndex + 4, 12, 17);
 | 
						|
                ws.AddMergedRegion(region);
 | 
						|
                ws.GetRow(rowIndex + 4).GetCell(12).CellStyle = style;
 | 
						|
                ws.GetRow(rowIndex + 4).GetCell(12).SetCellValue(DateTime.Now.ToString("yyyy年MM月dd日"));
 | 
						|
                //行6
 | 
						|
                ws.GetRow(rowIndex + 5).GetCell(0).CellStyle = styleBold;
 | 
						|
                ws.GetRow(rowIndex + 5).GetCell(0).SetCellValue("序号");
 | 
						|
                region = new CellRangeAddress(rowIndex + 5, rowIndex + 5, 1, 7);
 | 
						|
                ws.AddMergedRegion(region);
 | 
						|
                ws.GetRow(rowIndex + 5).GetCell(1).CellStyle = styleBold;
 | 
						|
                ws.GetRow(rowIndex + 5).GetCell(1).SetCellValue("检查项目");
 | 
						|
                region = new CellRangeAddress(rowIndex + 5, rowIndex + 5, 8, 12);
 | 
						|
                ws.AddMergedRegion(region);
 | 
						|
                ws.GetRow(rowIndex + 5).GetCell(8).CellStyle = styleBold;
 | 
						|
                ws.GetRow(rowIndex + 5).GetCell(8).SetCellValue("结果");
 | 
						|
                region = new CellRangeAddress(rowIndex + 5, rowIndex + 5, 13, 17);
 | 
						|
                ws.AddMergedRegion(region);
 | 
						|
                ws.GetRow(rowIndex + 5).GetCell(13).CellStyle = styleBold;
 | 
						|
                ws.GetRow(rowIndex + 5).GetCell(13).SetCellValue("备注");
 | 
						|
 | 
						|
                #endregion
 | 
						|
 | 
						|
                #region 表格
 | 
						|
 | 
						|
                var start = rowIndex + 6;
 | 
						|
                var end = rowIndex + 5 + termItems.Count;
 | 
						|
 | 
						|
                ws = ExcelCreateRowTitle(ws, hssfworkbook, style, start, end, 0, 17);
 | 
						|
 | 
						|
                //合并单元格
 | 
						|
                for (int hb = start; hb <= end; hb++)
 | 
						|
                {
 | 
						|
                    region = new CellRangeAddress(hb, hb, 1, 7);
 | 
						|
                    ws.AddMergedRegion(region);
 | 
						|
                    region = new CellRangeAddress(hb, hb, 8, 12);
 | 
						|
                    ws.AddMergedRegion(region);
 | 
						|
                    region = new CellRangeAddress(hb, hb, 13, 17);
 | 
						|
                    ws.AddMergedRegion(region);
 | 
						|
                }
 | 
						|
 | 
						|
                //数据
 | 
						|
                int num = 1;
 | 
						|
                var dataIndex = 6;
 | 
						|
                foreach (var item in termItems)
 | 
						|
                {
 | 
						|
                    //序号
 | 
						|
                    ws.GetRow(dataIndex).GetCell(0).SetCellValue(num);
 | 
						|
                    //检查项目
 | 
						|
                    ws.GetRow(dataIndex).GetCell(1).SetCellValue(item.WorkInspectName);
 | 
						|
                    ws.GetRow(dataIndex).GetCell(1).CellStyle = leftStyle;
 | 
						|
                    //结果
 | 
						|
                    ws.GetRow(dataIndex).GetCell(8).SetCellValue("");
 | 
						|
                    //备注
 | 
						|
                    ws.GetRow(dataIndex).GetCell(13).SetCellValue("");
 | 
						|
                    dataIndex++;
 | 
						|
                    num++;
 | 
						|
                }
 | 
						|
                rowIndex = start + termItems.Count;
 | 
						|
 | 
						|
                #endregion
 | 
						|
 | 
						|
                #region 尾部
 | 
						|
 | 
						|
                ws = ExcelCreateRowTitle(ws, hssfworkbook, style, rowIndex, rowIndex, 0, 17, 100);
 | 
						|
                //行1
 | 
						|
                ws.GetRow(rowIndex).GetCell(0).SetCellValue("结论");
 | 
						|
                region = new CellRangeAddress(rowIndex, rowIndex, 1, 17);
 | 
						|
                ws.AddMergedRegion(region);
 | 
						|
                ws.GetRow(rowIndex).GetCell(1).SetCellValue("是否同意进行(包括整改意见):");
 | 
						|
                ws.GetRow(rowIndex).GetCell(1).CellStyle = leftTopStyle;
 | 
						|
                //行2
 | 
						|
                ws = ExcelCreateRowTitle(ws, hssfworkbook, style, rowIndex + 1, rowIndex + 1, 0, 17, 80);
 | 
						|
                ws.GetRow(rowIndex + 1).GetCell(0).SetCellValue("检查人员");
 | 
						|
                region = new CellRangeAddress(rowIndex + 1, rowIndex + 1, 1, 4);
 | 
						|
                ws.AddMergedRegion(region);
 | 
						|
                ws.GetRow(rowIndex + 1).GetCell(1).SetCellValue("施工单位:");
 | 
						|
                ws.GetRow(rowIndex + 1).GetCell(1).CellStyle = leftTopStyle;
 | 
						|
                region = new CellRangeAddress(rowIndex + 1, rowIndex + 1, 5, 6);
 | 
						|
                ws.AddMergedRegion(region);
 | 
						|
                ws.GetRow(rowIndex + 1).GetCell(5).SetCellValue("承包商:");
 | 
						|
                ws.GetRow(rowIndex + 1).GetCell(5).CellStyle = leftTopStyle;
 | 
						|
                region = new CellRangeAddress(rowIndex + 1, rowIndex + 1, 7, 11);
 | 
						|
                ws.AddMergedRegion(region);
 | 
						|
                ws.GetRow(rowIndex + 1).GetCell(7).SetCellValue("业主:");
 | 
						|
                ws.GetRow(rowIndex + 1).GetCell(7).CellStyle = leftTopStyle;
 | 
						|
                region = new CellRangeAddress(rowIndex + 1, rowIndex + 1, 12, 17);
 | 
						|
                ws.AddMergedRegion(region);
 | 
						|
                ws.GetRow(rowIndex + 1).GetCell(12).SetCellValue("工艺专利商:");
 | 
						|
                ws.GetRow(rowIndex + 1).GetCell(12).CellStyle = leftTopStyle;
 | 
						|
 | 
						|
                #endregion
 | 
						|
 | 
						|
                ws.PrintSetup.Landscape = false;
 | 
						|
                ws.PrintSetup.PaperSize = 9;
 | 
						|
                ws.ForceFormulaRecalculation = true;
 | 
						|
                using (FileStream filess = File.OpenWrite(ReportFileName))
 | 
						|
                {
 | 
						|
                    hssfworkbook.Write(filess);
 | 
						|
                }
 | 
						|
                FileInfo filet = new FileInfo(ReportFileName);
 | 
						|
                Response.Clear();
 | 
						|
                Response.Charset = "GB2312";
 | 
						|
                Response.ContentEncoding = System.Text.Encoding.UTF8;
 | 
						|
                // 添加头信息,为"文件下载/另存为"对话框指定默认文件名
 | 
						|
                Response.AddHeader("Content-Disposition", "attachment; filename=" + Server.UrlEncode(this.ConfirmTypeName + "确认签字.xlsx"));
 | 
						|
                // 添加头信息,指定文件大小,让浏览器能够显示下载进度
 | 
						|
                Response.AddHeader("Content-Length", filet.Length.ToString());
 | 
						|
                // 指定返回的是一个不能被客户端读取的流,必须被下载
 | 
						|
                Response.ContentType = "application/ms-excel";
 | 
						|
                // 把文件流发送到客户端
 | 
						|
                Response.WriteFile(filet.FullName);
 | 
						|
                // 停止页面的执行
 | 
						|
                Response.End();
 | 
						|
            }
 | 
						|
        }
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// 行加载事件
 | 
						|
        /// </summary>
 | 
						|
        protected void Grid1_RowDataBound(object sender, GridRowEventArgs e)
 | 
						|
        {
 | 
						|
            System.Web.UI.WebControls.RadioButtonList rblIsPass = (System.Web.UI.WebControls.RadioButtonList)Grid1.Rows[e.RowIndex].FindControl("rblIsPass");
 | 
						|
            int isPass = 1;
 | 
						|
            if (Grid1.DataKeys[e.RowIndex][4] != null) isPass = int.Parse(Grid1.DataKeys[e.RowIndex][4].ToString());
 | 
						|
            rblIsPass.SelectedValue = isPass.ToString();
 | 
						|
            if (rblIsPass.SelectedValue != "1")
 | 
						|
            {
 | 
						|
                rblIsAllPass.SelectedValue = "0";
 | 
						|
            }
 | 
						|
        }
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// 实体绑定
 | 
						|
        /// </summary>
 | 
						|
        public class ConfirmIsPass
 | 
						|
        {
 | 
						|
            /// <summary>
 | 
						|
            /// 检查项主键
 | 
						|
            /// </summary>
 | 
						|
            public string TermItemId { get; set; }
 | 
						|
            /// <summary>
 | 
						|
            /// 检查表主键
 | 
						|
            /// </summary>
 | 
						|
            public string SubInspectId { get; set; }
 | 
						|
            /// <summary>
 | 
						|
            /// 检查人
 | 
						|
            /// </summary>
 | 
						|
            public string InspectedUser { get; set; }
 | 
						|
            /// <summary>
 | 
						|
            /// 检查人名称
 | 
						|
            /// </summary>
 | 
						|
            public string InspectedUserName { get; set; }
 | 
						|
            /// <summary>
 | 
						|
            /// 检查结果
 | 
						|
            /// </summary>
 | 
						|
            public int InspectionResults { get; set; }
 | 
						|
            /// <summary>
 | 
						|
            /// 名称
 | 
						|
            /// </summary>
 | 
						|
            public string WorkInspectName { get; set; }
 | 
						|
            /// <summary>
 | 
						|
            /// 确认类型1=承包商2=业主3=工艺专利商
 | 
						|
            /// </summary>
 | 
						|
            public int ConfirmType { get; set; }
 | 
						|
            /// <summary>
 | 
						|
            /// 确认类型名称
 | 
						|
            /// </summary>
 | 
						|
            public string ConfirmTypeName { get; set; }
 | 
						|
            /// <summary>
 | 
						|
            /// 是否通过
 | 
						|
            /// </summary>
 | 
						|
            public int? IsPass { get; set; }
 | 
						|
            /// <summary>
 | 
						|
            /// 备注
 | 
						|
            /// </summary>
 | 
						|
            public string Remark { get; set; }
 | 
						|
 | 
						|
        }
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// 检查项确认事件
 | 
						|
        /// </summary>
 | 
						|
        protected void rblIsPass_SelectedIndexChanged(object sender, EventArgs e)
 | 
						|
        {
 | 
						|
            for (int i = 0; i < Grid1.Rows.Count; i++)
 | 
						|
            {
 | 
						|
                System.Web.UI.WebControls.RadioButtonList rblIsPass = (System.Web.UI.WebControls.RadioButtonList)Grid1.Rows[i].FindControl("rblIsPass");
 | 
						|
                if (rblIsPass.SelectedValue != "1")
 | 
						|
                {
 | 
						|
                    rblIsAllPass.SelectedValue = "0";
 | 
						|
                }
 | 
						|
            }
 | 
						|
        }
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// 是否同意进行预试车活动事件
 | 
						|
        /// </summary>
 | 
						|
        protected void rblIsAllPass_SelectedIndexChanged(object sender, EventArgs e)
 | 
						|
        {
 | 
						|
            BindGrid(int.Parse(rblIsAllPass.SelectedValue));
 | 
						|
        }
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// 附件上传
 | 
						|
        /// </summary>
 | 
						|
        protected void btnAttach_Click(object sender, EventArgs e)
 | 
						|
        {
 | 
						|
            PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../../AttachFile/webuploader.aspx?type=0&toKeyId={0}&path=FileUpload/CheckControl&menuId={1}", $"{this.SubInspectId}_{this.ConfirmType}", Const.TestRunMenuId)));
 | 
						|
        }
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// 统一流转通过附件查看
 | 
						|
        /// </summary>
 | 
						|
        protected void btnUnifyUpload_Click(object sender, EventArgs e)
 | 
						|
        {
 | 
						|
            PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../../AttachFile/webuploader.aspx?type=-1&toKeyId={0}&path=FileUpload/CheckControl&menuId={1}", this.SubInspectId + "_unify", Const.TestRunMenuId)));
 | 
						|
        }
 | 
						|
 | 
						|
        #endregion
 | 
						|
 | 
						|
        #region 私有方法
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// 创建样式
 | 
						|
        /// </summary>
 | 
						|
        /// <returns></returns>
 | 
						|
        public static ICellStyle SetExcelStyle(XSSFWorkbook wb, BorderStyle Bottom, BorderStyle Left, BorderStyle Right, BorderStyle Top, VerticalAlignment VerAig, HorizontalAlignment HorAig, double FontSize, bool WrapText = true, bool Bold = false, string FontName = "宋体")
 | 
						|
        {
 | 
						|
            ICellStyle style = wb.CreateCellStyle();
 | 
						|
            style.BorderBottom = Bottom;
 | 
						|
            style.BorderLeft = Left;
 | 
						|
            style.BorderRight = Right;
 | 
						|
            style.BorderTop = Top;
 | 
						|
            style.VerticalAlignment = VerAig;
 | 
						|
            style.Alignment = HorAig;
 | 
						|
            IFont font = wb.CreateFont();
 | 
						|
            font.FontHeightInPoints = FontSize;
 | 
						|
            font.IsBold = Bold;
 | 
						|
            font.FontName = FontName;
 | 
						|
            style.SetFont(font);
 | 
						|
            style.WrapText = WrapText;
 | 
						|
            return style;
 | 
						|
        }
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// 创建头部
 | 
						|
        /// </summary>
 | 
						|
        /// <returns></returns>
 | 
						|
        private XSSFSheet ExcelCreateRowTitle(XSSFSheet ws, XSSFWorkbook hssfworkbook, ICellStyle style, int sRows, int eRows, int cStart, int cEnd, float height = 21)
 | 
						|
        {
 | 
						|
            for (int i = sRows; i <= eRows; i++)
 | 
						|
            {
 | 
						|
                ws.CreateRow(i);
 | 
						|
                ws.GetRow(i).HeightInPoints = height;
 | 
						|
                for (int j = cStart; j <= cEnd; j++)
 | 
						|
                {
 | 
						|
                    ws.GetRow(i).CreateCell(j);
 | 
						|
                    ws.GetRow(i).CreateCell(j).CellStyle = style;
 | 
						|
                }
 | 
						|
            }
 | 
						|
            return ws;
 | 
						|
        }
 | 
						|
 | 
						|
        #endregion
 | 
						|
 | 
						|
    }
 | 
						|
} |