private void Form1_Load(object sender, EventArgs e)
        {
            try
            {
                using (FileStream fs = new FileStream("Shops.xml", FileMode.OpenOrCreate))
                {
                    shops = (Shops)formatter.Deserialize(fs);
                }
            }
            catch (Exception)
            {
                shops = new Shops();
            }

            UpdateShopsOutput(shops);
            UpdateComboBoxes();
        }
        public Shops Search(string _Name, string _Adress, string _Specialization, string _OwnershipType, int Open, int Close)
        {
            Shops Ans = new Shops();

            foreach (Shop item in shops)
            {
                if ((item.Name == _Name || _Name == "Не вказано" || _Name == "") &&
                    (item.Adress == _Adress || _Adress == "Не вказано" || _Adress == "") &&
                    (item.Specialization == _Specialization || _Specialization == "Не вказано" || _Specialization == "") &&
                    (item.OwnershipType == _OwnershipType || _OwnershipType == "Не вказано" || _OwnershipType == "") &&
                    (item.WorkTime.Open <= Open && item.WorkTime.Close >= Close)
                    )
                {
                    Ans.Add(item);
                }
            }
            return(Ans);
        }
        public void UpdateShopsOutput(Shops Shops_)
        {
            List <string[]> data = new List <string[]>();

            foreach (Shop shop in Shops_.shops)
            {
                data.Add(new string[5]);

                data[data.Count - 1][0] = shop.Name;
                data[data.Count - 1][1] = shop.Adress;
                data[data.Count - 1][2] = shop.Specialization;
                data[data.Count - 1][3] = shop.OwnershipType;
                data[data.Count - 1][4] = shop.WorkTime.ToString();
            }

            dataGridView1.Rows.Clear();

            foreach (string[] s in data)
            {
                dataGridView1.Rows.Add(s);
            }
        }
 private void button4_Click(object sender, EventArgs e)
 {
     _shops = shops.Search(comboBox1.Text, comboBox2.Text, comboBox3.Text, comboBox4.Text, (int)numericUpDown1.Value, (int)numericUpDown2.Value);
     UpdateShopsOutput(_shops);
 }