Exemplo n.º 1
0
        private async void sendSaleSearch()
        {
            DBConn_SaleSearch dbs            = new DBConn_SaleSearch();
            List <SaleSearch> saleSearchList = dbs.ReadAllSaleSearch();

            Uri     requestUri  = new Uri("http://" + ip + "/action_refreshSaleSearch.php");
            dynamic dynamicJson = new ExpandoObject();

            dynamicJson.SaleSearch = saleSearchList;

            string json = "";

            json = "{\"PosId\":\"" + POS_main.PosId + "\"," + Newtonsoft.Json.JsonConvert.SerializeObject(dynamicJson).Substring(1);

            var objClint = new HttpClient();
            HttpResponseMessage respon = objClint.PostAsync(requestUri, new StringContent(json, System.Text.Encoding.UTF8, "application/json")).Result;

            String strRespon = await respon.Content.ReadAsStringAsync();

            if (!strRespon.Equals("1"))
            {
                MessageDialog messageDialog = new MessageDialog("판매기록이 정상적으로 전송되지 않았습니다.");
                await messageDialog.ShowAsync();
            }
        }
Exemplo n.º 2
0
        /* 라인차트 생성 */
        private void LoadLineChart()
        {
            List <SaleSearch> SaleList = Db_salesearch.ReadAllSaleSearch();
            List <SaleSum>    SumList  = new List <SaleSum>();

            switch (mode)
            {
            case 'W':
                for (int i = 0; i < 7; i++)                                       // 최근 7일동안의 내역만 보여줌
                {
                    SumList.Add(new SaleSum(DecreaseDate(i).Substring(3, 5), 0)); // MM-dd
                }
                break;

            case 'M':
                for (int i = 0; i < 7; i++)                        // 최근 7달동안의 내역만 보여줌
                {
                    SumList.Add(new SaleSum(DecreaseMonth(i), 0)); // yy-MM
                }
                break;

            case 'Y':
                for (int i = 0; i < 7; i++)     // 최근 7년동안의 내역만 보여줌
                {
                    SumList.Add(new SaleSum((Convert.ToInt32(DateTime.Now.ToString("yy")) - i).ToString(), 0));
                }
                break;
            }

            foreach (SaleSearch h in SaleList)
            {
                switch (mode)
                {
                case 'W':
                    foreach (SaleSum s in SumList)
                    {
                        if (s.Date.Equals(h.SaleTime.Substring(3, 5)))     // MM-dd
                        {
                            s.Sum += h.Price;
                            break;
                        }
                    }
                    break;

                case 'M':
                    foreach (SaleSum s in SumList)
                    {
                        if (s.Date.Equals(h.SaleTime.Substring(0, 5)))     // yy-MM
                        {
                            s.Sum += h.Price;
                            break;
                        }
                    }
                    break;

                case 'Y':
                    foreach (SaleSum s in SumList)
                    {
                        if (s.Date.Equals(h.SaleTime.Substring(0, 2)))     // yy
                        {
                            s.Sum += h.Price;
                            break;
                        }
                    }
                    break;
                }
            }
            SumList.Reverse(); // 가장 최근 년도의 매출액이 마지막(오른쪽)에 오도록 정렬
            (LineChart.Series[0] as LineSeries).ItemsSource = SumList;

            if (mode == 'W')
            {
                tb_todayAvg_value.Text = SumList.ElementAt(SumList.Count - 1).Sum.ToString();
            }

            switch (mode)
            {
            case 'W':
                int Sum = 0;
                foreach (SaleSum s in SumList)
                {
                    Sum += s.Sum;
                }

                tb_nowAvg_value.Text = Sum.ToString();
                break;

            case 'M':
            case 'Y':
                tb_nowAvg_value.Text = SumList.ElementAt(SumList.Count - 1).Sum.ToString();
                break;
            }
        }