467 lines
		
	
	
		
			22 KiB
		
	
	
	
		
			C#
		
	
	
	
		
		
			
		
	
	
			467 lines
		
	
	
		
			22 KiB
		
	
	
	
		
			C#
		
	
	
	
| 
								 | 
							
								using BLL;
							 | 
						|||
| 
								 | 
							
								using BLL.CQMS.Comprehensive;
							 | 
						|||
| 
								 | 
							
								using System;
							 | 
						|||
| 
								 | 
							
								using System.Linq;
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								namespace FineUIPro.Web.CQMS.Comprehensive
							 | 
						|||
| 
								 | 
							
								{
							 | 
						|||
| 
								 | 
							
								    public partial class SiteVisaManagementEdit : PageBase
							 | 
						|||
| 
								 | 
							
								    {
							 | 
						|||
| 
								 | 
							
								        #region 定义变量
							 | 
						|||
| 
								 | 
							
								        /// <summary>
							 | 
						|||
| 
								 | 
							
								        /// 主键
							 | 
						|||
| 
								 | 
							
								        /// </summary>
							 | 
						|||
| 
								 | 
							
								        public string VisaId
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            get
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                return (string)ViewState["VisaId"];
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								            set
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                ViewState["VisaId"] = 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.UnitService.InitUnitDownList(this.drpUnitId, this.CurrUser.LoginProjectId, true);
							 | 
						|||
| 
								 | 
							
								                BLL.CNProfessionalService.InitCNProfessionalDownList(this.drpCNProfessionalId, true);
							 | 
						|||
| 
								 | 
							
								                BLL.UnitWorkService.InitUnitWorkDownList(this.drpUnitWorkId, this.CurrUser.LoginProjectId, true);
							 | 
						|||
| 
								 | 
							
								                LoadAuditSelect();
							 | 
						|||
| 
								 | 
							
								                this.agree.Hidden = true;
							 | 
						|||
| 
								 | 
							
								                this.options.Hidden = true;
							 | 
						|||
| 
								 | 
							
								                
							 | 
						|||
| 
								 | 
							
								                this.btnSave.Hidden = true;
							 | 
						|||
| 
								 | 
							
								                this.btnSubmit.Hidden = true;
							 | 
						|||
| 
								 | 
							
								                this.VisaId = Request.Params["VisaId"];
							 | 
						|||
| 
								 | 
							
								                Model.Comprehensive_SiteVisaManagement siteVisaManagement = BLL.SiteVisaManagementService.GetSiteVisaManagementById(this.VisaId);
							 | 
						|||
| 
								 | 
							
								                if (siteVisaManagement != null)
							 | 
						|||
| 
								 | 
							
								                {
							 | 
						|||
| 
								 | 
							
								                    this.hdAttachUrl.Text = siteVisaManagement.VisaId;
							 | 
						|||
| 
								 | 
							
								                    this.VisaId = siteVisaManagement.VisaId;
							 | 
						|||
| 
								 | 
							
								                    if (!string.IsNullOrEmpty(siteVisaManagement.UnitId))
							 | 
						|||
| 
								 | 
							
								                    {
							 | 
						|||
| 
								 | 
							
								                        this.drpUnitId.SelectedValue = siteVisaManagement.UnitId;
							 | 
						|||
| 
								 | 
							
								                    }
							 | 
						|||
| 
								 | 
							
								                    this.txtVisaCode.Text = siteVisaManagement.VisaCode;
							 | 
						|||
| 
								 | 
							
								                    this.txtVisaContent.Text = siteVisaManagement.VisaContent;
							 | 
						|||
| 
								 | 
							
								                    if (!string.IsNullOrEmpty(siteVisaManagement.ProcessingState))
							 | 
						|||
| 
								 | 
							
								                    {
							 | 
						|||
| 
								 | 
							
								                        this.drpProcessingState.SelectedValue = siteVisaManagement.ProcessingState;
							 | 
						|||
| 
								 | 
							
								                    }
							 | 
						|||
| 
								 | 
							
								                    if (!string.IsNullOrEmpty(siteVisaManagement.UnitWorkId))
							 | 
						|||
| 
								 | 
							
								                    {
							 | 
						|||
| 
								 | 
							
								                        this.drpUnitWorkId.SelectedValue = siteVisaManagement.UnitWorkId;
							 | 
						|||
| 
								 | 
							
								                    }
							 | 
						|||
| 
								 | 
							
								                    if (!string.IsNullOrEmpty(siteVisaManagement.CNProfessionalId))
							 | 
						|||
| 
								 | 
							
								                    {
							 | 
						|||
| 
								 | 
							
								                        this.drpCNProfessionalId.SelectedValue = siteVisaManagement.CNProfessionalId;
							 | 
						|||
| 
								 | 
							
								                    }
							 | 
						|||
| 
								 | 
							
								                    if (siteVisaManagement.VisaDate != null)
							 | 
						|||
| 
								 | 
							
								                    {
							 | 
						|||
| 
								 | 
							
								                        this.txtVisaDate.Text = string.Format("{0:yyyy-MM-dd}", siteVisaManagement.VisaDate);
							 | 
						|||
| 
								 | 
							
								                    }
							 | 
						|||
| 
								 | 
							
								                    this.txtSignMan.Text = siteVisaManagement.SignMan;
							 | 
						|||
| 
								 | 
							
								                    this.txtAuditMan.Text = siteVisaManagement.AuditMan;
							 | 
						|||
| 
								 | 
							
								                    this.txtRemark.Text = siteVisaManagement.Remark;
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								                    var currApprove = SiteVisaManagementApproveService.GetCurrentApprove(siteVisaManagement.VisaId);
							 | 
						|||
| 
								 | 
							
								                    if (currApprove != null)
							 | 
						|||
| 
								 | 
							
								                    {
							 | 
						|||
| 
								 | 
							
								                        this.drpAudit.SelectedValue = currApprove.ApproveMan;
							 | 
						|||
| 
								 | 
							
								                        //重新编制  编制人 可以 显示 提交 保存按钮
							 | 
						|||
| 
								 | 
							
								                        if (currApprove.ApproveType == BLL.Const.Comprehensive_ReCompile && siteVisaManagement.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 (siteVisaManagement.Status == BLL.Const.Comprehensive_Compile && siteVisaManagement.CompileMan == CurrUser.UserId)
							 | 
						|||
| 
								 | 
							
								                        {
							 | 
						|||
| 
								 | 
							
								                            this.btnSubmit.Hidden = false;
							 | 
						|||
| 
								 | 
							
								                            this.btnSave.Hidden = false;
							 | 
						|||
| 
								 | 
							
								                        }
							 | 
						|||
| 
								 | 
							
								                    }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								                }
							 | 
						|||
| 
								 | 
							
								                else
							 | 
						|||
| 
								 | 
							
								                {
							 | 
						|||
| 
								 | 
							
								                    this.txtVisaDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now);
							 | 
						|||
| 
								 | 
							
								                    this.btnSave.Hidden = false;
							 | 
						|||
| 
								 | 
							
								                    this.btnSubmit.Hidden = false;
							 | 
						|||
| 
								 | 
							
								                }
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        /// <summary>
							 | 
						|||
| 
								 | 
							
								        /// 禁止编辑
							 | 
						|||
| 
								 | 
							
								        /// </summary>
							 | 
						|||
| 
								 | 
							
								        public void Readonly()
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            this.txtRemark.Readonly = true;
							 | 
						|||
| 
								 | 
							
								            this.drpUnitId.Readonly = true;
							 | 
						|||
| 
								 | 
							
								            this.drpCNProfessionalId.Readonly = true;
							 | 
						|||
| 
								 | 
							
								            this.txtSignMan.Readonly = true;
							 | 
						|||
| 
								 | 
							
								            this.txtVisaCode.Readonly = true;
							 | 
						|||
| 
								 | 
							
								            this.txtVisaContent.Readonly = true;
							 | 
						|||
| 
								 | 
							
								            this.txtVisaDate.Readonly = true;
							 | 
						|||
| 
								 | 
							
								            this.drpUnitWorkId.Readonly = true;
							 | 
						|||
| 
								 | 
							
								            this.drpProcessingState.Readonly = true; 
							 | 
						|||
| 
								 | 
							
								            this.drpAudit.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 (drpCNProfessionalId.SelectedValue == BLL.Const._Null)
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                Alert.ShowInTop("请选择专业!", MessageBoxIcon.Warning);
							 | 
						|||
| 
								 | 
							
								                return;
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								            Model.Comprehensive_SiteVisaManagement siteVisaManagement = new Model.Comprehensive_SiteVisaManagement();
							 | 
						|||
| 
								 | 
							
								            siteVisaManagement.ProjectId = this.CurrUser.LoginProjectId;
							 | 
						|||
| 
								 | 
							
								            if (!string.IsNullOrEmpty(this.drpAudit.SelectedValue))
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                siteVisaManagement.AuditMan = drpAudit.SelectedValue;
							 | 
						|||
| 
								 | 
							
								            }   //审核人
							 | 
						|||
| 
								 | 
							
								            if (this.drpUnitId.SelectedValue != BLL.Const._Null)
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                siteVisaManagement.UnitId = this.drpUnitId.SelectedValue;
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								            siteVisaManagement.VisaCode = this.txtVisaCode.Text.Trim();
							 | 
						|||
| 
								 | 
							
								            siteVisaManagement.VisaContent = this.txtVisaContent.Text.Trim();
							 | 
						|||
| 
								 | 
							
								            siteVisaManagement.ProcessingState = this.drpProcessingState.SelectedValue.Trim();
							 | 
						|||
| 
								 | 
							
								            if (this.drpUnitWorkId.SelectedValue != BLL.Const._Null)
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                siteVisaManagement.UnitWorkId = this.drpUnitWorkId.SelectedValue;
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								            if (this.drpCNProfessionalId.SelectedValue != BLL.Const._Null)
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                siteVisaManagement.CNProfessionalId = this.drpCNProfessionalId.SelectedValue;
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								            if (!string.IsNullOrEmpty(this.txtVisaDate.Text))
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                siteVisaManagement.VisaDate = Convert.ToDateTime(this.txtVisaDate.Text);
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								            siteVisaManagement.SignMan = this.txtSignMan.Text.Trim();
							 | 
						|||
| 
								 | 
							
								            siteVisaManagement.AuditMan = this.txtAuditMan.Text.Trim();
							 | 
						|||
| 
								 | 
							
								            siteVisaManagement.Remark = this.txtRemark.Text.Trim();
							 | 
						|||
| 
								 | 
							
								            if (string.IsNullOrEmpty(this.VisaId))
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                if (!string.IsNullOrEmpty(this.hdAttachUrl.Text))
							 | 
						|||
| 
								 | 
							
								                {
							 | 
						|||
| 
								 | 
							
								                    siteVisaManagement.VisaId = this.hdAttachUrl.Text;
							 | 
						|||
| 
								 | 
							
								                }
							 | 
						|||
| 
								 | 
							
								                else
							 | 
						|||
| 
								 | 
							
								                {
							 | 
						|||
| 
								 | 
							
								                    siteVisaManagement.VisaId = SQLHelper.GetNewID(typeof(Model.Comprehensive_SiteVisaManagement));
							 | 
						|||
| 
								 | 
							
								                    this.hdAttachUrl.Text = siteVisaManagement.VisaId;
							 | 
						|||
| 
								 | 
							
								                }
							 | 
						|||
| 
								 | 
							
								                var sour = Funs.DB.AttachFile.FirstOrDefault(x => x.ToKeyId == siteVisaManagement.VisaId);
							 | 
						|||
| 
								 | 
							
								                if (sour == null || string.IsNullOrEmpty(sour.AttachUrl))
							 | 
						|||
| 
								 | 
							
								                {
							 | 
						|||
| 
								 | 
							
								                    Alert.ShowInTop("请上传附件!", MessageBoxIcon.Warning);
							 | 
						|||
| 
								 | 
							
								                    return;
							 | 
						|||
| 
								 | 
							
								                }
							 | 
						|||
| 
								 | 
							
								                siteVisaManagement.CompileMan = this.CurrUser.UserId;
							 | 
						|||
| 
								 | 
							
								                siteVisaManagement.Status = BLL.Const.Comprehensive_Compile;
							 | 
						|||
| 
								 | 
							
								                BLL.SiteVisaManagementService.AddSiteVisaManagement(siteVisaManagement);
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								            else
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                siteVisaManagement.VisaId = this.VisaId;
							 | 
						|||
| 
								 | 
							
								                var sour = Funs.DB.AttachFile.FirstOrDefault(x => x.ToKeyId == this.VisaId);
							 | 
						|||
| 
								 | 
							
								                if (sour == null || string.IsNullOrEmpty(sour.AttachUrl))
							 | 
						|||
| 
								 | 
							
								                {
							 | 
						|||
| 
								 | 
							
								                    Alert.ShowInTop("请上传附件!", MessageBoxIcon.Warning);
							 | 
						|||
| 
								 | 
							
								                    return;
							 | 
						|||
| 
								 | 
							
								                }
							 | 
						|||
| 
								 | 
							
								                var model = Funs.DB.Comprehensive_SiteVisaManagement.Where(u => u.VisaId == this.VisaId).FirstOrDefault();
							 | 
						|||
| 
								 | 
							
								                if (model != null)
							 | 
						|||
| 
								 | 
							
								                {
							 | 
						|||
| 
								 | 
							
								                    siteVisaManagement.Status = model.Status;
							 | 
						|||
| 
								 | 
							
								                }
							 | 
						|||
| 
								 | 
							
								                BLL.SiteVisaManagementService.UpdateSiteVisaManagement(siteVisaManagement);
							 | 
						|||
| 
								 | 
							
								            } 
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								            ShowNotify("保存成功!", MessageBoxIcon.Success);
							 | 
						|||
