Basf_FCL/FCL/FineUIPro.Web/ContractorQuality/IncidentInvestigationEdit.a...

700 lines
34 KiB
C#
Raw Normal View History

2024-11-18 14:29:07 +08:00
using BLL;
using NPOI.OpenXml4Net.OPC.Internal.Unmarshallers;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace FineUIPro.Web.ContractorQuality
{
public partial class IncidentInvestigationEdit : PageBase
{
#region
/// <summary>
/// 主键
/// </summary>
public string PunishmentId
{
get
{
return (string)ViewState["PunishmentId"];
}
set
{
ViewState["PunishmentId"] = value;
}
}
#endregion
#region
/// <summary>
/// 加载页面
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
GetButtonPower();//按钮权限
GroupPanel2.Hidden = true;
GroupPanel3.Hidden = true;
GroupPanel4.Hidden = true;
GroupPanel5.Hidden = true;
this.btnClose.OnClientClick = ActiveWindow.GetHideReference();
BLL.ViolationClauseService.InitViolationClause(this.drpViolationClause, true);//违章条款
BLL.Sys_UserService.InitUserDropDownList(this.drpUserDep, true);//用户部门
BLL.Sys_UserService.InitUserDropDownList(this.drpContractAdmin, true);//合同管理员
BLL.Sys_UserService.InitUserDropDownList(this.drpContractRequester, true);//合同需求人
this.PunishmentId = Request.Params["punishmentId"];
if (!string.IsNullOrEmpty(this.PunishmentId))
{
Model.EMC_Punishment pun = BLL.PunishmentService.GetPunishmentById(this.PunishmentId);
if (pun != null)
{
string view = Request.Params["view"];
if (view == "1")
{
#region
Model.FC_SESRelatedData fcdata = BLL.SESRelatedDataService.GetSESRelatedDataByFoNo(pun.FO_NO);
this.btnSave.Hidden = true;
this.btnSbumit.Hidden = true;
if (this.CurrUser.UserId == pun.Violation_Inspector)
{
this.GroupPanel1.Hidden = false;
this.GroupPanel2.Hidden = true;
this.GroupPanel3.Hidden = true;
this.GroupPanel4.Hidden = true;
this.GroupPanel5.Hidden = true;
}
else if ((fcdata != null && this.CurrUser.UserId == fcdata.Main_Coordinator) || this.CurrUser.UserId == pun.ContractRequester)
{
this.GroupPanel1.Hidden = false;
this.GroupPanel2.Hidden = false;
this.GroupPanel3.Hidden = false;
this.GroupPanel4.Hidden = true;
this.GroupPanel5.Hidden = true;
this.GPAudit.Hidden = false;
if (pun.IsFrame == true)
{
frNoRequester.Hidden = true;
txtUserRepresentative.Hidden = true;
txtMainCoordinator.Hidden = false;
txtMCDept.Hidden = false;
}
else
{
frNoRequester.Hidden = false;
txtUserRepresentative.Hidden = false;
txtMainCoordinator.Hidden = true;
txtMCDept.Hidden = true;
}
}
else if (this.CurrUser.UserId == pun.UserDep && pun.IsFrame == true)
{
this.GroupPanel1.Hidden = false;
this.GroupPanel2.Hidden = false;
this.GroupPanel3.Hidden = false;
this.GroupPanel4.Hidden = false;
this.GroupPanel5.Hidden = true;
}
else if (this.CurrUser.UserId == pun.ContractAdmin && pun.IsFrame == true)
{
this.GroupPanel1.Hidden = false;
this.GroupPanel2.Hidden = false;
this.GroupPanel3.Hidden = false;
this.GroupPanel4.Hidden = false;
this.GroupPanel5.Hidden = false;
}
else
{
var role = BLL.Sys_RoleService.GetRole(CurrUser.RoleId);
if (role != null)
{
if (role.RoleName.Trim() == "SSRC")//申请人已提交、SSR办理
{
this.GroupPanel1.Hidden = false;
this.GroupPanel2.Hidden = false;
this.GroupPanel3.Hidden = true;
this.GroupPanel4.Hidden = true;
this.GroupPanel5.Hidden = true;
if (pun.IsFrame == true)//框架合同
{
this.txtMainCoordinator.Hidden = false;
this.txtMainCoordinator.Required = true;
this.txtMainCoordinator.ShowRedStar = true;
this.txtMCDept.Hidden = false;
this.txtMCDept.Required = true;
this.txtMCDept.ShowRedStar = true;
this.txtUserRepresentative.Hidden = false;
this.txtUserRepresentative.Required = true;
this.txtUserRepresentative.ShowRedStar = true;
frNoRequester.Hidden = true;
this.txtItemNo.Hidden = false;
}
else //非框架合同
{
this.txtMainCoordinator.Hidden = true;
this.txtMCDept.Hidden = true;
this.txtUserRepresentative.Hidden = true;
frNoRequester.Hidden = false;
this.drpContractRequester.Required = true;
this.drpContractRequester.ShowRedStar = true;
this.txtContractRequesterDep.Required = true;
this.txtContractRequesterDep.ShowRedStar = true;
this.drpContractAdmin.Required = true;
this.drpContractAdmin.ShowRedStar = true;
this.txtItemNo.Hidden = true;
}
}
}
}
#endregion
}
else
{
#region
if (pun.States == "1")
{
var role = BLL.Sys_RoleService.GetRole(CurrUser.RoleId);
if (role != null)
{
if (role.RoleName.Trim() == "SSRC")//申请人已提交、SSR办理
{
GroupPanel1.Enabled = false;
GroupPanel2.Hidden = false;
this.txtContractor.Hidden = true;
this.txtContractor2.Required = true;
this.txtContractor2.ShowRedStar = true;
this.txtFO_No.Required = true;
this.txtFO_No.ShowRedStar = true;
if (!string.IsNullOrEmpty(this.txtContractor.Text))
{
this.txtContractor2.Text = this.txtContractor.Text;
}
if (pun.IsFrame == true)//框架合同
{
this.txtMainCoordinator.Hidden = false;
this.txtMainCoordinator.Required = true;
this.txtMainCoordinator.ShowRedStar = true;
this.txtMCDept.Hidden = false;
this.txtMCDept.Required = true;
this.txtMCDept.ShowRedStar = true;
this.txtUserRepresentative.Hidden = false;
this.txtUserRepresentative.Required = true;
this.txtUserRepresentative.ShowRedStar = true;
frNoRequester.Hidden = true;
this.txtItemNo.Hidden = false;
}
else //非框架合同
{
this.txtMainCoordinator.Hidden = true;
this.txtMCDept.Hidden = true;
this.txtUserRepresentative.Hidden = true;
frNoRequester.Hidden = false;
this.drpContractRequester.Required = true;
this.drpContractRequester.ShowRedStar = true;
this.txtContractRequesterDep.Required = true;
this.txtContractRequesterDep.ShowRedStar = true;
this.drpContractAdmin.Required = true;
this.drpContractAdmin.ShowRedStar = true;
this.txtItemNo.Hidden = true;
}
}
}
}
else if (pun.States == "2") //框架合同:主协调员办理,非框架合同:需求人办理
{
GroupPanel1.Enabled = false;
GroupPanel2.Hidden = false;
GroupPanel2.Enabled = false;
GroupPanel3.Hidden = false;
this.GPAudit.Hidden = false;
this.drpViolationClause.Required = true;
this.drpViolationClause.ShowRedStar = true;
this.drpViolationDegree.Required = true;
this.drpViolationDegree.ShowRedStar = true;
this.txtCompany.Required = true;
this.txtCompany.ShowRedStar = true;
this.txtIndividual.Required = true;
this.txtIndividual.ShowRedStar = true;
if (pun.IsFrame == true)//框架合同
{
this.drpUserDep.Required = true;
this.drpUserDep.ShowRedStar = true;
GroupPanel3.Title = "主协调员填写";
//this.GPAudit.Hidden = false;
}
else //非框架合同
{
txtMainCoordinator.Hidden = true;
txtMCDept.Hidden = true;
this.txtItemNo.Hidden = true;
frNoRequester.Hidden = false;
txtUserRepresentative.Hidden = true;
this.drpUserDep.Required = false;
this.drpUserDep.ShowRedStar = false;
this.drpUserDep.Hidden = true;
GroupPanel3.Title = "合同需求人填写";
}
}
else if (pun.States == "3")//用户部门填写
{
GroupPanel1.Enabled = false;
GroupPanel2.Hidden = false;
GroupPanel2.Enabled = false;
GroupPanel3.Enabled = false;
GroupPanel3.Hidden = false;
GroupPanel4.Hidden = false;
}
else if (pun.States == "4")//合同管理员填写
{
GroupPanel1.Enabled = false;
GroupPanel2.Hidden = false;
GroupPanel2.Enabled = false;
GroupPanel3.Enabled = false;
GroupPanel3.Hidden = false;
GroupPanel4.Hidden = false;
GroupPanel4.Enabled = false;
GroupPanel5.Hidden = false;
}
#endregion
}
#region
this.hdId.Text = this.PunishmentId;
this.txtPunishDate.Text = pun.PunishDate.HasValue ? string.Format("{0:yyyy-MM-dd}", pun.PunishDate) : "";
this.txtLocation.Text = pun.Location;
this.txtDescription.Text = pun.Description;
this.txtContractor.Text = pun.Contractor;
if (!string.IsNullOrEmpty(this.txtContractor.Text))
{
this.txtContractor2.Text = this.txtContractor.Text;
}
else
{
this.txtContractor2.Text = pun.Contractor;
}
this.txtFO_No.Text = pun.FO_NO;
Model.View_FC_SESRelatedData fc = BLL.SESRelatedDataService.GetSESRelatedDataViewByFO(pun.FO_NO);
if (fc != null)
{
txtMainCoordinator.Text = fc.Main_Coordinator;
txtMCDept.Text = fc.MCDept;
txtUserRepresentative.Text = fc.User_Representative;
//this.drpContractAdmin.SelectedValue = fc.Contract_Admin;
}
if (!string.IsNullOrEmpty(pun.ContractAdmin))
{
this.drpContractAdmin.SelectedValue = pun.ContractAdmin;
}
this.txtItemNo.Text = pun.ItemNo;
if (!string.IsNullOrEmpty(pun.ContractRequester))
{
this.drpContractRequester.SelectedValue = pun.ContractRequester;
}
this.txtContractRequesterDep.Text = pun.ContractRequesterDep;
if (!string.IsNullOrEmpty(pun.ViolationClauseId))
{
this.drpViolationClause.SelectedValue = pun.ViolationClauseId;
}
if (!string.IsNullOrEmpty(pun.ViolationDegree))
{
this.drpViolationDegree.SelectedValue = pun.ViolationDegree;
}
this.txtCompany.Text = pun.Company.HasValue ? pun.Company.ToString() : "";
this.txtIndividualPerson.Text = pun.IndividualPerson;
this.txtIndividual.Text = pun.Individual.HasValue ? pun.Individual.ToString() : "";
if (!string.IsNullOrEmpty(pun.UserDep))
{
this.drpUserDep.SelectedValue = pun.UserDep;
}
this.txtIndividualSES.Text = pun.ViolationRelatedSes;
this.txtSES_No.Text = pun.SES_No;
this.txtCompletionDate.Text = pun.CompletionDate.HasValue ? string.Format("{0:yyyy-MM-dd}", pun.CompletionDate) : "";
this.rbIsPass.SelectedValue = pun.IsPass.HasValue && pun.IsPass == true ? "1" : "0";
this.txtAuditResult.Text = pun.AuditResult;
#endregion
}
}
else
{
this.txtPunishDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now);
}
}
}
#endregion
#region
/// <summary>
/// 保存
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnSave_Click(object sender, EventArgs e)
{
SaveMethod(BLL.Const.BtnSave);
}
/// <summary>
/// 提交
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnSbumit_Click(object sender, EventArgs e)
{
SaveMethod(BLL.Const.BtnSubmit);
}
private void SaveMethod(string type)
{
if (!string.IsNullOrEmpty(this.PunishmentId))
{
var pun = BLL.PunishmentService.GetPunishmentById(this.PunishmentId);
if (pun != null)
{
if (pun.States == "1")//SSR办理
{
pun.Contractor = this.txtContractor2.Text.Trim();
pun.FO_NO = this.txtFO_No.Text.Trim();
Model.View_FC_SESRelatedData fc = BLL.SESRelatedDataService.GetSESRelatedDataViewByFO(pun.FO_NO);
if (fc != null)
{
pun.ItemNo = this.txtItemNo.Text.Trim();
pun.IsFrame = true;
}
else
{
//非框架合同
pun.IsFrame = false;
if (this.drpContractRequester.SelectedValue != BLL.Const._Null)
{
pun.ContractRequester = this.drpContractRequester.SelectedValue;
}
pun.ContractRequesterDep = this.txtContractRequesterDep.Text.Trim();
}
if (this.drpContractAdmin.SelectedValue != BLL.Const._Null)
{
pun.ContractAdmin = this.drpContractAdmin.SelectedValue;
}
if (type == BLL.Const.BtnSubmit)
{
pun.States = "2";//SSR已提交
}
else
{
pun.States = "1";//SSR保存未提交
}
}
else if (pun.States == "2")
{
pun.ViolationClauseId = this.drpViolationClause.SelectedValue;
pun.ViolationDegree = this.drpViolationDegree.SelectedValue;
pun.Company = Funs.GetNewDecimal(this.txtCompany.Text.Trim());
pun.IndividualPerson = this.txtIndividualPerson.Text.Trim();
pun.Individual = Funs.GetNewDecimal(this.txtIndividual.Text.Trim());
if (rbIsPass.SelectedValue == "1")
{
pun.IsPass = true;
//pun.States = "3";//主协调员已通过并提交
}
else
{
pun.IsPass = false;
//pun.States = "0";//拒绝并打回 系统通知所有人
}
pun.AuditResult = txtAuditResult.Text.Trim();
if (pun.IsFrame == true)//框架合同
{
if (this.drpUserDep.SelectedValue != BLL.Const._Null)
{
pun.UserDep = this.drpUserDep.SelectedValue;
}
if (type == BLL.Const.BtnSubmit)
{
pun.States = "3";//主协调员提交
}
}
else //非框架合同
{
if (type == BLL.Const.BtnSubmit)
{
pun.States = "5";//合同需求人已提交
}
}
}
else if (pun.States == "3")//用户部门提交
{
pun.ViolationRelatedSes = this.txtIndividualSES.Text.Trim();
if (type == BLL.Const.BtnSubmit)
{
pun.States = "4";//用户部门提交
}
}
else if (pun.States == "4")//合同管理员
{
pun.SES_No = this.txtSES_No.Text.Trim();
pun.CompletionDate = Funs.GetNewDateTime(this.txtCompletionDate.Text);
if (type == BLL.Const.BtnSubmit)
{
pun.States = "5";//合同管理员已提交
}
}
else
{
pun.PunishDate = Funs.GetNewDateTime(this.txtPunishDate.Text);
pun.Location = this.txtLocation.Text.Trim();
pun.Description = this.txtDescription.Text.Trim();
pun.Contractor = this.txtContractor.Text.Trim();
pun.Flag = "2";//质量
if (type == BLL.Const.BtnSubmit)
{
pun.States = "1";//申请人已提交
}
else
{
pun.States = "0";//申请人未提交
}
}
}
pun.PunishmentId = this.PunishmentId;
var att = from x in Funs.DB.AttachFile where x.ToKeyId == this.PunishmentId select x;
if (att.Count() > 0)
{
pun.AttachUrl = att.First().AttachUrl;
}
BLL.PunishmentService.UpdatePunishment(pun);
BLL.Sys_LogService.AddLog(this.CurrUser.UserId, "修改承包商质量事件调查");
}
else
{
Model.EMC_Punishment punishment = new Model.EMC_Punishment();
punishment.PunishDate = Funs.GetNewDateTime(this.txtPunishDate.Text);
punishment.Location = this.txtLocation.Text.Trim();
punishment.Description = this.txtDescription.Text.Trim();
punishment.Contractor = this.txtContractor.Text.Trim();
punishment.Flag = "2";//质量
if (type == BLL.Const.BtnSubmit)
{
punishment.States = "1";//申请人已提交
}
else
{
punishment.States = "0";//申请人未提交
}
if (!string.IsNullOrEmpty(this.hdId.Text))
{
punishment.PunishmentId = this.hdId.Text.Trim();
}
else
{
punishment.PunishmentId = SQLHelper.GetNewID(typeof(Model.EMC_Punishment));
this.hdId.Text = punishment.PunishmentId;
}
var att = from x in Funs.DB.AttachFile where x.ToKeyId == punishment.PunishmentId select x;
if (att.Count() > 0)
{
punishment.AttachUrl = att.First().AttachUrl;
}
punishment.Violation_Inspector = this.CurrUser.UserId;//发起人
punishment.CreateDate = DateTime.Now;
BLL.PunishmentService.AddPunishment(punishment);
BLL.Sys_LogService.AddLog(this.CurrUser.UserId, "增加承包商质量事件调查");
}
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
}
#endregion
#region
/// <summary>
/// 合同号改变事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void txtText_TextChanged(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(txtFO_No.Text))
{
string foNO = txtFO_No.Text.Trim();
Model.View_FC_SESRelatedData fc = BLL.SESRelatedDataService.GetSESRelatedDataViewByFO(foNO);
if (fc != null)
{
this.drpContractAdmin.SelectedIndex = 0;
this.drpContractRequester.SelectedIndex = 0;
this.txtContractRequesterDep.Text = string.Empty;
this.drpContractRequester.Required = false;
this.drpContractRequester.ShowRedStar = false;
this.txtContractRequesterDep.Required = false;
this.txtContractRequesterDep.ShowRedStar = false;
this.frNoRequester.Hidden = true;
this.txtMainCoordinator.Hidden = false;
this.txtMCDept.Hidden = false;
this.txtUserRepresentative.Hidden = false;
this.txtItemNo.Hidden = false;
this.txtMainCoordinator.Required = true;
this.txtMainCoordinator.ShowRedStar = true;
this.txtMCDept.Required = true;
this.txtMCDept.ShowRedStar = true;
this.txtUserRepresentative.Required = true;
this.txtUserRepresentative.ShowRedStar = true;
if (string.IsNullOrEmpty(this.txtContractor.Text))
{
txtContractor2.Text = fc.Contractor;
}
txtMainCoordinator.Text = fc.Main_Coordinator;
txtMCDept.Text = fc.MCDept;
txtUserRepresentative.Text = fc.User_Representative;
this.drpContractAdmin.SelectedValue = fc.Contract_AdminId;
// 序号
var pun = from x in Funs.DB.EMC_Punishment where x.FO_NO == foNO && x.Flag == "2" select x;
if (pun.Count() == 0)
{
txtItemNo.Text = "001";
}
else
{
var max = pun.Max(x => x.ItemNo);
if (!string.IsNullOrEmpty(max))
{
int maxNo = Convert.ToInt32(max) + 1;
txtItemNo.Text = "00" + maxNo.ToString();
}
else
{
txtItemNo.Text = "001";
}
}
}
else
{
this.txtMainCoordinator.Text = string.Empty;
this.txtMCDept.Text = string.Empty;
this.txtUserRepresentative.Text = string.Empty;
this.drpContractAdmin.SelectedIndex = 0;
this.txtItemNo.Text = string.Empty;
this.txtMainCoordinator.Required = false;
this.txtMainCoordinator.ShowRedStar = false;
this.txtMCDept.Required = false;
this.txtMCDept.ShowRedStar = false;
this.txtUserRepresentative.Required = false;
this.txtUserRepresentative.ShowRedStar = false;
this.drpContractAdmin.Required = false;
this.drpContractAdmin.ShowRedStar = false;
txtMainCoordinator.Hidden = true;
txtMCDept.Hidden = true;
txtUserRepresentative.Hidden = true;
this.txtItemNo.Hidden = true;
frNoRequester.Hidden = false;
this.drpContractRequester.Required = true;
this.drpContractRequester.ShowRedStar = true;
this.txtContractRequesterDep.Required = true;
this.txtContractRequesterDep.ShowRedStar = true;
}
}
}
/// <summary>
/// 违章条款下拉选择事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void drpViolationClause_OnSelectedIndexChanged(object sender, EventArgs e)
{
if (drpViolationClause.SelectedValue != Const._Null)
{
var vio = BLL.ViolationClauseService.GetViolationClause(drpViolationClause.SelectedValue);
if (vio.DeductionComPany1 != 0)
{
drpViolationDegree.SelectedValue = "1";
txtCompany.Text = vio.DeductionComPany1.ToString();
txtIndividual.Text = vio.DeductionIndividual1.ToString();
//txtBackcharge.Text = (vio.DeductionComPany1 + vio.DeductionIndividual1).ToString();
}
if (vio.DeductionComPany2 != 0)
{
drpViolationDegree.SelectedValue = "2";
txtCompany.Text = vio.DeductionComPany2.ToString();
txtIndividual.Text = vio.DeductionIndividual2.ToString();
////txtBackcharge.Text = (vio.DeductionComPany2 + vio.DeductionIndividual2).ToString();
}
if (vio.DeductionComPany3 != 0)
{
drpViolationDegree.SelectedValue = "3";
txtCompany.Text = vio.DeductionComPany3.ToString();
txtIndividual.Text = vio.DeductionIndividual3.ToString();
//txtBackcharge.Text = (vio.DeductionComPany2 + vio.DeductionIndividual3).ToString();
}
}
}
#endregion
#region
/// <summary>
/// 相关附件上传
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnAttach_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(this.hdId.Text)) //新增记录
{
this.hdId.Text = SQLHelper.GetNewID(typeof(Model.EMC_Punishment));
}
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../AttachFile/webuploader2.aspx?type=0&toKeyId={0}&path=FileUpload/SES/EMC_Punishment&menuId={1}", this.hdId.Text, BLL.Const.IncidentInvestigationMenuId)));
}
/// <summary>
/// 质量调查相关附件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnAttach2_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(this.hdId.Text)) //新增记录
{
this.hdId.Text = SQLHelper.GetNewID(typeof(Model.EMC_Punishment));
}
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../AttachFile/webuploader2.aspx?type=0&toKeyId={0}&path=FileUpload/SES/EMC_Punishment&menuId={1}", this.hdId.Text, BLL.Const.IncidentInvestigationMenuId)));
}
#endregion
#region
/// <summary>
/// 菜单按钮权限
/// </summary>
private void GetButtonPower()
{
var buttonList = BLL.CommonService.GetAllButtonList(this.CurrUser.UserId, BLL.Const.IncidentInvestigationMenuId);
if (buttonList.Count() > 0)
{
if (buttonList.Contains(BLL.Const.BtnSave))
{
this.btnSave.Hidden = false;
}
if (buttonList.Contains(BLL.Const.BtnSubmit))
{
this.btnSbumit.Hidden = false;
}
}
}
#endregion
}
}