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; }
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); } }
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; } }