Example #1
0
        // GET: OderPage
        public ActionResult Index()
        {
            OrderPageVO orderpageVo = new OrderPageVO();
            OrderDac    odac        = new OrderDac();

            orderpageVo.LastestList = odac.GetLastestOrderList();

            OrderDac odac1 = new OrderDac();

            orderpageVo.LastestOrderList = odac1.GetLastestOrderDataList();
            OrderDac            odac2 = new OrderDac();
            List <SalesChartVO> ylist = odac2.GetYearSalesChartList();

            orderpageVo.YearSalesChartList = odac2.GetYearSalesChartList();

            OrderDac odac3 = new OrderDac();

            orderpageVo.YearSalesCompanyList = odac3.GetYearSalesCompanyList();
            ViewBag.SumTotalPrice            = orderpageVo.YearSalesCompanyList.Sum(p => p.totalprice);


            HomeDac        hdac3     = new HomeDac();
            List <SalesVO> salesList = hdac3.GetSalesRate();

            ViewBag.SalesPrice      = string.Format("{0:c}", Convert.ToInt32(salesList[1].price));
            ViewBag.SalesList       = salesList;
            ViewBag.SalesRateToView = ((salesList[1].price / salesList[0].price) * 100).ToString("#.0") + "%";


            OrderDac       odac4    = new OrderDac();
            List <SalesVO> costList = odac4.GetWorkCostList();

            ViewBag.WorkCostPrice   = string.Format("{0:c}", Convert.ToInt32(costList[1].price));
            ViewBag.CostList        = costList;
            ViewBag.SalesRateToView = ((salesList[1].price / salesList[0].price) * 100).ToString("#.0") + "%";



            string labels = string.Empty;
            List <List <SalesChartVO> > list = new List <List <SalesChartVO> >();


            foreach (var item in orderpageVo.YearSalesCompanyList)
            {
                labels += item.s_month + ",";
                var tlist = (from titem in orderpageVo.YearSalesChartList
                             where titem.s_company == item.s_company
                             select titem).ToList();
                list.Add(tlist);
            }

            foreach (var item in list)
            {
                foreach (var sitem in item)
                {
                    sitem.s_month = sitem.s_month.Substring(5, 2);
                }
            }

            orderpageVo.YearSalesChartList = ylist;
            string[] month  = new string[] { "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12" };
            int      imon   = DateTime.Now.Month;
            string   months = string.Empty;

            for (int i = imon - 1; i < imon + 11; i++)
            {
                if (i >= 12)
                {
                    months += month[i - 12] + ",";
                }
                else
                {
                    if (i == int.Parse(month[i - 1]))
                    {
                        months += month[i] + ",";
                    }
                }
            }
            string data = "[";

            foreach (var sitem in orderpageVo.YearSalesChartList)
            {
                data += sitem.totalprice + ",";
            }



            //ViewBag.Labels = months.TrimEnd(',');
            ViewBag.Labels = months.TrimEnd(',');
            string[] testmonth = months.TrimEnd(',').Split(',');
            ViewBag.Label1  = testmonth[0];
            ViewBag.Label2  = testmonth[1];
            ViewBag.Label3  = testmonth[2];
            ViewBag.Label4  = testmonth[3];
            ViewBag.Label5  = testmonth[4];
            ViewBag.Label6  = testmonth[5];
            ViewBag.Label7  = testmonth[6];
            ViewBag.Label8  = testmonth[7];
            ViewBag.Label9  = testmonth[8];
            ViewBag.Label10 = testmonth[9];
            ViewBag.Label11 = testmonth[10];
            ViewBag.Label12 = testmonth[11];
            ViewBag.data1   = data.TrimEnd(',') + "]";



            OrderDac odac5 = new OrderDac();

            orderpageVo.OrderCostList = odac5.GetOrderCostList();
            if (orderpageVo.OrderCostList[1].totalprice < orderpageVo.OrderCostList[0].totalprice)
            {
                ViewBag.OrderRate = 100 - @Convert.ToInt32((orderpageVo.OrderCostList[1].totalprice / orderpageVo.OrderCostList[0].totalprice) * 100);
            }


            ViewBag.MonthProfit = string.Format("{0:c}", salesList[1].price - orderpageVo.OrderCostList[1].totalprice - costList[1].price);

            return(View(orderpageVo));
        }
Example #2
0
        // GET: Home
        public ActionResult Index()
        {
            HomeVO  homevo = new HomeVO();
            HomeDac hdac   = new HomeDac();


            List <UserVO> userlist = hdac.GetLastestUsers();

            homevo.Userlist = userlist;

            HomeDac hdac1 = new HomeDac();

            homevo.WorkRate = hdac1.GetWorkRate();

            HomeDac hdac2 = new HomeDac();

            homevo.CompanyCount = hdac2.GetCompanyCount();
            List <CompanyVO> clist  = hdac2.GetCompanyCount();
            CompanyVO        result = new CompanyVO();

            result.sum         = clist.Sum(item => item.sum);
            result.month       = clist[1].sum;
            homevo.CompanyData = result;

            HomeDac hdac3 = new HomeDac();

            homevo.SalseRate = hdac3.GetSalesRate();

            homevo.SalesPrice      = string.Format("{0:c}", Convert.ToInt32(homevo.SalseRate[1].price));
            homevo.SalesRateToView = ((homevo.SalseRate[1].price / homevo.SalseRate[0].price) * 100).ToString("#.0") + "%";



            if ((homevo.SalseRate[1].price / homevo.SalseRate[0].price) * 100 > 100)
            {
                homevo.SalesRateBool = true;
            }
            else
            {
                homevo.SalesRateBool   = false;
                homevo.SalesRateToView = (100 - ((homevo.SalseRate[1].price / homevo.SalseRate[0].price) * 100)).ToString() + "%";
            }



            HomeDac hdac4 = new HomeDac();

            homevo.Orderlist = hdac4.GetLastestOrderList();


            //OrderDac oDac = new OrderDAC();
            //List<OrderStatsVO> list = oDac.GetOrderBestProduct();

            //var listStat = from stat in list
            //               orderby stat.MM
            //               group stat by stat.ProductName;

            //List<string> keys = new List<string>();
            //StringBuilder sb = new StringBuilder();
            //string data1 = string.Empty, data2 = string.Empty, data3 = string.Empty;

            //int k = 0;
            //foreach (var group in listStat)
            //{
            //    keys.Add(group.Key);
            //    List<int> qtys = new List<int>();
            //    foreach (var product in group)
            //    {
            //        if (k == 0)
            //        {
            //            sb.Append(product.MM + "월,");
            //        }
            //        qtys.Add(product.Qty);
            //    }
            //    if (k == 0)
            //        data1 = "[" + string.Join(",", qtys.ToArray()) + "]";
            //    else if (k == 1)
            //        data2 = "[" + string.Join(",", qtys.ToArray()) + "]";
            //    else if (k == 2)
            //        data3 = "[" + string.Join(",", qtys.ToArray()) + "]";
            //    k++;
            //    qtys.Clear();
            //}
            //string labels = sb.ToString().TrimEnd(',');
            //string label1 = keys[0];
            //string label2 = keys[1];
            //string label3 = keys[2];


            //ViewBag.Label1 = label1;
            //ViewBag.Data1 = data1;
            //ViewBag.Label2 = label2;
            //ViewBag.Data2 = data2;
            //ViewBag.Label3 = label3;
            //ViewBag.Data3 = data3;
            return(View(homevo));
        }