| 
								 | 
							
								            PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        protected void btnSubmit_Click(object sender, EventArgs e)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            if (drpCNProfessionalId.SelectedValue == BLL.Const._Null)
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                Alert.ShowInTop("请选择专业!", MessageBoxIcon.Warning);
							 | 
						|||
| 
								 | 
							
								                return;
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								            Model.Comprehensive_SiteVisaManagement siteVisaManagement = new Model.Comprehensive_SiteVisaManagement();
							 | 
						|||
| 
								 | 
							
								            siteVisaManagement.ProjectId = this.CurrUser.LoginProjectId;
							 | 
						|||
| 
								 | 
							
								            if (!string.IsNullOrEmpty(this.drpAudit.SelectedValue))
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                siteVisaManagement.AuditMan = drpAudit.SelectedValue;
							 | 
						|||
| 
								 | 
							
								            }   //审核人
							 | 
						|||
| 
								 | 
							
								            if (this.drpUnitId.SelectedValue != BLL.Const._Null)
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                siteVisaManagement.UnitId = this.drpUnitId.SelectedValue;
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								            siteVisaManagement.VisaCode = this.txtVisaCode.Text.Trim();
							 | 
						|||
| 
								 | 
							
								            siteVisaManagement.VisaContent = this.txtVisaContent.Text.Trim();
							 | 
						|||
