743 lines
		
	
	
		
			33 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			743 lines
		
	
	
		
			33 KiB
		
	
	
	
		
			C#
		
	
	
	
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;
 | 
						|
            }
 | 
						|
        }
 | 
						|
        public string welderId
 | 
						|
        {
 | 
						|
            get
 | 
						|
            {
 | 
						|
                return (string)ViewState["welderId"];
 | 
						|
            }
 | 
						|
            set
 | 
						|
            {
 | 
						|
                ViewState["welderId"] = 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.PostService.InitPostDownList(this.drpPostId, true);
 | 
						|
                BLL.CNProfessionalService.InitCNProfessionalDownList(this.drpCNProfessionalId, true);
 | 
						|
                LoadAuditSelect();
 | 
						|
                this.agree.Hidden = true;
 | 
						|
                this.options.Hidden = true;
 | 
						|
                
 | 
						|
                this.btnSave.Hidden = true;
 | 
						|
                this.btnSubmit.Hidden = 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;
 | 
						|
 | 
						|
                        if (this.drpPostId.SelectedText == "焊工")
 | 
						|
                        {
 | 
						|
                            var welder = Funs.DB.BS_Welder.FirstOrDefault(x => x.ProjectId == this.CurrUser.LoginProjectId && x.WED_Name == inspectionPerson.PersonName);
 | 
						|
                            if (welder != null)
 | 
						|
                            {
 | 
						|
                                welderId = welder.WED_ID;
 | 
						|
                                txtWelderCode.Text = welder.WED_Code;
 | 
						|
                                txtWelderCode.Hidden = false;
 | 
						|
                            }
 | 
						|
                        }
 | 
						|
                    }
 | 
						|
                    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.rblIsTrain.SelectedValue = inspectionPerson.IsTrain.HasValue && inspectionPerson.IsTrain == true ? "true" : "false";
 | 
						|
                    this.rblIsOnSite.SelectedValue = inspectionPerson.IsOnSite.HasValue && inspectionPerson.IsOnSite == 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)
 | 
						|
                    {
 | 
						|
                        this.drpAudit.SelectedValue = currApprove.ApproveMan;
 | 
						|
                        //重新编制  编制人 可以 显示 提交 保存按钮
 | 
						|
                        if (currApprove.ApproveType == BLL.Const.Comprehensive_ReCompile && inspectionPerson.CompileMan == CurrUser.UserId)
 | 
						|
                        {
 | 
						|
                            this.btnSubmit.Hidden = false;
 | 
						|
                            this.btnSave.Hidden = false;
 | 
						|
                        }//审核状态 审核人 可以显示  提交 保存按钮
 | 
						|
                        else if (currApprove.ApproveType == BLL.Const.Comprehensive_Audit && currApprove.ApproveMan == CurrUser.UserId)
 | 
						|
                        {
 | 
						|
                            //审核状态不可编辑
 | 
						|
                            Readonly();
 | 
						|
 | 
						|
                            this.agree.Hidden = false;
 | 
						|
                            this.options.Hidden = false;
 | 
						|
                            this.btnSubmit.Hidden = false;
 | 
						|
                            this.btnSave.Hidden = false;
 | 
						|
                        }
 | 
						|
                    }//没有当前审核人,已完成状态 或者 待提交状态
 | 
						|
                    else
 | 
						|
                    {
 | 
						|
                        if (inspectionPerson.Status == BLL.Const.Comprehensive_Compile && inspectionPerson.CompileMan == CurrUser.UserId)
 | 
						|
                        {
 | 
						|
                            this.btnSubmit.Hidden = false;
 | 
						|
                            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;
 | 
						|
                    this.btnSubmit.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.drpAudit.Readonly = true;
 | 
						|
            this.drpUnitWorkIds.Readonly = true; 
 | 
						|
            //this.btnAttach.Enabled = false; 
 | 
						|
           
 | 
						|
        }
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// 加载专业工程师
 | 
						|
        /// </summary>
 | 
						|
        public void LoadAuditSelect()
 | 
						|
        {
 | 
						|
 | 
						|
            var db = Funs.DB;
 | 
						|
            var userList = from x in db.Sys_User
 | 
						|
                           join y in db.Project_ProjectUnit
 | 
						|
                           on x.UnitId equals y.UnitId
 | 
						|
                           join p in db.Project_ProjectUser
 | 
						|
                           on x.UserId equals p.UserId
 | 
						|
                           where y.UnitId == Const.UnitId_TCC && p.ProjectId == CurrUser.LoginProjectId && y.ProjectId == CurrUser.LoginProjectId
 | 
						|
                           where p.RoleId.Contains(Const.ZBCNEngineer)
 | 
						|
                           select new { UserId = x.UserId, UserName = x.UserName };
 | 
						|
            drpAudit.DataValueField = "UserId";
 | 
						|
            drpAudit.DataTextField = "UserName";
 | 
						|
            this.drpAudit.DataSource = userList.ToList();
 | 
						|
            this.drpAudit.DataBind();
 | 
						|
        }
 | 
						|
 | 
						|
 | 
						|
 | 
						|
        #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;
 | 
						|
            }
 | 
						|
            if (this.drpPostId.SelectedText == "焊工")
 | 
						|
            {
 | 
						|
                if (string.IsNullOrEmpty(txtWelderCode.Text.Trim()))
 | 
						|
                {
 | 
						|
                    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.txtWelderCode.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 (!string.IsNullOrEmpty(this.drpAudit.SelectedValue))
 | 
						|
            {
 | 
						|
                inspectionPerson.AuditMan = drpAudit.SelectedValue;
 | 
						|
            }   //审核人
 | 
						|
            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.SelectedText == "焊工")
 | 
						|
                {
 | 
						|
                    //if (string.IsNullOrEmpty(welderId))
 | 
						|
                    //{
 | 
						|
                    //    // 焊工部分
 | 
						|
                    //    BLL.PersonManageService.AddBSWelder(welder);
 | 
						|
                    //}
 | 
						|
                    //else
 | 
						|
                    //{
 | 
						|
                    //    welder.WED_ID = welderId;
 | 
						|
                    //    BLL.PersonManageService.UpdateBSWelder(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);
 | 
						|
                if (this.drpPostId.SelectedText == "焊工")
 | 
						|
                {
 | 
						|
                    if (string.IsNullOrEmpty(welderId))
 | 
						|
                    {
 | 
						|
                        // 焊工部分
 | 
						|
                        BLL.PersonManageService.AddBSWelder(welder);
 | 
						|
                    }
 | 
						|
                    else
 | 
						|
                    {
 | 
						|
                        welder.WED_ID = welderId;
 | 
						|
                        BLL.PersonManageService.UpdateBSWelder(welder);
 | 
						|
                    }
 | 
						|
 | 
						|
 | 
						|
                }
 | 
						|
            } 
 | 
						|
            ShowNotify("保存成功!", MessageBoxIcon.Success);
 | 
						|
            PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
 | 
						|
        }
 | 
						|
 | 
						|
 | 
						|
        protected void btnSubmit_Click(object sender, EventArgs e)
 | 
						|
        {
 | 
						|
            if (this.drpUnitId.SelectedValue == BLL.Const._Null)
 | 
						|
            {
 | 
						|
                Alert.ShowInTop("请选择报验单位!", MessageBoxIcon.Warning);
 | 
						|
                return;
 | 
						|
            }
 | 
						|
 | 
						|
            if (this.drpPostId.SelectedText == "焊工")
 | 
						|
            {
 | 
						|
                if (string.IsNullOrEmpty(txtWelderCode.Text.Trim()))
 | 
						|
                {
 | 
						|
                    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_Code = txtWelderCode.Text.Trim();
 | 
						|
            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 (!string.IsNullOrEmpty(this.drpAudit.SelectedValue))
 | 
						|
            {
 | 
						|
                inspectionPerson.AuditMan = drpAudit.SelectedValue;
 | 
						|
            }   //审核人
 | 
						|
            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;
 | 
						|
                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;
 | 
						|
                }
 | 
						|
                inspectionPerson.Status = BLL.Const.Comprehensive_Audit;
 | 
						|
                // 人员报验
 | 
						|
                BLL.InspectionPersonService.AddInspectionPerson(inspectionPerson);
 | 
						|
 | 
						|
                if (this.drpPostId.SelectedText == "焊工")
 | 
						|
                {
 | 
						|
                    // 焊工部分
 | 
						|
                    if (string.IsNullOrEmpty(welderId))
 | 
						|
                    {
 | 
						|
                        // 焊工部分
 | 
						|
                        BLL.PersonManageService.AddBSWelder(welder);
 | 
						|
                    }
 | 
						|
                    else
 | 
						|
                    {
 | 
						|
                        welder.WED_ID = welderId;
 | 
						|
                        BLL.PersonManageService.UpdateBSWelder(welder);
 | 
						|
                    }
 | 
						|
                }
 | 
						|
            }
 | 
						|
            else
 | 
						|
            {
 | 
						|
                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;
 | 
						|
                }
 | 
						|
                // BLL.InspectionPersonService.UpdateInspectionPerson(inspectionPerson);
 | 
						|
                var oldInspectionPerson = Funs.DB.Comprehensive_InspectionPerson.Where(u => u.InspectionPersonId == this.InspectionPersonId).FirstOrDefault();
 | 
						|
                if (oldInspectionPerson == null) //数据库没有记录 直接点提交 当前状态为 审核状态
 | 
						|
                {
 | 
						|
                    inspectionPerson.CompileMan = this.CurrUser.UserId;
 | 
						|
                    inspectionPerson.CompileDate = DateTime.Now;
 | 
						|
                    inspectionPerson.Status = BLL.Const.Comprehensive_Audit;
 | 
						|
                    BLL.InspectionPersonService.AddInspectionPerson(inspectionPerson);
 | 
						|
                }
 | 
						|
                else
 | 
						|
                {
 | 
						|
                    inspectionPerson.CompileMan = oldInspectionPerson.CompileMan;
 | 
						|
                    inspectionPerson.CompileDate = oldInspectionPerson.CompileDate;
 | 
						|
                    if (oldInspectionPerson.Status == BLL.Const.Comprehensive_Compile)//编制状态提交变审核
 | 
						|
                    {
 | 
						|
                        inspectionPerson.Status = BLL.Const.Comprehensive_Audit;
 | 
						|
                    }
 | 
						|
                    else if (oldInspectionPerson.Status == BLL.Const.Comprehensive_ReCompile)//重新编制状态提交变审核
 | 
						|
                    {
 | 
						|
                        inspectionPerson.Status = BLL.Const.Comprehensive_Audit;
 | 
						|
                    }
 | 
						|
                    else //审核状态  提交 变 完成 或者 重新编制
 | 
						|
                    {
 | 
						|
                        if (Convert.ToBoolean(rblIsAgree.SelectedValue))
 | 
						|
                        {
 | 
						|
                            inspectionPerson.Status = BLL.Const.Comprehensive_Complete;
 | 
						|
                        }
 | 
						|
                        else
 | 
						|
                        {
 | 
						|
                            inspectionPerson.Status = BLL.Const.Comprehensive_ReCompile;
 | 
						|
                        }
 | 
						|
                    }
 | 
						|
 | 
						|
                    BLL.InspectionPersonService.UpdateInspectionPerson(inspectionPerson);
 | 
						|
                    if (this.drpPostId.SelectedText == "焊工")
 | 
						|
                    {
 | 
						|
                        // 焊工部分
 | 
						|
                        if (string.IsNullOrEmpty(welderId))
 | 
						|
                        {
 | 
						|
                            // 焊工部分
 | 
						|
                            BLL.PersonManageService.AddBSWelder(welder);
 | 
						|
                        }
 | 
						|
                        else
 | 
						|
                        {
 | 
						|
                            welder.WED_ID = welderId;
 | 
						|
                            BLL.PersonManageService.UpdateBSWelder(welder);
 | 
						|
                        }
 | 
						|
                    }
 | 
						|
 | 
						|
                }
 | 
						|
 | 
						|
            }
 | 
						|
            #region 审核记录
 | 
						|
 | 
						|
            var currApprove = InspectionPersonApproveService.GetCurrentApprove(inspectionPerson.InspectionPersonId);
 | 
						|
            if (currApprove == null) //为获取到为 当前编制状态 直接提交
 | 
						|
            {
 | 
						|
                var approve = new Model.Comprehensive_InspectionPersonApprove();
 | 
						|
                approve.InspectionPersonId = inspectionPerson.InspectionPersonId;
 | 
						|
                approve.ApproveMan = this.CurrUser.UserId;
 | 
						|
                approve.ApproveType = Const.Comprehensive_Compile;
 | 
						|
                approve.ApproveDate = DateTime.Now;
 | 
						|
                InspectionPersonApproveService.EditApprove(approve);  //新增编制记录
 | 
						|
 | 
						|
 | 
						|
                Model.Comprehensive_InspectionPersonApprove newApprove = new Model.Comprehensive_InspectionPersonApprove();
 | 
						|
                newApprove.InspectionPersonId = inspectionPerson.InspectionPersonId;
 | 
						|
                newApprove.ApproveMan = this.drpAudit.SelectedValue;
 | 
						|
                newApprove.ApproveType = Const.InspectionManagement_Audit;
 | 
						|
                InspectionPersonApproveService.EditApprove(newApprove); //新增专业工程师审核记录
 | 
						|
 | 
						|
            }
 | 
						|
            else if (currApprove.ApproveMan == CurrUser.UserId)
 | 
						|
            {
 | 
						|
                if (currApprove.ApproveType == BLL.Const.Comprehensive_ReCompile)
 | 
						|
                {
 | 
						|
                    currApprove.ApproveDate = DateTime.Now;
 | 
						|
                    //currApprove.IsAgree = true;
 | 
						|
                    InspectionPersonApproveService.EditApprove(currApprove); //新增专业工程师审核记录
 | 
						|
                    Model.Comprehensive_InspectionPersonApprove newApprove = new Model.Comprehensive_InspectionPersonApprove();
 | 
						|
                    newApprove.InspectionPersonId = inspectionPerson.InspectionPersonId;
 | 
						|
                    newApprove.ApproveMan = this.drpAudit.SelectedValue;
 | 
						|
                    newApprove.ApproveType = Const.InspectionManagement_Audit;
 | 
						|
                    InspectionPersonApproveService.EditApprove(newApprove); //新增专业工程师审核记录
 | 
						|
                }
 | 
						|
                else
 | 
						|
                {
 | 
						|
                    currApprove.ApproveDate = DateTime.Now;  //更新审核时间
 | 
						|
                    currApprove.IsAgree = Convert.ToBoolean(rblIsAgree.SelectedValue);
 | 
						|
                    currApprove.ApproveIdea = this.txtidea.Text;
 | 
						|
                    InspectionPersonApproveService.EditApprove(currApprove);
 | 
						|
 | 
						|
                    if (Convert.ToBoolean(rblIsAgree.SelectedValue))  //同意时 审批完成
 | 
						|
                    {
 | 
						|
                        Model.Comprehensive_InspectionPersonApprove reApprove = new Model.Comprehensive_InspectionPersonApprove();
 | 
						|
                        reApprove.InspectionPersonId = currApprove.InspectionPersonId;
 | 
						|
                        reApprove.ApproveDate = DateTime.Now.AddSeconds(10);
 | 
						|
                        reApprove.ApproveMan = CurrUser.UserId;
 | 
						|
                        reApprove.ApproveType = Const.Comprehensive_Complete;
 | 
						|
                        reApprove.ApproveIdea = txtidea.Text;
 | 
						|
                        InspectionPersonApproveService.EditApprove(reApprove);
 | 
						|
                    }
 | 
						|
                    else
 | 
						|
                    {
 | 
						|
                        Model.Comprehensive_InspectionPersonApprove reApprove = new Model.Comprehensive_InspectionPersonApprove();
 | 
						|
                        reApprove.InspectionPersonId = currApprove.InspectionPersonId;
 | 
						|
                        reApprove.ApproveMan = inspectionPerson.CompileMan;
 | 
						|
                        reApprove.ApproveType = Const.Comprehensive_ReCompile;
 | 
						|
                        InspectionPersonApproveService.EditApprove(reApprove);
 | 
						|
                    }
 | 
						|
                }
 | 
						|
            }
 | 
						|
 | 
						|
 | 
						|
            #endregion
 | 
						|
 | 
						|
 | 
						|
            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
 | 
						|
 | 
						|
        protected void drpPostId_SelectedIndexChanged(object sender, EventArgs e)
 | 
						|
        {
 | 
						|
            if (drpPostId.SelectedText=="焊工")
 | 
						|
            {
 | 
						|
                txtWelderCode.Hidden =  false;
 | 
						|
            }
 | 
						|
            else
 | 
						|
            {
 | 
						|
                txtWelderCode.Hidden = true;
 | 
						|
 | 
						|
            }
 | 
						|
        }
 | 
						|
    }
 | 
						|
} |