Example #1
0
        private void Filter()
        {
            DateTime date1 = new DateTime(dateTimePicker1.Value.Year, dateTimePicker1.Value.Month, dateTimePicker1.Value.Day);

            DateTime date2 = new DateTime(dateTimePicker2.Value.Year, dateTimePicker2.Value.Month, dateTimePicker2.Value.Day);

            if (radioButton1.Checked)
            {
                ProdStatisticsRepository prodStatistics = new ProdStatisticsRepository();
                var statistics = prodStatistics.GetProductStatistics();
                statistics = statistics.Where(element => element.Name.ToUpper().Contains(textBox1.Text.ToUpper())).ToList();
                if (comboBox1.SelectedItem.ToString() != "Все")
                {
                    statistics = statistics.Where(element => element.TypeEvent == comboBox1.SelectedItem.ToString()).ToList();
                }
                if (!checkBox1.Checked)
                {
                    statistics = statistics.Where(element => (element.Date >= date1.Date && element.Date <= date2.Date)).ToList();
                }
                dataGridView1.DataSource = statistics;
            }
            else
            {
                IngredStatisticsRepository ingredStatistics = new IngredStatisticsRepository();
                var statistics = ingredStatistics.GetIngredientStatistics();
                statistics = statistics.Where(element => element.Name.ToUpper().Contains(textBox1.Text.ToUpper())).ToList();
                if (comboBox1.SelectedItem.ToString() != "Все")
                {
                    statistics = statistics.Where(element => element.TypeEvent == comboBox1.SelectedItem.ToString()).ToList();
                }
                if (!checkBox1.Checked)
                {
                    statistics = statistics.Where(element => (element.Date >= date1.Date && element.Date <= date2.Date)).ToList();
                }
                dataGridView1.DataSource = statistics;
            }
        }
Example #2
0
        private void Statistics_Load(object sender, EventArgs e)
        {
            ProdStatisticsRepository prodStatistics = new ProdStatisticsRepository();

            dataGridView1.DataSource = prodStatistics.GetProductStatistics();
            dataGridView1.Columns["Weight"].DefaultCellStyle.Format = "#0.00";
            dataGridView1.RowHeadersVisible   = false;
            dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;

            dataGridView1.Columns[0].HeaderText = @"Назва";
            dataGridView1.Columns[1].HeaderText = @"Дія";
            dataGridView1.Columns[1].Width      = 50;
            dataGridView1.Columns[2].HeaderText = @"Вага";
            dataGridView1.Columns[2].Width      = 30;
            dataGridView1.Columns[3].HeaderText = @"Дата";
            dataGridView1.Columns[3].Width      = 80;


            RadioButton1_CheckedChanged(this, null);
            dateTimePicker1.MaxDate = DateTime.Today;
            dateTimePicker1.Value   = DateTime.Today;
            dateTimePicker2.MaxDate = DateTime.Today;
            dateTimePicker2.Value   = DateTime.Today;
        }