using System;
using System.Collections.Generic;
namespace FineUIPro.Web.TestRun.DriverReport
{
    public partial class MonthReportView : PageBase
    {
        #region 定义集合
        /// 
        /// 工作包完成情况统计
        /// 
        public static List monthReportItems = new List();
        /// 
        /// 开车绩效测量数据
        /// 
        public static List monthReportItems2 = new List();
        #endregion
        #region 页面加载
        /// 
        /// 页面加载
        /// 
        /// 
        /// 
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string id = Request.Params["id"];
                if (!string.IsNullOrEmpty(id))
                {
                    Model.TestRun_MonthReport data = BLL.TestRun_MonthReportService.GetMonthReportById(id);
                    if (data != null)
                    {
                        this.hdId.Text = id;
                        this.txtMonthReportCode.Text = data.MonthReportCode;
                        this.txtMonthReportDate.Text = data.MonthReportDate.HasValue ? string.Format("{0:yyyy-MM-dd}", data.MonthReportDate) : "";
                        this.txtProjectOverview.Text = data.ProjectOverview;
                        this.txtProjectBaseInfo.Text = data.ProjectBaseInfo;
                        this.txtEngineeringPlant.Text = data.EngineeringPlant;
                        this.txtProjectContract.Text = data.ProjectContract;
                        this.txtMilestone.Text = data.Milestone;
                        this.txtCompleteWork.Text = data.CompleteWork;
                        this.txtProblemSituation.Text = data.ProblemSituation;
                        this.txtBudget.Text = data.Budget.HasValue ? data.Budget.ToString() : "";
                        this.txtBudgetTotal.Text = data.BudgetTotal.HasValue ? data.BudgetTotal.ToString() : "";
                        this.txtActualCost.Text = data.ActualCost.HasValue ? data.ActualCost.ToString() : "";
                        this.txtActualCostTotal.Text = data.ActualCostTotal.HasValue ? data.ActualCostTotal.ToString() : "";
                        this.txtPublicationStatus.Text = data.PublicationStatus;
                        this.txtImplementationStatus.Text = data.ImplementationStatus;
                        this.txtHSEManageSituation.Text = data.HSEManageSituation;
                        this.txtNextMonthMilestone.Text = data.NextMonthMilestone;
                        this.txtNextMonthCompleteWork.Text = data.NextMonthCompleteWork;
                        this.txtNextMonthSchedule.Text = data.NextMonthSchedule;
                        this.txtNextMonthDrivingCost.Text = data.NextMonthDrivingCost;
                        this.txtProblemsMeasures.Text = data.ProblemsMeasures;
                        this.txtSolvedProblems.Text = data.SolvedProblems;
                    }
                    var items = BLL.TestRun_MonthReportItemService.GetMonthReportItemByReportId(this.hdId.Text);
                    if (items.Count > 0)
                    {
                        this.Grid1.DataSource = items;
                        this.Grid1.DataBind();
                    }
                    var items2 = BLL.TestRun_MonthReportItem2Service.GetMonthReportItem2ByReportId(this.hdId.Text, "1");
                    if (items2.Count > 0)
                    {
                        this.Grid2.DataSource = items2;
                        this.Grid2.DataBind();
                    }
                    var items3 = BLL.TestRun_MonthReportItem2Service.GetMonthReportItem2ByReportId(this.hdId.Text, "2");
                    if (items3.Count > 0)
                    {
                        this.Grid3.DataSource = items3;
                        this.Grid3.DataBind();
                    }
                }
                GroupPanel8.Title = "下月开车计划要点(" + Convert.ToDateTime(this.txtMonthReportDate.Text).AddMonths(1).Month + "月份)";
            }
        }
        #endregion
        #region 附件上传
        /// 
        /// 附件上传
        /// 
        /// 
        /// 
        protected void btnAttach_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(this.hdId.Text))
            {
                PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../../AttachFile/webuploader.aspx?type=-1&toKeyId={0}&path=FileUpload/TestRun/DriverReport/MonthReport&menuId={1}", this.hdId.Text, BLL.Const.MonthReportMenuId)));
            }
        }
        #endregion
    }
}