using BLL; using BLL.Common; using FineUIPro.Web.common.SysManage; using Model; using Newtonsoft.Json; using NPOI.SS.Formula.Functions; using System; using System.Collections.Generic; using System.Data; using System.Data.SqlClient; using System.Drawing; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using static NPOI.POIFS.Crypt.CryptoFunctions; namespace FineUIPro.Web.Evaluation { public partial class EvaluationNew : PageBase { protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (CurrUser.Account == Const.Gly) { btnAutoEvaluation.Hidden = false; drpUser.Hidden = false; drpContractNo.Hidden = false; btnUndo.Hidden = false; string strSql = @"SELECT t.UserId,u.UserName FROM (SELECT UserId FROM dbo.FC_Score WHERE YEAR(DateIn)=YEAR(GETDATE()) AND MONTH(DateIn)=MONTH(GETDATE()) AND DAY(DateIn)<12 GROUP BY UserId) t LEFT JOIN dbo.Sys_User u ON u.UserId = t.UserId ORDER BY u.UserName"; DataTable dt = SQLHelper.GetDataTableRunText(strSql, null); this.drpUser.DataTextField = "UserName"; this.drpUser.DataValueField = "UserId"; this.drpUser.DataSource = dt; this.drpUser.DataBind(); Funs.FineUIPleaseSelect(this.drpUser); } var userScoreList = Funs.DB.EmailUserView.Where(p => p.UserId == CurrUser.UserId.Trim() && p.IsSafetyEvaluate == 0).ToList(); var depScoreList = Funs.DB.EmailUserLeaderView.Where(p => p.UserId == CurrUser.UserId.Trim() && p.IsSafetyEvaluate == 0).ToList(); if (userScoreList.Count() > 0 && depScoreList.Count() > 0) { rdbUserType.Hidden = false; rdbUserType.SelectedValue = "1"; } else { rdbUserType.Hidden = true; if (depScoreList.Count() > 0) { rdbUserType.SelectedValue = "2"; } else { rdbUserType.SelectedValue = "1"; } } BindGrid(); } } #region 查询提交绑定 /// /// /// /// /// protected void drpUser_OnSelectedIndexChanged(object sender, EventArgs e) { if (drpUser.SelectedValue != Const._Null) { string strSql = @"SELECT DISTINCT Contract_No FROM dbo.FC_Score WHERE YEAR(DateIn)=YEAR(GETDATE()) AND MONTH(DateIn)=MONTH(GETDATE()) AND DAY(DateIn)<12 AND UserId=@UserId"; List listStr = new List(); listStr.Add(new SqlParameter("@UserId", drpUser.SelectedValue)); SqlParameter[] parameter = listStr.ToArray(); DataTable dt = SQLHelper.GetDataTableRunText(strSql, parameter); this.drpContractNo.DataTextField = "Contract_No"; this.drpContractNo.DataValueField = "Contract_No"; this.drpContractNo.DataSource = dt; this.drpContractNo.DataBind(); Funs.FineUIPleaseSelect(this.drpContractNo); } } /// /// /// /// /// protected void btnUndo_OnClick(object sender, EventArgs e) { if (this.drpContractNo.SelectedValue != Const._Null) { var log = from x in Funs.DB.Score_JournalEvaluation where x.Contract_No == drpContractNo.SelectedText && x.Evaluate_UserId == drpUser.SelectedValue && x.Evaluate_Time.Value.Year == DateTime.Now.Year && x.Evaluate_Time.Value.Month == DateTime.Now.Month select x; var score = from x in Funs.DB.FC_Score where x.Contract_No == drpContractNo.SelectedValue && x.UserId == drpUser.SelectedValue && x.DateIn.Value.Year == DateTime.Now.Year && x.DateIn.Value.Month == DateTime.Now.Month select x; Funs.DB.Score_JournalEvaluation.DeleteAllOnSubmit(log); Funs.DB.FC_Score.DeleteAllOnSubmit(score); Funs.DB.SubmitChanges(); Alert.ShowInParent("Contract:" + drpContractNo.SelectedText + " Already Undo Evaluation! "); } } #endregion #region 绑定Grid1 /// /// 绑定Grid1 /// private void BindGrid() { var bridList = new List(); var userScoreList = new List(); var depScoreList = new List(); //用户 User if (rdbUserType.SelectedValue == "1") { userScoreList = Funs.DB.EmailUserView.Where(p => p.UserId == CurrUser.UserId.Trim() && p.IsSafetyEvaluate == 0).ToList(); if (userScoreList.Count > 0) { foreach (var item in userScoreList) { EmailEvaluationModel bridModel = new EmailEvaluationModel(); bridModel.ConGuid = item.ConGuid.Value; bridModel.UserId = item.UserId; bridModel.UserName = item.UserName; bridModel.FO_NO = item.FO_NO; bridModel.Discipline = item.Discipline; bridModel.Email = item.Email; bridModel.UserType = item.UserType; bridModel.DateYear = item.DateYear.Value; bridModel.DateMonth = item.DateMonth.Value; bridModel.EmailType = item.EmailType; bridModel.EmailName = item.EmailName; bridModel.IsEvaluateType = item.IsEvaluateType; bridModel.IsEvaluateName = item.IsEvaluateName; bridModel.EvaluateType = "User"; bridList.Add(bridModel); } } } //部门 Dep if (rdbUserType.SelectedValue == "2") { depScoreList = Funs.DB.EmailUserLeaderView.Where(p => p.UserId == CurrUser.UserId.Trim() && p.IsSafetyEvaluate == 0).ToList(); if (depScoreList.Count > 0) { var gropDepFoNo = depScoreList.GroupBy(p => p.FO_NO).Select(p => new { FO_NO = p.Key }).ToList(); foreach (var item in gropDepFoNo) { var adddepScore = depScoreList.FirstOrDefault(p => p.FO_NO == item.FO_NO); if (adddepScore != null) { //判断,如果是部门,并且FO在用户里面没有,然后进行增加操作 EmailEvaluationModel bridModel = new EmailEvaluationModel(); bridModel.ConGuid = adddepScore.ConGuid.Value; bridModel.UserId = adddepScore.UserId; bridModel.UserName = adddepScore.UserName; bridModel.FO_NO = adddepScore.FO_NO; bridModel.Discipline = adddepScore.Discipline; bridModel.Email = adddepScore.Email; bridModel.UserType = adddepScore.UserType; bridModel.DateYear = adddepScore.DateYear.Value; bridModel.DateMonth = adddepScore.DateMonth.Value; bridModel.EmailType = adddepScore.EmailType; bridModel.EmailName = adddepScore.EmailName; bridModel.IsEvaluateType = adddepScore.IsEvaluateType; bridModel.IsEvaluateName = adddepScore.IsEvaluateName; bridModel.EvaluateType = "Dep"; bridList.Add(bridModel); } } } } //绑定数据 if (bridList.Count > 0) { //小星星赋值 var foList = bridList.Select(p => p.FO_NO); var fcScoreList = Funs.DB.FC_Score.Where(p => foList.Contains(p.Contract_No) && p.DateIn.Value.Year == DateTime.Now.Year && p.DateIn.Value.Month == DateTime.Now.Month && p.UserId == CurrUser.UserId.Trim()).ToList(); bridList.ForEach(p => { if (fcScoreList != null && fcScoreList.Count > 0) { if (p.EvaluateType == "User") { //用户绑定 var userScoreModel = fcScoreList.FirstOrDefault(x => x.Role == "User" && x.Contract_No == p.FO_NO); if (userScoreModel != null) { p.Score1 = userScoreModel.Score1 / 2; p.Score2 = userScoreModel.Score2 / 2; p.Score3 = userScoreModel.Score3 / 2; p.Score4 = userScoreModel.Score4 / 2; p.Score5 = userScoreModel.Score5 / 2; p.Score6 = userScoreModel.Score6 / 2; } } else { //部门绑定 var depScoreModel = fcScoreList.FirstOrDefault(x => x.Role == "Dep" && x.Contract_No == p.FO_NO); if (depScoreModel != null) { p.Score1 = depScoreModel.Score1; p.Score2 = depScoreModel.Score2; p.Score3 = depScoreModel.Score3; p.Score4 = depScoreModel.Score4; p.Score5 = depScoreModel.Score5; p.Score6 = depScoreModel.Score6; } } } }); Grid1.DataSource = bridList.OrderBy(x => x.FO_NO).ToList(); Grid1.DataBind(); #region 部门隐藏和显示小星星 if (Grid1.Rows.Count > 0) { var contractorList = Funs.DB.View_FC_SESRelatedData.Where(p => foList.Contains(p.FO_NO)).ToList(); for (int i = 0; i < Grid1.Rows.Count; i++) { System.Web.UI.WebControls.Label lblContractor = Grid1.Rows[i].FindControl("lblContractor") as System.Web.UI.WebControls.Label; HiddenField hidisDepScore1 = Grid1.Rows[i].FindControl("hidisDepScore1") as HiddenField; HiddenField hidisDepScore2 = Grid1.Rows[i].FindControl("hidisDepScore2") as HiddenField; HiddenField hidisDepScore3 = Grid1.Rows[i].FindControl("hidisDepScore3") as HiddenField; HiddenField hidisDepScore4 = Grid1.Rows[i].FindControl("hidisDepScore4") as HiddenField; HiddenField hidisDepScore5 = Grid1.Rows[i].FindControl("hidisDepScore5") as HiddenField; HiddenField hidisDepScore6 = Grid1.Rows[i].FindControl("hidisDepScore6") as HiddenField; HiddenField hidMaxScore1 = Grid1.Rows[i].FindControl("hidMaxScore1") as HiddenField; HiddenField hidMaxScore2 = Grid1.Rows[i].FindControl("hidMaxScore2") as HiddenField; HiddenField hidMsg = Grid1.Rows[i].FindControl("hidMsg") as HiddenField; var foNo = Grid1.Rows[i].DataKeys[0].ToString(); var isEvaluateType = Grid1.Rows[i].DataKeys[1].ToString(); var evaluateType = Grid1.Rows[i].DataKeys[2].ToString(); var userType = Grid1.Rows[i].DataKeys[3].ToString(); if (contractorList != null && contractorList.Count(p => p.FO_NO == foNo) > 0) { var contractModel = contractorList.FirstOrDefault(p => p.FO_NO == foNo); if (contractModel != null) { lblContractor.Text = contractModel.Contractor; } } // 违章扣分 if (userType == "1") { var sesList = Funs.DB.FC_SESReportView.Where(p => p.FO_NO == foNo && p.Requisitioner == CurrUser.Account).OrderByDescending(t => t.ViolationDegree).FirstOrDefault(); switch (sesList?.ViolationDegree) { case "1": hidMaxScore1.Text = "4.5"; hidMsg.Text = $"当前合同号:{foNo}下,SES:{sesList?.SES_No}存在一般违章,"; break; case "2": hidMaxScore1.Text = "4"; hidMsg.Text = $"当前合同号:{foNo}下,SES:{sesList?.SES_No}存在严重违章,"; break; case "3": hidMaxScore1.Text = "3.5"; hidMsg.Text = $"当前合同号:{foNo}下,SES:{sesList?.SES_No}存在零容忍违章,"; break; default: hidMaxScore1.Text = "5"; hidMsg.Text = ""; break; } } else { var sesList = Funs.DB.FC_SESReportView.AsQueryable(); var setList = Funs.DB.Sys_User.Where(p => new string[] { Const.Role_CTSSId, Const.Role_CTSCId, Const.Role_CTMTId }.Contains(p.RoleId) && p.UserId == CurrUser.UserId).ToList(); if (setList.Count > 0) sesList = sesList.Where(p => p.FO_NO == foNo && p.Requisitioner != "" && p.Requisitioner != null).OrderByDescending(t=>t.ViolationDegree); else sesList = sesList.Where(p => p.FO_NO == foNo && (p.MainCoordinatorUser == CurrUser.Account || p.ContractAdminUser == CurrUser.Account || p.UserRepresentativeUser == CurrUser.Account)).OrderByDescending(t => t.ViolationDegree); var max = sesList.FirstOrDefault(); switch (max?.ViolationDegree) { case "1": hidMaxScore2.Text = "4.5"; hidMsg.Text = $"当前合同号:{foNo}下,SES:{max?.SES_No}存在一般违章,"; break; case "2": hidMaxScore2.Text = "4"; hidMsg.Text = $"当前合同号:{foNo}下,SES:{max?.SES_No}存在严重违章,"; break; case "3": hidMaxScore2.Text = "3.5"; hidMsg.Text = $"当前合同号:{foNo}下,SES:{max?.SES_No}存在零容忍违章,"; break; default: hidMaxScore2.Text = "5"; hidMsg.Text = ""; break; } } if (isEvaluateType == "1") { Grid1.Rows[i].RowCssClass = "color1"; } GridColumn Score1 = Grid1.FindColumn("Score1"); GridColumn Score2 = Grid1.FindColumn("Score2"); GridColumn Score3 = Grid1.FindColumn("Score3"); GridColumn Score4 = Grid1.FindColumn("Score4"); GridColumn Score5 = Grid1.FindColumn("Score5"); GridColumn Score6 = Grid1.FindColumn("Score6"); //判断部门是否存在数据 if (depScoreList.Count(p => p.FO_NO == foNo) > 0 && evaluateType == "Dep") { //CTS/S UserType:5 if (depScoreList.Count(p => p.FO_NO == foNo && p.UserType == 5) > 0) { //Score1.Hidden = false; hidisDepScore1.Text = "1"; } else { //Score1.Hidden = true; hidisDepScore1.Text = "0"; Grid1.Rows[i].CellCssClasses[Score1.ColumnIndex] = "ycl"; } //CTS/C UserType:6 if (depScoreList.Count(p => p.FO_NO == foNo && p.UserType == 6) > 0) { //Score2.Hidden = false; hidisDepScore2.Text = "1"; } else { //Score2.Hidden = true; hidisDepScore2.Text = "0"; Grid1.Rows[i].CellCssClasses[Score2.ColumnIndex] = "ycl"; } //Main Coordinator UserType: 2 if (depScoreList.Count(p => p.FO_NO == foNo && p.UserType == 2) > 0) { //Score3.Hidden = false; hidisDepScore3.Text = "1"; } else { //Score3.Hidden = true; hidisDepScore3.Text = "0"; Grid1.Rows[i].CellCssClasses[Score3.ColumnIndex] = "ycl"; } //User Representative UserType:3 if (depScoreList.Count(p => p.FO_NO == foNo && p.UserType == 3) > 0) { //Score4.Hidden = false; hidisDepScore4.Text = "1"; } else { //Score4.Hidden = true; hidisDepScore4.Text = "0"; Grid1.Rows[i].CellCssClasses[Score4.ColumnIndex] = "ycl"; } //CTM/T UserType:7 if (depScoreList.Count(p => p.FO_NO == foNo && p.UserType == 7) > 0) { //Score5.Hidden = false; hidisDepScore5.Text = "1"; } else { //Score5.Hidden = true; hidisDepScore5.Text = "0"; Grid1.Rows[i].CellCssClasses[Score5.ColumnIndex] = "ycl"; } //CTE/D UserType:4 if (depScoreList.Count(p => p.FO_NO == foNo && p.UserType == 4) > 0) { //Score6.Hidden = false; hidisDepScore6.Text = "1"; } else { //Score6.Hidden = true; hidisDepScore6.Text = "0"; Grid1.Rows[i].CellCssClasses[Score6.ColumnIndex] = "ycl"; } } else { Score1.Hidden = false; Score2.Hidden = false; Score3.Hidden = false; Score4.Hidden = false; Score5.Hidden = false; Score6.Hidden = false; } } } #endregion } //更改表头 if (rdbUserType.SelectedValue == "1") { //一级 Grid1.Columns[3].HeaderText = "User(Requisitioner) 用户(请购人与相关工程师线下讨论后再进行评分)"; //二级 ((GroupField)Grid1.Columns[3]).Columns[0].HeaderText = "工作准备"; ((GroupField)Grid1.Columns[3]).Columns[1].HeaderText = "工作表现"; ((GroupField)Grid1.Columns[3]).Columns[2].HeaderText = "EHSS管理"; ((GroupField)Grid1.Columns[3]).Columns[3].HeaderText = "质量控制"; ((GroupField)Grid1.Columns[3]).Columns[4].HeaderText = "时间管理"; ((GroupField)Grid1.Columns[3]).Columns[5].HeaderText = "文档管理"; //三级 ((GroupField)((GroupField)Grid1.Columns[3]).Columns[0]).Columns[0].HeaderText = "Preparation"; ((GroupField)((GroupField)Grid1.Columns[3]).Columns[1]).Columns[0].HeaderText = "Performance"; ((GroupField)((GroupField)Grid1.Columns[3]).Columns[2]).Columns[0].HeaderText = "EHSS"; ((GroupField)((GroupField)Grid1.Columns[3]).Columns[3]).Columns[0].HeaderText = "Quality Control"; ((GroupField)((GroupField)Grid1.Columns[3]).Columns[4]).Columns[0].HeaderText = "Timeline Management"; ((GroupField)((GroupField)Grid1.Columns[3]).Columns[5]).Columns[0].HeaderText = "Documentation"; ((GroupField)((GroupField)Grid1.Columns[3]).Columns[0]).Columns[0].HeaderTextAlign = TextAlign.Center; ((GroupField)((GroupField)Grid1.Columns[3]).Columns[1]).Columns[0].HeaderTextAlign = TextAlign.Center; ((GroupField)((GroupField)Grid1.Columns[3]).Columns[2]).Columns[0].HeaderTextAlign = TextAlign.Center; ((GroupField)((GroupField)Grid1.Columns[3]).Columns[3]).Columns[0].HeaderTextAlign = TextAlign.Center; ((GroupField)((GroupField)Grid1.Columns[3]).Columns[4]).Columns[0].HeaderTextAlign = TextAlign.Center; ((GroupField)((GroupField)Grid1.Columns[3]).Columns[5]).Columns[0].HeaderTextAlign = TextAlign.Center; Grid1.Columns[3].HeaderToolTip = ((GroupField)Grid1.Columns[3]).Columns[0].HeaderToolTip = ((GroupField)Grid1.Columns[3]).Columns[1].HeaderToolTip = ((GroupField)Grid1.Columns[3]).Columns[2].HeaderToolTip = ((GroupField)Grid1.Columns[3]).Columns[3].HeaderToolTip = ((GroupField)Grid1.Columns[3]).Columns[4].HeaderToolTip = ((GroupField)Grid1.Columns[3]).Columns[5].HeaderToolTip = ((GroupField)((GroupField)Grid1.Columns[3]).Columns[0]).Columns[0].HeaderToolTip = ((GroupField)((GroupField)Grid1.Columns[3]).Columns[1]).Columns[0].HeaderToolTip = ((GroupField)((GroupField)Grid1.Columns[3]).Columns[2]).Columns[0].HeaderToolTip = ((GroupField)((GroupField)Grid1.Columns[3]).Columns[3]).Columns[0].HeaderToolTip = ((GroupField)((GroupField)Grid1.Columns[3]).Columns[4]).Columns[0].HeaderToolTip = ((GroupField)((GroupField)Grid1.Columns[3]).Columns[5]).Columns[0].HeaderToolTip = "10分 安全表现卓越 8分 安全表现较好无违章 6分 安全表现可接受有一般违章 4分 安全表现一般有严重违章 2分 安全表现差有零容忍违章 0分 安全表现非常差发生严重事故或违法行为"; } else { //一级 Grid1.Columns[3].HeaderText = "Functional Department 职能部门"; //二级 ((GroupField)Grid1.Columns[3]).Columns[0].HeaderText = "安全监管"; ((GroupField)Grid1.Columns[3]).Columns[1].HeaderText = "安保"; ((GroupField)Grid1.Columns[3]).Columns[2].HeaderText = "主协调员"; ((GroupField)Grid1.Columns[3]).Columns[3].HeaderText = "用户代表"; ((GroupField)Grid1.Columns[3]).Columns[4].HeaderText = "SSR检查"; ((GroupField)Grid1.Columns[3]).Columns[5].HeaderText = "合同管理"; //三级 ((GroupField)((GroupField)Grid1.Columns[3]).Columns[0]).Columns[0].HeaderText = "CTS/S"; ((GroupField)((GroupField)Grid1.Columns[3]).Columns[1]).Columns[0].HeaderText = "CTS/C"; ((GroupField)((GroupField)Grid1.Columns[3]).Columns[2]).Columns[0].HeaderText = "Main Coordinator"; ((GroupField)((GroupField)Grid1.Columns[3]).Columns[3]).Columns[0].HeaderText = "User Representative"; ((GroupField)((GroupField)Grid1.Columns[3]).Columns[4]).Columns[0].HeaderText = "CTE/D"; ((GroupField)((GroupField)Grid1.Columns[3]).Columns[5]).Columns[0].HeaderText = "CTE/D"; ((GroupField)((GroupField)Grid1.Columns[3]).Columns[0]).Columns[0].HeaderTextAlign = TextAlign.Center; ((GroupField)((GroupField)Grid1.Columns[3]).Columns[1]).Columns[0].HeaderTextAlign = TextAlign.Center; ((GroupField)((GroupField)Grid1.Columns[3]).Columns[2]).Columns[0].HeaderTextAlign = TextAlign.Center; ((GroupField)((GroupField)Grid1.Columns[3]).Columns[3]).Columns[0].HeaderTextAlign = TextAlign.Center; ((GroupField)((GroupField)Grid1.Columns[3]).Columns[4]).Columns[0].HeaderTextAlign = TextAlign.Center; ((GroupField)((GroupField)Grid1.Columns[3]).Columns[5]).Columns[0].HeaderTextAlign = TextAlign.Center; Grid1.Columns[3].HeaderToolTip = ((GroupField)Grid1.Columns[3]).Columns[0].HeaderToolTip = ((GroupField)Grid1.Columns[3]).Columns[1].HeaderToolTip = ((GroupField)Grid1.Columns[3]).Columns[2].HeaderToolTip = ((GroupField)Grid1.Columns[3]).Columns[3].HeaderToolTip = ((GroupField)Grid1.Columns[3]).Columns[4].HeaderToolTip = ((GroupField)Grid1.Columns[3]).Columns[5].HeaderToolTip = ((GroupField)((GroupField)Grid1.Columns[3]).Columns[0]).Columns[0].HeaderToolTip = ((GroupField)((GroupField)Grid1.Columns[3]).Columns[1]).Columns[0].HeaderToolTip = ((GroupField)((GroupField)Grid1.Columns[3]).Columns[2]).Columns[0].HeaderToolTip = ((GroupField)((GroupField)Grid1.Columns[3]).Columns[3]).Columns[0].HeaderToolTip = ((GroupField)((GroupField)Grid1.Columns[3]).Columns[4]).Columns[0].HeaderToolTip = ((GroupField)((GroupField)Grid1.Columns[3]).Columns[5]).Columns[0].HeaderToolTip = "10分 安全表现卓越 8分 安全表现较好无违章 6分 安全表现可接受有一般违章 4分 安全表现一般有严重违章 2分 安全表现差有零容忍违章 0分 安全表现非常差发生严重事故或违法行为"; } } #endregion #region 保存Grid1 /// /// 保存 /// /// /// protected void Grid1_RowCommand(object sender, GridCommandEventArgs e) { if (e.CommandName == "pg") { Window1.Hidden = true; try { var modifiedList = JsonConvert.DeserializeObject>(Grid1.GetModifiedData().ToString()); if (modifiedList.Count > 0) { modifiedList = modifiedList.Where(p => p.Index == e.RowIndex).ToList(); List editLs = new List(); foreach (var item in modifiedList) { HiddenField hidisDepScore1 = Grid1.Rows[item.Index].FindControl("hidisDepScore1") as HiddenField; HiddenField hidisDepScore2 = Grid1.Rows[item.Index].FindControl("hidisDepScore2") as HiddenField; HiddenField hidisDepScore3 = Grid1.Rows[item.Index].FindControl("hidisDepScore3") as HiddenField; HiddenField hidisDepScore4 = Grid1.Rows[item.Index].FindControl("hidisDepScore4") as HiddenField; HiddenField hidisDepScore5 = Grid1.Rows[item.Index].FindControl("hidisDepScore5") as HiddenField; HiddenField hidisDepScore6 = Grid1.Rows[item.Index].FindControl("hidisDepScore6") as HiddenField; var foNo = Grid1.Rows[item.Index].DataKeys[0].ToString(); var isEvaluateType = Grid1.Rows[item.Index].DataKeys[1].ToString(); var addEvaluateType = Grid1.Rows[item.Index].DataKeys[2].ToString(); editLs.Add(new ScoreEditDto() { Id = item.Id, Index = item.Index, Score1 = item.Values.ContainsKey("Score1") ? decimal.Parse(item.Values["Score1"].ToString()) : (decimal)-0.01, Score2 = item.Values.ContainsKey("Score2") ? decimal.Parse(item.Values["Score2"].ToString()) : (decimal)-0.01, Score3 = item.Values.ContainsKey("Score3") ? decimal.Parse(item.Values["Score3"].ToString()) : (decimal)-0.01, Score4 = item.Values.ContainsKey("Score4") ? decimal.Parse(item.Values["Score4"].ToString()) : (decimal)-0.01, Score5 = item.Values.ContainsKey("Score5") ? decimal.Parse(item.Values["Score5"].ToString()) : (decimal)-0.01, Score6 = item.Values.ContainsKey("Score6") ? decimal.Parse(item.Values["Score6"].ToString()) : (decimal)-0.01, EvaluateType = addEvaluateType, DepExtend1 = hidisDepScore1.Text, DepExtend2 = hidisDepScore2.Text, DepExtend3 = hidisDepScore3.Text, DepExtend4 = hidisDepScore4.Text, DepExtend5 = hidisDepScore5.Text, DepExtend6 = hidisDepScore6.Text, Status = item.Status, OriginalIndex = item.OriginalIndex }); } if (editLs.Count(p => p.EvaluateType == "1") > 0)//0:未评价 1:已评价 { BindGrid(); Alert.ShowInParent("You have already evaluated " + string.Join(",", editLs.Where(p => p.EvaluateType == "1").Select(p => p.Id).ToList()) + "!"); return; } var txValue = new List() { 0, 0.5, 1, 5 }; var sss = modifiedList.ConvertAll(p => p.Values); if (sss.SelectMany(p => p.Values).ToList().Count(s => txValue.Contains(s)) > 0) { PageContext.RegisterStartupScript(Confirm.GetShowReference("当前评价结果存在“零星”,“半星”,“一星”,“五星”,是否确认保存?", String.Empty, MessageBoxIcon.Question, PageManager1.GetCustomEventReference(false, "Confirm_OK"), // 第一个参数 false 用来指定当前不是AJAX请求 PageManager1.GetCustomEventReference("Confirm_Cancel"))); } else { SubmitScore(editLs); } } else { var msg = Grid1.Rows[e.RowIndex].DataKeys[1].ToString() == "1" ? "已评价,无法继续评价!" : "请点击星星评价!"; BindGrid(); Alert.ShowInParent(msg); return; } } catch (Exception ex) { ShowNotify("'" + ex.Message + "'", MessageBoxIcon.Error); } } } /// /// 批量评价 /// protected void BatchEvaluation_Click(object sender, EventArgs e) { Window1.Hidden = true; try { var modifiedList = JsonConvert.DeserializeObject>(Grid1.GetModifiedData().ToString()); if (modifiedList.Count > 0) { List editLs = new List(); foreach (var item in modifiedList) { HiddenField hidisDepScore1 = Grid1.Rows[item.Index].FindControl("hidisDepScore1") as HiddenField; HiddenField hidisDepScore2 = Grid1.Rows[item.Index].FindControl("hidisDepScore2") as HiddenField; HiddenField hidisDepScore3 = Grid1.Rows[item.Index].FindControl("hidisDepScore3") as HiddenField; HiddenField hidisDepScore4 = Grid1.Rows[item.Index].FindControl("hidisDepScore4") as HiddenField; HiddenField hidisDepScore5 = Grid1.Rows[item.Index].FindControl("hidisDepScore5") as HiddenField; HiddenField hidisDepScore6 = Grid1.Rows[item.Index].FindControl("hidisDepScore6") as HiddenField; var foNo = Grid1.Rows[item.Index].DataKeys[0].ToString(); var isEvaluateType = Grid1.Rows[item.Index].DataKeys[1].ToString(); var addEvaluateType = Grid1.Rows[item.Index].DataKeys[2].ToString(); editLs.Add(new ScoreEditDto() { Id = item.Id, Index = item.Index, Score1 = item.Values.ContainsKey("Score1") ? decimal.Parse(item.Values["Score1"].ToString()) : (decimal)-0.01, Score2 = item.Values.ContainsKey("Score2") ? decimal.Parse(item.Values["Score2"].ToString()) : (decimal)-0.01, Score3 = item.Values.ContainsKey("Score3") ? decimal.Parse(item.Values["Score3"].ToString()) : (decimal)-0.01, Score4 = item.Values.ContainsKey("Score4") ? decimal.Parse(item.Values["Score4"].ToString()) : (decimal)-0.01, Score5 = item.Values.ContainsKey("Score5") ? decimal.Parse(item.Values["Score5"].ToString()) : (decimal)-0.01, Score6 = item.Values.ContainsKey("Score6") ? decimal.Parse(item.Values["Score6"].ToString()) : (decimal)-0.01, EvaluateType = addEvaluateType, DepExtend1 = hidisDepScore1.Text, DepExtend2 = hidisDepScore2.Text, DepExtend3 = hidisDepScore3.Text, DepExtend4 = hidisDepScore4.Text, DepExtend5 = hidisDepScore5.Text, DepExtend6 = hidisDepScore6.Text, Status = item.Status, OriginalIndex = item.OriginalIndex }); ; } if (editLs.Count(p => p.EvaluateType == "1") > 0)//0:未评价 1:已评价 { BindGrid(); Alert.ShowInParent("You have already evaluated " + string.Join(",", editLs.Where(p => p.EvaluateType == "1").Select(p => p.Id).ToList()) + "!"); return; } var txValue = new List() { 0, 0.5, 1, 5 }; var sss = modifiedList.ConvertAll(p => p.Values); if (sss.SelectMany(p => p.Values).ToList().Count(s => txValue.Contains(s)) > 0) { PageContext.RegisterStartupScript(Confirm.GetShowReference("当前评价结果存在“零星”,“半星”,“一星”,“五星”,是否确认保存?", String.Empty, MessageBoxIcon.Question, PageManager1.GetCustomEventReference(false, "Confirm_OK"), // 第一个参数 false 用来指定当前不是AJAX请求 PageManager1.GetCustomEventReference("Confirm_Cancel"))); } else { SubmitScore(editLs); } } else { BindGrid(); Alert.ShowInParent("请点击星星评价!"); return; } } catch (Exception ex) { ShowNotify("'" + ex.Message + "'", MessageBoxIcon.Error); } } /// /// 保存询问 /// protected void PageManager1_CustomEvent(object sender, CustomEventArgs e) { if (e.EventArgument == "Confirm_OK") { List editLs = new List(); var modifiedList = JsonConvert.DeserializeObject>(Grid1.GetModifiedData().ToString()); if (modifiedList.Count > 0) { foreach (var item in modifiedList) { HiddenField hidisDepScore1 = Grid1.Rows[item.Index].FindControl("hidisDepScore1") as HiddenField; HiddenField hidisDepScore2 = Grid1.Rows[item.Index].FindControl("hidisDepScore2") as HiddenField; HiddenField hidisDepScore3 = Grid1.Rows[item.Index].FindControl("hidisDepScore3") as HiddenField; HiddenField hidisDepScore4 = Grid1.Rows[item.Index].FindControl("hidisDepScore4") as HiddenField; HiddenField hidisDepScore5 = Grid1.Rows[item.Index].FindControl("hidisDepScore5") as HiddenField; HiddenField hidisDepScore6 = Grid1.Rows[item.Index].FindControl("hidisDepScore6") as HiddenField; var foNo = Grid1.Rows[item.Index].DataKeys[0].ToString(); var isEvaluateType = Grid1.Rows[item.Index].DataKeys[1].ToString(); var addEvaluateType = Grid1.Rows[item.Index].DataKeys[2].ToString(); editLs.Add(new ScoreEditDto() { Id = item.Id, Index = item.Index, Score1 = item.Values.ContainsKey("Score1") ? decimal.Parse(item.Values["Score1"].ToString()) : (decimal)-0.01, Score2 = item.Values.ContainsKey("Score2") ? decimal.Parse(item.Values["Score2"].ToString()) : (decimal)-0.01, Score3 = item.Values.ContainsKey("Score3") ? decimal.Parse(item.Values["Score3"].ToString()) : (decimal)-0.01, Score4 = item.Values.ContainsKey("Score4") ? decimal.Parse(item.Values["Score4"].ToString()) : (decimal)-0.01, Score5 = item.Values.ContainsKey("Score5") ? decimal.Parse(item.Values["Score5"].ToString()) : (decimal)-0.01, Score6 = item.Values.ContainsKey("Score6") ? decimal.Parse(item.Values["Score6"].ToString()) : (decimal)-0.01, EvaluateType = addEvaluateType, DepExtend1 = hidisDepScore1.Text, DepExtend2 = hidisDepScore2.Text, DepExtend3 = hidisDepScore3.Text, DepExtend4 = hidisDepScore4.Text, DepExtend5 = hidisDepScore5.Text, DepExtend6 = hidisDepScore6.Text, Status = item.Status, OriginalIndex = item.OriginalIndex }); ; } } SubmitScore(editLs); } } /// /// 保存数据 /// private void SubmitScore(List scoreEdits) { if (scoreEdits.Count > 0) { foreach (var item in scoreEdits) { if (!string.IsNullOrEmpty(item.Id)) { var fo = BLL.SESRelatedDataService.GetSESRelatedDataByFoNo(item.Id); string fotype = string.Empty; if (fo != null && fo.FOTypeId != null && fo.FOTypeId != "") { var t = BLL.FOTypeService.GetFoTypeById(fo.FOTypeId); if (t != null) { fotype = t.FOType; } } var tar_homelyModel = Funs.DB.TAR_HonestyTimelyView.FirstOrDefault(p => p.Contract_No == item.Id); var homelyModel = Funs.DB.HonestyTimelyView.FirstOrDefault(p => p.Contract_No == item.Id); //用户 if (item.EvaluateType == "User") { FC_Score fsModel = new FC_Score(); fsModel.Contract_No = item.Id; fsModel.Score1 = (item.Score1 > 0) ? item.Score1 * 2 : 0; fsModel.Score2 = (item.Score2 > 0) ? item.Score2 * 2 : 0; fsModel.Score3 = (item.Score3 > 0) ? item.Score3 * 2 : 0; fsModel.Score4 = (item.Score4 > 0) ? item.Score4 * 2 : 0; fsModel.Score5 = (item.Score5 > 0) ? item.Score5 * 2 : 0; fsModel.Score6 = (item.Score6 > 0) ? item.Score6 * 2 : 0; fsModel.UserId = CurrUser.UserId; fsModel.UserName = CurrUser.UserName; fsModel.Role = CurrUser.RoleId; fsModel.DateIn = DateTime.Now; fsModel.Role = "User"; fsModel.RoleId = CurrUser.RoleId; if (homelyModel != null && homelyModel.Honesty != null) { fsModel.Honesty = homelyModel.Honesty; } if (fotype.Trim() == "FC") { if (homelyModel != null && homelyModel.Timely != null) { fsModel.Timely = homelyModel.Timely; } } else if (fotype.Trim() == "TAR") { if (tar_homelyModel != null && tar_homelyModel.Timely != null) { fsModel.Timely = tar_homelyModel.Timely; } } else { fsModel.Timely = Convert.ToDecimal(5.0); } Funs.DB.FC_Score.InsertOnSubmit(fsModel); //评价日志信息 var setList = new List(); var pjSESReport = new List(); pjSESReport = Funs.DB.FC_SESReportView.Where(p => p.FO_NO == item.Id && p.Requisitioner == CurrUser.Account).ToList(); if (pjSESReport.Count > 0) { var scoreJournalList = new List(); foreach (var itemSes in pjSESReport) { Score_JournalEvaluation scoreJournal = new Score_JournalEvaluation(); scoreJournal.SES_No = itemSes.SES_No; scoreJournal.Contract_No = itemSes.FO_NO; scoreJournal.Role = "User"; scoreJournal.Evaluate_UserId = CurrUser.UserId; scoreJournal.Evaluate_UserName = CurrUser.UserName; scoreJournal.Evaluate_Time = DateTime.Now; scoreJournalList.Add(scoreJournal); } Funs.DB.Score_JournalEvaluation.InsertAllOnSubmit(scoreJournalList); // 回写违章捐款(用户) var PunishList= from x in pjSESReport where x.ViolationDegree!=null select x; if (PunishList.Count() > 0) { foreach (var p in PunishList) { var punish = Funs.DB.EMC_Punishment.FirstOrDefault(x => x.FO_NO == p.FO_NO && x.ViolationRelatedSes == p.SES_No); if (punish != null) { punish.IsUserEvaluated = true; Funs.DB.SubmitChanges(); } } } } } //部门 if (item.EvaluateType == "Dep") { FC_Score fsModel = new FC_Score(); fsModel.Contract_No = item.Id; if (item.DepExtend1 == "1") { fsModel.Score1 = item.Score1 > 0 ? item.Score1 : 0; } else { fsModel.Score1 = (decimal)-0.01; } if (item.DepExtend2 == "1") { fsModel.Score2 = item.Score2 > 0 ? item.Score2 : 0; } else { fsModel.Score2 = (decimal)-0.01; } if (item.DepExtend3 == "1") { fsModel.Score3 = item.Score3 > 0 ? item.Score3 : 0; } else { fsModel.Score3 = (decimal)-0.01; } if (item.DepExtend4 == "1") { fsModel.Score4 = item.Score4 > 0 ? item.Score4 : 0; } else { fsModel.Score4 = (decimal)-0.01; } if (item.DepExtend5 == "1") { fsModel.Score5 = item.Score5 > 0 ? item.Score5 : 0; } else { fsModel.Score5 = (decimal)-0.01; } if (item.DepExtend6 == "1") { fsModel.Score6 = item.Score6 > 0 ? item.Score6 : 0; } else { fsModel.Score6 = (decimal)-0.01; } fsModel.UserId = CurrUser.UserId; fsModel.UserName = CurrUser.UserName; fsModel.Role = CurrUser.RoleId; fsModel.DateIn = DateTime.Now; fsModel.Role = "Dep"; fsModel.RoleId = CurrUser.RoleId; if (homelyModel != null && homelyModel.Honesty != null) { fsModel.Honesty = homelyModel.Honesty; } if (fotype.Trim() == "FC") { if (homelyModel != null && homelyModel.Timely != null) { fsModel.Timely = homelyModel.Timely; } } else if (fotype.Trim() == "TAR") { if (tar_homelyModel != null && tar_homelyModel.Timely != null) { fsModel.Timely = tar_homelyModel.Timely; } } else { fsModel.Timely = Convert.ToDecimal(5.0); } Funs.DB.FC_Score.InsertOnSubmit(fsModel); //评价日志信息 var pjSESReport = new List(); var setList = Funs.DB.Sys_User.Where(p => new string[] { Const.Role_CTSSId, Const.Role_CTSCId, Const.Role_CTMTId }.Contains(p.RoleId) && p.UserId == CurrUser.UserId).ToList(); if (setList.Count > 0) { pjSESReport = Funs.DB.FC_SESReportView.Where(p => p.FO_NO == item.Id && p.Requisitioner != "").ToList(); } else { pjSESReport = Funs.DB.FC_SESReportView.Where(p => p.FO_NO == item.Id && (p.MainCoordinatorUser == CurrUser.Account || p.ContractAdminUser == CurrUser.Account || p.UserRepresentativeUser == CurrUser.Account)).ToList(); } if (pjSESReport.Count > 0) { var scoreJournalList = new List(); foreach (var itemSes in pjSESReport) { Score_JournalEvaluation scoreJournal = new Score_JournalEvaluation(); scoreJournal.SES_No = itemSes.SES_No; scoreJournal.Contract_No = itemSes.FO_NO; scoreJournal.Role = "Dep"; scoreJournal.Evaluate_UserId = CurrUser.UserId; scoreJournal.Evaluate_UserName = CurrUser.UserName; scoreJournal.Evaluate_Time = DateTime.Now; scoreJournalList.Add(scoreJournal); } Funs.DB.Score_JournalEvaluation.InsertAllOnSubmit(scoreJournalList); } // 回写违章捐款(部门) var PunishList = from x in pjSESReport where x.ViolationDegree != null select x; if (PunishList.Count() > 0) { foreach (var p in PunishList) { var punish = Funs.DB.EMC_Punishment.FirstOrDefault(x => x.FO_NO == p.FO_NO && x.ViolationRelatedSes == p.SES_No); if (punish != null) { punish.IsDepEvaluated = true; Funs.DB.SubmitChanges(); } } } } } } } Funs.DB.SubmitChanges(); BindGrid(); ShowNotify("Evaluated successfully!
谢谢您的参与!", MessageBoxIcon.Success); } #endregion #region 绑定Grid2 /// /// 绑定Grid2 /// /// private void BindGrid2(string FoNo, string UserType) { var sesList = new List(); if (UserType != "1") { var setList = Funs.DB.Sys_User.Where(p => new string[] { Const.Role_CTSSId, Const.Role_CTSCId, Const.Role_CTMTId }.Contains(p.RoleId) && p.UserId == CurrUser.UserId).ToList(); if (setList.Count > 0) { sesList = Funs.DB.FC_SESReportView.Where(p => p.FO_NO == FoNo && p.Requisitioner != "" && p.Requisitioner != null).ToList(); } else { sesList = Funs.DB.FC_SESReportView.Where(p => p.FO_NO == FoNo && (p.MainCoordinatorUser == CurrUser.Account || p.ContractAdminUser == CurrUser.Account || p.UserRepresentativeUser == CurrUser.Account)).ToList(); } } else { sesList = Funs.DB.FC_SESReportView.Where(p => p.FO_NO == FoNo && p.Requisitioner == CurrUser.Account).ToList(); } Grid2.DataSource = sesList; Grid2.DataBind(); } #endregion #region 实体 /// /// 绑定Grid实体 /// public class EmailEvaluationModel { /// /// 主键 /// public Guid ConGuid { get; set; } = Guid.Empty; /// /// 用户ID /// public string UserId { get; set; } = string.Empty; /// /// 用户名称 /// public string UserName { get; set; } = string.Empty; /// /// 合同号 /// public string FO_NO { get; set; } = string.Empty; /// /// 专业 /// public string Discipline { get; set; } = string.Empty; /// /// 邮件 /// public string Email { get; set; } = string.Empty; /// /// 用户类型 /// public int UserType { get; set; } = 0; /// /// 查询数据年 /// public int DateYear { get; set; } = 0; /// /// 查询数据的月份 /// public int DateMonth { get; set; } = 0; /// /// 是否发送邮件 /// public int EmailType { get; set; } = 0; /// /// 邮件类型名称 /// public string EmailName { get; set; } = string.Empty; /// /// 是否评价0未评价1已评价 /// public int IsEvaluateType { get; set; } = 0; /// /// 是否评价类型名称 /// public string IsEvaluateName { get; set; } = string.Empty; /// /// 评价类型User:用户 Dep:部门 /// public string EvaluateType { get; set; } = string.Empty; /// /// 分数1 /// public decimal? Score1 { get; set; } = 0; /// /// 分数2 /// public decimal? Score2 { get; set; } = 0; /// /// 分数3 /// public decimal? Score3 { get; set; } = 0; /// /// 分数4 /// public decimal? Score4 { get; set; } = 0; /// /// 分数5 /// public decimal? Score5 { get; set; } = 0; /// /// 分数6 /// public decimal? Score6 { get; set; } = 0; } /// /// 分数修改实体 /// public class ScoreModified { /// /// 主键 /// public string Id { get; set; } /// /// 序号 /// public int Index { get; set; } /// /// 数据键值对 /// public Dictionary Values { get; set; } /// /// 操作类型 /// public string Status { get; set; } /// /// 顺序 /// public int OriginalIndex { get; set; } } /// /// 分数赋值实体 /// public class ScoreEditDto { /// /// 主键 /// public string Id { get; set; } /// /// 序号 /// public int Index { get; set; } /// /// /// public decimal Score1 { get; set; } = (decimal)-0.01; /// /// /// public decimal Score2 { get; set; } = (decimal)-0.01; /// /// /// public decimal Score3 { get; set; } = (decimal)-0.01; /// /// /// public decimal Score4 { get; set; } = (decimal)-0.01; /// /// /// public decimal Score5 { get; set; } = (decimal)-0.01; /// /// /// public decimal Score6 { get; set; } = (decimal)-0.01; /// /// /// public string EvaluateType { get; set; } = string.Empty; /// /// /// public string DepExtend1 { get; set; } = "0"; /// /// /// public string DepExtend2 { get; set; } = "0"; /// /// /// public string DepExtend3 { get; set; } = "0"; /// /// /// public string DepExtend4 { get; set; } = "0"; /// /// /// public string DepExtend5 { get; set; } = "0"; /// /// /// public string DepExtend6 { get; set; } = "0"; /// 操作类型 /// public string Status { get; set; } /// /// 顺序 /// public int OriginalIndex { get; set; } } #endregion #region 窗体 /// /// 窗体 /// /// /// protected void Window1_Close(object sender, EventArgs e) { //BindGrid(); } #endregion #region 列点击事件 /// /// 列点击事件 /// /// /// protected void LinkFoNo_Click(object sender, EventArgs e) { System.Web.UI.WebControls.LinkButton btn = (System.Web.UI.WebControls.LinkButton)sender; this.hdFo.Text = btn.Text; BindGrid2(btn.Text, btn.CommandName); } #endregion #region 点击行事件 /// /// 点击行事件 /// /// /// protected void Grid1_RowClick(object sender, GridRowClickEventArgs e) { var foNo = Grid1.Rows[e.RowIndex].DataKeys[0].ToString(); var userType = Grid1.Rows[e.RowIndex].DataKeys[3].ToString(); this.hdFo.Text = foNo; BindGrid2(foNo, userType); } #endregion #region 自动评价 /// /// 自动评价 /// /// /// protected void btnAutoEvaluation_OnClick(object sender, EventArgs e) { using (Model.FCLDB db = Funs.DB) { db.CommandTimeout = 600; //用户 string year = DateTime.Now.Year.ToString(); string month = DateTime.Now.Month.ToString(); if (DateTime.Now.Day >= 12) { var userEmail = db.EmailUserView.Where(p => p.IsEvaluateType != 1).ToList(); if (userEmail != null && userEmail.Count > 0) { foreach (var itemUser in userEmail) { FC_Score fsModel = new FC_Score(); var fo = BLL.SESRelatedDataService.GetSESRelatedDataByFoNo(itemUser.FO_NO); string fotype = string.Empty; if (fo != null && fo.FOTypeId != null && fo.FOTypeId != "") { var t = BLL.FOTypeService.GetFoTypeById(fo.FOTypeId); if (t != null) { fotype = t.FOType; } } var tar_homelyModel = db.TAR_HonestyTimelyView.FirstOrDefault(p => p.Contract_No == itemUser.FO_NO); var homelyModel = db.HonestyTimelyView.FirstOrDefault(p => p.Contract_No == itemUser.FO_NO); fsModel.Contract_No = itemUser.FO_NO; fsModel.Score1 = 0; fsModel.Score2 = 0; fsModel.Score3 = 0; fsModel.Score4 = 0; fsModel.Score5 = 0; fsModel.Score6 = 0; fsModel.UserId = itemUser.UserId; fsModel.UserName = itemUser.UserName; fsModel.DateIn = Convert.ToDateTime(year + "-" + month + "-12"); fsModel.Role = "User"; fsModel.Remark = "Auto"; if (homelyModel != null && homelyModel.Honesty != null) { fsModel.Honesty = homelyModel.Honesty; } if (fotype.Trim() == "FC") { if (homelyModel != null && homelyModel.Timely != null) { fsModel.Timely = homelyModel.Timely; } } else if (fotype.Trim() == "TAR") { if (tar_homelyModel != null && tar_homelyModel.Timely != null) { fsModel.Timely = tar_homelyModel.Timely; } } else { fsModel.Timely = Convert.ToDecimal(5.0); } db.FC_Score.InsertOnSubmit(fsModel); //评价日志信息 var setList = new List(); var pjSESReport = new List(); pjSESReport = db.FC_SESReportView.Where(p => p.FO_NO == itemUser.FO_NO && p.Requisitioner == itemUser.UserName).ToList(); if (pjSESReport.Count > 0) { var scoreJournalList = new List(); foreach (var item in pjSESReport) { Score_JournalEvaluation scoreJournal = new Score_JournalEvaluation(); scoreJournal.SES_No = item.SES_No; scoreJournal.Contract_No = item.FO_NO; scoreJournal.Role = "User"; scoreJournal.Remark = "Auto"; scoreJournal.Evaluate_UserId = itemUser.UserId; scoreJournal.Evaluate_UserName = itemUser.UserName; scoreJournal.Evaluate_Time = Convert.ToDateTime(year + "-" + month + "-12"); scoreJournalList.Add(scoreJournal); } db.Score_JournalEvaluation.InsertAllOnSubmit(scoreJournalList); } } db.SubmitChanges(); } //部门 var depEmail = db.EmailUserLeaderView.Where(p => p.IsEvaluateType != 1).ToList(); if (depEmail != null && depEmail.Count > 0) { foreach (var itemDep in depEmail.Select(p => new { p.FO_NO, p.UserName, p.UserId }).Distinct().ToList()) { FC_Score fsModel = new FC_Score(); var fo = BLL.SESRelatedDataService.GetSESRelatedDataByFoNo(itemDep.FO_NO); string fotype = string.Empty; if (fo != null && fo.FOTypeId != null && fo.FOTypeId != "") { var t = BLL.FOTypeService.GetFoTypeById(fo.FOTypeId); if (t != null) { fotype = t.FOType; } } var tar_homelyModel = db.TAR_HonestyTimelyView.FirstOrDefault(p => p.Contract_No == itemDep.FO_NO); var homelyModel = db.HonestyTimelyView.FirstOrDefault(p => p.Contract_No == itemDep.FO_NO); fsModel.Contract_No = itemDep.FO_NO; fsModel.Score1 = depEmail.Count(p => p.UserId == itemDep.UserId && p.UserType == 5) > 0 ? 0 : (decimal)-0.01; fsModel.Score2 = depEmail.Count(p => p.UserId == itemDep.UserId && p.UserType == 6) > 0 ? 0 : (decimal)-0.01; fsModel.Score3 = depEmail.Count(p => p.UserId == itemDep.UserId && p.UserType == 2) > 0 ? 0 : (decimal)-0.01; fsModel.Score4 = depEmail.Count(p => p.UserId == itemDep.UserId && p.UserType == 3) > 0 ? 0 : (decimal)-0.01; fsModel.Score5 = depEmail.Count(p => p.UserId == itemDep.UserId && p.UserType == 7) > 0 ? 0 : (decimal)-0.01; fsModel.Score6 = depEmail.Count(p => p.UserId == itemDep.UserId && p.UserType == 4) > 0 ? 0 : (decimal)-0.01; fsModel.UserId = itemDep.UserId; fsModel.UserName = itemDep.UserName; fsModel.DateIn = Convert.ToDateTime(year + "-" + month + "-12"); fsModel.Role = "Dep"; fsModel.Remark = "Auto"; if (homelyModel != null && homelyModel.Honesty != null) { fsModel.Honesty = homelyModel.Honesty; } if (fotype.Trim() == "FC") { if (homelyModel != null && homelyModel.Timely != null) { fsModel.Timely = homelyModel.Timely; } } else if (fotype.Trim() == "TAR") { if (tar_homelyModel != null && tar_homelyModel.Timely != null) { fsModel.Timely = tar_homelyModel.Timely; } } else { fsModel.Timely = Convert.ToDecimal(5.0); } db.FC_Score.InsertOnSubmit(fsModel); //评价日志信息 var pjSESReport = new List(); var setList = db.Sys_User.Where(p => new string[] { Const.Role_CTSSId, Const.Role_CTSCId, Const.Role_CTMTId }.Contains(p.RoleId) && p.UserId == itemDep.UserId).ToList(); if (setList.Count > 0) { pjSESReport = db.FC_SESReportView.Where(p => p.FO_NO == itemDep.FO_NO && p.Requisitioner != "").ToList(); } else { pjSESReport = db.FC_SESReportView.Where(p => p.FO_NO == itemDep.FO_NO && (p.MainCoordinatorUser == itemDep.UserName || p.ContractAdminUser == itemDep.UserName || p.UserRepresentativeUser == itemDep.UserName)).ToList(); } if (pjSESReport.Count > 0) { var scoreJournalList = new List(); foreach (var item in pjSESReport) { Score_JournalEvaluation scoreJournal = new Score_JournalEvaluation(); scoreJournal.SES_No = item.SES_No; scoreJournal.Contract_No = item.FO_NO; scoreJournal.Role = "Dep"; scoreJournal.Remark = "Auto"; scoreJournal.Evaluate_UserId = itemDep.UserId; scoreJournal.Evaluate_UserName = itemDep.UserName; scoreJournal.Evaluate_Time = Convert.ToDateTime(year + "-" + month + "-12"); scoreJournalList.Add(scoreJournal); } db.Score_JournalEvaluation.InsertAllOnSubmit(scoreJournalList); } } db.SubmitChanges(); } ShowNotify("Complete auto evaluation!", MessageBoxIcon.Success); } else { ShowNotify("Auto evaluation can be made only after the 12th!", MessageBoxIcon.Warning); } } } #endregion #region 默认加载条件筛选 /// /// 默认加载条件筛选 /// /// /// protected void rdbUserType_SelectedIndexChanged(object sender, EventArgs e) { BindGrid(); } #endregion protected void Grid2_RowDataBound(object sender, GridRowEventArgs e) { var row = e.DataItem as Model.FC_SESReportView; if (!string.IsNullOrEmpty(row.ShowViolationDegree)) { e.RowCssClass = "color2"; } } protected string ConvertViolationDegree(object violationDegree) { string degree = string.Empty; if (violationDegree != null) { if (violationDegree.ToString() == "1") { degree = "一般违章"; } if (violationDegree.ToString() == "2") { degree = "严重违章"; } if (violationDegree.ToString() == "3") { degree = "零容忍违章"; } } return degree; } } }