using BLL; using NPOI.XSSF.UserModel; using NPOI.SS.UserModel; using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Collections.Specialized; using System.Data; using System.Data.SqlClient; using System.IO; using System.Linq; using Model; using BLL.Common; using FineUIPro.Web.common; using Org.BouncyCastle.Bcpg.OpenPgp; namespace FineUIPro.Web.Evaluation { public partial class ContractorEvaluation : PageBase { protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { GetButtonPower(); BindGrid(); } } private void BindGrid() { string strSql = @"SELECT * from View_Contractor_Evaluation WHERE 1=1 "; List listStr = new List(); if (!string.IsNullOrEmpty(txtFO_NO.Text.Trim())) { strSql += " AND FO_NO LIKE @FO_NO"; listStr.Add(new SqlParameter("@FO_NO", "%" + this.txtFO_NO.Text.Trim() + "%")); } SqlParameter[] parameter = listStr.ToArray(); DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter); Grid1.RecordCount = tb.Rows.Count; var table = this.GetPagedDataTable(Grid1, tb); Grid1.DataSource = table.DefaultView; Grid1.DataBind(); } #region 分页、排序 /// /// 分页 /// /// /// protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e) { Grid1.PageIndex = e.NewPageIndex; BindGrid(); } /// /// 分页显示条数下拉框 /// /// /// protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e) { Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue); BindGrid(); } /// /// 排序 /// /// /// protected void Grid1_Sort(object sender, FineUIPro.GridSortEventArgs e) { Grid1.SortDirection = e.SortDirection; Grid1.SortField = e.SortField; BindGrid(); } #endregion protected void Grid1_RowSelect(object sender, GridRowSelectEventArgs e) { if (!string.IsNullOrEmpty(Grid1.SelectedRowID)) { GetButtonPower(); var depart = BLL.DepartService.GetDepartById(CurrUser.DepartId); string rowId = this.Grid1.SelectedRowID; var sESRelatedData = BLL.SESRelatedDataService.GetSESRelatedDataById(rowId); if (sESRelatedData != null) { if (CurrUser.UserId == Const.GlyId || CurrUser.UserId == sESRelatedData.Main_Coordinator || CurrUser.UserId == sESRelatedData.BuyerId || (depart != null && depart.DepartCode.Contains("CT/K"))) { btnEdit.Hidden = false; this.Grid1.EnableRowDoubleClickEvent = true; } else { btnEdit.Hidden = true; this.Grid1.EnableRowDoubleClickEvent = false; } } } } #region 查询 /// /// 查询 /// /// /// protected void Text_TextChanged(object sender, EventArgs e) { BindGrid(); } protected void btnSearch_Click(object sender, EventArgs e) { BindGrid(); } #endregion protected void btnEdit_Click(object sender, EventArgs e) { if (Grid1.SelectedRowIndexArray.Length == 0) { Alert.ShowInParent("Please select at least one record!"); return; } string Id = Grid1.SelectedRowID; var fo = BLL.SESRelatedDataService.GetSESRelatedDataById(Id); PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("ContractorEvaluationEdit.aspx?foNo={0}", fo.FO_NO, "编辑 - "))); } #region 过期提醒邮件发送 /// /// 过期提醒邮件发送 /// /// /// protected void btnSendEmail_Click(object sender, EventArgs e) { bool IsComplite = false; string errorMsg = string.Empty; string compMsg = string.Empty; // 过期提示,30天范围 var foList = from x in Funs.DB.FC_SESRelatedData where x.Expire_Date != null && x.Expire_Date.Value.AddMonths(-6).AddDays(-7).Date <= DateTime.Now.Date && x.Expire_Date.Value.Date >= DateTime.Now.Date select x; if (foList.Count() > 0) { foreach (var fo in foList) { List userList = new List(); EmailPop pops = Funs.DB.EmailPop.FirstOrDefault(x => x.EmailID == BLL.Const.EmailPopId); if (pops == null) { return; } string[] mailTo = null; string mailBody = string.Empty; string mailAttch = string.Empty; string mailCode = string.Empty; string mailPriority = string.Empty; string[] mailCC = null; string resultMessage = ""; string departId = string.Empty; var discipline = BLL.DisciplineService.GetDisciplineById(fo.DisciplineId); //string disc = discipline.Discipline; //if (!string.IsNullOrEmpty(discipline.DisciplineCN)) //{ // disc = disc + " " + discipline.DisciplineCN; //} var contractAdmin = from x in Funs.DB.Sys_User where x.UserId == fo.Contract_Admin && x.Email != null && x.Email != "" select x; if (contractAdmin.Count() > 0) { userList.Add(contractAdmin.First()); } var buyer = from x in Funs.DB.Sys_User where x.UserName == fo.Buyer && x.Email != null && x.Email != "" select x; if (buyer.Count() > 0) { userList.Add(buyer.First()); } var mainCoor = from x in Funs.DB.Sys_User where x.UserId == fo.Main_Coordinator && x.Email != null && x.Email != "" select x; if (mainCoor.Count() > 0) { userList.Add(mainCoor.First()); } var userRepresentative = from x in Funs.DB.Sys_User where x.UserId == fo.User_Representative && x.Email != null && x.Email != "" select x; if (userRepresentative.Count() > 0) { userList.Add(userRepresentative.First()); } // CT/K部门去掉 //var ctk = from x in Funs.DB.Sys_User // join z in Funs.DB.Base_Depart on x.DepartId equals z.DepartId // where z.DepartCode == "CT/K" && x.Email != null && x.Email != "" // select x; //if (ctk.Count() > 0) //{ // foreach (var c in ctk) // { // userList.Add(c); // } //} var ctss = from x in Funs.DB.Sys_User join y in Funs.DB.Sys_Role on x.RoleId equals y.RoleId where y.RoleName == "CTS/S" && x.Email != null && x.Email != "" select x; if (ctss.Count() > 0) { foreach (var c in ctss) { userList.Add(c); } } var cc = from x in Funs.DB.Sys_User join y in Funs.DB.Sys_Role on x.RoleId equals y.RoleId where x.Email != null && x.Email != "" && (y.RoleName == "CTE/D Manager" || y.RoleName == "Cost Engineer Leader" || y.RoleName == "Contractor_Leader") select x; mailTo = userList.Select(x => x.Email).Distinct().ToArray(); mailCC = cc.Select(x => x.Email).ToArray(); var email = Funs.DB.SendEmail.Where(p => p.EmailStatus == "发送成功" && p.EmailTile.Contains("框架合同评估表") && p.EmailTile.Contains(discipline.Discipline.Replace("\r\n", "")) && p.EmailTile.Contains(fo.FO_NO) && mailTo.Contains(p.EmailURL)).ToList(); if (email.Count > 0) { var emailurl = email.Select(p => p.EmailURL).ToList(); mailTo = mailTo.Where(p => !emailurl.Contains(p)).ToArray(); } //if (mailTo == null || mailTo.Length == 0) return; if (mailTo != null && mailTo.Length > 0) { var EmailTemplate = Funs.DB.SendEmailTemplate.Where(x => x.EmailName.Contains("框架合同评估")); if (EmailTemplate.Count() > 0) { string templetpath = EmailTemplate.Select(p => p.EmailContext).FirstOrDefault(); NameValueCollection myCol = new NameValueCollection(); mailBody = TemplateHelper.BulidByFile2(templetpath, myCol); IsComplite = MailHelper.SendNetMail1(pops, pops.EmailYx, mailTo, fo.FO_NO + "-" + discipline.Discipline.Replace("\r\n", "") + " 框架合同评估表填写通知", mailBody, mailAttch, mailCode, mailPriority, mailCC, null, out resultMessage); if (IsComplite) { compMsg = compMsg + "合同:" + fo.FO_NO + ",专业:" + discipline.Discipline.Replace("\r\n", "") + ",框架合同评估表填写通知邮件发送成功!"; } else { errorMsg = errorMsg + "合同:" + fo.FO_NO + ",专业:" + discipline.Discipline.Replace("\r\n", "") + ",框架合同评估表填写通知邮件发送失败!"; } } } } if (compMsg == string.Empty && errorMsg == string.Empty) { Alert.ShowInParent("框架合同评估表填写通知邮件已发送!"); } else { Alert.ShowInParent(compMsg + errorMsg); } } else { Alert.ShowInParent("无框架合同评估表填写通知邮件需发送!"); return; } } #endregion #region 关闭弹出窗口 /// /// 关闭窗口 /// /// /// protected void Window1_Close(object sender, EventArgs e) { BindGrid(); } #endregion #region 导出 /// /// 导出按钮 /// /// /// protected void btnExport_Click(object sender, EventArgs e) { string rootPath = Server.MapPath("~/") + Const.ExcelUrl; //模板文件 string TempletFileName = rootPath + "承包商评估表.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 FC_List XSSFSheet reportModel = (XSSFSheet)hssfworkbook.GetSheet("Sheet1"); IDataFormat dataformat = hssfworkbook.CreateDataFormat(); ICellStyle styleQfw = hssfworkbook.CreateCellStyle(); styleQfw.DataFormat = dataformat.GetFormat("#,##0.00"); ICellStyle styleTime = hssfworkbook.CreateCellStyle(); styleTime.DataFormat = dataformat.GetFormat("yyyy/m/d HH:mm:ss"); XSSFFont content_Font = (XSSFFont)hssfworkbook.CreateFont(); //创建字体 content_Font.FontName = "Wingdings 2";//字体 content_Font.FontHeightInPoints = 11; //字体大小 XSSFFont cs_content_Font = (XSSFFont)hssfworkbook.CreateFont(); //创建字体 cs_content_Font.FontName = "宋体";//字体 cs_content_Font.FontHeightInPoints = 8; //字体大小 ICellStyle styleDate = hssfworkbook.CreateCellStyle(); styleDate.DataFormat = dataformat.GetFormat("yyyy/m/d"); styleDate.VerticalAlignment= VerticalAlignment.Center; styleDate.Alignment= HorizontalAlignment.Center; styleDate.BorderTop = BorderStyle.Thin; styleDate.BorderRight = BorderStyle.Thin; styleDate.SetFont(cs_content_Font); XSSFFont cs_content_FontBlod = (XSSFFont)hssfworkbook.CreateFont(); //创建字体 cs_content_FontBlod.FontName = "Arial";//字体 cs_content_FontBlod.FontHeightInPoints = 14; //字体大小 cs_content_FontBlod.IsBold = true; ICellStyle styleBlod = hssfworkbook.CreateCellStyle(); styleBlod.VerticalAlignment = VerticalAlignment.Center; styleBlod.Alignment = HorizontalAlignment.Center; styleBlod.SetFont(cs_content_FontBlod); string txtNo = "£"; var eva = Funs.DB.View_Contractor_Evaluation.FirstOrDefault(x => x.ID.ToString() == Grid1.SelectedRowID); if (eva != null) { //4行 if (reportModel.GetRow(3) == null) reportModel.CreateRow(3); if (reportModel.GetRow(3).GetCell(2) == null) reportModel.GetRow(3).CreateCell(2); reportModel.GetRow(3).GetCell(2).SetCellValue(eva.Discipline); //6行 if (reportModel.GetRow(5) == null) reportModel.CreateRow(5); if (reportModel.GetRow(5).GetCell(2) == null) reportModel.GetRow(5).CreateCell(2); reportModel.GetRow(5).GetCell(2).SetCellValue(eva.FO_NO); if (reportModel.GetRow(5).GetCell(6) == null) reportModel.GetRow(5).CreateCell(6); if (eva.Validate_Date.HasValue) { reportModel.GetRow(5).GetCell(6).SetCellValue(eva.Validate_Date.Value.ToString("yyyy/MM/dd")); //reportModel.GetRow(6).GetCell(6).CellStyle = styleDate; } if (reportModel.GetRow(5).GetCell(8) == null) reportModel.GetRow(5).CreateCell(8); if (eva.Expire_Date.HasValue) { reportModel.GetRow(5).GetCell(8).SetCellValue(eva.Expire_Date.Value.ToString("yyyy/MM/dd")); //reportModel.GetRow(6).GetCell(8).CellStyle = styleDate; } //7行 if (reportModel.GetRow(6) == null) reportModel.CreateRow(6); if (reportModel.GetRow(6).GetCell(2) == null) reportModel.GetRow(6).CreateCell(2); reportModel.GetRow(6).GetCell(2).SetCellValue(eva.Contractor); if (reportModel.GetRow(6).GetCell(8) == null) reportModel.GetRow(6).CreateCell(8); reportModel.GetRow(6).GetCell(8).SetCellValue(eva.VolumeAllocation); //9行 if (reportModel.GetRow(8) == null) reportModel.CreateRow(8); if (reportModel.GetRow(8).GetCell(2) == null) reportModel.GetRow(8).CreateCell(2); reportModel.GetRow(8).GetCell(2).SetCellValue(eva.Spending_commitment != null ? eva.Spending_commitment.ToString() : ""); if (reportModel.GetRow(8).GetCell(4) == null) reportModel.GetRow(8).CreateCell(4); reportModel.GetRow(8).GetCell(4).SetCellValue(eva.Forecasted.ToString()); if (reportModel.GetRow(8).GetCell(6) == null) reportModel.GetRow(8).CreateCell(6); reportModel.GetRow(8).GetCell(6).SetCellValue(eva.Total != null ? eva.Total.ToString() : ""); if (reportModel.GetRow(8).GetCell(8) == null) reportModel.GetRow(8).CreateCell(8); reportModel.GetRow(8).GetCell(8).SetCellValue(eva.YearAvg != null ? eva.YearAvg.ToString() : ""); //10行 if (reportModel.GetRow(9) == null) reportModel.CreateRow(9); if (reportModel.GetRow(9).GetCell(2) == null) reportModel.GetRow(9).CreateCell(2); reportModel.GetRow(9).GetCell(2).SetCellValue(eva.IfExtend);//是否为续签合同 if (reportModel.GetRow(9).GetCell(4) == null) reportModel.GetRow(9).CreateCell(4); reportModel.GetRow(9).GetCell(4).SetCellValue(eva.PreviousFO);//续签前合同 var previous = BLL.SESRelatedDataService.GetSESRelatedDataByFoNo(eva.PreviousFO); if (previous != null) { if (reportModel.GetRow(9).GetCell(6) == null) reportModel.GetRow(9).CreateCell(6); reportModel.GetRow(9).GetCell(6).SetCellValue(previous.Validate_Date.HasValue ? string.Format("{0:yyyy-MM-dd}", previous.Validate_Date) : "");//合同生效日 if (reportModel.GetRow(9).GetCell(8) == null) reportModel.GetRow(9).CreateCell(8); reportModel.GetRow(9).GetCell(8).SetCellValue(previous.Expire_Date.HasValue ? string.Format("{0:yyyy-MM-dd}", previous.Expire_Date) : "");//合同结束日 } // 左边列表 int s = 0; DateTime startDate = DateTime.Now.AddMonths(-23); DateTime startTime = DateTime.Parse(startDate.Year + "-" + startDate.Month + "-01"); DateTime endTime = DateTime.Parse(DateTime.Now.Year + "-" + DateTime.Now.Month + "-13"); //绩效评估最终计算是每月12日,如果每月12日导出,那么此上月的数据的报告分数不显示 if (DateTime.Now.Day <= 12) { DateTime dtime = DateTime.Now.AddMonths(-2); endTime = DateTime.Parse(dtime.Year + "-" + dtime.Month + "-13"); } else { DateTime dtime = DateTime.Now.AddMonths(-1); endTime = DateTime.Parse(dtime.Year + "-" + dtime.Month + "-13"); } if (eva.IfExtend=="Y")//续签合同 { List yearToDateParam = new List(); yearToDateParam.Add(new SqlParameter("@StartTime", startTime)); yearToDateParam.Add(new SqlParameter("@EndTime", endTime)); yearToDateParam.Add(new SqlParameter("@FoNo", eva.FO_NO)); SqlParameter[] yearToDateParList = yearToDateParam.ToArray(); var sesDataTable = SQLHelper.GetDataTableRunProc("Sp_ContractorEvaluation", yearToDateParList); //上一轮合同 var fo = BLL.SESRelatedDataService.GetSESRelatedDataByFoNo(eva.FO_NO); if (fo != null) { if (!string.IsNullOrEmpty(fo.PreviousFO)) { List yearToDateParam2 = new List(); yearToDateParam2.Add(new SqlParameter("@StartTime", startTime)); yearToDateParam2.Add(new SqlParameter("@EndTime", endTime)); yearToDateParam2.Add(new SqlParameter("@FoNo", fo.PreviousFO)); SqlParameter[] yearToDateParList2 = yearToDateParam2.ToArray(); var sesDataTable2 = SQLHelper.GetDataTableRunProc("Sp_ContractorEvaluation", yearToDateParList2); sesDataTable.Merge(sesDataTable2);//上一轮合同合并到续签合同中 } } var sesDataScore = JsonConvert.DeserializeObject>(JsonConvert.SerializeObject(sesDataTable)); // 15行 if (reportModel.GetRow(14) == null) reportModel.CreateRow(14); if (reportModel.GetRow(15) == null) reportModel.CreateRow(15); if (reportModel.GetRow(16) == null) reportModel.CreateRow(16); if (reportModel.GetRow(17) == null) reportModel.CreateRow(17); if (reportModel.GetRow(18) == null) reportModel.CreateRow(18); if (reportModel.GetRow(19) == null) reportModel.CreateRow(19); if (reportModel.GetRow(20) == null) reportModel.CreateRow(20); if (reportModel.GetRow(21) == null) reportModel.CreateRow(21); if (reportModel.GetRow(22) == null) reportModel.CreateRow(22); if (reportModel.GetRow(23) == null) reportModel.CreateRow(23); if (reportModel.GetRow(24) == null) reportModel.CreateRow(24); if (reportModel.GetRow(25) == null) reportModel.CreateRow(25); for (int j = 0; j < 24; j++) { var curDate = DateTime.Parse("" + startDate.Year + "-" + startDate.Month + "-01").AddMonths(j); if (j >= 0 && j < 12) { if (reportModel.GetRow(14 + j).GetCell(0) == null) reportModel.GetRow(14 + j).CreateCell(0); reportModel.GetRow(14 + j).GetCell(0).SetCellValue(curDate.ToString("yyyy-MM")); if (sesDataScore.Count(p => p.dataMonth == curDate.ToString("yyyy-MM")) > 0 && Funs.GetNewDecimal(sesDataScore.FirstOrDefault(p => p.dataMonth == curDate.ToString("yyyy-MM")).SumScore) > 0) { var yearNums = float.Parse(sesDataScore.FirstOrDefault(p => p.dataMonth == curDate.ToString("yyyy-MM")).SumScore).ToString("0.##"); reportModel.GetRow(14 + j).GetCell(2).SetCellValue(yearNums); //本期合同字体加粗 var sesFo = sesDataScore.FirstOrDefault(p => p.dataMonth == curDate.ToString("yyyy-MM")).FO_NO; if (sesFo == eva.FO_NO) { reportModel.GetRow(14 + j).GetCell(2).CellStyle = styleBlod; } if (Funs.GetNewDecimalOrZero(yearNums) < 60) { s++; } } else { reportModel.GetRow(14 + j).GetCell(2).SetCellValue(""); } } else { if (reportModel.GetRow(14 + j - 12).GetCell(3) == null) reportModel.GetRow(14 + j - 12).CreateCell(3); reportModel.GetRow(14 + j - 12).GetCell(3).SetCellValue(curDate.ToString("yyyy-MM")); if (sesDataScore.Count(p => p.dataMonth == curDate.ToString("yyyy-MM")) > 0 && Funs.GetNewDecimal(sesDataScore.FirstOrDefault(p => p.dataMonth == curDate.ToString("yyyy-MM")).SumScore) > 0) { var yearNums = float.Parse(sesDataScore.FirstOrDefault(p => p.dataMonth == curDate.ToString("yyyy-MM")).SumScore).ToString("0.##"); reportModel.GetRow(14 + j - 12).GetCell(4).SetCellValue(yearNums); //本期合同字体加粗 var sesFo = sesDataScore.FirstOrDefault(p => p.dataMonth == curDate.ToString("yyyy-MM")).FO_NO; if (sesFo == eva.FO_NO) { reportModel.GetRow(14 + j - 12).GetCell(4).CellStyle = styleBlod; } if (Funs.GetNewDecimalOrZero(yearNums) < 60) { s++; } } else { reportModel.GetRow(14 + j - 12).GetCell(4).SetCellValue(""); } } } } else { List yearToDateParam = new List(); yearToDateParam.Add(new SqlParameter("@StartTime", startTime)); yearToDateParam.Add(new SqlParameter("@EndTime", endTime)); yearToDateParam.Add(new SqlParameter("@FoNo", eva.FO_NO)); SqlParameter[] yearToDateParList = yearToDateParam.ToArray(); var sesDataTable = SQLHelper.GetDataTableRunProc("Sp_ContractorEvaluation", yearToDateParList); var sesDataScore = JsonConvert.DeserializeObject>(JsonConvert.SerializeObject(sesDataTable)); // 15行 if (reportModel.GetRow(14) == null) reportModel.CreateRow(14); if (reportModel.GetRow(15) == null) reportModel.CreateRow(15); if (reportModel.GetRow(16) == null) reportModel.CreateRow(16); if (reportModel.GetRow(17) == null) reportModel.CreateRow(17); if (reportModel.GetRow(18) == null) reportModel.CreateRow(18); if (reportModel.GetRow(19) == null) reportModel.CreateRow(19); if (reportModel.GetRow(20) == null) reportModel.CreateRow(20); if (reportModel.GetRow(21) == null) reportModel.CreateRow(21); if (reportModel.GetRow(22) == null) reportModel.CreateRow(22); if (reportModel.GetRow(23) == null) reportModel.CreateRow(23); if (reportModel.GetRow(24) == null) reportModel.CreateRow(24); if (reportModel.GetRow(25) == null) reportModel.CreateRow(25); for (int j = 0; j < 24; j++) { var curDate = DateTime.Parse("" + startDate.Year + "-" + startDate.Month + "-01").AddMonths(j); if (j >= 0 && j < 12) { if (reportModel.GetRow(14 + j).GetCell(0) == null) reportModel.GetRow(14 + j).CreateCell(0); reportModel.GetRow(14 + j).GetCell(0).SetCellValue(curDate.ToString("yyyy-MM")); if (sesDataScore.Count(p => p.dataMonth == curDate.ToString("yyyy-MM")) > 0 && Funs.GetNewDecimal(sesDataScore.FirstOrDefault(p => p.dataMonth == curDate.ToString("yyyy-MM")).SumScore) > 0) { var yearNums = float.Parse(sesDataScore.FirstOrDefault(p => p.dataMonth == curDate.ToString("yyyy-MM")).SumScore).ToString("0.##"); reportModel.GetRow(14 + j).GetCell(2).SetCellValue(yearNums); if (Funs.GetNewDecimalOrZero(yearNums) < 60) { s++; } } else { reportModel.GetRow(14 + j).GetCell(2).SetCellValue(""); } } else { if (reportModel.GetRow(14 + j - 12).GetCell(3) == null) reportModel.GetRow(14 + j - 12).CreateCell(3); reportModel.GetRow(14 + j - 12).GetCell(3).SetCellValue(curDate.ToString("yyyy-MM")); if (sesDataScore.Count(p => p.dataMonth == curDate.ToString("yyyy-MM")) > 0 && Funs.GetNewDecimal(sesDataScore.FirstOrDefault(p => p.dataMonth == curDate.ToString("yyyy-MM")).SumScore) > 0) { var yearNums = float.Parse(sesDataScore.FirstOrDefault(p => p.dataMonth == curDate.ToString("yyyy-MM")).SumScore).ToString("0.##"); reportModel.GetRow(14 + j - 12).GetCell(4).SetCellValue(yearNums); if (Funs.GetNewDecimalOrZero(yearNums) < 60) { s++; } } else { reportModel.GetRow(14 + j - 12).GetCell(4).SetCellValue(""); } } } } if (reportModel.GetRow(13).GetCell(5) == null) reportModel.GetRow(13).CreateCell(5); reportModel.GetRow(13).GetCell(5).SetCellValue(eva.Enumeration);//有无其他潜在承包商?政府类,OEM?若有,请列举 if (reportModel.GetRow(17).GetCell(6) == null) reportModel.GetRow(17).CreateCell(6); reportModel.GetRow(17).GetCell(6).SetCellValue(eva.PriceEvaluation1);//参照1 if (reportModel.GetRow(18).GetCell(6) == null) reportModel.GetRow(18).CreateCell(6); reportModel.GetRow(18).GetCell(6).SetCellValue(eva.PriceEvaluation2);//参照2 //价格水平 if (reportModel.GetRow(21).GetCell(6) == null) reportModel.GetRow(21).CreateCell(6); reportModel.GetRow(21).GetCell(6).SetCellValue(eva.PriceLevel == "1" ? "☑" : "□");//很高 if (reportModel.GetRow(22).GetCell(6) == null) reportModel.GetRow(22).CreateCell(6); reportModel.GetRow(22).GetCell(6).SetCellValue(eva.PriceLevel == "2" ? "☑" : "□");//较高 if (reportModel.GetRow(23).GetCell(6) == null) reportModel.GetRow(23).CreateCell(6); reportModel.GetRow(23).GetCell(6).SetCellValue(eva.PriceLevel == "3" ? "☑" : "□");//适宜 if (reportModel.GetRow(24).GetCell(6) == null) reportModel.GetRow(24).CreateCell(6); reportModel.GetRow(24).GetCell(6).SetCellValue(eva.PriceLevel == "4" ? "☑" : "□");//较低 if (reportModel.GetRow(25).GetCell(6) == null) reportModel.GetRow(25).CreateCell(6); reportModel.GetRow(25).GetCell(6).SetCellValue(eva.PriceLevel == "5" ? "☑" : "□");//很低 if (reportModel.GetRow(27).GetCell(2) == null) reportModel.GetRow(27).CreateCell(2); reportModel.GetRow(27).GetCell(2).SetCellValue(eva.InterviewTimes.ToString());//约谈次数 if (reportModel.GetRow(27).GetCell(5) == null) reportModel.GetRow(27).CreateCell(5); reportModel.GetRow(27).GetCell(5).SetCellValue(eva.ReviewOfFC);//原合同竞标/续签过程回顾 if (reportModel.GetRow(30).GetCell(2) == null) reportModel.GetRow(30).CreateCell(2); reportModel.GetRow(30).GetCell(2).SetCellValue(eva.NCRTimes.ToString());//NCR次数 if (reportModel.GetRow(33).GetCell(2) == null) reportModel.GetRow(33).CreateCell(2); reportModel.GetRow(33).GetCell(2).SetCellValue(eva.RectificationTimes.ToString());//停工整改次数 //框架合同EHSQ审计结果 if (reportModel.GetRow(36).GetCell(2) == null) reportModel.GetRow(36).CreateCell(2); reportModel.GetRow(36).GetCell(2).SetCellValue(eva.GreenTimes.ToString());//绿区次数 if (reportModel.GetRow(36).GetCell(4) == null) reportModel.GetRow(36).CreateCell(4); reportModel.GetRow(36).GetCell(4).SetCellValue(eva.YellowGreenTimes.ToString());//黄绿区次数 if (reportModel.GetRow(37).GetCell(2) == null) reportModel.GetRow(37).CreateCell(2); reportModel.GetRow(37).GetCell(2).SetCellValue(eva.YellowTimes.ToString());//黄区次数 if (reportModel.GetRow(37).GetCell(4) == null) reportModel.GetRow(37).CreateCell(4); reportModel.GetRow(37).GetCell(4).SetCellValue(eva.RedYellowTimes.ToString());//红黄区次数 if (reportModel.GetRow(38).GetCell(2) == null) reportModel.GetRow(38).CreateCell(2); reportModel.GetRow(38).GetCell(2).SetCellValue(eva.RedTimes.ToString());//红区次数 if (reportModel.GetRow(38).GetCell(3) == null) reportModel.GetRow(38).CreateCell(3); reportModel.GetRow(38).GetCell(3).SetCellValue(eva.NotAudit == "√" ? "☑" : "□");//不在审计清单 //41行 if (reportModel.GetRow(40).GetCell(3) == null) reportModel.GetRow(40).CreateCell(3); reportModel.GetRow(40).GetCell(3).SetCellValue(eva.OthersNum.ToString());//其他 //43行 decimal? technicalBonusMalus = eva.TechnicalBonusMalus.HasValue ? Convert.ToDecimal(eva.TechnicalBonusMalus.Value.ToString("0.0")) : 0; if (reportModel.GetRow(42).GetCell(3) == null) reportModel.GetRow(42).CreateCell(3); reportModel.GetRow(42).GetCell(3).SetCellValue(technicalBonusMalus.ToString()+"%");//技术减值 //44行 decimal? safetyBonus = 0; safetyBonus = Funs.GetNewDecimal(eva.SafetyBonus); if (safetyBonus == null) { safetyBonus = 0; } if (reportModel.GetRow(43).GetCell(3) == null) reportModel.GetRow(43).CreateCell(3); reportModel.GetRow(43).GetCell(3).SetCellValue(safetyBonus.HasValue ? safetyBonus.Value.ToString("0.0") + "%" : "0");//安全业绩加值 //45行 decimal? totalSocre = technicalBonusMalus + safetyBonus; if (reportModel.GetRow(44).GetCell(3) == null) reportModel.GetRow(44).CreateCell(3); reportModel.GetRow(44).GetCell(3).SetCellValue(totalSocre.HasValue ? totalSocre.ToString() + "%" : "");//Total Score (Technical and Safety) //48行 string proposed = string.Empty; string rs = string.Empty; if (s >= 3 && eva.NCRTimes >= 3) { rs = "序号1:该合同累计3次月度评估低于60分, 不得参与下轮合同\r\n序号2:该合同累计三个NCR提前终止合同且不得参与下轮合同"; } else if (s >= 3) { rs = "序号1:该合同累计3次月度评估低于60分, 不得参与下轮合同"; } else if (eva.NCRTimes >= 3) { rs = "序号1:该合同累计三个NCR提前终止合同且不得参与下轮合同"; } if (!string.IsNullOrEmpty(eva.Proposed) && !string.IsNullOrEmpty(rs)) { proposed = rs + "\r\n" + eva.Proposed; } else if (!string.IsNullOrEmpty(eva.Proposed) && string.IsNullOrEmpty(rs)) { proposed = eva.Proposed; } else { proposed = rs; } if (reportModel.GetRow(47).GetCell(0) == null) reportModel.GetRow(47).CreateCell(0); reportModel.GetRow(47).GetCell(0).SetCellValue(proposed);//合同管理小组对该承包商在本合同期表现的评价 //if (reportModel.GetRow(21).GetCell(6) == null) reportModel.GetRow(21).CreateCell(6); //if (reportModel.GetRow(22).GetCell(6) == null) reportModel.GetRow(22).CreateCell(6); //if (reportModel.GetRow(23).GetCell(6) == null) reportModel.GetRow(23).CreateCell(6); //if (reportModel.GetRow(24).GetCell(6) == null) reportModel.GetRow(24).CreateCell(6); //if (reportModel.GetRow(25).GetCell(6) == null) reportModel.GetRow(25).CreateCell(6); //string priceLevel = string.Empty; //if (eva.PriceLevel == "1") //{ // reportModel.GetRow(22).GetCell(6).SetCellValue(txtNo); // reportModel.GetRow(22).GetCell(6).CellStyle.SetFont(content_Font); // reportModel.GetRow(23).GetCell(6).SetCellValue(txtNo); // reportModel.GetRow(23).GetCell(6).CellStyle.SetFont(content_Font); // reportModel.GetRow(24).GetCell(6).SetCellValue(txtNo); // reportModel.GetRow(24).GetCell(6).CellStyle.SetFont(content_Font); // reportModel.GetRow(25).GetCell(6).SetCellValue(txtNo); // reportModel.GetRow(25).GetCell(6).CellStyle.SetFont(content_Font); //} //if (eva.PriceLevel == "2") //{ // reportModel.GetRow(20).GetCell(6).SetCellValue(txtNo); // reportModel.GetRow(20).GetCell(6).CellStyle.SetFont(content_Font); // reportModel.GetRow(22).GetCell(6).SetCellValue(txtNo); // reportModel.GetRow(22).GetCell(6).CellStyle.SetFont(content_Font); // reportModel.GetRow(23).GetCell(6).SetCellValue(txtNo); // reportModel.GetRow(23).GetCell(6).CellStyle.SetFont(content_Font); // reportModel.GetRow(24).GetCell(6).SetCellValue(txtNo); // reportModel.GetRow(24).GetCell(6).CellStyle.SetFont(content_Font); //} //if (eva.PriceLevel == "3") //{ // reportModel.GetRow(21).GetCell(6).SetCellValue(txtNo); // reportModel.GetRow(21).GetCell(6).CellStyle.SetFont(content_Font); // reportModel.GetRow(20).GetCell(6).SetCellValue(txtNo); // reportModel.GetRow(20).GetCell(6).CellStyle.SetFont(content_Font); // reportModel.GetRow(23).GetCell(6).SetCellValue(txtNo); // reportModel.GetRow(23).GetCell(6).CellStyle.SetFont(content_Font); // reportModel.GetRow(24).GetCell(6).SetCellValue(txtNo); // reportModel.GetRow(24).GetCell(6).CellStyle.SetFont(content_Font); //} //if (eva.PriceLevel == "4") //{ // reportModel.GetRow(21).GetCell(6).SetCellValue(txtNo); // reportModel.GetRow(21).GetCell(6).CellStyle.SetFont(content_Font); // reportModel.GetRow(22).GetCell(6).SetCellValue(txtNo); // reportModel.GetRow(22).GetCell(6).CellStyle.SetFont(content_Font); // reportModel.GetRow(20).GetCell(6).SetCellValue(txtNo); // reportModel.GetRow(20).GetCell(6).CellStyle.SetFont(content_Font); // reportModel.GetRow(24).GetCell(6).SetCellValue(txtNo); // reportModel.GetRow(24).GetCell(6).CellStyle.SetFont(content_Font); //} //if (eva.PriceLevel == "5") //{ // reportModel.GetRow(21).GetCell(6).SetCellValue(txtNo); // reportModel.GetRow(21).GetCell(6).CellStyle.SetFont(content_Font); // reportModel.GetRow(22).GetCell(6).SetCellValue(txtNo); // reportModel.GetRow(22).GetCell(6).CellStyle.SetFont(content_Font); // reportModel.GetRow(23).GetCell(6).SetCellValue(txtNo); // reportModel.GetRow(23).GetCell(6).CellStyle.SetFont(content_Font); // reportModel.GetRow(20).GetCell(6).SetCellValue(txtNo); // reportModel.GetRow(20).GetCell(6).CellStyle.SetFont(content_Font); //} //if (string.IsNullOrEmpty(eva.PriceLevel)) //{ // reportModel.GetRow(20).GetCell(6).SetCellValue(txtNo); // reportModel.GetRow(20).GetCell(6).CellStyle.SetFont(content_Font); // reportModel.GetRow(21).GetCell(6).SetCellValue(txtNo); // reportModel.GetRow(21).GetCell(6).CellStyle.SetFont(content_Font); // reportModel.GetRow(22).GetCell(6).SetCellValue(txtNo); // reportModel.GetRow(22).GetCell(6).CellStyle.SetFont(content_Font); // reportModel.GetRow(23).GetCell(6).SetCellValue(txtNo); // reportModel.GetRow(23).GetCell(6).CellStyle.SetFont(content_Font); // reportModel.GetRow(24).GetCell(6).SetCellValue(txtNo); // reportModel.GetRow(24).GetCell(6).CellStyle.SetFont(content_Font); //} // 28 //if (reportModel.GetRow(26) == null) reportModel.CreateRow(26); //if (reportModel.GetRow(27) == null) reportModel.CreateRow(27); //if (reportModel.GetRow(28) == null) reportModel.CreateRow(28); //if (reportModel.GetRow(29) == null) reportModel.CreateRow(29); //if (reportModel.GetRow(31) == null) reportModel.CreateRow(31); //if (reportModel.GetRow(32) == null) reportModel.CreateRow(32); //if (reportModel.GetRow(33) == null) reportModel.CreateRow(33); //if (reportModel.GetRow(34) == null) reportModel.CreateRow(34); //if (reportModel.GetRow(35) == null) reportModel.CreateRow(35); //if (reportModel.GetRow(36) == null) reportModel.CreateRow(36); //if (reportModel.GetRow(37) == null) reportModel.CreateRow(37); //if (reportModel.GetRow(38) == null) reportModel.CreateRow(38); //if (reportModel.GetRow(39) == null) reportModel.CreateRow(39); //if (reportModel.GetRow(42) == null) reportModel.CreateRow(42); //if (reportModel.GetRow(26).GetCell(5) == null) reportModel.GetRow(26).CreateCell(5); //reportModel.GetRow(26).GetCell(5).SetCellValue(eva.ReviewOfFC); //if (eva.IsInquiry == true) //{ // reportModel.GetRow(27).GetCell(1).SetCellValue(eva.InquiryNum != null ? eva.InquiryNum.Value.ToString() : "0"); // reportModel.GetRow(26).GetCell(2).SetCellValue(txtNo); // reportModel.GetRow(26).GetCell(2).CellStyle.SetFont(content_Font); //} //else if (eva.IsInquiry == false) //{ // reportModel.GetRow(27).GetCell(1).SetCellValue(""); // reportModel.GetRow(26).GetCell(0).SetCellValue(txtNo); // reportModel.GetRow(26).GetCell(0).CellStyle.SetFont(content_Font); //} //else //{ // reportModel.GetRow(26).GetCell(0).SetCellValue(txtNo); // reportModel.GetRow(26).GetCell(0).CellStyle.SetFont(content_Font); // reportModel.GetRow(26).GetCell(2).SetCellValue(txtNo); // reportModel.GetRow(26).GetCell(2).CellStyle.SetFont(content_Font); //} //if (eva.NCRIsReview == true) //{ // reportModel.GetRow(30).GetCell(1).SetCellValue(eva.NCRReviewNum != null ? eva.NCRReviewNum.Value.ToString() : "0"); // reportModel.GetRow(29).GetCell(2).SetCellValue(txtNo); // reportModel.GetRow(29).GetCell(2).CellStyle.SetFont(content_Font); //} //else if (eva.NCRIsReview == false) //{ // reportModel.GetRow(30).GetCell(1).SetCellValue(""); // reportModel.GetRow(29).GetCell(0).SetCellValue(txtNo); // reportModel.GetRow(29).GetCell(0).CellStyle.SetFont(content_Font); //} //else //{ // reportModel.GetRow(29).GetCell(0).SetCellValue(txtNo); // reportModel.GetRow(29).GetCell(0).CellStyle.SetFont(content_Font); // reportModel.GetRow(29).GetCell(2).SetCellValue(txtNo); // reportModel.GetRow(29).GetCell(2).CellStyle.SetFont(content_Font); //} //if (eva.AuditResult == "1") //{ // reportModel.GetRow(32).GetCell(2).SetCellValue(txtNo); // reportModel.GetRow(32).GetCell(2).CellStyle.SetFont(content_Font); // reportModel.GetRow(33).GetCell(0).SetCellValue(txtNo); // reportModel.GetRow(33).GetCell(0).CellStyle.SetFont(content_Font); // reportModel.GetRow(33).GetCell(2).SetCellValue(txtNo); // reportModel.GetRow(33).GetCell(2).CellStyle.SetFont(content_Font); // reportModel.GetRow(34).GetCell(0).SetCellValue(txtNo); // reportModel.GetRow(34).GetCell(0).CellStyle.SetFont(content_Font); // reportModel.GetRow(34).GetCell(2).SetCellValue(txtNo); // reportModel.GetRow(34).GetCell(2).CellStyle.SetFont(content_Font); //} //if (eva.AuditResult == "2") //{ // reportModel.GetRow(32).GetCell(0).SetCellValue(txtNo); // reportModel.GetRow(32).GetCell(0).CellStyle.SetFont(content_Font); // reportModel.GetRow(33).GetCell(0).SetCellValue(txtNo); // reportModel.GetRow(33).GetCell(0).CellStyle.SetFont(content_Font); // reportModel.GetRow(33).GetCell(2).SetCellValue(txtNo); // reportModel.GetRow(33).GetCell(2).CellStyle.SetFont(content_Font); // reportModel.GetRow(34).GetCell(0).SetCellValue(txtNo); // reportModel.GetRow(34).GetCell(0).CellStyle.SetFont(content_Font); // reportModel.GetRow(34).GetCell(2).SetCellValue(txtNo); // reportModel.GetRow(34).GetCell(2).CellStyle.SetFont(content_Font); //} //if (eva.AuditResult == "3") //{ // reportModel.GetRow(32).GetCell(0).SetCellValue(txtNo); // reportModel.GetRow(32).GetCell(0).CellStyle.SetFont(content_Font); // reportModel.GetRow(32).GetCell(2).SetCellValue(txtNo); // reportModel.GetRow(32).GetCell(2).CellStyle.SetFont(content_Font); // reportModel.GetRow(33).GetCell(2).SetCellValue(txtNo); // reportModel.GetRow(33).GetCell(2).CellStyle.SetFont(content_Font); // reportModel.GetRow(34).GetCell(0).SetCellValue(txtNo); // reportModel.GetRow(34).GetCell(0).CellStyle.SetFont(content_Font); // reportModel.GetRow(34).GetCell(2).SetCellValue(txtNo); // reportModel.GetRow(34).GetCell(2).CellStyle.SetFont(content_Font); //} //if (eva.AuditResult == "4") //{ // reportModel.GetRow(32).GetCell(0).SetCellValue(txtNo); // reportModel.GetRow(32).GetCell(0).CellStyle.SetFont(content_Font); // reportModel.GetRow(32).GetCell(2).SetCellValue(txtNo); // reportModel.GetRow(32).GetCell(2).CellStyle.SetFont(content_Font); // reportModel.GetRow(33).GetCell(0).SetCellValue(txtNo); // reportModel.GetRow(33).GetCell(0).CellStyle.SetFont(content_Font); // reportModel.GetRow(34).GetCell(0).SetCellValue(txtNo); // reportModel.GetRow(34).GetCell(0).CellStyle.SetFont(content_Font); // reportModel.GetRow(34).GetCell(2).SetCellValue(txtNo); // reportModel.GetRow(34).GetCell(2).CellStyle.SetFont(content_Font); //} //if (eva.AuditResult == "5") //{ // reportModel.GetRow(32).GetCell(0).SetCellValue(txtNo); // reportModel.GetRow(32).GetCell(0).CellStyle.SetFont(content_Font); // reportModel.GetRow(32).GetCell(2).SetCellValue(txtNo); // reportModel.GetRow(32).GetCell(2).CellStyle.SetFont(content_Font); // reportModel.GetRow(33).GetCell(0).SetCellValue(txtNo); // reportModel.GetRow(33).GetCell(0).CellStyle.SetFont(content_Font); // reportModel.GetRow(33).GetCell(2).SetCellValue(txtNo); // reportModel.GetRow(33).GetCell(2).CellStyle.SetFont(content_Font); // reportModel.GetRow(34).GetCell(2).SetCellValue(txtNo); // reportModel.GetRow(34).GetCell(2).CellStyle.SetFont(content_Font); //} //if (eva.AuditResult == "6") //{ // reportModel.GetRow(32).GetCell(0).SetCellValue(txtNo); // reportModel.GetRow(32).GetCell(0).CellStyle.SetFont(content_Font); // reportModel.GetRow(32).GetCell(2).SetCellValue(txtNo); // reportModel.GetRow(32).GetCell(2).CellStyle.SetFont(content_Font); // reportModel.GetRow(33).GetCell(0).SetCellValue(txtNo); // reportModel.GetRow(33).GetCell(0).CellStyle.SetFont(content_Font); // reportModel.GetRow(33).GetCell(2).SetCellValue(txtNo); // reportModel.GetRow(33).GetCell(2).CellStyle.SetFont(content_Font); // reportModel.GetRow(34).GetCell(0).SetCellValue(txtNo); // reportModel.GetRow(34).GetCell(0).CellStyle.SetFont(content_Font); //} //if (string.IsNullOrEmpty(eva.AuditResult)) //{ // reportModel.GetRow(32).GetCell(0).SetCellValue(txtNo); // reportModel.GetRow(32).GetCell(0).CellStyle.SetFont(content_Font); // reportModel.GetRow(32).GetCell(2).SetCellValue(txtNo); // reportModel.GetRow(32).GetCell(2).CellStyle.SetFont(content_Font); // reportModel.GetRow(33).GetCell(0).SetCellValue(txtNo); // reportModel.GetRow(33).GetCell(0).CellStyle.SetFont(content_Font); // reportModel.GetRow(33).GetCell(2).SetCellValue(txtNo); // reportModel.GetRow(33).GetCell(2).CellStyle.SetFont(content_Font); // reportModel.GetRow(34).GetCell(0).SetCellValue(txtNo); // reportModel.GetRow(34).GetCell(0).CellStyle.SetFont(content_Font); // reportModel.GetRow(34).GetCell(2).SetCellValue(txtNo); // reportModel.GetRow(34).GetCell(2).CellStyle.SetFont(content_Font); //} //if (eva.IsOthers == true) //{ // reportModel.GetRow(37).GetCell(1).SetCellValue(eva.OtherDef); // reportModel.GetRow(36).GetCell(2).SetCellValue(txtNo); // reportModel.GetRow(36).GetCell(2).CellStyle.SetFont(content_Font); //} //else if (eva.IsOthers == false) //{ // reportModel.GetRow(36).GetCell(0).SetCellValue(txtNo); // reportModel.GetRow(36).GetCell(0).CellStyle.SetFont(content_Font); //} //else //{ // reportModel.GetRow(36).GetCell(0).SetCellValue(txtNo); // reportModel.GetRow(36).GetCell(0).CellStyle.SetFont(content_Font); // reportModel.GetRow(36).GetCell(2).SetCellValue(txtNo); // reportModel.GetRow(36).GetCell(2).CellStyle.SetFont(content_Font); //} //if (reportModel.GetRow(38).GetCell(3) == null) reportModel.GetRow(38).CreateCell(3); //reportModel.GetRow(38).GetCell(3).SetCellValue(eva.TechnicalBonus); //if (reportModel.GetRow(39).GetCell(3) == null) reportModel.GetRow(39).CreateCell(3); //reportModel.GetRow(39).GetCell(3).SetCellValue(eva.SafetyBonus); //reportModel.GetRow(42).GetCell(0).SetCellValue(eva.Proposed); } #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=承包商评估表_" + 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(); } #endregion /// /// Grid行双击事件 /// /// /// protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e) { btnEdit_Click(null, null); } #region 所需实体 /// /// 实体 /// public class YearToDateModel { public string FO_NO { get; set; } = string.Empty; public string dataMonth { get; set; } = string.Empty; public string SumScore { get; set; } = string.Empty; } #endregion #region 权限设置 /// /// 菜单按钮权限 /// private void GetButtonPower() { var buttonList = BLL.CommonService.GetAllButtonList(this.CurrUser.UserId, BLL.Const.ContractorEvaluationMenuId); if (buttonList.Count() > 0) { if (buttonList.Contains(BLL.Const.BtnOut)) { this.btnExport.Hidden = false; } if (buttonList.Contains(BLL.Const.BtnSend)) { this.btnSendEmail.Hidden = false; } } } #endregion } }