-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHotelList.cs
More file actions
116 lines (102 loc) · 3.71 KB
/
HotelList.cs
File metadata and controls
116 lines (102 loc) · 3.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Booking3
{
public partial class HotelList : UserControl
{
public HotelList(/*string City = ""*/)
{
InitializeComponent();
List<string> cities = SQLClass.Select(
"SELECT DISTINCT Name FROM cities ORDER BY Name");
CityComboBox.Items.Clear();
CityComboBox.Items.Add("");
foreach (string city in cities)
CityComboBox.Items.Add(city);
//Ищем город
/*for (int i = 0; i < CityComboBox.Items.Count; i++)
{
if (CityComboBox.Items[i].ToString() == City)
{
CityComboBox.SelectedIndex = i;
}
}*/
Filter(null, null);
}
/// <summary>
/// Открытие гостиницы
/// </summary>
private void pictureBox1_Click(object sender, EventArgs e)
{
PictureBox pb = (PictureBox)sender;
HotelForm hf = new HotelForm(pb.Tag.ToString());
Controls.Clear();
Controls.Add(hf);
hf.Dock = DockStyle.Fill;
Filter(sender, e);
}
/// <summary>
/// Открытие гостиницы
/// </summary>
private void label4_Click(object sender, EventArgs e)
{
Label pb = (Label)sender;
HotelForm hf = new HotelForm(pb.Tag.ToString());
Controls.Clear();
Controls.Add(hf);
hf.Dock = DockStyle.Fill;
Filter(sender, e);
}
/// <summary>
/// ФИльтр
/// </summary>
private void Filter(object sender, EventArgs e)
{
HotelsPanel.Controls.Clear();
string command = "SELECT id, Name, City, Image, Rating FROM " + SQLClass.HOTELS + " WHERE 1";
if (CityComboBox.Text != "")
command += " AND city = '" + CityComboBox.Text + "'";
if (RatingComboBox.Text != "")
command += " AND Rating >= " + RatingComboBox.Text;
List<string> hotels = SQLClass.Select(command);
int x = 15;
for (int i = 0; i < hotels.Count; i += 5)
{
PictureBox pb = new PictureBox();
try
{
pb.Load("../../Pictures/" + hotels[i + 3]);
}
catch (Exception) { }
pb.Location = new Point(x, 10);
pb.Size = new Size(190, 120);
pb.SizeMode = PictureBoxSizeMode.StretchImage;
pb.Tag = hotels[i];
pb.Click += new EventHandler(pictureBox1_Click);
HotelsPanel.Controls.Add(pb);
Label lbl = new Label();
lbl.Location = new Point(x, 140);
lbl.Size = new Size(200, 30);
lbl.Text = hotels[i + 1];
lbl.Tag = hotels[i];
lbl.Click += new EventHandler(label4_Click);
HotelsPanel.Controls.Add(lbl);
x += 205;
}
}
private void FilterButton_Click(object sender, EventArgs e)
{
if (FilterPanel.Size.Height < 50)
FilterPanel.Size = new Size(FilterPanel.Size.Width, 120);
else
FilterPanel.Size = new Size(FilterPanel.Size.Width, FilterButton.Size.Height);
}
}
}