Example #1
0
        private List <OperatingCostData> GetDataTotal(string DateType, string PageType, bool Repeat)
        {
            string      Format    = "yyyy/MM";
            CompanyTool tool      = new CompanyTool();
            string      ProjectId = this.ddlXMProjectNameId.SelectedValue;
            string      NickId    = this.ddlNickList.SelectedValue;

            string Year = this.ddlYear.SelectedValue;
            int    Month;

            if (DateType == "year")
            {
                Month = DateTime.Now.Month;
            }
            else
            {
                Month = 12;
            }

            List <OperatingCostData> list = new List <OperatingCostData>();
            string now = DateTime.Now.ToLongDateString();

            for (int i = 1; i <= Month; i++)
            {
                OperatingCostData Item = new OperatingCostData();
                Item.Date = Year + "/" + i.ToString().PadLeft(2, '0');
                list.Add(Item);
            }
            DateTime begin = DateTime.Parse(Year + "/01/01");
            DateTime end;

            if (Year == DateTime.Now.Year.ToString())
            {
                end = DateTime.Parse(now).AddDays(1);
            }
            else
            {
                end = DateTime.Parse((int.Parse(Year) + 1) + "/01/01");
            }

            string mark = "";

            if (Session["Mark"] != null)
            {
                mark = Session["Mark"].ToString();
            }

            if (Repeat)
            {
                tool.GetDayTotal(DateType, PageType, begin, end, list, Format, Year, ProjectId, NickId, "Table");
            }
            else
            {
                if (mark == DateType + "," + ProjectId + "," + NickId)
                {
                    if (Session["HightChartsLineYear"] != null)
                    {
                        list = (List <OperatingCostData>)Session["HightChartsLineYear"];
                    }
                }
                else
                {
                    tool.GetTableDayTotal(DateType, PageType, begin, end, list, Format, Year, ProjectId, NickId);
                    if (Session["HightChartsLine"] != null)
                    {
                        list = (List <OperatingCostData>)Session["HightChartsLine"];
                    }
                }
            }
            return(list);
        }
        private void GetDataTotal(string DateType, string PageType, string Year, string Month, string ProjectId, string NickId)
        {
            CompanyTool tool   = new CompanyTool();
            string      Format = "";

            if ((DateType == "year") || DateType == "custom_year")
            {
                Format = "yyyy/MM";
            }
            else
            {
                Format = "MM/dd";
            }
            List <OperatingCostData> list = new List <OperatingCostData>();
            //List<List<HighChart>> List = new List<List<HighChart>>();
            string   now   = DateTime.Now.ToLongDateString();
            DateTime begin = new DateTime();
            DateTime end   = new DateTime();

            if (DateType == "week")
            {
                for (int i = 6; i >= 0; i--)
                {
                    OperatingCostData Item = new OperatingCostData();
                    if (DateTime.Now.Day < 7 && DateTime.Now.AddDays(-i).Day > 7)
                    {
                        Item.Date = (DateTime.Now.Month - 1).ToString().PadLeft(2, '0') + "/" + (DateTime.Now.AddDays(-i).Day).ToString().PadLeft(2, '0');
                    }
                    else
                    {
                        Item.Date = DateTime.Now.Month.ToString().PadLeft(2, '0') + "/" + (DateTime.Now.AddDays(-i).Day).ToString().PadLeft(2, '0');
                    }
                    list.Add(Item);
                }
                begin = DateTime.Parse(now).AddDays(-6);
                end   = DateTime.Parse(now).AddDays(1);
                //List = tool.GetDayTotal(DateType, PageType, begin, end, list, Format, Year, ProjectId, NickId);
            }
            else if (DateType == "month")
            {
                for (int i = DateTime.Now.Day - 1; i >= 0; i--)
                {
                    OperatingCostData Item = new OperatingCostData();
                    Item.Date = DateTime.Now.Month.ToString().PadLeft(2, '0') + "/" + (DateTime.Now.AddDays(-i).Day).ToString().PadLeft(2, '0');
                    list.Add(Item);
                }
                begin = DateTime.Parse(now).AddDays(-DateTime.Now.Day + 1);
                end   = DateTime.Parse(now).AddDays(1);
                //List = tool.GetDayTotal(DateType, PageType, begin, end, list, Format, Year, ProjectId, NickId);
            }
            else if (DateType == "year")
            {
                for (int i = 1; i <= DateTime.Now.Month; i++)
                {
                    OperatingCostData Item = new OperatingCostData();
                    Item.Date = DateTime.Now.Year + "/" + i.ToString().PadLeft(2, '0');
                    list.Add(Item);
                }
                begin = DateTime.Parse(DateTime.Now.Year + "/01/01");
                end   = DateTime.Parse(now).AddDays(1);
                //List = tool.GetDayTotal(DateType, PageType, begin, end, list, Format, Year, ProjectId, NickId);
            }
            else if (DateType == "custom_year")
            {
                begin = DateTime.Parse(Year + "/01/01");
                for (int i = 1; i <= 12; i++)
                {
                    OperatingCostData Item = new OperatingCostData();
                    Item.Date = Year + "/" + i.ToString().PadLeft(2, '0');
                    list.Add(Item);
                }
                end = DateTime.Parse((int.Parse(Year) + 1) + "/01/01");
                //List = tool.GetDayTotal(DateType, PageType, begin, end, list, Format, Year, ProjectId, NickId);
            }
            else if (DateType == "custom_month")
            {
                int days = DateTime.DaysInMonth(int.Parse(Year), int.Parse(Month));
                for (int i = days - 1; i >= 0; i--)
                {
                    OperatingCostData Item = new OperatingCostData();
                    Item.Date = Month.PadLeft(2, '0') + "/" + (days - i).ToString().PadLeft(2, '0');
                    list.Add(Item);
                }
                begin = DateTime.Parse(Year + "/" + Month + "/01");
                if (Month != "12")
                {
                    end = DateTime.Parse(Year + "/" + (int.Parse(Month) + 1) + "/01");
                }
                else
                {
                    end = DateTime.Parse((int.Parse(Year) + 1) + "/01/01");
                }
                //List = tool.GetDayTotal(DateType, PageType, begin, end, list, Format, Year, ProjectId, NickId);
            }
            tool.GetDayTotal(DateType, PageType, begin, end, list, Format, Year, ProjectId, NickId);
            return;
        }