using BLL; using Model; using System; using System.Collections.Generic; using System.Data; using System.Data.SqlClient; using System.IO; using System.Linq; using System.Web.UI.WebControls; namespace FineUIPro.Web.Evaluation { public partial class Evaluation : 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()).ToList(); var depScoreList = Funs.DB.EmailUserLeaderView.Where(p => p.UserId == CurrUser.UserId.Trim()).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(); } } /// /// /// /// /// 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! "); } } #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()).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()).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; p.Score2 = userScoreModel.Score2; p.Score3 = userScoreModel.Score3; p.Score4 = userScoreModel.Score4; p.Score5 = userScoreModel.Score5; p.Score6 = userScoreModel.Score6; } } 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; } } } }); hidXingNum.Text = bridList.Count.ToString(); 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 hidFoNo = Grid1.Rows[i].FindControl("hidFoNo") as HiddenField; HiddenField hidIsEvaluateType = Grid1.Rows[i].FindControl("hidIsEvaluateType") as HiddenField; HiddenField hidEvaluateType = Grid1.Rows[i].FindControl("hidEvaluateType") as HiddenField; if (contractorList != null && contractorList.Count(p => p.FO_NO == hidFoNo.Text) > 0) { var contractModel = contractorList.FirstOrDefault(p => p.FO_NO == hidFoNo.Text); if (contractModel != null) { lblContractor.Text = contractModel.Contractor; } } if (hidIsEvaluateType.Text == "1") { Grid1.Rows[i].RowCssClass = "color1"; } System.Web.UI.HtmlControls.HtmlGenericControl score1 = Grid1.Rows[i].FindControl("score1") as System.Web.UI.HtmlControls.HtmlGenericControl; System.Web.UI.HtmlControls.HtmlGenericControl score2 = Grid1.Rows[i].FindControl("score2") as System.Web.UI.HtmlControls.HtmlGenericControl; System.Web.UI.HtmlControls.HtmlGenericControl score3 = Grid1.Rows[i].FindControl("score3") as System.Web.UI.HtmlControls.HtmlGenericControl; System.Web.UI.HtmlControls.HtmlGenericControl score4 = Grid1.Rows[i].FindControl("score4") as System.Web.UI.HtmlControls.HtmlGenericControl; System.Web.UI.HtmlControls.HtmlGenericControl score5 = Grid1.Rows[i].FindControl("score5") as System.Web.UI.HtmlControls.HtmlGenericControl; System.Web.UI.HtmlControls.HtmlGenericControl score6 = Grid1.Rows[i].FindControl("score6") as System.Web.UI.HtmlControls.HtmlGenericControl; //判断部门是否存在数据 if (depScoreList.Count(p => p.FO_NO == hidFoNo.Text) > 0 && hidEvaluateType.Text == "Dep") { //CTS/S UserType:5 if (depScoreList.Count(p => p.FO_NO == hidFoNo.Text && p.UserType == 5) > 0) { score1.Style.Add("display", ""); hidisDepScore1.Text = "1"; } else { score1.Style.Add("display", "none"); hidisDepScore1.Text = "0"; } //CTS/C UserType:6 if (depScoreList.Count(p => p.FO_NO == hidFoNo.Text && p.UserType == 6) > 0) { score2.Style.Add("display", ""); hidisDepScore2.Text = "1"; } else { score2.Style.Add("display", "none"); hidisDepScore2.Text = "0"; } //Main Coordinator UserType: 2 if (depScoreList.Count(p => p.FO_NO == hidFoNo.Text && p.UserType == 2) > 0) { score3.Style.Add("display", ""); hidisDepScore3.Text = "1"; } else { score3.Style.Add("display", "none"); hidisDepScore3.Text = "0"; } //User Representative UserType:3 if (depScoreList.Count(p => p.FO_NO == hidFoNo.Text && p.UserType == 3) > 0) { score4.Style.Add("display", ""); hidisDepScore4.Text = "1"; } else { score4.Style.Add("display", "none"); hidisDepScore4.Text = "0"; } //CTM/T UserType:7 if (depScoreList.Count(p => p.FO_NO == hidFoNo.Text && p.UserType == 7) > 0) { score5.Style.Add("display", ""); hidisDepScore5.Text = "1"; } else { score5.Style.Add("display", "none"); hidisDepScore5.Text = "0"; } //CTE/D UserType:4 if (depScoreList.Count(p => p.FO_NO == hidFoNo.Text && p.UserType == 4) > 0) { score6.Style.Add("display", ""); hidisDepScore6.Text = "1"; } else { score6.Style.Add("display", "none"); hidisDepScore6.Text = "0"; } } else { score1.Style.Add("display", ""); score2.Style.Add("display", ""); score3.Style.Add("display", ""); score4.Style.Add("display", ""); score5.Style.Add("display", ""); score6.Style.Add("display", ""); } } } #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"; } 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 = "CTM/T"; ((GroupField)((GroupField)Grid1.Columns[3]).Columns[5]).Columns[0].HeaderText = "CTE/D"; } } #endregion #region 保存Grid1 /// /// 保存Grid1 /// /// /// protected void btnSave_Click(object sender, EventArgs e) { Window1.Hidden = true; System.Web.UI.WebControls.Button btn = (System.Web.UI.WebControls.Button)sender; HiddenField hidisDepScore1 = Grid1.Rows[int.Parse(btn.CommandArgument)].FindControl("hidisDepScore1") as HiddenField; HiddenField hidisDepScore2 = Grid1.Rows[int.Parse(btn.CommandArgument)].FindControl("hidisDepScore2") as HiddenField; HiddenField hidisDepScore3 = Grid1.Rows[int.Parse(btn.CommandArgument)].FindControl("hidisDepScore3") as HiddenField; HiddenField hidisDepScore4 = Grid1.Rows[int.Parse(btn.CommandArgument)].FindControl("hidisDepScore4") as HiddenField; HiddenField hidisDepScore5 = Grid1.Rows[int.Parse(btn.CommandArgument)].FindControl("hidisDepScore5") as HiddenField; HiddenField hidisDepScore6 = Grid1.Rows[int.Parse(btn.CommandArgument)].FindControl("hidisDepScore6") as HiddenField; List depExtendLs = new List() { hidisDepScore1.Text, hidisDepScore2.Text, hidisDepScore3.Text, hidisDepScore4.Text, hidisDepScore5.Text, hidisDepScore6.Text }; try { string[] fsValue = hidSaveValue.Value.Split(','); if (fsValue[7] == "1")//0:未评价 1:已评价 { BindGrid(); Alert.ShowInParent("You have already evaluated " + fsValue[0] + "!"); return; } if (fsValue[8] == "User")//只存在用户 { if ((fsValue[1] == "0" || fsValue[1] == "0.5" || fsValue[1] == "1" || fsValue[1] == "5") || (fsValue[2] == "0" || fsValue[2] == "0.5" || fsValue[2] == "1" || fsValue[2] == "5") || (fsValue[3] == "0" || fsValue[3] == "0.5" || fsValue[3] == "1" || fsValue[3] == "5") || (fsValue[4] == "0" || fsValue[4] == "0.5" || fsValue[4] == "1" || fsValue[4] == "5") || (fsValue[5] == "0" || fsValue[5] == "0.5" || fsValue[5] == "1" || fsValue[5] == "5") || (fsValue[6] == "0" || fsValue[6] == "0.5" || fsValue[6] == "1" || fsValue[6] == "5")) { PageContext.RegisterStartupScript(Confirm.GetShowReference("当前评价结果存在“零星”,“半星”,“一星”,“五星”,是否确认保存?", String.Empty, MessageBoxIcon.Question, PageManager1.GetCustomEventReference(false, "Confirm_OK|" + btn.CommandArgument), // 第一个参数 false 用来指定当前不是AJAX请求 PageManager1.GetCustomEventReference("Confirm_Cancel|" + btn.CommandArgument))); } else { SubmitScore(depExtendLs); } } else//只存在部门 { if (((fsValue[1] == "0" || fsValue[1] == "0.5" || fsValue[1] == "1" || fsValue[1] == "5") && hidisDepScore1.Text == "1") || ((fsValue[2] == "0" || fsValue[2] == "0.5" || fsValue[2] == "1" || fsValue[2] == "5") && hidisDepScore2.Text == "1") || ((fsValue[3] == "0" || fsValue[3] == "0.5" || fsValue[3] == "1" || fsValue[3] == "5") && hidisDepScore3.Text == "1") || ((fsValue[4] == "0" || fsValue[4] == "0.5" || fsValue[4] == "1" || fsValue[4] == "5") && hidisDepScore4.Text == "1") || ((fsValue[5] == "0" || fsValue[5] == "0.5" || fsValue[5] == "1" || fsValue[5] == "5") && hidisDepScore5.Text == "1") || ((fsValue[6] == "0" || fsValue[6] == "0.5" || fsValue[6] == "1" || fsValue[6] == "5") && hidisDepScore6.Text == "1")) { PageContext.RegisterStartupScript(Confirm.GetShowReference("当前评价结果存在“零星”,“半星”,“一星”,“五星”,是否确认保存?", String.Empty, MessageBoxIcon.Question, PageManager1.GetCustomEventReference(false, "Confirm_OK|" + btn.CommandArgument), // 第一个参数 false 用来指定当前不是AJAX请求 PageManager1.GetCustomEventReference("Confirm_Cancel|" + btn.CommandArgument))); } else { SubmitScore(depExtendLs); } } } catch (Exception ex) { ShowNotify("'" + ex.Message + "'", MessageBoxIcon.Error); } } /// /// 确认和取消保存执行事件 /// /// /// protected void PageManager1_CustomEvent(object sender, CustomEventArgs e) { if (e.EventArgument.Split('|').First() == "Confirm_OK") { var btnNum = e.EventArgument.Split('|').Last(); HiddenField hidisDepScore1 = Grid1.Rows[int.Parse(btnNum)].FindControl("hidisDepScore1") as HiddenField; HiddenField hidisDepScore2 = Grid1.Rows[int.Parse(btnNum)].FindControl("hidisDepScore2") as HiddenField; HiddenField hidisDepScore3 = Grid1.Rows[int.Parse(btnNum)].FindControl("hidisDepScore3") as HiddenField; HiddenField hidisDepScore4 = Grid1.Rows[int.Parse(btnNum)].FindControl("hidisDepScore4") as HiddenField; HiddenField hidisDepScore5 = Grid1.Rows[int.Parse(btnNum)].FindControl("hidisDepScore5") as HiddenField; HiddenField hidisDepScore6 = Grid1.Rows[int.Parse(btnNum)].FindControl("hidisDepScore6") as HiddenField; List depExtendLs = new List() { hidisDepScore1.Text, hidisDepScore2.Text, hidisDepScore3.Text, hidisDepScore4.Text, hidisDepScore5.Text, hidisDepScore6.Text }; SubmitScore(depExtendLs); } } /// /// 保存数据 /// private void SubmitScore(List depExtend) { string[] fsValue = hidSaveValue.Value.Split(','); #region 评价信息 if (!string.IsNullOrEmpty(fsValue[0])) { var fo = BLL.SESRelatedDataService.GetSESRelatedDataByFoNo(fsValue[0]); 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 == fsValue[0]); var homelyModel = Funs.DB.HonestyTimelyView.FirstOrDefault(p => p.Contract_No == fsValue[0]); //用户 if (fsValue[8] == "User") { FC_Score fsModel = new FC_Score(); fsModel.Contract_No = fsValue[0]; fsModel.Score1 = (!string.IsNullOrEmpty(fsValue[1]) && fsValue[1] != "0") ? decimal.Parse(fsValue[1]) * 2 : 0; fsModel.Score2 = (!string.IsNullOrEmpty(fsValue[2]) && fsValue[2] != "0") ? decimal.Parse(fsValue[2]) * 2 : 0; fsModel.Score3 = (!string.IsNullOrEmpty(fsValue[3]) && fsValue[3] != "0") ? decimal.Parse(fsValue[3]) * 2 : 0; fsModel.Score4 = (!string.IsNullOrEmpty(fsValue[4]) && fsValue[4] != "0") ? decimal.Parse(fsValue[4]) * 2 : 0; fsModel.Score5 = (!string.IsNullOrEmpty(fsValue[5]) && fsValue[5] != "0") ? decimal.Parse(fsValue[5]) * 2 : 0; fsModel.Score6 = (!string.IsNullOrEmpty(fsValue[6]) && fsValue[6] != "0") ? decimal.Parse(fsValue[6]) * 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 == fsValue[0] && p.Requisitioner == CurrUser.Account).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.Evaluate_UserId = CurrUser.UserId; scoreJournal.Evaluate_UserName = CurrUser.UserName; scoreJournal.Evaluate_Time = DateTime.Now; scoreJournalList.Add(scoreJournal); } Funs.DB.Score_JournalEvaluation.InsertAllOnSubmit(scoreJournalList); } } //部门 if (fsValue[8] == "Dep") { FC_Score fsModel = new FC_Score(); fsModel.Contract_No = fsValue[0]; if (depExtend[0] == "1") { fsModel.Score1 = (!string.IsNullOrEmpty(fsValue[1]) && fsValue[1] != "0") ? decimal.Parse(fsValue[1]) : 0; } else { fsModel.Score1 = (decimal)-0.01; } if (depExtend[1] == "1") { fsModel.Score2 = (!string.IsNullOrEmpty(fsValue[2]) && fsValue[2] != "0") ? decimal.Parse(fsValue[2]) : 0; } else { fsModel.Score2 = (decimal)-0.01; } if (depExtend[2] == "1") { fsModel.Score3 = (!string.IsNullOrEmpty(fsValue[3]) && fsValue[3] != "0") ? decimal.Parse(fsValue[3]) : 0; } else { fsModel.Score3 = (decimal)-0.01; } if (depExtend[3] == "1") { fsModel.Score4 = (!string.IsNullOrEmpty(fsValue[4]) && fsValue[4] != "0") ? decimal.Parse(fsValue[4]) : 0; } else { fsModel.Score4 = (decimal)-0.01; } if (depExtend[4] == "1") { fsModel.Score5 = (!string.IsNullOrEmpty(fsValue[5]) && fsValue[5] != "0") ? decimal.Parse(fsValue[5]) : 0; } else { fsModel.Score5 = (decimal)-0.01; } if (depExtend[5] == "1") { fsModel.Score6 = (!string.IsNullOrEmpty(fsValue[6]) && fsValue[6] != "0") ? decimal.Parse(fsValue[6]) : 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 == fsValue[0] && p.Requisitioner != "").ToList(); } else { pjSESReport = Funs.DB.FC_SESReportView.Where(p => p.FO_NO == fsValue[0] && (p.MainCoordinatorUser == CurrUser.Account || p.ContractAdminUser == CurrUser.Account || p.UserRepresentativeUser == CurrUser.Account)).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.Evaluate_UserId = CurrUser.UserId; scoreJournal.Evaluate_UserName = CurrUser.UserName; scoreJournal.Evaluate_Time = DateTime.Now; scoreJournalList.Add(scoreJournal); } Funs.DB.Score_JournalEvaluation.InsertAllOnSubmit(scoreJournalList); } } } #endregion Funs.DB.SubmitChanges(); BindGrid(); ShowNotify("" + fsValue[0] + " 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 != null && p.Requisitioner != "").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实体 /// /// 绑定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; } #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) { HiddenField hidUserType = Grid1.Rows[e.RowIndex].FindControl("hidUserType") as HiddenField; HiddenField hidFoNo = Grid1.Rows[e.RowIndex].FindControl("hidFoNo") as HiddenField; this.hdFo.Text = hidFoNo.Text; BindGrid2(hidFoNo.Text, hidUserType.Text); } #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 } }