| 
								 | 
							
								            siteVisaManagement.ProcessingState = this.drpProcessingState.SelectedValue.Trim();
							 | 
						|||
| 
								 | 
							
								            if (this.drpUnitWorkId.SelectedValue != BLL.Const._Null)
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                siteVisaManagement.UnitWorkId = this.drpUnitWorkId.SelectedValue;
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								            if (this.drpCNProfessionalId.SelectedValue != BLL.Const._Null)
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                siteVisaManagement.CNProfessionalId = this.drpCNProfessionalId.SelectedValue;
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								            if (!string.IsNullOrEmpty(this.txtVisaDate.Text))
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                siteVisaManagement.VisaDate = Convert.ToDateTime(this.txtVisaDate.Text);
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								            siteVisaManagement.SignMan = this.txtSignMan.Text.Trim();
							 | 
						|||
| 
								 | 
							
								            siteVisaManagement.AuditMan = this.txtAuditMan.Text.Trim();
							 | 
						|||
| 
								 | 
							
								            siteVisaManagement.Remark = this.txtRemark.Text.Trim();
							 | 
						|||
| 
								 | 
							
								            if (string.IsNullOrEmpty(this.VisaId))
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                if (!string.IsNullOrEmpty(this.hdAttachUrl.Text))
							 | 
						|||
