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

402 lines
18 KiB
C#
Raw Normal View History

2024-05-08 10:17:02 +08:00
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;
namespace FineUIPro.Web.Evaluation
{
public partial class ContractorEvaluationEdit : PageBase
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
btnClose.OnClientClick = ActiveWindow.GetHideReference();
2024-05-08 10:20:39 +08:00
//
2024-05-08 10:17:02 +08:00
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;
cbAuditResult.Enabled = false;
//cbBoQIsAudit.Enabled = false;
//txtBoQ.Enabled = false;
cbIsOthers.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;
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;
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();
if (foview.First().Forecasted.HasValue)
{
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();
// 采购
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;
// 主协调人
if (foview.First().IsInquiry.HasValue)
{
if (foview.First().IsInquiry == true)
{
cbInquiry.SelectedValueArray = new string[] { "True" };
}
else
{
cbInquiry.SelectedValueArray = new string[] { "False" };
}
}
if (foview.First().InquiryNum.HasValue)
{
numInquiryTime.Text = foview.First().InquiryNum.ToString();
}
if (foview.First().NCRIsReview.HasValue)
{
if (foview.First().NCRIsReview == true)
{
cbNCR.SelectedValueArray = new string[] { "True" };
}
else
{
cbNCR.SelectedValueArray = new string[] { "False" };
}
}
if (foview.First().NCRReviewNum.HasValue)
{
numNCRTime.Text = foview.First().NCRReviewNum.ToString();
}
if (!string.IsNullOrEmpty(foview.First().AuditResult))
{
cbAuditResult.SelectedValueArray = new string[] { foview.First().AuditResult };
}
//if (foview.First().BoQIsAudit.HasValue)
//{
// if (foview.First().BoQIsAudit == true)
// {
// cbBoQIsAudit.SelectedValueArray = new string[] { "True" };
// }
// else
// {
// cbBoQIsAudit.SelectedValueArray = new string[] { "False" };
// }
//}
//txtBoQ.Text = foview.First().BoQAuditComments;
if (foview.First().IsOthers.HasValue)
{
if (foview.First().IsOthers == true)
{
cbIsOthers.SelectedValueArray = new string[] { "True" };
}
else
{
cbIsOthers.SelectedValueArray = new string[] { "False" };
}
}
if (foview.First().OthersNum.HasValue)
{
numOthers.Text = foview.First().OthersNum.ToString();
}
txtTechnicalBonus.Text = foview.First().TechnicalBonus;
txtSafetyBonus.Text = foview.First().SafetyBonus;
txtProposed.Text = foview.First().Proposed;
}
else
{
}
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");
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));
//var sesFoDataScore = sesDataScore.Where(p => p.FO_NO == foNo).ToList();
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[j] = "1st Year";
Grid1.Rows[1].Values[j] = "";
Grid1.Rows[2].Values[j] = "2st Year";
Grid1.Rows[3].Values[j] = "";
}
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;
}
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;
}
else
{
Grid1.Rows[3].Values[j - 11] = "";
}
}
}
}
}
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.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
}
}