`
nintenyun
  • 浏览: 26167 次
  • 性别: Icon_minigender_1
  • 来自: 上海
最近访客 更多访客>>
社区版块
存档分类
最新评论

NOTE

阅读更多

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using MetLife.RMDashboard.BLL;
using MetLife.RMDashboard.BLL.Entity;
using MetLife.RMDashboard.Common;

namespace MetLife.RMDashboard.Web
{
    public partial class Trend : BasePageResourceManagement
    {
        #region page event handler
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                btnView.Attributes.Add("onclick", "javascript:CheckDataValue('" + txtDateFrom.ClientID + "','" + txtDateTo.ClientID + "')");
                DateTime endDate = DateTime.Now;
                DateTime startDate = endDate.AddMonths(-5);
                txtDateFrom.Text = startDate.ToShortDateString();
                txtDateTo.Text = endDate.ToShortDateString();
                buildTrendModel(startDate.ToString(), endDate.ToString());
            }
            string reportType = ApplicationHelper.GetReportType(this.Page);
            Session[Constants.QUERY_STRING_REPORT_TYPE] = reportType;
            string calscript = "$(function(){$('#" + txtDateFrom.ClientID + "').datepicker({yearRange: '1900:2099',showOn: 'both', buttonImage: 'Image/calendar.gif', buttonImageOnly: true,showButtonPanel: true});});";
            Page.ClientScript.RegisterStartupScript(this.GetType(), txtDateFrom.ClientID, calscript, true);
            string calscript2 = "$(function(){$('#" + txtDateTo.ClientID + "').datepicker({yearRange: '1900:2099',showOn: 'both', buttonImage: 'Image/calendar.gif', buttonImageOnly: true,showButtonPanel: true});});";
            Page.ClientScript.RegisterStartupScript(this.GetType(), txtDateTo.ClientID, calscript2, true);
        }

        protected void btnView_Click(object sender, EventArgs e)
        {
            string startDate = txtDateFrom.Text;
            string endDate = txtDateTo.Text;
            buildTrendModel(startDate,endDate);
           
        }
        #endregion  

        #region page private method
        protected void buildTrendModel(string startDate, string endDate)
        {
         
            string trendSessionIdentify = startDate + endDate+Session[Constants.QUERY_STRING_REPORT_TYPE].ToString();
            List<TrendModel> utlOfTrend = null;
            try
            {
                if (Session[trendSessionIdentify] != null)
                {
                    utlOfTrend = Session[trendSessionIdentify] as List<TrendModel>;
                    BindToChart(utlOfTrend);
                    BindToGridView(utlOfTrend);
                }
                else
                {
                    if (Session[Constants.QUERY_STRING_REPORT_TYPE] != null)
                    {
                        if (Session[Constants.QUERY_STRING_REPORT_TYPE].ToString() == Constants.QUERY_STRING_REPORT_TYPE_VALUE_ACTUAL)
                        {
                            utlOfTrend = BizTrend.GetActualTrendList(startDate, endDate);
                        }
                        else
                        {
                            utlOfTrend = BizTrend.GetPredictionTrendList(startDate, endDate);
                        }
                    }
                    else
                    {
                        utlOfTrend = BizTrend.GetActualTrendList(startDate, endDate);
                    }
                    Session[trendSessionIdentify] = utlOfTrend;
                    int count = utlOfTrend.Count;
                    if (count == 0)
                    {
                        Chart1.Visible = false;
                    }
                    BindToChart(utlOfTrend);
                    BindToGridView(utlOfTrend);
                 }
            }
            catch (Exception ex)
            {
                ExceptionProcesser.HandleExceptionWithRedirection(ex, Constants.LOAD_DATA_ERROR_MESSAGE);
            }
        }
        protected void BindToChart(List<TrendModel> utlOfTrend)
        {
            Chart1.Series["Series1"].Points.DataBind(utlOfTrend, "DateFormat", "Utlization", "Label=UtilizationPercent,ToolTip=UtilizationPercent");
            //Chart1.Series["Series1"].IsValueShownAsLabel = true;
           //DataBindXY(utlOfTrend, "DateString", utlOfTrend, "Utlization");
        }
        protected void BindToGridView(List<TrendModel> utlOfTrend)
        {
            gvTrendOfMetLife.AutoGenerateColumns = false;
            gvTrendOfMetLife.DataSource = utlOfTrend;
            gvTrendOfMetLife.DataBind();
           
        }

        #endregion
    }
}

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MetLife.RMDashboard.BLL.Entity
{
    public class TrendModel
    {
        public DateTime? Date { get; set; }
        public string  DateString
        {
            get
            {
                return Date.Value.Year.ToString()+ "-" + Date.Value.Month.ToString();
            }
        }
        public double? SumBilledHrs { get; set; }
        public double? SumAvailableHrs { get; set; }
        public string Utlization 
        {
            get
            {
                return double.Parse((SumBilledHrs / SumAvailableHrs * 100).ToString()).ToString("F2");
                
            }
 
        }
        public string UtilizationPercent
        {
            get
            {
                return double.Parse((SumBilledHrs / SumAvailableHrs * 100).ToString()).ToString("F2") + "%";
            }
        }
        public string DateFormat
        {
            
            get
            {
                int month = Date.Value.Month;
                int year = Date.Value.Year;
                EnglishShortMonth englishMonth = (EnglishShortMonth)month;
                return englishMonth.ToString() + "-" + year.ToString();
            }
        }
        public enum EnglishShortMonth
        {
            Jan = 1, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec
        } 
    }
}
 
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics