using BLL;
using BLL.Common;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.SessionState;

namespace FineUIPro.Web.common
{
    /// <summary>
    /// MainHandler 的摘要说明
    /// </summary>
    public class MainHandler : IHttpHandler, IRequiresSessionState
    {
       
        
        public void ProcessRequest(HttpContext context)
        {
            string sId = context.Request["sId"].ToString();
            try
            {
                //string CurrentMonth = DateTime.Now.ToString("yyyyMM");
                //string EndMonth = DateTime.Now.AddMonths(11).ToString("yyyyMM");
                string strSql = @"SELECT [CostReportId] ,[EProjectId] ,[Monthly] ,[OrginalBudget] ,[ChangedBudget] ,[ActualCost],"
                               + @" [CommittedPRPO],[CommittedSSRs] ,[CostToComplete] FROM [Editor_CostReport]"
                               + @" WHERE EProjectId=@eProjectId order by MonthLy ";
//and Monthly BETWEEN @startMonth AND @EndMonth";

                List<SqlParameter> listStr = new List<SqlParameter>();
                listStr.Add(new SqlParameter("@EProjectId", sId));
                //listStr.Add(new SqlParameter("@startMonth", CurrentMonth));
                //listStr.Add(new SqlParameter("@EndMonth", EndMonth));
                SqlParameter[] parameter = listStr.ToArray();
                DataTable table = SQLHelper.GetDataTableRunText(strSql, parameter);
                string json = JsonHelper.DataTableToJSON(table);
                SqlParameter[] parameter1 = new SqlParameter[]       
                    {
                        new SqlParameter("@sId",sId),
                        //new SqlParameter("@startMonth",CurrentMonth),
                        //new SqlParameter("@EndMonth",EndMonth)
                    };
                DataSet ds = SQLHelper.RunProcedure("Proc_ManHoursPlan", parameter1, "t");
                DataTable table1 = ds.Tables[0];
                string json1 = JsonHelper.DataTableToJSON(table1);
                string JON = "{\"json\":" + json + ",\"json1\":" + json1 + "}";
                HttpContext.Current.Response.Write(JON);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}