using BLL;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Web.UI.WebControls;
namespace FineUIPro.Web.HSSE.Check
{
    public partial class CheckSpecialView : PageBase
    {
        #region 定义变量
        /// 
        /// 主键
        /// 
        public string InspectionItemId
        {
            get
            {
                return (string)ViewState["InspectionItemId"];
            }
            set
            {
                ViewState["InspectionItemId"] = value;
            }
        }
        #endregion
        #region 加载页面
        /// 
        /// 加载页面
        /// 
        /// 
        /// 
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                this.InspectionItemId = Request.Params["InspectionItemId"];
                var item = (from x in Funs.DB.Inspect_InspectionItem 
                            join y in Funs.DB.Inspect_Inspection on x.InspectionId equals y.InspectionId
                            where x.InspectionItemId == this.InspectionItemId
                            select new { 
                                InspectionItemId = x.InspectionItemId,
                                InspectionId = x.InspectionId,
                                ProjectId = y.ProjectId,
                                ProjectName = Funs.DB.Base_Project.FirstOrDefault(p => p.ProjectId == y.ProjectId).ProjectName,
                                InspectionCode = y.InspectionCode,
                                CheckMan = y.CheckMan,
                                ProblemTypeName = y.ProblemTypeName,
                                Place = y.Place,
                                PersonResponsible = y.PersonResponsible,
                                PersonResponsibleName = Funs.DB.Sys_User.FirstOrDefault(p => p.UserId == y.PersonResponsible).UserName,
                                WorkAreaName = x.WorkAreaName,
                                States = y.States,
                                ItemStates = x.States,
                                EvaluateResults = x.EvaluateResults,
                                BeforelUrl = x.BeforelUrl,
                                AfterUrl = x.AfterUrl,
                                AuditTime = x.AuditTime,
                                AuditMan = x.AuditMan,
                                RectificationResults = x.RectificationResults,
                                AuditManName = Funs.DB.Sys_User.FirstOrDefault(p => p.UserId == x.AuditMan).UserName
                            }
                            ).FirstOrDefault();
                this.Code.Text = item.InspectionCode;
                this.PName.Text = item.ProjectName;
                this.Cman.Text = item.CheckMan;
                this.Pman.Text = item.PersonResponsibleName;
                this.Ptype.Text = item.ProblemTypeName;
                this.Iarea.Text = item.Place;
                this.Carea.Text = item.WorkAreaName;
                this.conclusion.Text = item.RectificationResults;
                this.divImageUrl.InnerHtml = BLL.UploadAttachmentService.ShowAttachment(ConfigurationManager.AppSettings["CEMS_IMG_URL"], item.BeforelUrl);
                this.divRectificationImageUrl.InnerHtml = BLL.UploadAttachmentService.ShowAttachment(ConfigurationManager.AppSettings["CEMS_IMG_URL"], item.AfterUrl);
                if (item.States == "1"&&item.ItemStates == "1")
                {
                    this.state.Text = "待提交";
                }
                if (item.States == "2" && item.ItemStates == "1")
                {
                    this.state.Text = "待审批";
                }
                if (item.States == "2" && item.ItemStates == "2")
                {
                    this.state.Text = "待整改";
                }
                if (item.States == "2" && item.ItemStates == "3")
                {
                    this.state.Text = "已闭环";
                }
                if (item.States == "2" && item.ItemStates == "3")
                {
                    this.state.Text = "已闭环";
                }
                if(item.States == "3")
                {
                    this.state.Text = "已闭环";
                }
            }
        }
        #endregion
       
    }
}