-
Notifications
You must be signed in to change notification settings - Fork 0
/
Form_P.cs
129 lines (115 loc) · 5.37 KB
/
Form_P.cs
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
117
118
119
120
121
122
123
124
125
126
127
128
129
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace Maket
{
public partial class Form_P : Form
{
SqlConnection con = new SqlConnection(@"Data Source=DESKTOP-JO84FD1\HP;Initial Catalog=Autobuspark;Integrated Security=True");
public Form_P()
{
InitializeComponent();
}
private void Form_P_Load(object sender, EventArgs e)
{
con.Open();
load_data(painter_table, 1);
load_data(museum_table, 2);
load_data(exposition_table, 3);
DateTime date = DateTime.Today;
label1.Text = date.ToString();
}
// //////////////////////////////////////////////ФУНКЦИИ///////////////////////////////////////////
void load_data(DataGridView d, int n)
{
SqlDataAdapter da;
DataTable dt = new DataTable();
switch (n)
{
case 1:
da = new SqlDataAdapter("SELECT Table_bus.ID, Kolvo_bus as 'Количество', Mest_in_bus as 'Мест в автобусе', Adress_park as 'Адрес парка' FROM Table_bus", con);
da.Fill(dt);
d.DataSource = dt;
break;
case 2:
da = new SqlDataAdapter("SELECT Table_Passengers.ID,FIO_passagers as 'ФИО пассажира', User_ID as 'ID водителя', FIO_Voditely as 'ФИО водителя' FROM Table_Passengers", con);
da.Fill(dt);
d.DataSource = dt;
break;
case 3:
da = new SqlDataAdapter("SELECT Table_Stop.ID, Type_Stop as 'Тип остановки', ID_Way as 'ID маршрута', Ticket_office as 'Билетная касса' FROM Table_Stop", con);
da.Fill(dt);
d.DataSource = dt;
break;
}
}
// ////////////////////////////////////////////////////////////////////////////////
private void button1_Click(object sender, EventArgs e)
{
this.Close();
Form_Enter f = new Form_Enter();
f.Show();
}
// //////////////////////////////////////////Пассажиры//////////////////////////////////////////////////
private void start2_btn_Click(object sender, EventArgs e)
{
this.Close();
Form_Enter f = new Form_Enter();
f.Show();
}
private void open2_btn_Click(object sender, EventArgs e)
{
SqlDataAdapter da = new SqlDataAdapter("select Adress_park as 'Адрес парка', Kolvo_bus as 'Количество автобусов' from dbo.Table_bus where Availability=1", con);
DataTable dt = new DataTable();
da.Fill(dt);
museum_table.DataSource = dt;
}
private void update2_btn_Click(object sender, EventArgs e)
{
{
SqlDataAdapter da = new SqlDataAdapter("SELECT Name as 'Название', City as 'Город', Max_Number_of_Visitors as 'Макс.Кол-во.Посетителей', Open_Date as 'Дата Открытия', Topic as 'Тематика', Start_Date as 'Дата Начала', End_Date as 'Дата Окончания' FROM dbo.Museum left join dbo.Exposition on (dbo.Museum.ID=dbo.Exposition.Museum_ID) WHERE " + "' ", con);
DataTable dt = new DataTable();
da.Fill(dt);
museum_table.DataSource = dt;
}
}
// //////////////////////////////////////////Остановки//////////////////////////////////////////////////
private void start3_btn_Click(object sender, EventArgs e)
{
this.Close();
Form_Enter f = new Form_Enter();
f.Show();
}
private void exposition_btn_Click(object sender, EventArgs e)
{
SqlDataAdapter da = new SqlDataAdapter("SELECT Topic as 'Тематика', Start_Date as 'Дата Начала', End_Date as 'Дата Окончания', Name as 'Музей' FROM dbo.Exposition join dbo.Museum on(dbo.Exposition.Museum_ID= dbo.Museum.ID) where getdate() between Start_Date and End_Date", con);
DataTable dt = new DataTable();
da.Fill(dt);
exposition_table.DataSource = dt;
}
private void update1_btn_Click(object sender, EventArgs e)
{
if (comboBox1.Text == "") load_data(painter_table, 1);
else
{
SqlDataAdapter da = new SqlDataAdapter("SELECT Table_bus.ID, Table_bus.Kolvo_bus as 'Количество', Mest_in_bus as 'Мест в автобусе', Adress_park as 'Адрес парка'FROM dbo.Table_bus WHERE " + comboBox1.Text + " LIKE '%" + find1_txt.Text + "%' ", con);
DataTable dt = new DataTable();
da.Fill(dt);
painter_table.DataSource = dt;
}
}
private void button2_Click(object sender, EventArgs e)
{
this.Close();
Form_Enter f = new Form_Enter();
f.Show();
}
}
}