using System;
using System.Linq;
namespace FineUIPro.Web.HSSE.Manager
{
    public partial class HSSELogMonthView : PageBase
    {
        #region 定义项
        /// 
        /// 主键
        /// 
        private string HSSELogMonthId
        {
            get
            {
                return (string)ViewState["HSSELogMonthId"];
            }
            set
            {
                ViewState["HSSELogMonthId"] = value;
            }
        }
        /// 
        /// 项目主键
        /// 
        public string ProjectId
        {
            get
            {
                return (string)ViewState["ProjectId"];
            }
            set
            {
                ViewState["ProjectId"] = value;
            }
        }
        #endregion
        #region 加载
        /// 
        /// 加载页面
        /// 
        /// 
        /// 
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                var unit = BLL.UnitService.GetUnitByUnitId(BLL.Const.UnitId_TCC);
                if (unit != null && !string.IsNullOrEmpty(unit.UnitCode))
                {
                    string url = "../Images/SUBimages/" + unit.UnitCode + ".gif";
                    if (url.Contains('*'))
                    {
                        url = url.Replace('*', '-');
                    }
                    this.Image1.ImageUrl = url;
                }
                this.ProjectId = this.CurrUser.LoginProjectId;
                this.HSSELogMonthId = Request.Params["HSSELogMonthId"];
                Model.Manager_HSSELogMonth hsseLogMonth = BLL.HSSELogMonthService.GetHSSELogMonthByHSSELogMonthId(this.HSSELogMonthId);
                if (hsseLogMonth != null)
                {
                    this.InitText(hsseLogMonth);
                }
            }
        }
        /// 
        ///  设置页面项目信息
        /// 
        private void SetProject()
        {
            var project = BLL.ProjectService.GetProjectByProjectId(this.ProjectId);
            if (project != null)
            {
                this.lblProjectName.Text = project.ProjectName;
                this.lblProjectCode.Text = project.ProjectCode;
                this.txtProjectName.Text = project.ProjectName;
            }
        }
        #endregion
        #region 初始页面信息
        /// 
        /// 初始页面信息
        /// 
        private void InitText(Model.Manager_HSSELogMonth hsseLogMonth)
        {
            this.ProjectId = hsseLogMonth.ProjectId;
            this.SetProject();  //设置页面项目信息
            this.HSSELogMonthId = hsseLogMonth.HSSELogMonthId;
            this.lbHSSELogMonthCode.Text = hsseLogMonth.HSSELogMonthCode;
            this.txtMonths.Text = string.Format("{0:yyyy-MM}", hsseLogMonth.Months);
            this.lbHSSELogMonthCode.Text = BLL.CodeRecordsService.ReturnCodeByDataId(this.HSSELogMonthId);
            this.txtCompileMan.Text = BLL.UserService.GetUserNameByUserId(hsseLogMonth.CompileMan);
            this.txtCompileDate.Text = string.Format("{0:yyyy-MM-dd}", hsseLogMonth.CompileDate);
            this.lbTitleName.Text = hsseLogMonth.Months.Value.GetDateTimeFormats('y')[0].ToString() + "HSE经理暨HSE工程师细则";
            this.txtProjectRange.Text = hsseLogMonth.ProjectRange;
            this.txtManHour.Text = hsseLogMonth.ManHour.ToString();
            this.txtRate.Text = hsseLogMonth.Rate.ToString();
            this.txtRealManHour.Text = hsseLogMonth.RealManHour.ToString();
            this.txtTotalManHour.Text = hsseLogMonth.TotalManHour.ToString();
            this.txtNum1.Text = hsseLogMonth.Num1.ToString();
            this.txtNum2.Text = hsseLogMonth.Num2.ToString();
            this.txtNum3.Text = hsseLogMonth.Num3.ToString();
            this.txtNum4.Text = hsseLogMonth.Num4.ToString();
            this.txtNum5.Text = hsseLogMonth.Num5.ToString();
            this.txtNum6.Text = hsseLogMonth.Num6.ToString();
            this.txtNum7.Text = hsseLogMonth.Num7.ToString();
            this.txtNum8.Text = hsseLogMonth.Num8.ToString();
            this.txtNum9.Text = hsseLogMonth.Num9.ToString();
            this.txtNum10.Text = hsseLogMonth.Num10.ToString();
            this.txtNum11.Text = hsseLogMonth.Num11.ToString();
            this.txtNum12.Text = hsseLogMonth.Num12.ToString();
            this.txtNum13.Text = hsseLogMonth.Num13.ToString();
            this.txtNum14.Text = hsseLogMonth.Num14.ToString();
            this.txtNum15.Text = hsseLogMonth.Num15.ToString();
        }
        #endregion
    }
}