Basf_FCL/FCL/FineUIPro.Web/Evaluation/ContractorEvaluationEdit.as...

526 lines
26 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using BLL;
using System.Drawing;
namespace FineUIPro.Web.Evaluation
{
public partial class ContractorEvaluationEdit : PageBase
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
btnClose.OnClientClick = ActiveWindow.GetHideReference();
//
string foNo = Request.Params["foNo"];
var foview = from x in Funs.DB.View_Contractor_Evaluation where x.FO_NO == foNo select x;
if (foview.Count() > 0)
{
// 权限
if (CurrUser.UserId != Const.GlyId)
{
txtReviewOfFC.Enabled = false;
lbPriceEvaluation.Enabled = false;
txtPriceEvaluation1.Enabled = false;
txtPriceEvaluation2.Enabled = false;
cbPriceLevel.Enabled = false;
txtEnumeration.Enabled = false;
txtForecasted.Enabled = false;
//cbNCR.Enabled = false;
numNCRTime.Enabled = false;
//cbInquiry.Enabled = false;
numInquiryTime.Enabled = false;
numWorkRe.Enabled = false;
txtGreenTimes.Enabled = false;
txtYellowGreenTimes.Enabled = false;
txtYellowTimes.Enabled = false;
txtRedYellowTimes.Enabled = false;
txtRedTimes.Enabled = false;
//cbAuditResult.Enabled = false;
//cbBoQIsAudit.Enabled = false;
//txtBoQ.Enabled = false;
//cbIsOthers.Enabled = false;
//txtOtherDef.Enabled = false;
numOthers.Enabled = false;
txtProposed.Enabled = false;
txtTechnicalBonus.Enabled = false;
txtSafetyBonus.Enabled = false;
btnSave.Hidden = true;
// 商务
if (foview.First().BuyerId == CurrUser.UserId)
{
txtReviewOfFC.Enabled = true;
lbPriceEvaluation.Enabled = false;
txtPriceEvaluation1.Enabled = true;
txtPriceEvaluation2.Enabled = true;
cbPriceLevel.Enabled = true;
txtEnumeration.Enabled = true;
btnSave.Hidden = false;
}
// 合同员
if (foview.First().Contract_Admin == CurrUser.UserId)
{
//cbNCR.Enabled = true;
numNCRTime.Enabled = true;
//cbInquiry.Enabled = true;
numInquiryTime.Enabled = true;
numWorkRe.Enabled = true;
txtGreenTimes.Enabled = true;
txtYellowGreenTimes.Enabled = true;
txtYellowTimes.Enabled = true;
txtRedYellowTimes.Enabled = true;
txtRedTimes.Enabled = true;
numOthers.Enabled = true;
//cbAuditResult.Enabled = true;
btnSave.Hidden = false;
}
// 主协调员
if (foview.First().Main_CoordinatorId == CurrUser.UserId)
{
txtForecasted.Enabled = true;
txtTechnicalBonus.Enabled = true;
//cbIsOthers.Enabled = true;
numOthers.Enabled = true;
//txtOtherDef.Enabled= true;
txtProposed.Enabled = true;
btnSave.Hidden = false;
}
var role = BLL.Sys_RoleService.GetRole(CurrUser.RoleId);
//if (role != null && role.RoleName.Contains("CTK Engineer"))
var depart = BLL.DepartService.GetDepartById(CurrUser.DepartId);
// CT/K部门
//if (depart != null && depart.DepartCode.Contains("CT/K"))
//{
// cbBoQIsAudit.Enabled = true;
// txtBoQ.Enabled = true;
// btnSave.Hidden = false;
//}
// CTS/S角色
if (role != null && role.RoleName.Contains("CTS/S"))
{
txtSafetyBonus.Enabled = true;
btnSave.Hidden = false;
}
}
// 框架合同信息
txtSpending_commitment.Text = foview.First().Spending_commitment.ToString();
txtForecasted.Text = foview.First().Forecasted.ToString();
txtTotal.Text = foview.First().Total.ToString();
txtYearAvg.Text = foview.First().YearAvg.ToString();
txtFo.Text = foview.First().FO_NO;
txtContractor.Text = foview.First().Contractor;
txtDiscipline.Text = foview.First().Discipline;
txtValidate_Date.Text = foview.First().Validate_Date.HasValue ? foview.First().Validate_Date.Value.ToString("yyyy-MM-dd") : "";
txtExpire_Date.Text = foview.First().Expire_Date.HasValue ? foview.First().Expire_Date.Value.ToString("yyyy-MM-dd") : "";
txtPercentage.Text = foview.First().VolumeAllocation;
txtYearDiff.Text = foview.First().YearDiff.ToString();
if (foview.First().IfExtend == "Y")
{
cbIfExtend.Checked = true;
}
else
{
cbIfExtend.Checked = false;
}
if (!string.IsNullOrEmpty(foview.First().PreviousFO))
{
txtPreviousFO.Text = foview.First().PreviousFO.ToString();
}
var d = BLL.SESRelatedDataService.GetSESRelatedDataByFoNo(txtPreviousFO.Text.Trim());
if (d != null)
{
txtFoValidateDate.Text = d.Validate_Date.HasValue ? string.Format("{0:yyyy-MM-dd}", d.Validate_Date) : "";
txtFoExpiryDate.Text = d.Expire_Date.HasValue ? string.Format("{0:yyyy-MM-dd}", d.Expire_Date) : "";
}
// 采购
txtReviewOfFC.Text = foview.First().ReviewOfFC;
txtPriceEvaluation1.Text = foview.First().PriceEvaluation1;
txtPriceEvaluation2.Text = foview.First().PriceEvaluation2;
if (!string.IsNullOrEmpty(foview.First().PriceLevel))
{
cbPriceLevel.SelectedValueArray = new string[] { foview.First().PriceLevel };
}
txtEnumeration.Text = foview.First().Enumeration;
numInquiryTime.Text = foview.First().InterviewTimes.ToString();//约谈
numNCRTime.Text = foview.First().NCRTimes.ToString();//NCR
numWorkRe.Text = foview.First().RectificationTimes.ToString();//停工整改
txtGreenTimes.Text = foview.First().GreenTimes.ToString();
txtYellowGreenTimes.Text = foview.First().YellowGreenTimes.ToString();
txtYellowTimes.Text = foview.First().YellowTimes.ToString();
txtRedYellowTimes.Text = foview.First().RedYellowTimes.ToString();
txtRedTimes.Text = foview.First().RedTimes.ToString();
if (txtGreenTimes.Text.Trim() == "0" && txtYellowGreenTimes.Text.Trim() == "0" && txtYellowTimes.Text.Trim() == "0" && txtRedYellowTimes.Text.Trim() == "0" && txtRedTimes.Text.Trim() == "0")
{
cbNotAudit.Checked = true;
}
numOthers.Text = foview.First().OthersNum.ToString();
txtTechnicalBonus.Text = foview.First().TechnicalBonusMalus.ToString();
if (!string.IsNullOrEmpty(foview.First().SafetyBonus))
{
txtSafetyBonus.Text = Funs.GetNewDecimalOrZero(foview.First().SafetyBonus).ToString();
}
}
else
{
}
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 (cbIfExtend.Checked)//续签合同如果2年数据跨域两个合同期本合同周期的评分使用加粗字体
{
List<SqlParameter> yearToDateParam = new List<SqlParameter>();
yearToDateParam.Add(new SqlParameter("@StartTime", startTime));
yearToDateParam.Add(new SqlParameter("@EndTime", endTime));
yearToDateParam.Add(new SqlParameter("@FoNo", foNo));
SqlParameter[] yearToDateParList = yearToDateParam.ToArray();
var sesDataTable = SQLHelper.GetDataTableRunProc("Sp_ContractorEvaluation", yearToDateParList);
//上一轮合同
var fo = BLL.SESRelatedDataService.GetSESRelatedDataByFoNo(foNo);
if (fo != null)
{
if (!string.IsNullOrEmpty(fo.PreviousFO))
{
List<SqlParameter> yearToDateParam2 = new List<SqlParameter>();
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<List<YearToDateModel>>(JsonConvert.SerializeObject(sesDataTable));
string strSql = "SELECT * FROM dbo.YearsScore";
DataTable dt = SQLHelper.GetDataTableRunText(strSql, null);
Grid1.DataSource = dt;
Grid1.DataBind();
for (int j = 0; j < 24; j++)
{
var curDate = DateTime.Parse("" + startDate.Year + "-" + startDate.Month + "-01").AddMonths(j);
if (j >= 0 && j < 12)
{
Grid1.Rows[0].Values[j + 1] = curDate.ToString("yyyy-MM");
//if (j == 0)
//{
Grid1.Rows[0].Values[0] = "1st Year";
Grid1.Rows[1].Values[0] = "";
Grid1.Rows[2].Values[0] = "2st Year";
Grid1.Rows[3].Values[0] = "";
//}
//else
//{
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.##");
Grid1.Rows[1].Values[j + 1] = yearNums;
//设置字体加粗
var sesFo = sesDataScore.FirstOrDefault(p => p.dataMonth == curDate.ToString("yyyy-MM")).FO_NO;
if (sesFo == foNo)
{
Grid1.Rows[1].Values[j + 1] = "<font style='font-weight: bold'>" + yearNums + "</font>";
}
//记录小于60分的次数
if (Funs.GetNewDecimalOrZero(yearNums) < 60)
{
s++;
}
}
else
{
Grid1.Rows[1].Values[j + 1] = "";
}
//}
}
if (j >= 12 && j < 24)
{
Grid1.Rows[2].Values[j - 11] = 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.##");
Grid1.Rows[3].Values[j - 11] = yearNums;
//本期合同字体加粗
var sesFo = sesDataScore.FirstOrDefault(p => p.dataMonth == curDate.ToString("yyyy-MM")).FO_NO;
if (sesFo == foNo)
{
Grid1.Rows[3].Values[j - 11] = "<font style='font-weight: bold'>" + yearNums + "</font>";
}
//记录小于60的次数
if (Funs.GetNewDecimalOrZero(yearNums) < 60)
{
s++;
}
}
else
{
Grid1.Rows[3].Values[j - 11] = "";
}
}
}
}
else
{
List<SqlParameter> yearToDateParam = new List<SqlParameter>();
yearToDateParam.Add(new SqlParameter("@StartTime", startTime));
yearToDateParam.Add(new SqlParameter("@EndTime", endTime));
yearToDateParam.Add(new SqlParameter("@FoNo", foNo));
SqlParameter[] yearToDateParList = yearToDateParam.ToArray();
var sesDataTable = SQLHelper.GetDataTableRunProc("Sp_ContractorEvaluation", yearToDateParList);
var sesDataScore = JsonConvert.DeserializeObject<List<YearToDateModel>>(JsonConvert.SerializeObject(sesDataTable));
string strSql = "SELECT * FROM dbo.YearsScore";
DataTable dt = SQLHelper.GetDataTableRunText(strSql, null);
Grid1.DataSource = dt;
Grid1.DataBind();
for (int j = 0; j < 24; j++)
{
var curDate = DateTime.Parse("" + startDate.Year + "-" + startDate.Month + "-01").AddMonths(j);
if (j >= 0 && j < 12)
{
Grid1.Rows[0].Values[j + 1] = curDate.ToString("yyyy-MM");
//if (j == 0)
//{
Grid1.Rows[0].Values[0] = "1st Year";
Grid1.Rows[1].Values[0] = "";
Grid1.Rows[2].Values[0] = "2st Year";
Grid1.Rows[3].Values[0] = "";
//}
//else
//{
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.##");
Grid1.Rows[1].Values[j + 1] = yearNums;
if (Funs.GetNewDecimalOrZero(yearNums) < 60)
{
s++;
}
}
else
{
Grid1.Rows[1].Values[j + 1] = "";
}
//}
}
if (j >= 12 && j < 24)
{
Grid1.Rows[2].Values[j - 11] = 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.##");
Grid1.Rows[3].Values[j - 11] = yearNums;
if (Funs.GetNewDecimalOrZero(yearNums) < 60)
{
s++;
}
}
else
{
Grid1.Rows[3].Values[j - 11] = "";
}
}
}
}
string rs = string.Empty;
if (s >= 3 && foview.First().NCRTimes >= 3)
{
rs = "序号1该合同累计3次月度评估低于60分, 不得参与下轮合同\r\n序号2该合同累计三个NCR提前终止合同且不得参与下轮合同";
}
else if (s >= 3)
{
rs = "序号1该合同累计3次月度评估低于60分, 不得参与下轮合同";
}
else if (foview.First().NCRTimes >= 3)
{
rs = "序号1该合同累计三个NCR提前终止合同且不得参与下轮合同";
}
if (!string.IsNullOrEmpty(foview.First().Proposed) && !string.IsNullOrEmpty(rs))
{
txtProposed.Text = rs + "\r\n" + foview.First().Proposed;
}
else if (!string.IsNullOrEmpty(foview.First().Proposed) && string.IsNullOrEmpty(rs))
{
txtProposed.Text = foview.First().Proposed;
}
else
{
txtProposed.Text = rs;
}
}
}
protected void btnSave_Click(object sender, EventArgs e)
{
string foNo = Request.Params["foNo"];
Model.FC_SESRelatedData newFo = Funs.DB.FC_SESRelatedData.FirstOrDefault(x => x.FO_NO == foNo);
if (newFo != null)
{
if (txtForecasted.Text!=string.Empty)
{
newFo.Forecasted = Convert.ToDecimal(txtForecasted.Text);
}
newFo.ReviewOfFC= txtReviewOfFC.Text.Trim();
newFo.PriceEvaluation1= txtPriceEvaluation1.Text.Trim();
newFo.PriceEvaluation2= txtPriceEvaluation2.Text.Trim();
if (cbPriceLevel.SelectedValueArray.Length>0)
{
newFo.PriceLevel = cbPriceLevel.SelectedValueArray[0].ToString();
}
newFo.Enumeration= txtEnumeration.Text.Trim();
// 合同员
//if (cbInquiry.SelectedValueArray.Length > 0)
//{
// newFo.IsInquiry = Convert.ToBoolean(cbInquiry.SelectedValueArray[0].ToString());
//}
//else if (newFo.Contract_Admin == CurrUser.UserId)
//{
// Alert.ShowInTop("若无Interview请勾选无No!", MessageBoxIcon.Warning);
// return;
//}
if (!string.IsNullOrEmpty(numInquiryTime.Text))
{
newFo.InquiryNum = Convert.ToInt32(numInquiryTime.Text);
}
//if (cbNCR.SelectedValueArray.Length>0)
//{
// newFo.NCRIsReview = Convert.ToBoolean(cbNCR.SelectedValueArray[0].ToString());
//}
//else if (newFo.Contract_Admin == CurrUser.UserId)
//{
// Alert.ShowInTop("若无Review请勾选无No!", MessageBoxIcon.Warning);
// return;
//}
if (!string.IsNullOrEmpty(numNCRTime.Text))
{
newFo.NCRReviewNum = Convert.ToInt32(numNCRTime.Text);
}
//if (cbAuditResult.SelectedValueArray.Length>0)
//{
// newFo.AuditResult = cbAuditResult.SelectedValueArray[0].ToString();
//}
//else if (newFo.Contract_Admin == CurrUser.UserId)
//{
// Alert.ShowInTop("若无FC EHSQ Audit result ,请勾选无不适用!", MessageBoxIcon.Warning);
// return;
//}
//if (cbBoQIsAudit.SelectedValueArray.Length>0)
//{
// newFo.BoQIsAudit = Convert.ToBoolean(cbBoQIsAudit.SelectedValueArray[0].ToString());
//}
//newFo.BoQAuditComments= txtBoQ.Text.Trim();
//if (cbIsOthers.SelectedValueArray.Length>0)
//{
// newFo.IsOthers = Convert.ToBoolean(cbIsOthers.SelectedValueArray[0].ToString());
//}
//else if (newFo.Main_Coordinator == CurrUser.UserId)
//{
// Alert.ShowInTop("若无Others 请勾选无No!", MessageBoxIcon.Warning);
// return;
//}
if (!string.IsNullOrEmpty(numOthers.Text))
{
newFo.OthersNum = Convert.ToInt32(numOthers.Text);
}
//newFo.OtherDef = txtOtherDef.Text.Trim();
newFo.TechnicalBonus = txtTechnicalBonus.Text.Trim();
var role = BLL.Sys_RoleService.GetRole(CurrUser.RoleId);
//if (txtSafetyBonus.Text != string.Empty)
//{
newFo.SafetyBonus = txtSafetyBonus.Text.Trim();
//}
//else if (role != null && role.RoleName.Contains("CTS/S"))
//{
// Alert.ShowInTop("若无加减分,请填写无!", MessageBoxIcon.Warning);
// return;
//}
newFo.Proposed= txtProposed.Text.Trim();
Funs.DB.SubmitChanges();
BLL.Sys_LogService.AddLog(this.CurrUser.UserId, "Modify FC List!");
ShowNotify("Save successfully!", MessageBoxIcon.Success);
}
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
}
protected void Forecasted_OnTextChanged(object sender, EventArgs e)
{
if (txtForecasted.Text != string.Empty)
{
txtTotal.Text = (Convert.ToDecimal(txtForecasted.Text) + Convert.ToDecimal(txtSpending_commitment.Text != string.Empty ? txtSpending_commitment.Text : "0")).ToString();
if (txtYearDiff.Text != string.Empty && Convert.ToDecimal(txtYearDiff.Text) != 0)
{
txtYearAvg.Text = ((Convert.ToDecimal(txtForecasted.Text) + Convert.ToDecimal(txtSpending_commitment.Text != string.Empty ? txtSpending_commitment.Text : "0")) / Convert.ToDecimal(txtYearDiff.Text)).ToString("0.00");
}
}
}
#region
/// <summary>
/// 实体
/// </summary>
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
}
}