コード例 #1
0
        public void reloadListViewOrder(bool isBaseOnFilter)
        {
            List <int> listTableId = new List <int>();
            double     timeFrom    = 0;
            double     timeTo      = UtilFuction.GetTime(DateTime.Now);

            if (isBaseOnFilter)
            {
                foreach (CheckBox checkBox in LVFilterTable.Items.OfType <CheckBox>())
                {
                    if (checkBox.IsChecked == true)
                    {
                        listTableId.Add((int)checkBox.Tag);
                    }
                }
                if (listTableId.Count == LVFilterTable.Items.Count)
                {
                    listTableId.Clear();
                }

                if (CheckBoxFilterDate.IsChecked == true)
                {
                    if (DatePickerFrom.SelectedDate != null)
                    {
                        timeFrom = UtilFuction.GetTime(DatePickerFrom.SelectedDate.Value) - DatePickerFrom.SelectedDate.Value.TimeOfDay.TotalMilliseconds;
                    }
                    if (DatePickerTo.SelectedDate != null)
                    {
                        timeTo = UtilFuction.GetTime(DatePickerTo.SelectedDate.Value) + (TimeSpan.TicksPerDay / TimeSpan.TicksPerMillisecond - DatePickerFrom.SelectedDate.Value.TimeOfDay.TotalMilliseconds);
                    }
                    if (timeFrom >= timeTo)
                    {
                        timeFrom = 0;
                        timeTo   = DateTime.Now.Millisecond;
                    }
                }
            }
            LVOrderInfo.Items.Clear();
            foreach (KeyValuePair <int, Order> entry in OrderManager.getInstance().OrderList)
            {
                if (entry.Value != null)
                {
                    if (listTableId.Count > 0 &&
                        !listTableId.Contains(entry.Value.TableId))
                    {
                        continue;
                    }
                    if (UtilFuction.GetTime(entry.Value.CreatedDate) < timeFrom ||
                        UtilFuction.GetTime(entry.Value.CreatedDate) > timeTo)
                    {
                        continue;
                    }
                    var orderInfo = new OrderInfo(entry.Value.OrderId, null, this);
                    LVOrderInfo.Items.Add(orderInfo);

                    orderInfo.ExpandOrderInfo.IsExpanded = false;
                }
            }
        }
コード例 #2
0
        public void reloadListViewBill(bool isBaseOnFilter)
        {
            double timeFrom = 0;
            double timeTo   = UtilFuction.GetTime(DateTime.Now);

            if (isBaseOnFilter)
            {
                if (CheckBoxFilterDate.IsChecked == true)
                {
                    if (DatePickerFrom.SelectedDate != null)
                    {
                        timeFrom = UtilFuction.GetTime(DatePickerFrom.SelectedDate.Value) - DatePickerFrom.SelectedDate.Value.TimeOfDay.TotalMilliseconds;
                    }
                    if (DatePickerTo.SelectedDate != null)
                    {
                        timeTo = UtilFuction.GetTime(DatePickerTo.SelectedDate.Value) + (TimeSpan.TicksPerDay / TimeSpan.TicksPerMillisecond - DatePickerFrom.SelectedDate.Value.TimeOfDay.TotalMilliseconds);
                    }
                    if (timeFrom >= timeTo)
                    {
                        timeFrom = 0;
                        timeTo   = DateTime.Now.Millisecond;
                    }
                }
            }
            LVBill.Items.Clear();
            foreach (KeyValuePair <int, ImportBill> entry in ImportBillManager.getInstance().ImportBillList)
            {
                if (entry.Value != null)
                {
                    if (UtilFuction.GetTime(entry.Value.CreatedDate) < timeFrom ||
                        UtilFuction.GetTime(entry.Value.CreatedDate) > timeTo)
                    {
                        continue;
                    }
                    var billCell = new ImportHistoryCell(entry.Value);
                    LVBill.Items.Add(billCell);
                }
            }
        }
