Ejemplo n.º 1
0
        private void RadioButton1_CheckedChanged(object sender, EventArgs e)
        {
            List <string> statisticList = new List <string>();

            statisticList.Add("Все");
            if (radioButton1.Checked)
            {
                ProdStatisticsRepository prodStatistics = new ProdStatisticsRepository();
                statisticList.AddRange(prodStatistics.TypeEvents.Values);
            }
            else
            {
                IngredStatisticsRepository ingredStatistics = new IngredStatisticsRepository();
                statisticList.AddRange(ingredStatistics.TypeEvents.Values);
            }
            checkBox1.Checked    = true;
            comboBox1.DataSource = statisticList;
            dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
        }
Ejemplo n.º 2
0
 private void Button1_Click(object sender, EventArgs e)
 {
     try
     {
         if (radioButton1.Checked)
         {
             ProdStatisticsRepository prodStatistics = new ProdStatisticsRepository();
             prodStatistics.Remove(dateTimePicker1.Value, dateTimePicker2.Value);
         }
         else
         {
             IngredStatisticsRepository ingredStatistics = new IngredStatisticsRepository();
             ingredStatistics.Remove(dateTimePicker1.Value, dateTimePicker2.Value);
         }
         MessageBox.Show(@"Статистику очищено.", "Sucsess", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     catch (Exception excep)
     {
         MessageBox.Show(excep.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Ejemplo n.º 3
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;
            }
        }
Ejemplo n.º 4
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;
        }