| 
								 | 
							
								                {
							 | 
						|||
| 
								 | 
							
								                    siteVisaManagement.VisaId = this.hdAttachUrl.Text;
							 | 
						|||
| 
								 | 
							
								                }
							 | 
						|||
| 
								 | 
							
								                else
							 | 
						|||
| 
								 | 
							
								                {
							 | 
						|||
| 
								 | 
							
								                    siteVisaManagement.VisaId = SQLHelper.GetNewID(typeof(Model.Comprehensive_SiteVisaManagement));
							 | 
						|||
| 
								 | 
							
								                    this.hdAttachUrl.Text = siteVisaManagement.VisaId;
							 | 
						|||
| 
								 | 
							
								                }
							 | 
						|||
| 
								 | 
							
								                var sour = Funs.DB.AttachFile.FirstOrDefault(x => x.ToKeyId == siteVisaManagement.VisaId);
							 | 
						|||
| 
								 | 
							
								                if (sour == null || string.IsNullOrEmpty(sour.AttachUrl))
							 | 
						|||
| 
								 | 
							
								                {
							 | 
						|||
| 
								 | 
							
								                    Alert.ShowInTop("请上传附件!", MessageBoxIcon.Warning);
							 | 
						|||
| 
								 | 
							
								                    return;
							 | 
						|||
| 
								 | 
							
								                }
							 | 
						|||
