示例#1
0
        void ResetColumns()
        {
            if (ProductInfo.Products.Count <= 0)
            {
                return;
            }

            DayStat ds = (DayStat)Activator.CreateInstance(((DayStatInfo)tscboProductBunds.SelectedItem).DayStatType, DateTime.Now);

            foreach (ProductCount pc in ds.Products)
            {
                lvwDayStats.Columns.Insert(lvwDayStats.Columns.Count - 1, ProductInfo.GetProductInfo(pc.Id).ShortName, 80);
            }
        }
示例#2
0
            public StockHistoryRecordListViewItem(StockHistoryRecord record)
            {
                _record   = record;
                this.Text = User.GetDisplayName(_record.Op);
                this.SubItems.Add(_record.DateTime.ToString("yyyy-MM-dd HH:mm:ss"));
                this.SubItems.Add(ProductInfo.GetProductInfo(_record.ProductId).Name);
                this.SubItems.Add(_record.Count.ToString());
                this.SubItems.Add(_record.FromTo);
                this.SubItems.Add(_record.Comment);

                if (_record.Count < 0)
                {
                    this.ForeColor = Color.FromArgb(0xff, 0xff, 0x40, 0x40);
                }
                else if (_record.Count > 0)
                {
                    this.ForeColor = Color.DarkGreen;
                }
            }
示例#3
0
        private void tsbtnExport_Click(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;

            SaveFileDialog sfd = new SaveFileDialog();

            sfd.Filter = "csv files(*.csv)|*.csv|All Files(*.*)|*.*";
            if (DialogResult.OK != sfd.ShowDialog(this))
            {
                return;
            }

            string filename = sfd.FileName;

            if (0 == sfd.FilterIndex && !filename.ToLower().EndsWith(".csv"))
            {
                filename += ".csv";
            }

            StreamWriter writer = new StreamWriter(filename, false, Encoding.UTF8);

            //writer.WriteLine("\"Date\",\"Product\",\"Count\",\"FromTo\",\"Comment\"");
            writer.WriteLine("Date,Product,Count,FromTo,Comment");

            foreach (StockHistoryRecordListViewItem item in lvwHistory.Items)
            {
                //writer.WriteLine(string.Format("\"{0}\",\"{1}\",\"{2}\",\"{3}\",\"{4}\"",
                writer.WriteLine(string.Format("{0},{1},{2},{3},{4}",
                                               item.Record.DateTime.ToString("yyyy/MM/dd HH:mm:ss"),
                                               ProductInfo.GetProductInfo(item.Record.ProductId).Name.Replace(",", ","),
                                               item.Record.Count, item.Record.FromTo.Replace(",", ","), item.Record.Comment.Replace(",", ",")));
            }

            writer.Close();
            Cursor.Current = Cursors.Default;
        }
示例#4
0
        private void RefreshList()
        {
            try
            {
                lvwDayStats.Items.Clear();

                int[] totals = new int[_daystats[0].Products.Count];                // total0 = 0, total1 = 0, total2 = 0, total3 = 0, total4 = 0, total5 = 0;

                foreach (DayStat day in _daystats)
                {
                    if (day.Date < _dtpFrom.Value || day.Date > _dtpTo.Value)
                    {
                        continue;
                    }

                    DayStatListViewItem item = new DayStatListViewItem(day);
                    lvwDayStats.Items.Add(item);

                    for (int i = 0; i < day.Products.Count; i++)
                    {
                        totals[i] += day.Products[i].Count;
                    }
                }

                if (lvwDayStats.Items.Count > 0)
                {
                    StringBuilder sb = new StringBuilder();
                    sb.Append(string.Format("统计时间段: \n{0} - {1}\n\n",
                                            ((DayStatListViewItem)lvwDayStats.Items[lvwDayStats.Items.Count - 1]).DayStat.Date.ToString("yyyy/MM/dd"),
                                            ((DayStatListViewItem)lvwDayStats.Items[0]).DayStat.Date.ToString("yyyy/MM/dd")));

                    for (int i = 0; i < _daystats[0].Products.Count; i++)
                    {
                        ProductCount pc = _daystats[0].Products[i];
                        sb.Append(string.Format(
                                      "{0}: {1}({2:0.0})\n",
                                      ProductInfo.GetProductInfo(pc.Id).ShortName,
                                      totals[i], (float)totals[i] / lvwDayStats.Items.Count));
                    }

                    int periodTotal = 0;
                    foreach (int i in totals)
                    {
                        periodTotal += i;
                    }

                    sb.Append(string.Format("\n总计: {0}({1:0.0})", periodTotal, (float)periodTotal / lvwDayStats.Items.Count));

                    lblTotalInfo.Text = sb.ToString();

                    //lblTotalInfo.Text = string.Format(
                    //    "统计时间段: \n{7} - {8}\n\nPre: {0}({9:0.0})\n1段: {1}({10:0.0})\n2段: {2}({11:0.0})\n3段: {3}({12:0.0})\n1+: {4}({13:0.0})\n2+: {5}({14:0.0})\n\n总计: {6}({15:0.0})",
                    //    total0, total1, total2, total3, total4, total5,
                    //    total0 + total1 + total2 + total3 + total4 + total5,
                    //    ((DayStatListViewItem)lvwDayStats.Items[lvwDayStats.Items.Count-1]).DayStat.Date.ToString("yyyy/MM/dd"),
                    //    ((DayStatListViewItem)lvwDayStats.Items[0]).DayStat.Date.ToString("yyyy/MM/dd"),
                    //    (float)total0 / lvwDayStats.Items.Count, (float)total1 / lvwDayStats.Items.Count, (float)total2 / lvwDayStats.Items.Count,
                    //    (float)total3 / lvwDayStats.Items.Count, (float)total4 / lvwDayStats.Items.Count, (float)total5 / lvwDayStats.Items.Count,
                    //    (float)(total0 + total1 + total2 + total3 + total4 + total5) / lvwDayStats.Items.Count);
                }
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.ToString());
            }
        }