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
        } 
    }
}
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值