コード例 #3
0
        private void calculateAndReloadChart()
        {
            var rp     = ReportManager.getInstance().ReportModel;
            var orders = ReportManager.getInstance().ReportModel.payOrders.ToList();
            Dictionary <string, int> valuesByTimes = new Dictionary <string, int>();
            ChartTime chartTime = ChartTime.ChartByHourse;

            if (rp.startDate == rp.endDate)   //gio
            {
                chartTime = ChartTime.ChartByHourse;
                for (int i = 0; i < 24; i++)
                {
                    valuesByTimes[i.ToString()] = 0;
                }
            }
            else if ((rp.endDate - rp.startDate).TotalDays >= 735)     // nam
            {
                chartTime = ChartTime.ChartByYear;
                for (int i = rp.startDate.Year; i <= rp.endDate.Year; i++)
                {
                    valuesByTimes[i.ToString()] = 0;
                }
            }
            else if ((rp.endDate - rp.startDate).TotalDays >= 24)     // thang
            {
                chartTime = ChartTime.ChartByMonth;
                for (int i = rp.startDate.Year; i <= rp.endDate.Year; i++)
                {
                    for (int j = 1; j <= 12; j++)
                    {
                        var month   = new DateTime(i, j, 1);
                        var monthTs = UtilFuction.GetTime(month);
                        var startTs = UtilFuction.GetTime(rp.startDate) - TimeSpan.TicksPerDay * 31 * 10000;
                        var endTs   = UtilFuction.GetTime(rp.endDate);
                        if (startTs <= monthTs && endTs >= monthTs)
                        {
                            valuesByTimes[j.ToString("D2") + '/' + i.ToString()] = 0;
                        }
                    }
                }
            }
            else     //ngay
            {
                chartTime = ChartTime.ChartByDate;
                for (int i = rp.startDate.Year; i <= rp.endDate.Year; i++)
                {
                    for (int j = 1; j <= 12; j++)
                    {
                        var totalDay = DateTime.DaysInMonth(i, j);
                        for (int z = 1; z <= totalDay; z++)
                        {
                            var day     = new DateTime(i, j, z);
                            var dayTs   = UtilFuction.GetTime(day);
                            var startTs = UtilFuction.GetTime(rp.startDate);
                            var endTs   = UtilFuction.GetTime(rp.endDate);
                            if (startTs <= dayTs && endTs >= dayTs)
                            {
                                valuesByTimes[z.ToString("D2") + '/' + j.ToString("D2")] = 0;
                            }
                        }
                    }
                }
            }
            while (orders.Count > 0)
            {
                var frontOrder = orders[0];
                switch (chartTime)
                {
                case ChartTime.ChartByHourse: {
                    valuesByTimes[frontOrder.CreatedDate.TimeOfDay.Hours.ToString()] += 1;
                    break;
                }

                case ChartTime.ChartByDate: {
                    valuesByTimes[frontOrder.CreatedDate.ToString("dd/MM")] += 1;
                    break;
                }

                case ChartTime.ChartByMonth: {
                    valuesByTimes[frontOrder.CreatedDate.ToString("MM/yyyy")] += 1;
                    break;
                }

                case ChartTime.ChartByYear: {
                    valuesByTimes[frontOrder.CreatedDate.ToString("yyyy")] += 1;
                    break;
                }
                }

                orders.RemoveAt(0);
            }
            List <KeyValuePair <string, int> > MyValue = new List <KeyValuePair <string, int> >();

            foreach (KeyValuePair <string, int> entry in valuesByTimes)
            {
                MyValue.Add(new KeyValuePair <string, int>(entry.Key, entry.Value));
            }

            //List<KeyValuePair<string, int>> MyValue = new List<KeyValuePair<string, int>>();
            //MyValue.Add(new KeyValuePair<string, int>("Administration", 20));
            //MyValue.Add(new KeyValuePair<string, int>("Management", 36));
            //MyValue.Add(new KeyValuePair<string, int>("Development", 89));
            //MyValue.Add(new KeyValuePair<string, int>("Support", 270));
            //MyValue.Add(new KeyValuePair<string, int>("Sales", 140));
            LineChart1.DataContext = MyValue;
        }