Пример #1
0
        private void BtTask_Click(object sender, EventArgs e)
        {
            InputQualityForm qualityForm = new InputQualityForm();
            InputForm        timeForm    = new InputForm("Введите максимальную длительность:");
            int time = 0;

            if (qualityForm.ShowDialog() == DialogResult.OK && timeForm.ShowDialog() == DialogResult.OK &&
                Int32.TryParse(timeForm.inText, out time) && time > 0)
            {
                enumQuality quality = qualityForm.quality;
                qualityForm.Dispose();
                timeForm.Dispose();
                List <DataGridViewRow> rowList = new List <DataGridViewRow>();
                foreach (DataGridViewRow row in dgv.Rows)
                {
                    if (Movie.StringToQuality(row.Cells[1].Value.ToString()) != quality || Int32.Parse(row.Cells[2].Value.ToString()) > time)
                    {
                        rowList.Add(row);
                        backList.Add(Movie.MovieToRow(Movie.RowToMovie(row), dgv));
                    }
                }
                foreach (DataGridViewRow row in rowList)
                {
                    dgv.Rows.Remove(row);
                }
                dgv.Sort(dgv.Columns[2], ListSortDirection.Ascending);
            }
            else if (time <= 0)
            {
                MessageBox.Show("Вы ввели некорректное время");
            }
        }
Пример #2
0
        private void BtFind_Click(object sender, EventArgs e)
        {
            InputForm inForm = new InputForm("Введите сорт:");
            int       index  = -1;

            if (inForm.ShowDialog() == DialogResult.OK && inForm.inText != "")
            {
                try
                {
                    foreach (DataGridViewRow row in dgv.Rows)
                    {
                        if (row.Cells[0].Value.ToString().ToLower() == inForm.inText.ToLower())
                        {
                            index = row.Index;
                            break;
                        }
                    }
                }
                catch
                {
                    MessageBox.Show("Такого сорта нет", "Ошибка");
                }
            }
            inForm.Dispose();
            if (index != -1)
            {
                ChangeRow(dgv.Rows[index]);
            }
        }