| 
								 | 
							
								                siteVisaManagement.CompileMan = this.CurrUser.UserId;
							 | 
						|||
| 
								 | 
							
								                siteVisaManagement.Status = BLL.Const.Comprehensive_Audit;
							 | 
						|||
| 
								 | 
							
								                BLL.SiteVisaManagementService.AddSiteVisaManagement(siteVisaManagement);
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								            else
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                siteVisaManagement.VisaId = this.VisaId;
							 | 
						|||
| 
								 | 
							
								                var sour = Funs.DB.AttachFile.FirstOrDefault(x => x.ToKeyId == this.VisaId);
							 | 
						|||
| 
								 | 
							
								                if (sour == null || string.IsNullOrEmpty(sour.AttachUrl))
							 | 
						|||
| 
								 | 
							
								                {
							 | 
						|||
| 
								 | 
							
								                    Alert.ShowInTop("请上传附件!", MessageBoxIcon.Warning);
							 | 
						|||
| 
								 | 
							
								                    return;
							 | 
						|||
| 
								 | 
							
								                }
							 | 
						|||
| 
								 | 
							
								                // BLL.SiteVisaManagementService.UpdateSiteVisaManagement(siteVisaManagement);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								                var oldSiteVisaManagement = Funs.DB.Comprehensive_SiteVisaManagement.Where(u => u.VisaId == this.VisaId).FirstOrDefault();
							 | 
						|||
| 
								 | 
							
								                if (oldSiteVisaManagement == null) //数据库没有记录 直接点提交 当前状态为 审核状态
							 | 
						|||
| 
								 | 
							
								                {
							 | 
						|||
| 
								 | 
							
								                    siteVisaManagement.CompileMan = this.CurrUser.UserId;
							 | 
						|||
| 
								 | 
							
								                    //siteVisaManagement.CompileDate = DateTime.Now;
							 | 
						|||
| 
								 | 
							
								                    siteVisaManagement.Status = BLL.Const.Comprehensive_Audit;
							 | 
						|||
| 
								 | 
							
								                    BLL.SiteVisaManagementService.AddSiteVisaManagement(siteVisaManagement);
							 | 
						|||
| 
								 | 
							
								                }
							 | 
						|||
| 
								 | 
							
								                else
							 | 
						|||
| 
								 | 
							
								                {
							 | 
						|||
| 
								 | 
							
								                    siteVisaManagement.CompileMan = oldSiteVisaManagement.CompileMan;
							 | 
						|||
| 
								 | 
							
								                    //siteVisaManagement.CompileDate = oldSiteVisaManagement.CompileDate;
							 | 
						|||
| 
								 | 
							
								                    if (oldSiteVisaManagement.Status == BLL.Const.Comprehensive_Compile)//编制状态提交变审核
							 | 
						|||
| 
								 | 
							
								                    {
							 | 
						|||
| 
								 | 
							
								                        siteVisaManagement.Status = BLL.Const.Comprehensive_Audit;
							 | 
						|||
| 
								 | 
							
								                    }
							 | 
						|||
| 
								 | 
							
								                    else if (oldSiteVisaManagement.Status == BLL.Const.Comprehensive_ReCompile)//重新编制状态提交变审核
							 | 
						|||
| 
								 | 
							
								                    {
							 | 
						|||
| 
								 | 
							
								                        siteVisaManagement.Status = BLL.Const.Comprehensive_Audit;
							 | 
						|||
| 
								 | 
							
								                    }
							 | 
						|||
| 
								 | 
							
								                    else //审核状态  提交 变 完成 或者 重新编制
							 | 
						|||
| 
								 | 
							
								                    {
							 | 
						|||
| 
								 | 
							
								                        if (Convert.ToBoolean(rblIsAgree.SelectedValue))
							 | 
						|||
| 
								 | 
							
								                        {
							 | 
						|||
| 
								 | 
							
								                            siteVisaManagement.Status = BLL.Const.Comprehensive_Complete;
							 | 
						|||
| 
								 | 
							
								                        }
							 | 
						|||
| 
								 | 
							
								                        else
							 | 
						|||
| 
								 | 
							
								                        {
							 | 
						|||
| 
								 | 
							
								                            siteVisaManagement.Status = BLL.Const.Comprehensive_ReCompile;
							 | 
						|||
| 
								 | 
							
								                        }
							 | 
						|||
| 
								 | 
							
								                    }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								                    BLL.SiteVisaManagementService.UpdateSiteVisaManagement(siteVisaManagement);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								                }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								            #region 审核记录
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								            var currApprove = SiteVisaManagementApproveService.GetCurrentApprove(siteVisaManagement.VisaId);
							 | 
						|||
