using BLL;
using BLL.Common;
using Org.BouncyCastle.Bcpg.OpenPgp;
using System;
using System.Collections.Specialized;
using System.Drawing;
using System.Linq;
namespace FineUIPro.Web.ContractorQuality
{
public partial class IncidentInvestigationEdit : PageBase
{
#region 定义项
///
/// 主键
///
public string PunishmentId
{
get
{
return (string)ViewState["PunishmentId"];
}
set
{
ViewState["PunishmentId"] = value;
}
}
#endregion
#region 加载页面
///
/// 加载页面
///
///
///
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
//GetButtonPower();//按钮权限
GroupPanel2.Hidden = true;
GroupPanel3.Hidden = true;
GroupPanel4.Hidden = true;
GroupPanel5.Hidden = true;
GroupPanel6.Hidden = true;
GroupPanel7.Hidden = true;
BLL.ViolationClauseService.InitViolationClause(this.drpViolationClause, true);//违章条款
BLL.ViolationClauseService.InitViolationClause(this.drpViolationClause2, true);//违章条款
BLL.DepartService.InitDropDownList(this.drpUserDep, true);//用户部门
//BLL.Sys_UserService.InitUserDropDownList(this.drpContractAdmin, true);
//合同管理员
this.drpContractAdmin.DataTextField = "UserName";
this.drpContractAdmin.DataValueField = "UserId";
this.drpContractAdmin.DataSource = BLL.Sys_UserService.getUserListByRoleId(BLL.Const.Role_ContractAdministratorId, true);
this.drpContractAdmin.DataBind();
Funs.FineUIPleaseSelect(this.drpContractAdmin);
//BLL.Sys_UserService.InitUserDropDownList(this.drpNoFrameContractAdmin, true);//非框架合同管理员
this.drpNoFrameContractAdmin.DataTextField = "UserName";
this.drpNoFrameContractAdmin.DataValueField = "UserId";
this.drpNoFrameContractAdmin.DataSource = BLL.Sys_UserService.getUserListByRoleId(BLL.Const.Role_ContractAdministratorId, true);
this.drpNoFrameContractAdmin.DataBind();
Funs.FineUIPleaseSelect(this.drpNoFrameContractAdmin);
BLL.Sys_UserService.InitUserDropDownList(this.drpContractRequester, true);//合同需求人
BLL.Sys_UserService.InitUserDropDownList(this.drpBuyer, true);//采购员
BLL.Sys_UserService.InitUserDropDownList(this.drpBuyer2, true);//采购员
BLL.Sys_UserService.InitUserDropDownList(this.drpPVTRequester, true);//PVT小组组长/请购人
//BLL.Sys_UserService.InitUserDropDownList(this.drpPVTRequester2, true);//PVT小组组长/请购人
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 查看显示
btnSave.Hidden = true;
GroupPanel1.Hidden = false;
GroupPanel2.Hidden = false;
if (pun.SeType == "1")//服务
{
if (pun.IsFrame == true)//框架合同
{
fr1.Hidden = false;
fr2.Hidden = false;
fr3.Hidden = false;
fr4.Hidden = false;
frNoFrame1.Hidden = true;
frNoFrame2.Hidden = true;
frWz.Hidden = true;
GroupPanel3.Hidden = false;
GroupPanel4.Hidden = false;
GroupPanel5.Hidden = false;
var audit = BLL.PunishmentAuditService.GetAuditBypunishmentIdAndAuditMan(this.PunishmentId,this.CurrUser.UserId);
if (pun.IsPass == false && audit != null)
{
frMCNoPass.Hidden = false;
this.txtMCNoPassReason.Text = pun.AuditResult;
}
}
else//非框架合同
{
fr1.Hidden = true;
fr2.Hidden = true;
fr3.Hidden = true;
fr4.Hidden = true;
frNoFrame1.Hidden = false;
frNoFrame2.Hidden = false;
frWz.Hidden = true;
GroupPanel3.Hidden = false;
drpUserDep.Hidden = true;
GroupPanel6.Hidden = false;
var audit = BLL.PunishmentAuditService.GetAuditBypunishmentIdAndAuditMan(this.PunishmentId, this.CurrUser.UserId);
if (pun.IsPass == false && audit != null)
{
frMCNoPass.Hidden = false;
this.txtMCNoPassReason.Text = pun.AuditResult;
}
}
}
else if(pun.SeType=="2")//物资
{
fr1.Hidden = true;
fr2.Hidden = true;
fr3.Hidden = true;
fr4.Hidden = true;
frNoFrame1.Hidden = true;
frNoFrame2.Hidden = true;
frWz.Hidden = false;
GroupPanel7.Hidden = false;
GroupPanel6.Hidden = false;
var audit = BLL.PunishmentAuditService.GetAuditByAuditMan(this.PunishmentId, this.CurrUser.UserId);
if (pun.IsPass == false && audit != null)
{
frPVTNoPass.Hidden = false;
this.txtPVTNoPassReason.Text = pun.AuditResult;
}
}
else
{
fr1.Hidden = false;
fr2.Hidden = false;
fr3.Hidden = false;
fr4.Hidden = false;
frNoFrame1.Hidden = true;
frNoFrame2.Hidden = true;
frWz.Hidden = true;
GroupPanel3.Hidden = false;
GroupPanel4.Hidden = false;
GroupPanel5.Hidden = false;
var audit = BLL.PunishmentAuditService.GetAuditBypunishmentIdAndAuditMan(this.PunishmentId, "SSR");
if (pun.IsPass == false && audit != null)
{
frRRSNoPass.Hidden = false;
this.txtRRSNoPassReson.Text = pun.AuditResult;
}
}
#endregion
}
else
{
#region 操作显示
if (pun.States == "1")
{
var role = BLL.Sys_RoleService.GetRole(CurrUser.RoleId);
if ((role != null && role.RoleName.Trim() == "SSRC") || this.CurrUser.UserId == BLL.Const.GlyId)
{
this.btnSave.Hidden = false;
this.btnSbumit.Hidden = false;
this.btnNoPass.Hidden = false;//拒绝按钮
GroupPanel1.Enabled = false;
GroupPanel2.Hidden = false;
if (pun.SeType == "1")//服务
{
frWz.Hidden = true;
fr1.Hidden = false;
this.txtFO_No.Required = true;
this.txtFO_No.ShowRedStar = true;
if (pun.IsFrame == true)//框架合同
{
fr2.Hidden = false;
fr3.Hidden = false;
fr4.Hidden = false;
frNoFrame1.Hidden = true;
frNoFrame2.Hidden = true;
this.txtContractor.Required = true;
this.txtContractor.ShowRedStar = true;
this.txtMainCoordinator.Required = true;
this.txtMainCoordinator.ShowRedStar = true;
this.txtMCDept.Required = true;
this.txtMCDept.ShowRedStar = true;
this.txtUserRepresentative.Required = true;
this.txtUserRepresentative.ShowRedStar = true;
this.drpContractAdmin.Required = true;
this.drpContractAdmin.ShowRedStar = true;
}
else //非框架合同
{
fr2.Hidden = true;
fr3.Hidden = true;
fr4.Hidden = true;
frNoFrame1.Hidden = false;
frNoFrame2.Hidden = false;
txtFO_No.Required = true;
txtFO_No.ShowRedStar = true;
txtContractor.Required = true;
txtContractor.ShowRedStar = true;
drpContractRequester.Required = true;
drpContractRequester.ShowRedStar = true;
txtContractRequesterDep.Required = true;
txtContractRequesterDep.ShowRedStar = true;
drpBuyer.Required = true;
drpBuyer.ShowRedStar = true;
}
}
else if (pun.SeType == "2") //物资
{
fr1.Hidden = true;
fr2.Hidden = true;
fr3.Hidden = true;
fr4.Hidden = true;
frNoFrame1.Hidden = true;
frNoFrame2.Hidden = true;
this.frWz.Hidden = false;
this.txtContractor2.Required = true;
this.txtContractor2.ShowRedStar = true;
this.drpPVTRequester.Required = true;
this.drpPVTRequester.ShowRedStar = true;
}
}
}
else if (pun.States == "2") //框架合同:主协调员办理,非框架合同:需求人办理
{
GroupPanel1.Enabled = false;
GroupPanel2.Hidden = false;
GroupPanel2.Enabled = false;
GroupPanel3.Hidden = false;
this.btnReturn.Hidden = false;
this.btnNoPass.Hidden = false;
this.btnSbumit.Hidden = false;
if (pun.SeType == "1")//服务
{
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 = "主协调员填写";
}
else //非框架合同
{
fr1.Hidden = false;
fr2.Hidden = true;
fr3.Hidden = true;
fr4.Hidden = true;
frNoFrame1.Hidden = false;
frNoFrame2.Hidden = false;
frWz.Hidden = true;
GroupPanel3.Title = "合同需求人填写";
this.drpUserDep.Hidden = true;
}
}
else//物资
{
fr1.Hidden = true;
fr2.Hidden = true;
fr3.Hidden = true;
fr4.Hidden = true;
frNoFrame1.Hidden = true;
frNoFrame2.Hidden = true;
frWz.Hidden = false;
GroupPanel3.Hidden = true;
GroupPanel7.Hidden = false;
drpBuyer2.Required = true;
drpBuyer2.ShowRedStar = true;
}
}
else if (pun.States == "3" && pun.IsFrame == true)//用户部门填写
{
GroupPanel1.Enabled = false;
GroupPanel2.Hidden = false;
GroupPanel2.Enabled = false;
GroupPanel3.Enabled = false;
GroupPanel3.Hidden = false;
GroupPanel4.Hidden = false;
this.btnSbumit.Hidden = false;
}
else if (pun.States == "4" && pun.IsFrame == true)//合同管理员填写
{
GroupPanel1.Enabled = false;
GroupPanel2.Hidden = false;
GroupPanel2.Enabled = false;
GroupPanel3.Enabled = false;
GroupPanel3.Hidden = false;
GroupPanel4.Hidden = false;
GroupPanel4.Enabled = false;
GroupPanel5.Hidden = false;
this.btnClose.Hidden = false;
}
else if (pun.States == "5")//采购员填写
{
GroupPanel1.Enabled = false;
GroupPanel2.Hidden = false;
GroupPanel2.Enabled = false;
fr2.Hidden = true;
fr3.Hidden = true;
fr4.Hidden = true;
this.btnClose.Hidden = false;
this.drpUserDep.Hidden = true;
if (pun.SeType == "1")
{
GroupPanel3.Hidden = false;
GroupPanel3.Enabled = false;
GroupPanel6.Hidden = false;
fr1.Hidden = false;
frNoFrame1.Hidden = false;
frNoFrame2.Hidden = false;
frWz.Hidden = true;
}
else
{
fr1.Hidden = true;
frNoFrame1.Hidden = true;
frNoFrame2.Hidden = true;
frWz.Hidden = false;
GroupPanel7.Hidden = false;
GroupPanel7.Enabled = false;
GroupPanel6.Hidden = false;
}
}
else
{
this.btnSbumit.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;
if (!string.IsNullOrEmpty(pun.Violation_Inspector))
{
var user = BLL.Sys_UserService.GetUsersByUserId(pun.Violation_Inspector);
if (user != null)
{
this.txtViolation_Inspector.Text = user.UserName;
if (!string.IsNullOrEmpty(user.DepartId))
{
this.txtViolation_InspectorDep.Text = BLL.DepartService.GetDepartNameById(user.DepartId);
}
}
}
this.txtMIContractor.Text = pun.MIContractor;
if (pun.SeType == "1")
{
this.txtFO_No.Text = pun.FO_NO;
}
else
{
this.txtFo.Text = pun.FO_NO;
}
if (pun.IsFrame == true)
{
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.txtContractor.Text = BLL.ContractorService.GetContractorById(fc.ContractorId).ContractorCN;
}
}
else
{
this.txtContractor.Text = pun.Contractor;
}
if (pun.SeType == "2")
{
this.txtContractor2.Text = pun.Contractor;
//this.txtContractor3.Text = pun.Contractor;
}
if (!string.IsNullOrEmpty(pun.ContractAdmin))
{
this.drpContractAdmin.SelectedValue = pun.ContractAdmin;
this.drpNoFrameContractAdmin.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))
{
if (pun.SeType == "1")
{
this.drpViolationClause.SelectedValue = pun.ViolationClauseId;
}
else
{
this.drpViolationClause2.SelectedValue = pun.ViolationClauseId;
}
}
if (!string.IsNullOrEmpty(pun.ViolationDegree))
{
if (pun.SeType == "1")
{
this.drpViolationDegree.SelectedValue = pun.ViolationDegree;
this.txtCompany.Text = pun.Company.HasValue ? pun.Company.ToString() : "";
}
else
{
this.drpViolationDegree2.SelectedValue = pun.ViolationDegree;
this.txtCompany2.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;
if (pun.IsFrame == true)
{
this.txtCompletionDate.Text = pun.CompletionDate.HasValue ? string.Format("{0:yyyy-MM-dd}", pun.CompletionDate) : "";
}
else
{
this.txtNoFrameCompletionDate.Text = pun.CompletionDate.HasValue ? string.Format("{0:yyyy-MM-dd}", pun.CompletionDate) : "";
}
rblSeType.SelectedValue = pun.SeType == "2" ? "2" : "1";
if (!string.IsNullOrEmpty(pun.PVTRequester))
{
this.drpPVTRequester.SelectedValue = pun.PVTRequester;
}
if (!string.IsNullOrEmpty(pun.Buyer))
{
if (pun.SeType == "1")
{
this.drpBuyer.SelectedValue = pun.Buyer;
}
else
{
this.drpBuyer2.SelectedValue = pun.Buyer;
}
}
this.txtIndividualSESReason.Text = pun.IndividualSESReason;
this.txtSESReson.Text = pun.SESReason;
this.txtBuyerReson.Text = pun.BuyerReson;
#endregion
}
}
else
{
this.txtPunishDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now);
this.btnSbumit.Hidden = false;
}
}
}
#endregion
#region 保存、提交
///
/// 保存
///
///
///
protected void btnSave_Click(object sender, EventArgs e)
{
SaveMethod(BLL.Const.BtnSave);
}
///
/// 提交
///
///
///
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.SeType = rblSeType.SelectedValue;
if (rblSeType.SelectedValue == "1")//服务
{
pun.Contractor = this.txtContractor.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;
if (this.drpContractAdmin.SelectedValue != BLL.Const._Null)
{
pun.ContractAdmin = this.drpContractAdmin.SelectedValue;
}
}
else
{
//非框架合同
pun.IsFrame = false;
if (this.drpContractRequester.SelectedValue != BLL.Const._Null)
{
pun.ContractRequester = this.drpContractRequester.SelectedValue;
}
pun.ContractRequesterDep = this.txtContractRequesterDep.Text.Trim();
if (this.drpBuyer.SelectedValue != BLL.Const._Null)
{
pun.Buyer = this.drpBuyer.SelectedValue;
}
if (this.drpNoFrameContractAdmin.SelectedValue != BLL.Const._Null)
{
pun.ContractAdmin = this.drpNoFrameContractAdmin.SelectedValue;
}
}
}
else //物资
{
pun.Contractor = this.txtContractor2.Text.Trim();
if (this.drpPVTRequester.SelectedValue != BLL.Const._Null && !string.IsNullOrEmpty(this.drpPVTRequester.SelectedValue))
{
pun.PVTRequester = this.drpPVTRequester.SelectedValue;
}
}
if (type == BLL.Const.BtnSubmit)
{
pun.States = "2";//SSR已提交
var updateAudit = BLL.PunishmentAuditService.GetAuditByAuditMan(this.PunishmentId, "SSR");
if (updateAudit != null)
{
updateAudit.AuditMan = this.CurrUser.UserId;
updateAudit.AuditDate = DateTime.Now;
updateAudit.IsPass = true;
BLL.PunishmentAuditService.UpdatePunishmentAudit(updateAudit);
}
Model.EMC_PunishmentAudit audit = new Model.EMC_PunishmentAudit();
audit.AuditId = SQLHelper.GetNewID(typeof(Model.EMC_PunishmentAudit));
audit.PunishmentId = this.PunishmentId;
if (this.rblSeType.SelectedValue == "1")
{
Model.View_FC_SESRelatedData fc = BLL.SESRelatedDataService.GetSESRelatedDataViewByFO(pun.FO_NO);
if (fc != null)
{
audit.AuditMan = fc.Main_CoordinatorId;//框架合同:主协调员
}
else
{
audit.AuditMan = pun.ContractRequester;//非框架合同:合同需求人
}
}
else
{
audit.AuditMan = pun.PVTRequester;
}
BLL.PunishmentAuditService.AddPunishmentAudit(audit);
#region SSR审批通过发送邮件
Model.EmailPop pops = Funs.DB.EmailPop.FirstOrDefault(x => x.EmailID == BLL.Const.EmailPopId);
if (pops == null)
{
return;
}
string[] mailTo = null;
string[] mailCC = null;
string resultMessage = "";
var emailTemplate = Funs.DB.SendEmailTemplate.Where(x => x.EmailName.Contains("SSR管理员填写完成后审批通过通知"));
if (emailTemplate.Count() > 0)
{
string userId = string.Empty;
if (pun.SeType == "1")
{
if (pun.IsFrame == true)
{
Model.View_FC_SESRelatedData fc = BLL.SESRelatedDataService.GetSESRelatedDataViewByFO(pun.FO_NO);
if (fc != null)
{
userId = fc.Main_CoordinatorId;//框架内合同:发送给主协调员
}
}
else
{
userId = pun.ContractRequester;//非框架合同:发送给主协调合同需求人
}
}
else
{
userId = pun.PVTRequester;//物资:发送给PVT小组组长
}
var userTo = from x in Funs.DB.Sys_User
where x.UserId.Contains(userId)
&& x.Email != null && x.Email != ""
select x;
if (userTo != null)
{
mailTo = userTo.Select(x => x.Email).ToArray();
}
//抄送给流程经办人:SSR流程经办人-发起人
var userCC = from x in Funs.DB.View_EMail_UserTo
where ((x.PunishmentId == this.PunishmentId && x.AuditDate != null)
|| x.UserId.Contains(pun.Violation_Inspector))
&& x.Email != null && x.Email != ""
select x;
if (userCC != null)
{
mailCC = userCC.Select(x => x.Email).ToArray();
}
if (mailTo.Length > 0)
{
NameValueCollection myPram = new NameValueCollection();
myPram.Add("发现日期", pun.PunishDate != null ? pun.PunishDate.Value.ToString("yyyy-MM-dd") : "");
myPram.Add("位置", pun.Location);
myPram.Add("质量事件描述", pun.Description);
MailHelper.SendPunishSesMail(pops, myPram, "SSR管理员填写完成后审批通过通知", mailTo, mailCC, out resultMessage);
}
}
#endregion
}
else
{
pun.States = "1";//SSR保存未提交
}
}
else if (pun.States == "2")
{
if (pun.SeType == "1")
{
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 (pun.IsFrame == true)//框架合同
{
if (this.drpUserDep.SelectedValue != BLL.Const._Null)
{
pun.UserDep = this.drpUserDep.SelectedValue;
}
if (type == BLL.Const.BtnSubmit)
{
pun.States = "3";//主协调员提交
var updateAudit = BLL.PunishmentAuditService.GetAuditByAuditMan(this.PunishmentId, this.CurrUser.UserId);
if (updateAudit != null)
{
//updateAudit.AuditMan = this.CurrUser.UserId;
updateAudit.AuditDate = DateTime.Now;
updateAudit.IsPass = true;
BLL.PunishmentAuditService.UpdatePunishmentAudit(updateAudit);
}
Model.EMC_PunishmentAudit audit = new Model.EMC_PunishmentAudit();
audit.AuditId = SQLHelper.GetNewID(typeof(Model.EMC_PunishmentAudit));
audit.PunishmentId = this.PunishmentId;
audit.AuditMan = pun.UserDep;
BLL.PunishmentAuditService.AddPunishmentAudit(audit);
#region 主协调员审批通过邮件:发送给部门经理,抄送流程经办人
Model.EmailPop pops = Funs.DB.EmailPop.FirstOrDefault(x => x.EmailID == BLL.Const.EmailPopId);
if (pops == null)
{
return;
}
string[] mailTo = null;
string[] mailCC = null;
string resultMessage = "";
var emailTemplate = Funs.DB.SendEmailTemplate.Where(x => x.EmailName.Contains("主协调员填写完成后审批通过通知"));
if (emailTemplate.Count() > 0)
{
string departLeader = string.Empty;
var depart = BLL.DepartService.GetDepartById(drpUserDep.SelectedValue);
if (depart != null)
{
departLeader = depart.DepartLeader;
}
if (!string.IsNullOrEmpty(departLeader))
{
var userTo = from x in Funs.DB.Sys_User
where x.UserId.Contains(departLeader) && x.Email != null && x.Email != ""
select x;
if (userTo != null)
{
mailTo = userTo.Select(x => x.Email).ToArray();
}
}
var userCc = from x in Funs.DB.View_EMail_UserTo
where ((x.PunishmentId == this.PunishmentId && x.AuditDate != null) || x.UserId.Contains(pun.Violation_Inspector))
&& x.Email != null && x.Email != ""
select x;
if (userCc!=null)
{
mailCC = userCc.Select(x => x.Email).Distinct().ToArray();
}
if (mailTo.Length > 0)
{
NameValueCollection myPram = new NameValueCollection();
myPram.Add("发现日期", pun.PunishDate != null ? pun.PunishDate.Value.ToString("yyyy-MM-dd") : "");
myPram.Add("位置", pun.Location);
myPram.Add("质量事件描述", pun.Description);
MailHelper.SendPunishSesMail(pops, myPram, "主协调员填写完成后审批通过通知", mailTo, mailCC, out resultMessage);
}
}
#endregion
}
}
else //非框架合同
{
if (type == BLL.Const.BtnSubmit)
{
pun.States = "5";//合同需求人已提交
var updateAudit = BLL.PunishmentAuditService.GetAuditByAuditMan(this.PunishmentId, this.CurrUser.UserId);
if (updateAudit != null)
{
//updateAudit.AuditMan = this.CurrUser.UserId;
updateAudit.AuditDate = DateTime.Now;
updateAudit.IsPass = true;
BLL.PunishmentAuditService.UpdatePunishmentAudit(updateAudit);
}
Model.EMC_PunishmentAudit audit = new Model.EMC_PunishmentAudit();
audit.AuditId = SQLHelper.GetNewID(typeof(Model.EMC_PunishmentAudit));
audit.PunishmentId = this.PunishmentId;
audit.AuditMan = pun.Buyer;
BLL.PunishmentAuditService.AddPunishmentAudit(audit);
#region 合同需求人填写完成后邮件:发送给采购员,抄送流程经办人
Model.EmailPop pops = Funs.DB.EmailPop.FirstOrDefault(x => x.EmailID == BLL.Const.EmailPopId);
if (pops == null)
{
return;
}
string[] mailTo = null;
string[] mailCC = null;
string resultMessage = "";
var emailTemplate = Funs.DB.SendEmailTemplate.Where(x => x.EmailName.Contains("合同需求人填写完成后通知"));
if (emailTemplate.Count() > 0)
{
var userTo = from x in Funs.DB.Sys_User
where x.UserId.Contains(pun.Buyer) && x.Email != null && x.Email != ""
select x;
if (userTo != null)
{
mailTo = userTo.Select(x => x.Email).ToArray();
}
var userCc = from x in Funs.DB.View_EMail_UserTo
where ((x.PunishmentId == this.PunishmentId && x.AuditDate != null) || x.UserId.Contains(pun.Violation_Inspector))
&& x.Email != null && x.Email != ""
select x;
if (userCc != null)
{
mailCC = userCc.Select(x => x.Email).Distinct().ToArray();
}
if (mailTo.Length > 0)
{
NameValueCollection myPram = new NameValueCollection();
myPram.Add("发现日期", pun.PunishDate != null ? pun.PunishDate.Value.ToString("yyyy-MM-dd") : "");
myPram.Add("位置", pun.Location);
myPram.Add("质量事件描述", pun.Description);
MailHelper.SendPunishSesMail(pops, myPram, "合同需求人填写完成后通知", mailTo, mailCC, out resultMessage);
}
}
#endregion
}
}
}
else
{
if (this.drpBuyer2.SelectedValue != BLL.Const._Null && !string.IsNullOrEmpty(this.drpBuyer2.SelectedValue))
{
pun.Buyer = this.drpBuyer2.SelectedValue;
}
if (this.drpViolationClause2.SelectedValue != BLL.Const._Null && !string.IsNullOrEmpty(this.drpViolationClause2.SelectedValue))
{
pun.ViolationClauseId = this.drpViolationClause2.SelectedValue;
}
pun.ViolationDegree = this.drpViolationDegree2.SelectedValue;
pun.Company = Funs.GetNewDecimal(this.txtCompany2.Text.Trim());
pun.FO_NO = this.txtFo.Text.Trim();
if (type == BLL.Const.BtnSubmit)
{
pun.States = "5";//提交到采购员
var updateAudit = BLL.PunishmentAuditService.GetAuditByAuditMan(this.PunishmentId, this.CurrUser.UserId);
if (updateAudit != null)
{
updateAudit.AuditMan = this.CurrUser.UserId;
updateAudit.AuditDate = DateTime.Now;
updateAudit.IsPass = true;
BLL.PunishmentAuditService.UpdatePunishmentAudit(updateAudit);
}
Model.EMC_PunishmentAudit audit = new Model.EMC_PunishmentAudit();
audit.AuditId = SQLHelper.GetNewID(typeof(Model.EMC_PunishmentAudit));
audit.PunishmentId = this.PunishmentId;
audit.AuditMan = pun.Buyer;
BLL.PunishmentAuditService.AddPunishmentAudit(audit);
#region PVT小组组长/请购人填写完成后邮件:发送给采购员,抄送流程经办人
Model.EmailPop pops = Funs.DB.EmailPop.FirstOrDefault(x => x.EmailID == BLL.Const.EmailPopId);
if (pops == null)
{
return;
}
string[] mailTo = null;
string[] mailCC = null;
string resultMessage = "";
var emailTemplate = Funs.DB.SendEmailTemplate.Where(x => x.EmailName.Contains("PVT小组组长请购人填写完成后通知"));
if (emailTemplate.Count() > 0)
{
var userTo = from x in Funs.DB.Sys_User
where x.UserId.Contains(pun.Buyer) && x.Email != null && x.Email != ""
select x;
if (userTo != null)
{
mailTo = userTo.Select(x => x.Email).ToArray();
}
var userCc = from x in Funs.DB.View_EMail_UserTo
where ((x.PunishmentId == this.PunishmentId && x.AuditDate != null) || x.UserId.Contains(pun.Violation_Inspector))
&& x.Email != null && x.Email != ""
select x;
if (userCc != null)
{
mailCC = userCc.Select(x => x.Email).Distinct().ToArray();
}
if (mailTo.Length > 0)
{
NameValueCollection myPram = new NameValueCollection();
myPram.Add("发现日期", pun.PunishDate != null ? pun.PunishDate.Value.ToString("yyyy-MM-dd") : "");
myPram.Add("位置", pun.Location);
myPram.Add("质量事件描述", pun.Description);
MailHelper.SendPunishSesMail(pops, myPram, "PVT小组组长请购人填写完成后通知", mailTo, mailCC, out resultMessage);
}
}
#endregion
}
}
}
else if (pun.States == "3")//用户部门提交
{
if (!string.IsNullOrEmpty(this.txtIndividualSES.Text.Trim()))
{
pun.ViolationRelatedSes = this.txtIndividualSES.Text.Trim();
}
else
{
if (!string.IsNullOrEmpty(this.txtIndividualSESReason.Text.Trim()))
{
pun.IndividualSESReason = this.txtIndividualSESReason.Text.Trim();
}
else
{
Alert.ShowInTop("如不填写请描述原因!", MessageBoxIcon.Warning);
return;
}
}
if (type == BLL.Const.BtnSubmit)
{
pun.States = "4";//用户部门提交
var u = BLL.Sys_UserService.GetUsersByUserId(this.CurrUser.UserId);
if (u != null)
{
var updateAudit = BLL.PunishmentAuditService.GetAuditByAuditMan(this.PunishmentId, u.DepartId);
if (updateAudit != null)
{
updateAudit.AuditMan = this.CurrUser.UserId;
updateAudit.AuditDate = DateTime.Now;
updateAudit.IsPass = true;
BLL.PunishmentAuditService.UpdatePunishmentAudit(updateAudit);
}
}
Model.EMC_PunishmentAudit audit = new Model.EMC_PunishmentAudit();
audit.AuditId = SQLHelper.GetNewID(typeof(Model.EMC_PunishmentAudit));
audit.PunishmentId = this.PunishmentId;
audit.AuditMan = pun.ContractAdmin;
BLL.PunishmentAuditService.AddPunishmentAudit(audit);
#region 用户部门填写后审批邮件:发送给合同管理员,抄送给流程经办人
Model.EmailPop pops = Funs.DB.EmailPop.FirstOrDefault(x => x.EmailID == BLL.Const.EmailPopId);
if (pops == null)
{
return;
}
string[] mailTo = null;
string[] mailCC = null;
string resultMessage = "";
var emailTemplate = Funs.DB.SendEmailTemplate.Where(x => x.EmailName.Contains("用户部门填写后审核通知"));
if (emailTemplate.Count() > 0)
{
var userTo = from x in Funs.DB.Sys_User
where x.UserId.Contains(this.drpContractAdmin.SelectedValue)
&& x.Email != null && x.Email != ""
select x;
if (userTo != null)
{
mailTo = userTo.Select(x => x.Email).ToArray();
}
var userCc = from x in Funs.DB.View_EMail_UserTo
where (x.PunishmentId == this.PunishmentId && x.AuditDate != null)
|| (x.UserId.Contains(pun.Violation_Inspector))
&& x.Email != null && x.Email != ""
select x;
if (userCc != null)
{
mailCC = userCc.Select(x => x.Email).Distinct().ToArray();
}
if (mailTo.Length > 0)
{
NameValueCollection myPram = new NameValueCollection();
myPram.Add("发现日期", pun.PunishDate != null ? pun.PunishDate.Value.ToString("yyyy-MM-dd") : "");
myPram.Add("位置", pun.Location);
myPram.Add("质量事件描述", pun.Description);
MailHelper.SendPunishSesMail(pops, myPram, "用户部门填写后审核通知", mailTo, mailCC, out resultMessage);
}
}
#endregion
}
}
else if (pun.States == "4")//合同管理员
{
if (!string.IsNullOrEmpty(this.txtSES_No.Text.Trim()) && !string.IsNullOrEmpty(this.txtCompletionDate.Text.Trim()))
{
pun.SES_No = this.txtSES_No.Text.Trim();
pun.CompletionDate = Funs.GetNewDateTime(this.txtCompletionDate.Text);
}
else
{
if (!string.IsNullOrEmpty(this.txtSESReson.Text.Trim()))
{
pun.SESReason = this.txtSESReson.Text.Trim();
}
else
{
Alert.ShowInTop("如不填写请描述原因!", MessageBoxIcon.Warning);
return;
}
}
if (type == BLL.Const.BtnSubmit)
{
if (pun.SeType == "1" && pun.IsFrame == true)
{
pun.States = "6";//合同管理员已提交
var updateAudit = BLL.PunishmentAuditService.GetAuditByAuditMan(this.PunishmentId, this.CurrUser.UserId);
if (updateAudit != null)
{
updateAudit.AuditMan = this.CurrUser.UserId;
updateAudit.AuditDate = DateTime.Now;
updateAudit.IsPass = true;
BLL.PunishmentAuditService.UpdatePunishmentAudit(updateAudit);
}
#region 用户部门填写后审批邮件:发送给合同管理员,抄送给流程经办人
Model.EmailPop pops = Funs.DB.EmailPop.FirstOrDefault(x => x.EmailID == BLL.Const.EmailPopId);
if (pops == null)
{
return;
}
string[] mailTo = null;
string[] mailCC = null;
string resultMessage = "";
var emailTemplate = Funs.DB.SendEmailTemplate.Where(x => x.EmailName.Contains("合同管理员SES完成后通知"));
if (emailTemplate.Count() > 0)
{
string departLeader = string.Empty;
var user = BLL.Sys_UserService.GetUsersByUserId(pun.Violation_Inspector);
if (user!=null)
{
var depart = BLL.DepartService.GetDepartById(user.DepartId);
if (depart!=null)
{
departLeader = depart.DepartLeader;
}
}
if (!string.IsNullOrEmpty(departLeader))
{
var userTo = from x in Funs.DB.View_EMail_UserTo
where (x.PunishmentId == this.PunishmentId && x.AuditDate != null)
|| x.UserId.Contains(pun.Violation_Inspector) || x.UserId.Contains(departLeader) || x.ChineseName.Contains("王志高")
&& x.Email != null && x.Email != ""
select x;
if (userTo != null)
{
mailTo = userTo.Select(x => x.Email).Distinct().ToArray();
}
}
else
{
var userTo = from x in Funs.DB.View_EMail_UserTo
where (x.PunishmentId == this.PunishmentId && x.AuditDate != null)
|| x.UserId.Contains(pun.Violation_Inspector) || x.ChineseName.Contains("王志高")
&& x.Email != null && x.Email != ""
select x;
if (userTo != null)
{
mailTo = userTo.Select(x => x.Email).Distinct().ToArray();
}
}
if (mailTo.Length > 0)
{
NameValueCollection myPram = new NameValueCollection();
myPram.Add("发现日期", pun.PunishDate != null ? pun.PunishDate.Value.ToString("yyyy-MM-dd") : "");
myPram.Add("位置", pun.Location);
myPram.Add("质量事件描述", pun.Description);
MailHelper.SendPunishSesMail(pops, myPram, "合同管理员SES完成后通知", mailTo, mailCC, out resultMessage);
}
}
#endregion
}
else
{
pun.States = "5";//合同管理员已提交
var updateAudit = BLL.PunishmentAuditService.GetAuditByAuditMan(this.PunishmentId, this.CurrUser.UserId);
if (updateAudit != null)
{
updateAudit.AuditMan = this.CurrUser.UserId;
updateAudit.AuditDate = DateTime.Now;
updateAudit.IsPass = true;
BLL.PunishmentAuditService.UpdatePunishmentAudit(updateAudit);
}
Model.EMC_PunishmentAudit audit = new Model.EMC_PunishmentAudit();
audit.AuditId = SQLHelper.GetNewID(typeof(Model.EMC_PunishmentAudit));
audit.PunishmentId = this.PunishmentId;
audit.AuditMan = pun.Buyer;
BLL.PunishmentAuditService.AddPunishmentAudit(audit);
}
}
}
else if (pun.States == "5")
{
if (!string.IsNullOrEmpty(this.txtNoFrameCompletionDate.Text))
{
pun.CompletionDate = Funs.GetNewDateTime(this.txtNoFrameCompletionDate.Text.Trim());
}
else
{
if (!string.IsNullOrEmpty(this.txtBuyerReson.Text))
{
pun.BuyerReson = this.txtBuyerReson.Text.Trim();
}
else
{
Alert.ShowInTop("如不填写请描述原因!", MessageBoxIcon.Warning);
return;
}
}
if (type == BLL.Const.BtnSubmit)
{
pun.States = "6";//采购员已提交,流程结束
var updateAudit = BLL.PunishmentAuditService.GetAuditByAuditMan(this.PunishmentId, this.CurrUser.UserId);
if (updateAudit != null)
{
updateAudit.AuditDate = DateTime.Now;
updateAudit.IsPass = true;
BLL.PunishmentAuditService.UpdatePunishmentAudit(updateAudit);
if (pun.SeType == "2")//物资
{
#region 采购员填写完成后邮件:发送给流程经办人、发起人经理,王志高
Model.EmailPop pops = Funs.DB.EmailPop.FirstOrDefault(x => x.EmailID == BLL.Const.EmailPopId);
if (pops == null)
{
return;
}
string[] mailTo = null;
string[] mailCC = null;
string resultMessage = "";
var emailTemplate = Funs.DB.SendEmailTemplate.Where(x => x.EmailName.Contains("物资采购员填写完成后通知"));
if (emailTemplate.Count() > 0)
{
string departLeader = string.Empty;
var user = BLL.Sys_UserService.GetUsersByUserId(pun.Violation_Inspector);
if (user != null)
{
if (!string.IsNullOrEmpty(user.DepartId))
{
var depart = BLL.DepartService.GetDepartById(user.DepartId);
if (depart != null)
{
departLeader = depart.DepartLeader;
}
}
}
if (!string.IsNullOrEmpty(departLeader))
{
var userTo = from x in Funs.DB.View_EMail_UserTo
where ((x.PunishmentId == this.PunishmentId && x.AuditDate != null) || x.ChineseName.Contains("王志高") || x.UserId.Contains(departLeader))
&& x.Email != null && x.Email != ""
select x;
if (userTo != null)
{
mailTo = userTo.Select(x => x.Email).ToArray();
}
}
else
{
var userTo = from x in Funs.DB.View_EMail_UserTo
where ((x.PunishmentId == this.PunishmentId && x.AuditDate != null) || x.ChineseName.Contains("王志高"))
&& x.Email != null && x.Email != ""
select x;
if (userTo != null)
{
mailTo = userTo.Select(x => x.Email).ToArray();
}
}
if (mailTo.Length > 0)
{
NameValueCollection myPram = new NameValueCollection();
myPram.Add("发现日期", pun.PunishDate != null ? pun.PunishDate.Value.ToString("yyyy-MM-dd") : "");
myPram.Add("位置", pun.Location);
myPram.Add("质量事件描述", pun.Description);
MailHelper.SendPunishSesMail(pops, myPram, "物资采购员填写完成后通知", mailTo, mailCC, out resultMessage);
}
}
#endregion
}
else
{
#region 采购员填写完成后邮件:发送给流程经办人,抄送发起人经理、王志高
Model.EmailPop pops = Funs.DB.EmailPop.FirstOrDefault(x => x.EmailID == BLL.Const.EmailPopId);
if (pops == null)
{
return;
}
string[] mailTo = null;
string[] mailCC = null;
string resultMessage = "";
var emailTemplate = Funs.DB.SendEmailTemplate.Where(x => x.EmailName.Contains("采购员填写完成后通知"));
if (emailTemplate.Count() > 0)
{
var userTo = from x in Funs.DB.View_EMail_UserTo
where (x.PunishmentId == this.PunishmentId && x.AuditDate != null)
&& x.Email != null && x.Email != ""
select x;
if (userTo != null)
{
mailTo = userTo.Select(x => x.Email).ToArray();
}
string departLeader = string.Empty;
var user = BLL.Sys_UserService.GetUsersByUserId(pun.Violation_Inspector);
if (user != null)
{
if (!string.IsNullOrEmpty(user.DepartId))
{
var depart = BLL.DepartService.GetDepartById(user.DepartId);
if (depart != null)
{
departLeader = depart.DepartLeader;
}
}
}
if (!string.IsNullOrEmpty(departLeader))
{
var userCc = from x in Funs.DB.Sys_User
where x.ChineseName.Contains("王志高")
|| x.UserId.Contains(departLeader)
&& x.Email != null && x.Email != ""
select x;
if (userCc != null)
{
mailCC = userCc.Select(x => x.Email).Distinct().ToArray();
}
}
else
{
var userCc = from x in Funs.DB.Sys_User
where x.ChineseName.Contains("王志高")
&& x.Email != null && x.Email != ""
select x;
if (userCc != null)
{
mailCC = userCc.Select(x => x.Email).Distinct().ToArray();
}
}
if (mailTo.Length > 0)
{
NameValueCollection myPram = new NameValueCollection();
myPram.Add("发现日期", pun.PunishDate != null ? pun.PunishDate.Value.ToString("yyyy-MM-dd") : "");
myPram.Add("位置", pun.Location);
myPram.Add("质量事件描述", pun.Description);
MailHelper.SendPunishSesMail(pops, myPram, "采购员填写完成后通知", mailTo, mailCC, out resultMessage);
}
}
#endregion
}
}
}
}
else
{
pun.PunishDate = Funs.GetNewDateTime(this.txtPunishDate.Text);
pun.Location = this.txtLocation.Text.Trim();
pun.Description = this.txtDescription.Text.Trim();
pun.MIContractor = this.txtMIContractor.Text.Trim();
pun.Flag = "2";//质量
if (type == BLL.Const.BtnSubmit)
{
pun.States = "1";//申请人已提交
Model.EMC_PunishmentAudit audit = new Model.EMC_PunishmentAudit();
audit.AuditId = SQLHelper.GetNewID(typeof(Model.EMC_PunishmentAudit));
audit.PunishmentId = this.PunishmentId;
audit.AuditMan = "SSR";
BLL.PunishmentAuditService.AddPunishmentAudit(audit);
}
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.MIContractor = this.txtMIContractor.Text.Trim();
punishment.Flag = "2";//质量
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;
}
if (type == BLL.Const.BtnSubmit)
{
punishment.States = "1";//申请人已提交
}
else
{
punishment.States = "0";//申请人未提交
}
var att = from x in Funs.DB.AttachFile where x.ToKeyId == punishment.PunishmentId select x;
if (att.Count() > 0)
{
punishment.AttachUrl = att.First().AttachUrl;
}
else
{
Alert.ShowInTop("请上传相关附件!", MessageBoxIcon.Warning);
return;
}
punishment.Violation_Inspector = this.CurrUser.UserId;//发起人
punishment.CreateDate = DateTime.Now;
BLL.PunishmentService.AddPunishment(punishment);
BLL.Sys_LogService.AddLog(this.CurrUser.UserId, "增加承包商及供应商质量事件报告");
if (type == BLL.Const.BtnSubmit)
{
Model.EMC_PunishmentAudit audit = new Model.EMC_PunishmentAudit();
audit.AuditId = SQLHelper.GetNewID(typeof(Model.EMC_PunishmentAudit));
audit.PunishmentId = this.hdId.Text;
audit.AuditMan = "SSR";
BLL.PunishmentAuditService.AddPunishmentAudit(audit);
}
#region 发起人发送邮件
Model.EmailPop pops = Funs.DB.EmailPop.FirstOrDefault(x => x.EmailID == BLL.Const.EmailPopId);
if (pops == null)
{
return;
}
string[] mailTo = null;
string[] mailCC = null;
string resultMessage = "";
var emailTemplate = Funs.DB.SendEmailTemplate.Where(x => x.EmailName.Contains("申报人填写完成后通知"));
if (emailTemplate.Count() > 0)
{
var userTo = from x in Funs.DB.Sys_User
where x.ChineseName.Contains("周海霄") || x.ChineseName.Contains("林敏")
&& x.Email != null && x.Email != ""
select x;
if (userTo != null)
{
mailTo = userTo.Select(x => x.Email).ToArray();
}
var userCC = from x in Funs.DB.Sys_User
where x.ChineseName.Contains("王志高")
&& x.Email != null && x.Email != ""
select x;
if (userCC != null)
{
mailCC = userCC.Select(x => x.Email).ToArray();
}
if (mailTo.Length > 0)
{
NameValueCollection myPram = new NameValueCollection();
myPram.Add("发现日期", punishment.PunishDate != null ? punishment.PunishDate.Value.ToString("yyyy-MM-dd") : "");
myPram.Add("位置", punishment.Location);
myPram.Add("质量事件描述", punishment.Description);
MailHelper.SendPunishSesMail(pops, myPram, "申报人填写完成后通知", mailTo, mailCC, out resultMessage);
}
}
#endregion
}
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
}
#endregion
#region 文本框、下拉框事件
///
/// 合同号改变事件
///
///
///
protected void txtText_TextChanged(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(txtFO_No.Text))
{
this.fr1.Hidden = false;
this.frWz.Hidden = true;
this.txtFO_No.Required = true;
this.txtFO_No.ShowRedStar = true;
this.txtContractor.Required = true;
this.txtContractor.ShowRedStar = true;
string foNO = txtFO_No.Text.Trim();
Model.View_FC_SESRelatedData fc = BLL.SESRelatedDataService.GetSESRelatedDataViewByFO(foNO);
if (fc != null)
{
this.fr2.Hidden = false;
this.fr3.Hidden = false;
this.fr4.Hidden = false;
this.frNoFrame1.Hidden = true;
this.frNoFrame2.Hidden = true;
this.txtMainCoordinator.Required = true;
this.txtMainCoordinator.ShowRedStar = true;
this.txtMCDept.Required = true;
this.txtMCDept.ShowRedStar = true;
this.txtUserRepresentative.Required = true;
this.txtUserRepresentative.ShowRedStar = true;
this.drpContractAdmin.Required = true;
this.drpContractAdmin.ShowRedStar = true;
this.txtContractor.Text = BLL.ContractorService.GetContractorById(fc.ContractorId).ContractorCN;
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.fr2.Hidden = true;
this.fr3.Hidden = true;
this.fr4.Hidden = true;
this.frNoFrame1.Hidden = false;
this.frNoFrame2.Hidden = false;
this.drpContractRequester.Required = true;
this.drpContractRequester.ShowRedStar = true;
this.txtContractRequesterDep.Required = true;
this.txtContractRequesterDep.ShowRedStar = true;
this.drpBuyer.Required = true;
this.drpBuyer.ShowRedStar = true;
}
}
}
///
/// 违章条款下拉选择事件
///
///
///
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.DeductionIndividual1.ToString();
txtIndividual.Text = vio.DeductionComPany1.ToString();
}
if (vio.DeductionComPany2 != 0)
{
drpViolationDegree.SelectedValue = "2";
txtCompany.Text = vio.DeductionIndividual2.ToString();
txtIndividual.Text = vio.DeductionComPany2.ToString();
}
if (vio.DeductionComPany3 != 0)
{
drpViolationDegree.SelectedValue = "3";
txtCompany.Text = vio.DeductionIndividual3.ToString();
txtIndividual.Text = vio.DeductionComPany3.ToString();
}
}
}
///
/// 违章条款下拉选择事件
///
///
///
protected void drpViolationClause2_OnSelectedIndexChanged(object sender, EventArgs e)
{
if (drpViolationClause2.SelectedValue != Const._Null)
{
var vio = BLL.ViolationClauseService.GetViolationClause(drpViolationClause2.SelectedValue);
if (vio.DeductionComPany1 != 0)
{
drpViolationDegree2.SelectedValue = "1";
txtCompany2.Text = vio.DeductionIndividual1.ToString();
////txtIndividual.Text = vio.DeductionComPany1.ToString();
}
if (vio.DeductionComPany2 != 0)
{
drpViolationDegree2.SelectedValue = "2";
txtCompany2.Text = vio.DeductionIndividual2.ToString();
//txtIndividual.Text = vio.DeductionComPany2.ToString();
}
if (vio.DeductionComPany3 != 0)
{
drpViolationDegree2.SelectedValue = "3";
txtCompany2.Text = vio.DeductionIndividual3.ToString();
//txtIndividual.Text = vio.DeductionComPany3.ToString();
}
}
}
///
/// 合同需求人下拉选择事件
///
///
///
protected void drpContractRequester_SelectedIndexChanged(object sender, EventArgs e)
{
this.txtContractRequesterDep.Text = string.Empty;
if (!string.IsNullOrEmpty(this.drpContractRequester.SelectedValue) && this.drpContractRequester.SelectedValue != BLL.Const._Null)
{
var user = BLL.Sys_UserService.GetUsersByUserId(this.drpContractRequester.SelectedValue);
if (user != null)
{
if (!string.IsNullOrEmpty(user.DepartId))
{
this.txtContractRequesterDep.Text = BLL.DepartService.GetDepartNameById(user.DepartId);
}
}
}
}
///
/// 物资/服务选项
///
///
///
protected void rblSeType_SelectedIndexChanged(object sender, EventArgs e)
{
if (this.rblSeType.SelectedValue == "1")
{
fr1.Hidden = false;
var fc = BLL.SESRelatedDataService.GetSESRelatedDataByFoNo(this.txtFO_No.Text.Trim());
if (fc != null)
{
fr2.Hidden = false;
fr3.Hidden = false;
fr4.Hidden = false;
frNoFrame1.Hidden = true;
frNoFrame2.Hidden = true;
frWz.Hidden = true;
}
else
{
fr2.Hidden = true;
fr3.Hidden = true;
fr4.Hidden = true;
frNoFrame1.Hidden = false;
frNoFrame2.Hidden = false;
frWz.Hidden = true;
}
}
else
{
frWz.Hidden = false;
fr1.Hidden = true;
fr2.Hidden = true;
fr3.Hidden = true;
fr4.Hidden = true;
frNoFrame1.Hidden = true;
frNoFrame2.Hidden = true;
this.txtContractor2.Required = true;
this.txtContractor2.ShowRedStar = true;
this.drpPVTRequester.Required = true;
this.drpPVTRequester.ShowRedStar = true;
}
}
#endregion
#region 附件上传
///
/// 相关附件上传
///
///
///
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)));
}
///
/// 质量调查相关附件
///
///
///
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 拒绝
///
/// 拒绝按钮
///
///
///
protected void btnNoPass_Click(object sender, EventArgs e)
{
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("NoPassEdit.aspx?punishmentId={0}", this.PunishmentId, "编辑 - ")));
}
#endregion
#region 退回到上一流程
///
/// 退回到上一流程
///
///
///
protected void btnReturn_Click(object sender, EventArgs e)
{
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("ReturnReason.aspx?punishmentId={0}", this.PunishmentId, "编辑 - ")));
}
#endregion
#region 流程结束
///
/// 流程结束
///
///
///
protected void btnClose_Click(object sender, EventArgs e)
{
SaveMethod(BLL.Const.BtnSubmit);
}
#endregion
#region 关闭弹出框
///
/// 关闭弹出框
///
///
///
protected void Window1_Close(object sender, WindowCloseEventArgs e)
{
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
}
#endregion
}
}