714 lines
		
	
	
		
			36 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			714 lines
		
	
	
		
			36 KiB
		
	
	
	
		
			C#
		
	
	
	
using BLL;
 | 
						|
using NPOI.XSSF.UserModel;
 | 
						|
using NPOI.SS.UserModel;
 | 
						|
using System;
 | 
						|
using System.Collections.Generic;
 | 
						|
using System.Data;
 | 
						|
using System.Data.SqlClient;
 | 
						|
using System.IO;
 | 
						|
using System.Linq;
 | 
						|
namespace FineUIPro.Web.Report
 | 
						|
{
 | 
						|
    public partial class ProjectManhourReport : PageBase
 | 
						|
    {
 | 
						|
        #region 加载
 | 
						|
        /// <summary>
 | 
						|
        /// 加载页面
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="sender"></param>
 | 
						|
        /// <param name="e"></param>
 | 
						|
        protected void Page_Load(object sender, EventArgs e)
 | 
						|
        {
 | 
						|
            // 表头过滤
 | 
						|
            FilterDataRowItem = FilterDataRowItemImplement;
 | 
						|
            if (!IsPostBack)
 | 
						|
            {
 | 
						|
                GetButtonPower();//权限设置
 | 
						|
                ddlPageSize.SelectedValue = Grid1.PageSize.ToString();
 | 
						|
 | 
						|
                BLL.ConstService.InitConstValueDropDownList(this.drpJobStatus, BLL.Const.ProjectPlanner_JobStatus, true);
 | 
						|
 | 
						|
                // 绑定表格
 | 
						|
                BindGrid();
 | 
						|
            }
 | 
						|
            else if (GetRequestEventArgument() == "FilterChange")
 | 
						|
            {
 | 
						|
                BindGrid();
 | 
						|
            }
 | 
						|
 | 
						|
        }
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// 绑定数据
 | 
						|
        /// </summary>
 | 
						|
        private void BindGrid()
 | 
						|
        {
 | 
						|
            List<SqlParameter> listStr = new List<SqlParameter>();
 | 
						|
            if (this.drpJobStatus.SelectedValue != BLL.Const._Null && this.drpJobStatus.SelectedValue != null)
 | 
						|
            {
 | 
						|
                string status = String.Join(",", drpJobStatus.SelectedItemArray.Select(e => e.Text));
 | 
						|
                listStr.Add(new SqlParameter("@JobStatus", status));
 | 
						|
            }
 | 
						|
            SqlParameter[] parameter = listStr.ToArray();
 | 
						|
            DataTable tb = SQLHelper.GetDataTableRunProc("Proc_ProjectManhourReport", parameter);
 | 
						|
            Grid1.RecordCount = tb.Rows.Count;
 | 
						|
            var table = this.GetPagedDataTable(Grid1, tb);
 | 
						|
            Grid1.DataSource = table;
 | 
						|
            Grid1.DataBind();
 | 
						|
        }
 | 
						|
        #endregion
 | 
						|
 | 
						|
        #region 过滤表头
 | 
						|
        /// <summary>
 | 
						|
        /// 过滤表头
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="sender"></param>
 | 
						|
        /// <param name="e"></param>
 | 
						|
        protected void Grid1_FilterChange(object sender, EventArgs e)
 | 
						|
        {
 | 
						|
            BindGrid();
 | 
						|
        }
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// 根据表头信息过滤列表数据
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="sourceObj"></param>
 | 
						|
        /// <param name="fillteredOperator"></param>
 | 
						|
        /// <param name="fillteredObj"></param>
 | 
						|
        /// <param name="column"></param>
 | 
						|
        /// <returns></returns>
 | 
						|
        private bool FilterDataRowItemImplement(object sourceObj, string fillteredOperator, object fillteredObj, string column)
 | 
						|
        {
 | 
						|
            bool valid = false;
 | 
						|
            if (column == "ProjectControl_JobNo")
 | 
						|
            {
 | 
						|
                string sourceValue = sourceObj.ToString();
 | 
						|
                string fillteredValue = fillteredObj.ToString();
 | 
						|
                if (fillteredOperator == "equal" && sourceValue == fillteredValue)
 | 
						|
                {
 | 
						|
                    valid = true;
 | 
						|
                }
 | 
						|
                else if (fillteredOperator == "contain" && sourceValue.Contains(fillteredValue))
 | 
						|
                {
 | 
						|
                    valid = true;
 | 
						|
                }
 | 
						|
            }
 | 
						|
            if (column == "ProjectControl_JobType")
 | 
						|
            {
 | 
						|
                string sourceValue = sourceObj.ToString();
 | 
						|
                string fillteredValue = fillteredObj.ToString();
 | 
						|
                if (fillteredOperator == "equal" && sourceValue == fillteredValue)
 | 
						|
                {
 | 
						|
                    valid = true;
 | 
						|
                }
 | 
						|
                else if (fillteredOperator == "contain" && sourceValue.Contains(fillteredValue))
 | 
						|
                {
 | 
						|
                    valid = true;
 | 
						|
                }
 | 
						|
            }
 | 
						|
            if (column == "ProjectControl_JobTitle")
 | 
						|
            {
 | 
						|
                string sourceValue = sourceObj.ToString();
 | 
						|
                string fillteredValue = fillteredObj.ToString();
 | 
						|
                if (fillteredOperator == "equal" && sourceValue == fillteredValue)
 | 
						|
                {
 | 
						|
                    valid = true;
 | 
						|
                }
 | 
						|
                else if (fillteredOperator == "contain" && sourceValue.Contains(fillteredValue))
 | 
						|
                {
 | 
						|
                    valid = true;
 | 
						|
                }
 | 
						|
            }
 | 
						|
            if (column == "ProjectControl_JobStatus")
 | 
						|
            {
 | 
						|
                string sourceValue = sourceObj.ToString();
 | 
						|
                string fillteredValue = fillteredObj.ToString();
 | 
						|
                if (fillteredOperator == "equal" && sourceValue == fillteredValue)
 | 
						|
                {
 | 
						|
                    valid = true;
 | 
						|
                }
 | 
						|
                else if (fillteredOperator == "contain" && sourceValue.Contains(fillteredValue))
 | 
						|
                {
 | 
						|
                    valid = true;
 | 
						|
                }
 | 
						|
            }
 | 
						|
            if (column == "PM_General_Priority")
 | 
						|
            {
 | 
						|
                string sourceValue = sourceObj.ToString();
 | 
						|
                string fillteredValue = fillteredObj.ToString();
 | 
						|
                if (fillteredOperator == "equal" && sourceValue == fillteredValue)
 | 
						|
                {
 | 
						|
                    valid = true;
 | 
						|
                }
 | 
						|
                else if (fillteredOperator == "contain" && sourceValue.Contains(fillteredValue))
 | 
						|
                {
 | 
						|
                    valid = true;
 | 
						|
                }
 | 
						|
            }
 | 
						|
            if (column == "PM_MA_JobReveive")
 | 
						|
            {
 | 
						|
                string sourceValue = sourceObj.ToString();
 | 
						|
                string fillteredValue = fillteredObj.ToString();
 | 
						|
                if (fillteredOperator == "equal" && sourceValue == fillteredValue)
 | 
						|
                {
 | 
						|
                    valid = true;
 | 
						|
                }
 | 
						|
                else if (fillteredOperator == "contain" && sourceValue.Contains(fillteredValue))
 | 
						|
                {
 | 
						|
                    valid = true;
 | 
						|
                }
 | 
						|
            }
 | 
						|
            if (column == "ProjectControl_MS_Approval")
 | 
						|
            {
 | 
						|
                string sourceValue = sourceObj.ToString();
 | 
						|
                string fillteredValue = fillteredObj.ToString();
 | 
						|
                if (fillteredOperator == "equal" && sourceValue == fillteredValue)
 | 
						|
                {
 | 
						|
                    valid = true;
 | 
						|
                }
 | 
						|
                else if (fillteredOperator == "contain" && sourceValue.Contains(fillteredValue))
 | 
						|
                {
 | 
						|
                    valid = true;
 | 
						|
                }
 | 
						|
            }
 | 
						|
            if (column == "CM_MA_MC")
 | 
						|
            {
 | 
						|
                string sourceValue = sourceObj.ToString();
 | 
						|
                string fillteredValue = fillteredObj.ToString();
 | 
						|
                if (fillteredOperator == "equal" && sourceValue == fillteredValue)
 | 
						|
                {
 | 
						|
                    valid = true;
 | 
						|
                }
 | 
						|
                else if (fillteredOperator == "contain" && sourceValue.Contains(fillteredValue))
 | 
						|
                {
 | 
						|
                    valid = true;
 | 
						|
                }
 | 
						|
            }
 | 
						|
            if (column == "ProjectControl_BC_CloseDate")
 | 
						|
            {
 | 
						|
                string sourceValue = sourceObj.ToString();
 | 
						|
                string fillteredValue = fillteredObj.ToString();
 | 
						|
                if (fillteredOperator == "equal" && sourceValue == fillteredValue)
 | 
						|
                {
 | 
						|
                    valid = true;
 | 
						|
                }
 | 
						|
                else if (fillteredOperator == "contain" && sourceValue.Contains(fillteredValue))
 | 
						|
                {
 | 
						|
                    valid = true;
 | 
						|
                }
 | 
						|
            }
 | 
						|
            if (column == "AccountDisabled")
 | 
						|
            {
 | 
						|
                string sourceValue = sourceObj.ToString();
 | 
						|
                string fillteredValue = fillteredObj.ToString();
 | 
						|
                if (fillteredOperator == "equal" && sourceValue == fillteredValue)
 | 
						|
                {
 | 
						|
                    valid = true;
 | 
						|
                }
 | 
						|
                else if (fillteredOperator == "contain" && sourceValue.Contains(fillteredValue))
 | 
						|
                {
 | 
						|
                    valid = true;
 | 
						|
                }
 | 
						|
            }
 | 
						|
            if (column == "Roles")
 | 
						|
            {
 | 
						|
                string sourceValue = sourceObj.ToString();
 | 
						|
                string fillteredValue = fillteredObj.ToString();
 | 
						|
                if (fillteredOperator == "equal" && sourceValue == fillteredValue)
 | 
						|
                {
 | 
						|
                    valid = true;
 | 
						|
                }
 | 
						|
                else if (fillteredOperator == "contain" && sourceValue.Contains(fillteredValue))
 | 
						|
                {
 | 
						|
                    valid = true;
 | 
						|
                }
 | 
						|
            }
 | 
						|
            if (column == "EngineerName")
 | 
						|
            {
 | 
						|
                string sourceValue = sourceObj.ToString();
 | 
						|
                string fillteredValue = fillteredObj.ToString();
 | 
						|
                if (fillteredOperator == "equal" && sourceValue == fillteredValue)
 | 
						|
                {
 | 
						|
                    valid = true;
 | 
						|
                }
 | 
						|
                else if (fillteredOperator == "contain" && sourceValue.Contains(fillteredValue))
 | 
						|
                {
 | 
						|
                    valid = true;
 | 
						|
                }
 | 
						|
            }
 | 
						|
            if (column == "ManHours")
 | 
						|
            {
 | 
						|
                string sourceValue = sourceObj.ToString();
 | 
						|
                string fillteredValue = fillteredObj.ToString();
 | 
						|
                if (fillteredOperator == "equal" && sourceValue == fillteredValue)
 | 
						|
                {
 | 
						|
                    valid = true;
 | 
						|
                }
 | 
						|
                else if (fillteredOperator == "contain" && sourceValue.Contains(fillteredValue))
 | 
						|
                {
 | 
						|
                    valid = true;
 | 
						|
                }
 | 
						|
            }
 | 
						|
            if (column == "PlanHoursSum")
 | 
						|
            {
 | 
						|
                string sourceValue = sourceObj.ToString();
 | 
						|
                string fillteredValue = fillteredObj.ToString();
 | 
						|
                if (fillteredOperator == "equal" && sourceValue == fillteredValue)
 | 
						|
                {
 | 
						|
                    valid = true;
 | 
						|
                }
 | 
						|
                else if (fillteredOperator == "contain" && sourceValue.Contains(fillteredValue))
 | 
						|
                {
 | 
						|
                    valid = true;
 | 
						|
                }
 | 
						|
            }
 | 
						|
            if (column == "ActualSum")
 | 
						|
            {
 | 
						|
                string sourceValue = sourceObj.ToString();
 | 
						|
                string fillteredValue = fillteredObj.ToString();
 | 
						|
                if (fillteredOperator == "equal" && sourceValue == fillteredValue)
 | 
						|
                {
 | 
						|
                    valid = true;
 | 
						|
                }
 | 
						|
                else if (fillteredOperator == "contain" && sourceValue.Contains(fillteredValue))
 | 
						|
                {
 | 
						|
                    valid = true;
 | 
						|
                }
 | 
						|
            }
 | 
						|
            return valid;
 | 
						|
        }
 | 
						|
        #endregion
 | 
						|
 | 
						|
        #region 查询
 | 
						|
        /// <summary>
 | 
						|
        /// 查询
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="sender"></param>
 | 
						|
        /// <param name="e"></param>
 | 
						|
        protected void btnSearch_Click(object sender, EventArgs e)
 | 
						|
        {
 | 
						|
            BindGrid();
 | 
						|
        }
 | 
						|
        #endregion
 | 
						|
       
 | 
						|
 | 
						|
        #region 分页、排序
 | 
						|
        /// <summary>
 | 
						|
        /// 分页
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="sender"></param>
 | 
						|
        /// <param name="e"></param>
 | 
						|
        protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
 | 
						|
        {
 | 
						|
            BindGrid();
 | 
						|
        }
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// 分页显示条数下拉框
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="sender"></param>
 | 
						|
        /// <param name="e"></param>
 | 
						|
        protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
 | 
						|
        {
 | 
						|
            BindGrid();
 | 
						|
        }
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// 排序
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="sender"></param>
 | 
						|
        /// <param name="e"></param>
 | 
						|
        protected void Grid1_Sort(object sender, FineUIPro.GridSortEventArgs e)
 | 
						|
        {
 | 
						|
            BindGrid();
 | 
						|
        }
 | 
						|
        #endregion
 | 
						|
 | 
						|
        #region 导出
 | 
						|
        /// <summary>
 | 
						|
        /// 导出按钮
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="sender"></param>
 | 
						|
        /// <param name="e"></param>
 | 
						|
        protected void btnExport_Click(object sender, EventArgs e)
 | 
						|
        {
 | 
						|
            string rootPath = Server.MapPath("~/") + Const.ExcelUrl;
 | 
						|
            //模板文件
 | 
						|
            string TempletFileName = rootPath + "Project_Manhour_Report.xlsx";
 | 
						|
            //导出文件
 | 
						|
            string filePath = rootPath + DateTime.Now.ToString("yyyyMMddhhmmss") + "\\";
 | 
						|
            if (!Directory.Exists(filePath))
 | 
						|
            {
 | 
						|
                Directory.CreateDirectory(filePath);
 | 
						|
            }
 | 
						|
            string ReportFileName = filePath + "out.xlsx";
 | 
						|
 | 
						|
            FileStream file = new FileStream(TempletFileName, FileMode.Open, FileAccess.Read);
 | 
						|
            XSSFWorkbook hssfworkbook = new XSSFWorkbook(file);
 | 
						|
 | 
						|
            #region Project_Manhour_Report
 | 
						|
            XSSFSheet reportModel = (XSSFSheet)hssfworkbook.GetSheet("Project_Manhour_Report");
 | 
						|
 | 
						|
            XSSFFont cs_content_Font = (XSSFFont)hssfworkbook.CreateFont(); //创建字体
 | 
						|
            cs_content_Font.FontName = "sans-serif";//字体
 | 
						|
            cs_content_Font.FontHeightInPoints = 10; //字体大小
 | 
						|
 | 
						|
            ICellStyle styleCenter = hssfworkbook.CreateCellStyle();
 | 
						|
            styleCenter.VerticalAlignment = VerticalAlignment.Center;
 | 
						|
            styleCenter.Alignment = HorizontalAlignment.Center;
 | 
						|
            styleCenter.SetFont(cs_content_Font);
 | 
						|
 | 
						|
            IDataFormat dataformat = hssfworkbook.CreateDataFormat();
 | 
						|
            ICellStyle styleDate = hssfworkbook.CreateCellStyle();
 | 
						|
            styleDate.VerticalAlignment = VerticalAlignment.Center;
 | 
						|
            styleDate.Alignment = HorizontalAlignment.Center;
 | 
						|
            styleDate.SetFont(cs_content_Font);
 | 
						|
            styleDate.DataFormat = dataformat.GetFormat("yyyy/m/d");
 | 
						|
 | 
						|
            List<SqlParameter> listStr = new List<SqlParameter>();
 | 
						|
            if (drpJobStatus.SelectedValue != BLL.Const._Null && drpJobStatus.SelectedValue != null)
 | 
						|
            {
 | 
						|
                string status = String.Join(",", drpJobStatus.SelectedItemArray.Select(x => x.Text));
 | 
						|
                listStr.Add(new SqlParameter("@JobStatus", status));
 | 
						|
            }
 | 
						|
            else
 | 
						|
            {
 | 
						|
                listStr.Add(new SqlParameter("@JobStatus", null));
 | 
						|
            }
 | 
						|
            SqlParameter[] parameter = listStr.ToArray();
 | 
						|
            DataTable table = SQLHelper.GetDataTableRunProc("Proc_ProjectManhourReport", parameter);
 | 
						|
            if (table.Rows.Count > 0)
 | 
						|
            {
 | 
						|
                var rowIndex = 1;
 | 
						|
                for (int i = 0; i < table.Rows.Count; i++)
 | 
						|
                {
 | 
						|
                    if (reportModel.GetRow(rowIndex) == null) reportModel.CreateRow(rowIndex);
 | 
						|
                    //Job No.
 | 
						|
                    if (reportModel.GetRow(rowIndex).GetCell(0) == null) reportModel.GetRow(rowIndex).CreateCell(0);
 | 
						|
                    reportModel.GetRow(rowIndex).GetCell(0).SetCellValue(table.Rows[i]["ProjectControl_JobNo"].ToString());
 | 
						|
                    reportModel.GetRow(rowIndex).GetCell(0).CellStyle = styleCenter;
 | 
						|
 | 
						|
                    //Job Type
 | 
						|
                    if (reportModel.GetRow(rowIndex).GetCell(1) == null) reportModel.GetRow(rowIndex).CreateCell(1);
 | 
						|
                    reportModel.GetRow(rowIndex).GetCell(1).SetCellValue(table.Rows[i]["ProjectControl_JobType"].ToString());
 | 
						|
                    reportModel.GetRow(rowIndex).GetCell(1).CellStyle = styleCenter;
 | 
						|
                    //Job Title
 | 
						|
                    if (reportModel.GetRow(rowIndex).GetCell(2) == null) reportModel.GetRow(rowIndex).CreateCell(2);
 | 
						|
                    reportModel.GetRow(rowIndex).GetCell(2).SetCellValue(table.Rows[i]["ProjectControl_JobTitle"].ToString());
 | 
						|
                    reportModel.GetRow(rowIndex).GetCell(2).CellStyle.SetFont(cs_content_Font);
 | 
						|
                    //Job Status
 | 
						|
                    if (reportModel.GetRow(rowIndex).GetCell(3) == null) reportModel.GetRow(rowIndex).CreateCell(3);
 | 
						|
                    reportModel.GetRow(rowIndex).GetCell(3).SetCellValue(table.Rows[i]["ProjectControl_JobStatus"].ToString());
 | 
						|
                    reportModel.GetRow(rowIndex).GetCell(3).CellStyle = styleCenter;
 | 
						|
                    //Job Priority
 | 
						|
                    if (reportModel.GetRow(rowIndex).GetCell(4) == null) reportModel.GetRow(rowIndex).CreateCell(4);
 | 
						|
                    reportModel.GetRow(rowIndex).GetCell(4).SetCellValue(table.Rows[i]["PM_General_Priority"].ToString());
 | 
						|
                    reportModel.GetRow(rowIndex).GetCell(4).CellStyle = styleCenter;
 | 
						|
 | 
						|
                    //Phase
 | 
						|
                    if (reportModel.GetRow(rowIndex).GetCell(5) == null) reportModel.GetRow(rowIndex).CreateCell(5);
 | 
						|
                    reportModel.GetRow(rowIndex).GetCell(5).SetCellValue(table.Rows[i]["Phase"].ToString());
 | 
						|
                    reportModel.GetRow(rowIndex).GetCell(5).CellStyle = styleCenter;
 | 
						|
 | 
						|
                    //Receive Date
 | 
						|
                    if (reportModel.GetRow(rowIndex).GetCell(6) == null) reportModel.GetRow(rowIndex).CreateCell(6);
 | 
						|
                    if (table.Rows[i]["PM_MA_JobReveive"] != null && table.Rows[i]["PM_MA_JobReveive"].ToString() != "")
 | 
						|
                    {
 | 
						|
                        reportModel.GetRow(rowIndex).GetCell(6).SetCellValue((DateTime)Convert.ToDateTime(table.Rows[i]["PM_MA_JobReveive"].ToString()));
 | 
						|
                        reportModel.GetRow(rowIndex).GetCell(6).CellStyle = styleDate;
 | 
						|
                    }
 | 
						|
                    //Approval  Date
 | 
						|
                    if (reportModel.GetRow(rowIndex).GetCell(7) == null) reportModel.GetRow(rowIndex).CreateCell(7);
 | 
						|
                    if (table.Rows[i]["PM_MA_ProjectApproval"] != null && table.Rows[i]["PM_MA_ProjectApproval"].ToString() != "")
 | 
						|
                    {
 | 
						|
                        reportModel.GetRow(rowIndex).GetCell(7).SetCellValue((DateTime)Convert.ToDateTime(table.Rows[i]["PM_MA_ProjectApproval"].ToString()));
 | 
						|
                        reportModel.GetRow(rowIndex).GetCell(7).CellStyle = styleDate;
 | 
						|
                    }
 | 
						|
                    //MC Date
 | 
						|
                    if (reportModel.GetRow(rowIndex).GetCell(8) == null) reportModel.GetRow(rowIndex).CreateCell(8);
 | 
						|
                    if (table.Rows[i]["CM_MA_MC"] != null && table.Rows[i]["CM_MA_MC"].ToString() != "")
 | 
						|
                    {
 | 
						|
                        reportModel.GetRow(rowIndex).GetCell(8).SetCellValue((DateTime)Convert.ToDateTime(table.Rows[i]["CM_MA_MC"].ToString()));
 | 
						|
                        reportModel.GetRow(rowIndex).GetCell(8).CellStyle = styleDate;
 | 
						|
                    }
 | 
						|
                    //Business Date
 | 
						|
                    if (reportModel.GetRow(rowIndex).GetCell(9) == null) reportModel.GetRow(rowIndex).CreateCell(9);
 | 
						|
                    if (table.Rows[i]["ProjectControl_BC_CloseDate"] != null && table.Rows[i]["ProjectControl_BC_CloseDate"].ToString() != "")
 | 
						|
                    {
 | 
						|
                        reportModel.GetRow(rowIndex).GetCell(9).SetCellValue((DateTime)Convert.ToDateTime(table.Rows[i]["ProjectControl_BC_CloseDate"].ToString()));
 | 
						|
                        reportModel.GetRow(rowIndex).GetCell(9).CellStyle = styleDate;
 | 
						|
                    }
 | 
						|
                    //Disabled?
 | 
						|
                    if (!string.IsNullOrEmpty(table.Rows[i]["AccountDisabled"].ToString()))
 | 
						|
                    {
 | 
						|
                        if (reportModel.GetRow(rowIndex).GetCell(10) == null) reportModel.GetRow(rowIndex).CreateCell(10);
 | 
						|
                        reportModel.GetRow(rowIndex).GetCell(10).SetCellValue(Convert.ToDouble(table.Rows[i]["AccountDisabled"]));
 | 
						|
                        reportModel.GetRow(rowIndex).GetCell(10).CellStyle = styleCenter;
 | 
						|
                    }
 | 
						|
                    //Role
 | 
						|
                    if (reportModel.GetRow(rowIndex).GetCell(11) == null) reportModel.GetRow(rowIndex).CreateCell(11);
 | 
						|
                    reportModel.GetRow(rowIndex).GetCell(11).SetCellValue(table.Rows[i]["Roles"].ToString());
 | 
						|
                    reportModel.GetRow(rowIndex).GetCell(11).CellStyle = styleCenter;
 | 
						|
                    //Account
 | 
						|
                    if (reportModel.GetRow(rowIndex).GetCell(12) == null) reportModel.GetRow(rowIndex).CreateCell(12);
 | 
						|
                    reportModel.GetRow(rowIndex).GetCell(12).SetCellValue(table.Rows[i]["Account"].ToString());
 | 
						|
                    reportModel.GetRow(rowIndex).GetCell(12).CellStyle = styleCenter;
 | 
						|
                    //Name
 | 
						|
                    if (reportModel.GetRow(rowIndex).GetCell(13) == null) reportModel.GetRow(rowIndex).CreateCell(13);
 | 
						|
                    reportModel.GetRow(rowIndex).GetCell(13).SetCellValue(table.Rows[i]["EngineerName"].ToString());
 | 
						|
                    reportModel.GetRow(rowIndex).GetCell(13).CellStyle = styleCenter;
 | 
						|
                    //Orginal Plan
 | 
						|
                    if (!string.IsNullOrEmpty(table.Rows[i]["ManHours"].ToString()))
 | 
						|
                    {
 | 
						|
                        if (reportModel.GetRow(rowIndex).GetCell(14) == null) reportModel.GetRow(rowIndex).CreateCell(14);
 | 
						|
                        reportModel.GetRow(rowIndex).GetCell(14).SetCellValue(Convert.ToDouble(table.Rows[i]["ManHours"]));
 | 
						|
                        reportModel.GetRow(rowIndex).GetCell(14).CellStyle = styleCenter;
 | 
						|
                    }
 | 
						|
                    //∑Plan
 | 
						|
                    if (!string.IsNullOrEmpty(table.Rows[i]["PlanHoursSum"].ToString()))
 | 
						|
                    {
 | 
						|
                        if (reportModel.GetRow(rowIndex).GetCell(15) == null) reportModel.GetRow(rowIndex).CreateCell(15);
 | 
						|
                        reportModel.GetRow(rowIndex).GetCell(15).SetCellValue(Convert.ToDouble(table.Rows[i]["PlanHoursSum"]));
 | 
						|
                        reportModel.GetRow(rowIndex).GetCell(15).CellStyle = styleCenter;
 | 
						|
                    }
 | 
						|
                    //∑Actual
 | 
						|
                    if (!string.IsNullOrEmpty(table.Rows[i]["ActualSum"].ToString()))
 | 
						|
                    {
 | 
						|
                        if (reportModel.GetRow(rowIndex).GetCell(16) == null) reportModel.GetRow(rowIndex).CreateCell(16);
 | 
						|
                        reportModel.GetRow(rowIndex).GetCell(16).SetCellValue(Convert.ToDouble(table.Rows[i]["ActualSum"]));
 | 
						|
                        reportModel.GetRow(rowIndex).GetCell(16).CellStyle = styleCenter;
 | 
						|
                    }
 | 
						|
 | 
						|
                    //PM_General_CDI
 | 
						|
                    if (reportModel.GetRow(rowIndex).GetCell(17) == null) reportModel.GetRow(rowIndex).CreateCell(17);
 | 
						|
                    reportModel.GetRow(rowIndex).GetCell(17).SetCellValue(table.Rows[i]["PM_General_CDI"].ToString());
 | 
						|
                    reportModel.GetRow(rowIndex).GetCell(17).CellStyle = styleCenter;
 | 
						|
                    //OutSourceType
 | 
						|
                    if (reportModel.GetRow(rowIndex).GetCell(18) == null) reportModel.GetRow(rowIndex).CreateCell(18);
 | 
						|
                    reportModel.GetRow(rowIndex).GetCell(18).SetCellValue(table.Rows[i]["OutSourceType"].ToString());
 | 
						|
                    reportModel.GetRow(rowIndex).GetCell(18).CellStyle = styleCenter;
 | 
						|
 | 
						|
                    //Process
 | 
						|
                    if (reportModel.GetRow(rowIndex).GetCell(19) == null) reportModel.GetRow(rowIndex).CreateCell(19);
 | 
						|
                    if (table.Rows[i]["Process"] != null && table.Rows[i]["Process"].ToString() != "")
 | 
						|
                    {
 | 
						|
                        reportModel.GetRow(rowIndex).GetCell(19).SetCellValue((DateTime)Convert.ToDateTime(table.Rows[i]["Process"].ToString()));
 | 
						|
                        reportModel.GetRow(rowIndex).GetCell(19).CellStyle = styleDate;
 | 
						|
                    }
 | 
						|
                    //Plumbling
 | 
						|
                    if (reportModel.GetRow(rowIndex).GetCell(20) == null) reportModel.GetRow(rowIndex).CreateCell(20);
 | 
						|
                    if (table.Rows[i]["Plumbling"] != null && table.Rows[i]["Plumbling"].ToString() != "")
 | 
						|
                    {
 | 
						|
                        reportModel.GetRow(rowIndex).GetCell(20).SetCellValue((DateTime)Convert.ToDateTime(table.Rows[i]["Plumbling"].ToString()));
 | 
						|
                        reportModel.GetRow(rowIndex).GetCell(20).CellStyle = styleDate;
 | 
						|
                    }
 | 
						|
                    //Equipment
 | 
						|
                    if (reportModel.GetRow(rowIndex).GetCell(21) == null) reportModel.GetRow(rowIndex).CreateCell(21);
 | 
						|
                    if (table.Rows[i]["Equipment"] != null && table.Rows[i]["Equipment"].ToString() != "")
 | 
						|
                    {
 | 
						|
                        reportModel.GetRow(rowIndex).GetCell(21).SetCellValue((DateTime)Convert.ToDateTime(table.Rows[i]["Equipment"].ToString()));
 | 
						|
                        reportModel.GetRow(rowIndex).GetCell(21).CellStyle = styleDate;
 | 
						|
                    }
 | 
						|
                    //Piping
 | 
						|
                    if (reportModel.GetRow(rowIndex).GetCell(22) == null) reportModel.GetRow(rowIndex).CreateCell(22);
 | 
						|
                    if (table.Rows[i]["Piping"] != null && table.Rows[i]["Piping"].ToString() != "")
 | 
						|
                    {
 | 
						|
                        reportModel.GetRow(rowIndex).GetCell(22).SetCellValue((DateTime)Convert.ToDateTime(table.Rows[i]["Piping"].ToString()));
 | 
						|
                        reportModel.GetRow(rowIndex).GetCell(22).CellStyle = styleDate;
 | 
						|
                    }
 | 
						|
                    //Electrical
 | 
						|
                    if (reportModel.GetRow(rowIndex).GetCell(23) == null) reportModel.GetRow(rowIndex).CreateCell(23);
 | 
						|
                    if (table.Rows[i]["Electrical"] != null && table.Rows[i]["Electrical"].ToString() != "")
 | 
						|
                    {
 | 
						|
                        reportModel.GetRow(rowIndex).GetCell(23).SetCellValue((DateTime)Convert.ToDateTime(table.Rows[i]["Electrical"].ToString()));
 | 
						|
                        reportModel.GetRow(rowIndex).GetCell(23).CellStyle = styleDate;
 | 
						|
                    }
 | 
						|
                    //Communication
 | 
						|
                    if (reportModel.GetRow(rowIndex).GetCell(24) == null) reportModel.GetRow(rowIndex).CreateCell(24);
 | 
						|
                    if (table.Rows[i]["Communication"] != null && table.Rows[i]["Communication"].ToString() != "")
 | 
						|
                    {
 | 
						|
                        reportModel.GetRow(rowIndex).GetCell(24).SetCellValue((DateTime)Convert.ToDateTime(table.Rows[i]["Communication"].ToString()));
 | 
						|
                        reportModel.GetRow(rowIndex).GetCell(24).CellStyle = styleDate;
 | 
						|
                    }
 | 
						|
                    //Instrument
 | 
						|
                    if (reportModel.GetRow(rowIndex).GetCell(25) == null) reportModel.GetRow(rowIndex).CreateCell(25);
 | 
						|
                    if (table.Rows[i]["Instrument"] != null && table.Rows[i]["Instrument"].ToString() != "")
 | 
						|
                    {
 | 
						|
                        reportModel.GetRow(rowIndex).GetCell(25).SetCellValue((DateTime)Convert.ToDateTime(table.Rows[i]["Instrument"].ToString()));
 | 
						|
                        reportModel.GetRow(rowIndex).GetCell(25).CellStyle = styleDate;
 | 
						|
                    }
 | 
						|
                    //Civil
 | 
						|
                    if (reportModel.GetRow(rowIndex).GetCell(26) == null) reportModel.GetRow(rowIndex).CreateCell(26);
 | 
						|
                    if (table.Rows[i]["Civil"] != null && table.Rows[i]["Civil"].ToString() != "")
 | 
						|
                    {
 | 
						|
                        reportModel.GetRow(rowIndex).GetCell(26).SetCellValue((DateTime)Convert.ToDateTime(table.Rows[i]["Civil"].ToString()));
 | 
						|
                        reportModel.GetRow(rowIndex).GetCell(26).CellStyle = styleDate;
 | 
						|
                    }
 | 
						|
                    //Architectral
 | 
						|
                    if (reportModel.GetRow(rowIndex).GetCell(27) == null) reportModel.GetRow(rowIndex).CreateCell(27);
 | 
						|
                    if (table.Rows[i]["Architectral"] != null && table.Rows[i]["Architectral"].ToString() != "")
 | 
						|
                    {
 | 
						|
                        reportModel.GetRow(rowIndex).GetCell(27).SetCellValue((DateTime)Convert.ToDateTime(table.Rows[i]["Architectral"].ToString()));
 | 
						|
                        reportModel.GetRow(rowIndex).GetCell(27).CellStyle = styleDate;
 | 
						|
                    }
 | 
						|
                    //HVAC
 | 
						|
                    if (reportModel.GetRow(rowIndex).GetCell(28) == null) reportModel.GetRow(rowIndex).CreateCell(28);
 | 
						|
                    if (table.Rows[i]["HVAC"] != null && table.Rows[i]["HVAC"].ToString() != "")
 | 
						|
                    {
 | 
						|
                        reportModel.GetRow(rowIndex).GetCell(28).SetCellValue((DateTime)Convert.ToDateTime(table.Rows[i]["HVAC"].ToString()));
 | 
						|
                        reportModel.GetRow(rowIndex).GetCell(28).CellStyle = styleDate;
 | 
						|
                    }
 | 
						|
                    //MasterpLanning
 | 
						|
                    if (reportModel.GetRow(rowIndex).GetCell(29) == null) reportModel.GetRow(rowIndex).CreateCell(29);
 | 
						|
                    if (table.Rows[i]["MasterpLanning"] != null && table.Rows[i]["MasterpLanning"].ToString() != "")
 | 
						|
                    {
 | 
						|
                        reportModel.GetRow(rowIndex).GetCell(29).SetCellValue((DateTime)Convert.ToDateTime(table.Rows[i]["MasterpLanning"].ToString()));
 | 
						|
                        reportModel.GetRow(rowIndex).GetCell(29).CellStyle = styleDate;
 | 
						|
                    }
 | 
						|
 | 
						|
                    if (reportModel.GetRow(rowIndex).GetCell(30) == null) reportModel.GetRow(rowIndex).CreateCell(30);
 | 
						|
                    if (table.Rows[i]["IFC_All"] != null && table.Rows[i]["IFC_All"].ToString() != "")
 | 
						|
                    {
 | 
						|
                        reportModel.GetRow(rowIndex).GetCell(30).SetCellValue((DateTime)Convert.ToDateTime(table.Rows[i]["IFC_All"].ToString()));
 | 
						|
                        reportModel.GetRow(rowIndex).GetCell(30).CellStyle = styleDate;
 | 
						|
                    }
 | 
						|
 | 
						|
                    //Detail_Eng_Civil_Sch_Start
 | 
						|
                    if (reportModel.GetRow(rowIndex).GetCell(31) == null) reportModel.GetRow(rowIndex).CreateCell(31);
 | 
						|
                    if (table.Rows[i]["Detail_Eng_Civil_Sch_Start"] != null && table.Rows[i]["Detail_Eng_Civil_Sch_Start"].ToString() != "")
 | 
						|
                    {
 | 
						|
                        reportModel.GetRow(rowIndex).GetCell(31).SetCellValue((DateTime)Convert.ToDateTime(table.Rows[i]["Detail_Eng_Civil_Sch_Start"].ToString()));
 | 
						|
                        reportModel.GetRow(rowIndex).GetCell(31).CellStyle = styleDate;
 | 
						|
                    }
 | 
						|
                    //Detail_Eng_Civil_Sch_End
 | 
						|
                    if (reportModel.GetRow(rowIndex).GetCell(32) == null) reportModel.GetRow(rowIndex).CreateCell(32);
 | 
						|
                    if (table.Rows[i]["Detail_Eng_Civil_Sch_End"] != null && table.Rows[i]["Detail_Eng_Civil_Sch_End"].ToString() != "")
 | 
						|
                    {
 | 
						|
                        reportModel.GetRow(rowIndex).GetCell(32).SetCellValue((DateTime)Convert.ToDateTime(table.Rows[i]["Detail_Eng_Civil_Sch_End"].ToString()));
 | 
						|
                        reportModel.GetRow(rowIndex).GetCell(32).CellStyle = styleDate;
 | 
						|
                    }
 | 
						|
                    //PROJ_DE_CIVIL_ACU_START_DATE
 | 
						|
                    if (reportModel.GetRow(rowIndex).GetCell(33) == null) reportModel.GetRow(rowIndex).CreateCell(33);
 | 
						|
                    if (table.Rows[i]["PROJ_DE_CIVIL_ACU_START_DATE"] != null && table.Rows[i]["PROJ_DE_CIVIL_ACU_START_DATE"].ToString() != "")
 | 
						|
                    {
 | 
						|
                        reportModel.GetRow(rowIndex).GetCell(33).SetCellValue((DateTime)Convert.ToDateTime(table.Rows[i]["PROJ_DE_CIVIL_ACU_START_DATE"].ToString()));
 | 
						|
                        reportModel.GetRow(rowIndex).GetCell(33).CellStyle = styleDate;
 | 
						|
                    }
 | 
						|
                    //PROJ_DE_CIVIL_ACU_END_DATE
 | 
						|
                    if (reportModel.GetRow(rowIndex).GetCell(34) == null) reportModel.GetRow(rowIndex).CreateCell(34);
 | 
						|
                    if (table.Rows[i]["PROJ_DE_CIVIL_ACU_END_DATE"] != null && table.Rows[i]["PROJ_DE_CIVIL_ACU_END_DATE"].ToString() != "")
 | 
						|
                    {
 | 
						|
                        reportModel.GetRow(rowIndex).GetCell(34).SetCellValue((DateTime)Convert.ToDateTime(table.Rows[i]["PROJ_DE_CIVIL_ACU_END_DATE"].ToString()));
 | 
						|
                        reportModel.GetRow(rowIndex).GetCell(34).CellStyle = styleDate;
 | 
						|
                    }
 | 
						|
                    //Detail_Eng_Mech_EI_Sch_Start
 | 
						|
                    if (reportModel.GetRow(rowIndex).GetCell(35) == null) reportModel.GetRow(rowIndex).CreateCell(35);
 | 
						|
                    if (table.Rows[i]["Detail_Eng_Mech_EI_Sch_Start"] != null && table.Rows[i]["Detail_Eng_Mech_EI_Sch_Start"].ToString() != "")
 | 
						|
                    {
 | 
						|
                        reportModel.GetRow(rowIndex).GetCell(35).SetCellValue((DateTime)Convert.ToDateTime(table.Rows[i]["Detail_Eng_Mech_EI_Sch_Start"].ToString()));
 | 
						|
                        reportModel.GetRow(rowIndex).GetCell(35).CellStyle = styleDate;
 | 
						|
                    }
 | 
						|
                    //PROJ_DE_ME_SCH_END_DATE
 | 
						|
                    if (reportModel.GetRow(rowIndex).GetCell(36) == null) reportModel.GetRow(rowIndex).CreateCell(36);
 | 
						|
                    if (table.Rows[i]["PROJ_DE_ME_SCH_END_DATE"] != null && table.Rows[i]["PROJ_DE_ME_SCH_END_DATE"].ToString() != "")
 | 
						|
                    {
 | 
						|
                        reportModel.GetRow(rowIndex).GetCell(36).SetCellValue((DateTime)Convert.ToDateTime(table.Rows[i]["PROJ_DE_ME_SCH_END_DATE"].ToString()));
 | 
						|
                        reportModel.GetRow(rowIndex).GetCell(36).CellStyle = styleDate;
 | 
						|
                    }
 | 
						|
                    //Detail_Eng_Mech_EI_Sch_End
 | 
						|
                    if (reportModel.GetRow(rowIndex).GetCell(37) == null) reportModel.GetRow(rowIndex).CreateCell(37);
 | 
						|
                    if (table.Rows[i]["Detail_Eng_Mech_EI_Sch_End"] != null && table.Rows[i]["Detail_Eng_Mech_EI_Sch_End"].ToString() != "")
 | 
						|
                    {
 | 
						|
                        reportModel.GetRow(rowIndex).GetCell(37).SetCellValue((DateTime)Convert.ToDateTime(table.Rows[i]["Detail_Eng_Mech_EI_Sch_End"].ToString()));
 | 
						|
                        reportModel.GetRow(rowIndex).GetCell(37).CellStyle = styleDate;
 | 
						|
                    }
 | 
						|
                    //PROJ_DE_ME_ACU_END_DATE
 | 
						|
                    if (reportModel.GetRow(rowIndex).GetCell(38) == null) reportModel.GetRow(rowIndex).CreateCell(38);
 | 
						|
                    if (table.Rows[i]["PROJ_DE_ME_ACU_END_DATE"] != null && table.Rows[i]["PROJ_DE_ME_ACU_END_DATE"].ToString() != "")
 | 
						|
                    {
 | 
						|
                        reportModel.GetRow(rowIndex).GetCell(38).SetCellValue((DateTime)Convert.ToDateTime(table.Rows[i]["PROJ_DE_ME_ACU_END_DATE"].ToString()));
 | 
						|
                        reportModel.GetRow(rowIndex).GetCell(38).CellStyle = styleDate;
 | 
						|
                    }
 | 
						|
                    // ProjectControl_LeadByName
 | 
						|
                    if (reportModel.GetRow(rowIndex).GetCell(39) == null) reportModel.GetRow(rowIndex).CreateCell(39);
 | 
						|
                    reportModel.GetRow(rowIndex).GetCell(39).SetCellValue(table.Rows[i]["ProjectControl_LeadByName"].ToString());
 | 
						|
                    reportModel.GetRow(rowIndex).GetCell(39).CellStyle = styleCenter;
 | 
						|
 | 
						|
                    rowIndex++;
 | 
						|
                }
 | 
						|
            }
 | 
						|
            #endregion
 | 
						|
            reportModel.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=P05_Project_Manhour_Report_" + Server.UrlEncode(DateTime.Now.ToString("yyyyMMddhhmmss") + ".xlsx"));
 | 
						|
            // 添加头信息,指定文件大小,让浏览器能够显示下载进度
 | 
						|
            Response.AddHeader("Content-Length", filet.Length.ToString());
 | 
						|
            // 指定返回的是一个不能被客户端读取的流,必须被下载
 | 
						|
            Response.ContentType = "application/ms-excel";
 | 
						|
            // 把文件流发送到客户端
 | 
						|
            Response.WriteFile(filet.FullName);
 | 
						|
            // 停止页面的执行
 | 
						|
            Response.End();
 | 
						|
        }
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// 根据sql获取数据
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="strSql"></param>
 | 
						|
        /// <param name="tableName"></param>
 | 
						|
        /// <param name="parameters"></param>
 | 
						|
        /// <returns></returns>
 | 
						|
        public static DataTable GetDataTableNameRunText(string strSql, string tableName = "", params SqlParameter[] parameters)
 | 
						|
        {
 | 
						|
            DataTable dataTable = string.IsNullOrEmpty(tableName) ? new DataTable() : new DataTable(tableName);
 | 
						|
            using (SqlConnection Connection = new SqlConnection(Funs.ConnString))
 | 
						|
            {
 | 
						|
                try
 | 
						|
                {
 | 
						|
                    Connection.Open();
 | 
						|
                    SqlCommand command = new SqlCommand(strSql, Connection);
 | 
						|
                    command.CommandType = CommandType.Text;
 | 
						|
                    if (parameters != null)
 | 
						|
                    {
 | 
						|
                        command.Parameters.AddRange(parameters);
 | 
						|
                    }
 | 
						|
 | 
						|
                    SqlDataAdapter adapter = new SqlDataAdapter(command);
 | 
						|
                    adapter.Fill(dataTable);
 | 
						|
                }
 | 
						|
                finally
 | 
						|
                {
 | 
						|
                    Connection.Close();
 | 
						|
                }
 | 
						|
            }
 | 
						|
            return dataTable;
 | 
						|
        }
 | 
						|
        #endregion
 | 
						|
 | 
						|
        #region 权限设置
 | 
						|
        /// <summary>
 | 
						|
        /// 菜单按钮权限
 | 
						|
        /// </summary>
 | 
						|
        private void GetButtonPower()
 | 
						|
        {
 | 
						|
            var buttonList = BLL.CommonService.GetAllButtonList(this.CurrUser.UserId, BLL.Const.ProjectManhourReportMenuId);
 | 
						|
            if (buttonList.Count() > 0)
 | 
						|
            {
 | 
						|
                if (buttonList.Contains(BLL.Const.BtnOut))
 | 
						|
                {
 | 
						|
                    this.btnExport.Hidden = false;
 | 
						|
                }
 | 
						|
            }
 | 
						|
        }
 | 
						|
        #endregion
 | 
						|
    }
 | 
						|
} |