| 
								 | 
							
								            if (currApprove == null) //为获取到为 当前编制状态 直接提交
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                var approve = new Model.Comprehensive_SiteVisaManagementApprove();
							 | 
						|||
| 
								 | 
							
								                approve.VisaId = siteVisaManagement.VisaId;
							 | 
						|||
| 
								 | 
							
								                approve.ApproveMan = this.CurrUser.UserId;
							 | 
						|||
| 
								 | 
							
								                approve.ApproveType = Const.Comprehensive_Compile;
							 | 
						|||
| 
								 | 
							
								                approve.ApproveDate = DateTime.Now;
							 | 
						|||
| 
								 | 
							
								                SiteVisaManagementApproveService.EditApprove(approve);  //新增编制记录
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								                Model.Comprehensive_SiteVisaManagementApprove newApprove = new Model.Comprehensive_SiteVisaManagementApprove();
							 | 
						|||
| 
								 | 
							
								                newApprove.VisaId = siteVisaManagement.VisaId;
							 | 
						|||
| 
								 | 
							
								                newApprove.ApproveMan = this.drpAudit.SelectedValue;
							 | 
						|||
| 
								 | 
							
								                newApprove.ApproveType = Const.InspectionManagement_Audit;
							 | 
						|||
| 
								 | 
							
								                SiteVisaManagementApproveService.EditApprove(newApprove); //新增专业工程师审核记录
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								            else if (currApprove.ApproveMan == CurrUser.UserId)
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                if (currApprove.ApproveType == BLL.Const.Comprehensive_ReCompile)
							 | 
						|||
| 
								 | 
							
								                {
							 | 
						|||
| 
								 | 
							
								                    currApprove.ApproveDate = DateTime.Now;
							 | 
						|||
| 
								 | 
							
								                    //currApprove.IsAgree = true;
							 | 
						|||
| 
								 | 
							
								                    SiteVisaManagementApproveService.EditApprove(currApprove); //新增专业工程师审核记录
							 | 
						|||
| 
								 | 
							
								                    Model.Comprehensive_SiteVisaManagementApprove newApprove = new Model.Comprehensive_SiteVisaManagementApprove();
							 | 
						|||
| 
								 | 
							
								                    newApprove.VisaId = siteVisaManagement.VisaId;
							 | 
						|||
| 
								 | 
							
								                    newApprove.ApproveMan = this.drpAudit.SelectedValue;
							 | 
						|||
| 
								 | 
							
								                    newApprove.ApproveType = Const.InspectionManagement_Audit;
							 | 
						|||
| 
								 | 
							
								                    SiteVisaManagementApproveService.EditApprove(newApprove); //新增专业工程师审核记录
							 | 
						|||
| 
								 | 
							
								                }
							 | 
						|||
| 
								 | 
							
								                else
							 | 
						|||
