1
This commit is contained in:
@@ -0,0 +1,357 @@
|
||||
using BLL;
|
||||
using BLL.CQMS.Comprehensive;
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace FineUIPro.Web.CQMS.Comprehensive
|
||||
{
|
||||
public partial class InspectionPersonEdit : PageBase
|
||||
{
|
||||
#region 定义变量
|
||||
/// <summary>
|
||||
/// 主键
|
||||
/// </summary>
|
||||
public string InspectionPersonId
|
||||
{
|
||||
get
|
||||
{
|
||||
return (string)ViewState["InspectionPersonId"];
|
||||
}
|
||||
set
|
||||
{
|
||||
ViewState["InspectionPersonId"] = value;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 加载
|
||||
/// <summary>
|
||||
/// 加载页面
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (!IsPostBack)
|
||||
{
|
||||
GetButtonPower();
|
||||
BLL.UnitWorkService.InitUnitWorkDownList(this.drpUnitWorkIds, this.CurrUser.LoginProjectId, false);
|
||||
BLL.UnitService.InitUnitDownList(this.drpUnitId, this.CurrUser.LoginProjectId, true);
|
||||
BLL.WorkPostService.InitWorkPostDropDownList(this.drpPostId, true);
|
||||
BLL.CNProfessionalService.InitCNProfessionalDownList(this.drpCNProfessionalId, true);
|
||||
this.InspectionPersonId = Request.Params["InspectionPersonId"];
|
||||
Model.Comprehensive_InspectionPerson inspectionPerson = BLL.InspectionPersonService.GetInspectionPersonById(this.InspectionPersonId);
|
||||
if (inspectionPerson != null)
|
||||
{
|
||||
this.InspectionPersonId = inspectionPerson.InspectionPersonId;
|
||||
this.hdAttachUrl.Text =this.InspectionPersonId;
|
||||
if (!string.IsNullOrEmpty(inspectionPerson.CNProfessionalId))
|
||||
{
|
||||
this.drpCNProfessionalId.SelectedValue = inspectionPerson.CNProfessionalId;
|
||||
}
|
||||
if (!string.IsNullOrEmpty(inspectionPerson.UnitId))
|
||||
{
|
||||
this.drpUnitId.SelectedValue = inspectionPerson.UnitId;
|
||||
}
|
||||
this.txtInspectionCode.Text = inspectionPerson.InspectionPersonCode;
|
||||
if (!string.IsNullOrEmpty(inspectionPerson.PostId))
|
||||
{
|
||||
this.drpPostId.SelectedValue = inspectionPerson.PostId;
|
||||
}
|
||||
this.txtPersonName.Text = inspectionPerson.PersonName;
|
||||
this.txtCertificateNumber.Text = inspectionPerson.CertificateNumber;
|
||||
this.txtQualifiedProjectCode.Text = inspectionPerson.QualifiedProjectCode;
|
||||
if (inspectionPerson.ValidityDate != null)
|
||||
{
|
||||
this.txtValidityDate.Text = string.Format("{0:yyyy-MM-dd}", inspectionPerson.ValidityDate);
|
||||
}
|
||||
if (inspectionPerson.ApprovalTime != null)
|
||||
{
|
||||
this.txtApprovalTime.Text = string.Format("{0:yyyy-MM-dd}", inspectionPerson.ApprovalTime);
|
||||
}
|
||||
this.rblIsOnSite.SelectedValue = inspectionPerson.IsOnSite.HasValue && inspectionPerson.IsOnSite == true ? "true" : "false";
|
||||
this.rblIsTrain.SelectedValue = inspectionPerson.IsTrain.HasValue && inspectionPerson.IsTrain == true ? "true" : "false";
|
||||
if (inspectionPerson.DepartureTime != null)
|
||||
{
|
||||
this.txtDepartureTime.Text = string.Format("{0:yyyy-MM-dd}", inspectionPerson.DepartureTime);
|
||||
}
|
||||
if (!string.IsNullOrEmpty(inspectionPerson.UnitWorkId))
|
||||
{
|
||||
this.drpUnitWorkIds.SelectedValueArray = inspectionPerson.UnitWorkId.Split(',');
|
||||
}
|
||||
this.txtRemark.Text = inspectionPerson.Remark;
|
||||
|
||||
|
||||
var currApprove = InspectionPersonApproveService.GetCurrentApprove(inspectionPerson.InspectionPersonId);
|
||||
if (currApprove != null)
|
||||
{ //重新编制 编制人 可以 显示 提交 保存按钮
|
||||
if (currApprove.ApproveType == BLL.Const.Comprehensive_ReCompile && inspectionPerson.CompileMan == CurrUser.UserId)
|
||||
{
|
||||
this.btnSave.Hidden = false;
|
||||
}//审核状态 审核人 可以显示 提交 保存按钮
|
||||
else if (currApprove.ApproveType == BLL.Const.Comprehensive_Audit && currApprove.ApproveMan == CurrUser.UserId)
|
||||
{
|
||||
//审核状态不可编辑
|
||||
Readonly();
|
||||
|
||||
this.btnSave.Hidden = false;
|
||||
}
|
||||
}//没有当前审核人,已完成状态 或者 待提交状态
|
||||
else
|
||||
{
|
||||
if (inspectionPerson.Status == BLL.Const.Comprehensive_Compile && inspectionPerson.CompileMan == CurrUser.UserId)
|
||||
{
|
||||
this.btnSave.Hidden = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
this.txtValidityDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now);
|
||||
this.txtApprovalTime.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now);
|
||||
this.txtDepartureTime.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now);
|
||||
this.btnSave.Hidden = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 禁止编辑
|
||||
/// </summary>
|
||||
public void Readonly()
|
||||
{
|
||||
this.txtApprovalTime.Readonly = true;
|
||||
this.drpUnitId.Readonly = true;
|
||||
this.drpCNProfessionalId.Readonly = true;
|
||||
this.txtCertificateNumber.Readonly = true;
|
||||
this.txtDepartureTime.Readonly = true;
|
||||
this.txtInspectionCode.Readonly = true;
|
||||
this.txtPersonName.Readonly = true;
|
||||
this.txtQualifiedProjectCode.Readonly = true;
|
||||
this.txtRemark.Readonly = true;
|
||||
this.txtValidityDate.Readonly = true;
|
||||
this.drpPostId.Readonly = true;
|
||||
this.drpUnitWorkIds.Readonly = true;
|
||||
//this.btnAttach.Enabled = false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region 保存
|
||||
/// <summary>
|
||||
/// 保存按钮
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void btnSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (this.drpUnitId.SelectedValue == BLL.Const._Null)
|
||||
{
|
||||
Alert.ShowInTop("请选择报验单位!", MessageBoxIcon.Warning);
|
||||
return;
|
||||
}
|
||||
// 焊工部分
|
||||
Model.BS_Welder welder = new Model.BS_Welder();
|
||||
if (this.drpUnitId.SelectedValue != BLL.Const._Null)
|
||||
{
|
||||
welder.WED_Unit = this.drpUnitId.SelectedValue;
|
||||
}
|
||||
welder.WED_Code = this.txtInspectionCode.Text.Trim();
|
||||
welder.WED_Name = this.txtPersonName.Text.Trim();
|
||||
if (!String.IsNullOrEmpty(this.txtValidityDate.Text.ToString()))
|
||||
{
|
||||
welder.LimitDate = Convert.ToDateTime(this.txtValidityDate.Text.ToString());
|
||||
}
|
||||
if (!String.IsNullOrEmpty(this.txtDepartureTime.Text.ToString()))
|
||||
{
|
||||
welder.LeaveDate = Convert.ToDateTime(this.txtDepartureTime.Text.ToString());
|
||||
}
|
||||
if (!String.IsNullOrEmpty(this.txtApprovalTime.Text.ToString()))
|
||||
{
|
||||
welder.PostDate = Convert.ToDateTime(this.txtApprovalTime.Text.ToString());
|
||||
}
|
||||
welder.WED_WorkCode = this.txtCertificateNumber.Text.Trim();
|
||||
welder.WED_Class = this.txtQualifiedProjectCode.Text.Trim();
|
||||
if (this.rblIsOnSite.SelectedValue == "true")
|
||||
{
|
||||
welder.WED_IfOnGuard = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
welder.WED_IfOnGuard = false;
|
||||
}
|
||||
welder.WED_Remark = this.txtRemark.Text.Trim();
|
||||
welder.ProjectId = this.CurrUser.LoginProjectId;
|
||||
//人员报验
|
||||
Model.Comprehensive_InspectionPerson inspectionPerson = new Model.Comprehensive_InspectionPerson();
|
||||
inspectionPerson.ProjectId = this.CurrUser.LoginProjectId;
|
||||
if (this.drpUnitId.SelectedValue != BLL.Const._Null)
|
||||
{
|
||||
inspectionPerson.UnitId = this.drpUnitId.SelectedValue;
|
||||
}
|
||||
inspectionPerson.InspectionPersonCode = this.txtInspectionCode.Text.Trim();
|
||||
if (this.drpPostId.SelectedValue != BLL.Const._Null)
|
||||
{
|
||||
inspectionPerson.PostId = this.drpPostId.SelectedValue;
|
||||
}
|
||||
if (this.drpCNProfessionalId.SelectedValue != BLL.Const._Null)
|
||||
{
|
||||
inspectionPerson.CNProfessionalId = this.drpCNProfessionalId.SelectedValue;
|
||||
}
|
||||
inspectionPerson.PersonName = this.txtPersonName.Text.Trim();
|
||||
inspectionPerson.CertificateNumber = this.txtCertificateNumber.Text.Trim();
|
||||
inspectionPerson.QualifiedProjectCode = this.txtQualifiedProjectCode.Text.Trim();
|
||||
if (!string.IsNullOrEmpty(this.txtValidityDate.Text.ToString()))
|
||||
{
|
||||
inspectionPerson.ValidityDate = Convert.ToDateTime(this.txtValidityDate.Text.ToString());
|
||||
}
|
||||
if (!string.IsNullOrEmpty(this.txtApprovalTime.Text.ToString()))
|
||||
{
|
||||
inspectionPerson.ApprovalTime = Convert.ToDateTime(this.txtApprovalTime.Text.ToString());
|
||||
}
|
||||
if (this.rblIsOnSite.SelectedValue == "true")
|
||||
{
|
||||
inspectionPerson.IsOnSite = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
inspectionPerson.IsOnSite = false;
|
||||
}
|
||||
if (this.rblIsTrain.SelectedValue == "true")
|
||||
{
|
||||
inspectionPerson.IsTrain = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
inspectionPerson.IsTrain = false;
|
||||
}
|
||||
if (!string.IsNullOrEmpty(this.txtDepartureTime.Text.ToString()))
|
||||
{
|
||||
inspectionPerson.DepartureTime = Convert.ToDateTime(this.txtDepartureTime.Text.ToString());
|
||||
}
|
||||
inspectionPerson.Remark = this.txtRemark.Text.Trim();
|
||||
string ids = string.Empty;
|
||||
var lists = this.drpUnitWorkIds.SelectedValueArray;
|
||||
foreach (var item in lists)
|
||||
{
|
||||
ids += item + ",";
|
||||
}
|
||||
if (!string.IsNullOrEmpty(ids))
|
||||
{
|
||||
ids = ids.Substring(0, ids.LastIndexOf(","));
|
||||
}
|
||||
inspectionPerson.UnitWorkId = ids;
|
||||
if (string.IsNullOrEmpty(this.InspectionPersonId))
|
||||
{
|
||||
inspectionPerson.CompileMan = this.CurrUser.UserId;
|
||||
inspectionPerson.CompileDate = DateTime.Now;
|
||||
inspectionPerson.Status = BLL.Const.Comprehensive_Compile;
|
||||
if (!string.IsNullOrEmpty(this.hdAttachUrl.Text))
|
||||
{
|
||||
inspectionPerson.InspectionPersonId = this.hdAttachUrl.Text;
|
||||
}
|
||||
else
|
||||
{
|
||||
inspectionPerson.InspectionPersonId = SQLHelper.GetNewID(typeof(Model.Comprehensive_InspectionPerson));
|
||||
this.hdAttachUrl.Text = inspectionPerson.InspectionPersonId;
|
||||
}
|
||||
|
||||
var sour = Funs.DB.AttachFile.FirstOrDefault(x => x.ToKeyId == inspectionPerson.InspectionPersonId);
|
||||
if (sour == null || string.IsNullOrEmpty(sour.AttachUrl))
|
||||
{
|
||||
Alert.ShowInTop("请上传附件!", MessageBoxIcon.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
// 人员报验
|
||||
BLL.InspectionPersonService.AddInspectionPerson(inspectionPerson);
|
||||
|
||||
if (this.drpPostId.SelectedItem.Text == "焊工")
|
||||
{
|
||||
// 焊工部分
|
||||
BLL.PersonManageService.AddBSWelder(welder);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
inspectionPerson.Status = BLL.Const.Comprehensive_Compile;
|
||||
inspectionPerson.InspectionPersonId = this.InspectionPersonId;
|
||||
var sour = Funs.DB.AttachFile.FirstOrDefault(x => x.ToKeyId == this.InspectionPersonId);
|
||||
if (sour == null || string.IsNullOrEmpty(sour.AttachUrl))
|
||||
{
|
||||
Alert.ShowInTop("请上传附件!", MessageBoxIcon.Warning);
|
||||
return;
|
||||
}
|
||||
var model = Funs.DB.Comprehensive_InspectionPerson.Where(u => u.InspectionPersonId == this.InspectionPersonId).FirstOrDefault();
|
||||
if (model != null)
|
||||
{
|
||||
|
||||
inspectionPerson.Status = model.Status;
|
||||
}
|
||||
BLL.InspectionPersonService.UpdateInspectionPerson(inspectionPerson);
|
||||
}
|
||||
//Project_CQMSDataService.StatisticalData(this.CurrUser.LoginProjectId, Project_CQMSDataService.CQMSDateType.QualityTraining);
|
||||
//Project_CQMSDataService.StatisticalData(this.CurrUser.LoginProjectId, Project_CQMSDataService.CQMSDateType.ManagerData);
|
||||
ShowNotify("保存成功!", MessageBoxIcon.Success);
|
||||
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 附件上传
|
||||
/// <summary>
|
||||
/// 附件上传
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void btnAttach_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(this.hdAttachUrl.Text)) //新增记录
|
||||
{
|
||||
this.hdAttachUrl.Text = SQLHelper.GetNewID(typeof(Model.Comprehensive_InspectionPerson));
|
||||
}
|
||||
Model.Comprehensive_InspectionPerson inspectionPerson = BLL.InspectionPersonService.GetInspectionPersonById(this.InspectionPersonId);
|
||||
if (inspectionPerson == null || ((inspectionPerson.CompileMan == CurrUser.UserId && inspectionPerson.Status == BLL.Const.Comprehensive_Compile) || (inspectionPerson.CompileMan == CurrUser.UserId && inspectionPerson.Status == BLL.Const.Comprehensive_ReCompile)))
|
||||
{
|
||||
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../../AttachFile/webuploader.aspx?type=0&toKeyId={0}&path=FileUpload/CQMS/inspectionPerson&menuId={1}", this.hdAttachUrl.Text, BLL.Const.InspectionPersonMenuId)));
|
||||
}
|
||||
else
|
||||
{
|
||||
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../../AttachFile/webuploader.aspx?type=-1&toKeyId={0}&path=FileUpload/CQMS/inspectionPerson&menuId={1}", this.hdAttachUrl.Text, BLL.Const.InspectionPersonMenuId)));
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 获取按钮权限
|
||||
/// <summary>
|
||||
/// 获取按钮权限
|
||||
/// </summary>
|
||||
/// <param name="button"></param>
|
||||
/// <returns></returns>
|
||||
private void GetButtonPower()
|
||||
{
|
||||
if (Request.Params["value"] == "0")
|
||||
{
|
||||
return;
|
||||
}
|
||||
var buttonList = BLL.CommonService.GetAllButtonList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.InspectionPersonMenuId);
|
||||
if (buttonList.Count() > 0)
|
||||
{
|
||||
if (buttonList.Contains(BLL.Const.BtnSave))
|
||||
{
|
||||
this.btnSave.Hidden = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user