예제 #1
0
        //подсветка подходящих комнат
        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                int kol = String.IsNullOrWhiteSpace(Convert.ToString(comboBox1.SelectedItem)) ? 0 : Convert.ToInt32(comboBox1.SelectedItem);
                int min = String.IsNullOrWhiteSpace(textBox1.Text) ? 0 : Convert.ToInt32(textBox1.Text);
                int max = String.IsNullOrWhiteSpace(textBox2.Text) ? 1000 : Convert.ToInt32(textBox2.Text);

                List <int> res = roomList.FindRooms(min, max, kol, dateTimePicker1.Value, dateTimePicker2.Value);
                foreach (DataGridViewRow row in dataGridView1.Rows)
                {
                    foreach (DataGridViewCell cell in row.Cells)
                    {
                        if (!res.Contains(Convert.ToInt32(cell.Value)))
                        {
                            cell.Style.BackColor = Color.LightGray;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Неверно заполнены поля.", "Подбор номеров", MessageBoxButtons.OK);
            }
        }