| 
								 | 
							
								                {
							 | 
						|||
| 
								 | 
							
								                    currApprove.ApproveDate = DateTime.Now;  //更新审核时间
							 | 
						|||
| 
								 | 
							
								                    currApprove.IsAgree = Convert.ToBoolean(rblIsAgree.SelectedValue);
							 | 
						|||
| 
								 | 
							
								                    currApprove.ApproveIdea = this.txtidea.Text;
							 | 
						|||
| 
								 | 
							
								                    SiteVisaManagementApproveService.EditApprove(currApprove);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								                    if (Convert.ToBoolean(rblIsAgree.SelectedValue))  //同意时 审批完成
							 | 
						|||
| 
								 | 
							
								                    {
							 | 
						|||
| 
								 | 
							
								                        Model.Comprehensive_SiteVisaManagementApprove reApprove = new Model.Comprehensive_SiteVisaManagementApprove();
							 | 
						|||
| 
								 | 
							
								                        reApprove.VisaId = currApprove.VisaId;
							 | 
						|||
| 
								 | 
							
								                        reApprove.ApproveDate = DateTime.Now.AddSeconds(10);
							 | 
						|||
| 
								 | 
							
								                        reApprove.ApproveMan = CurrUser.UserId;
							 | 
						|||
| 
								 | 
							
								                        reApprove.ApproveType = Const.Comprehensive_Complete;
							 | 
						|||
| 
								 | 
							
								                        reApprove.ApproveIdea = txtidea.Text;
							 | 
						|||
| 
								 | 
							
								                        SiteVisaManagementApproveService.EditApprove(reApprove);
							 | 
						|||
| 
								 | 
							
								                    }
							 | 
						|||
| 
								 | 
							
								                    else
							 | 
						|||
| 
								 | 
							
								                    {
							 | 
						|||
| 
								 | 
							
								                        Model.Comprehensive_SiteVisaManagementApprove reApprove = new Model.Comprehensive_SiteVisaManagementApprove();
							 | 
						|||
| 
								 | 
							
								                        reApprove.VisaId = currApprove.VisaId;
							 | 
						|||
| 
								 | 
							
								                        reApprove.ApproveMan = siteVisaManagement.CompileMan;
							 | 
						|||
| 
								 | 
							
								                        reApprove.ApproveType = Const.Comprehensive_ReCompile;
							 | 
						|||
| 
								 | 
							
								                        SiteVisaManagementApproveService.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_SiteVisaManagement));
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								            Model.Comprehensive_SiteVisaManagement siteVisaManagement = BLL.SiteVisaManagementService.GetSiteVisaManagementById(this.VisaId);
							 | 
						|||
| 
								 | 
							
								            if (siteVisaManagement == null || ((siteVisaManagement.CompileMan == CurrUser.UserId && siteVisaManagement.Status == BLL.Const.Comprehensive_Compile) || (siteVisaManagement.CompileMan == CurrUser.UserId && siteVisaManagement.Status == BLL.Const.Comprehensive_ReCompile)))
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../../AttachFile/webuploader.aspx?type=0&toKeyId={0}&path=FileUpload/CQMS/siteVisaManagement&menuId={1}", this.hdAttachUrl.Text, BLL.Const.SiteVisaManagementMenuId)));
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								            else
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../../AttachFile/webuploader.aspx?type=-1&toKeyId={0}&path=FileUpload/CQMS/siteVisaManagement&menuId={1}", this.hdAttachUrl.Text, BLL.Const.SiteVisaManagementMenuId)));
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								        #endregion
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        #region 获取按钮权限
							 | 
						|||
| 
								 | 
							
								        /// <summary>
							 | 
						|||
| 
								 | 
							
								        /// 获取按钮权限
							 | 
						|||
| 
								 | 
							
								        /// </summary>
							 | 
						|||
| 
								 | 
							
								        /// <param name="button"></param>
							 | 
						|||
| 
								 | 
							
								        /// <returns></returns>
							 | 
						|||
| 
								 | 
							
								        private void GetButtonPower()
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            if (Request.Params["value"] == BLL.Const._Null)
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                return;
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								            var buttonList = BLL.CommonService.GetAllButtonList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.SiteVisaManagementMenuId);
							 | 
						|||
| 
								 | 
							
								            if (buttonList.Count() > 0)
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                if (buttonList.Contains(BLL.Const.BtnSave))
							 | 
						|||
| 
								 | 
							
								                {
							 | 
						|||
| 
								 | 
							
								                    this.btnSave.Hidden = false;
							 | 
						|||
| 
								 | 
							
								                }
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								        #endregion
							 | 
						|||
| 
								 | 
							
								    }
							 | 
						|||
| 
								 | 
							
								}
							 |