Vous êtes sur la page 1sur 27

1r

Transport Company Data Base


TECHNICAL MANUAL

Tabela: car_types

Kolumny
Nazwa Typ Rozmiar
id_car_type Liczba całkowita długa 4
manufacturer Tekst 50
model Tekst 50
combustion p/100 Liczba całkowita długa 4
maximal speed Liczba całkowita długa 4
capacity Liczba całkowita długa 4

Relacje

Tabela: cars

Kolumny
Nazwa Typ Rozmiar
id_car Liczba całkowita długa 4
type Liczba całkowita długa 4
color Tekst 50
year Liczba całkowita długa 4

Tabela: cars_drivers/deals
2r
Kolumny
Nazwa Typ Rozmiar
id_car_driver/deal Liczba całkowita długa 4
car Liczba całkowita długa 4
driver Liczba całkowita długa 4
deal Liczba całkowita długa 4
hours Liczba całkowita długa 4
price Liczba całkowita długa 4

Tabela: cities

Kolumny
Nazwa Typ Rozmiar
id_city Liczba całkowita długa 4
name Tekst 50
longitude Liczba całkowita długa 4
latitude Dziesiętne 16

Tabela: clients

Kolumny
Nazwa Typ Rozmiar
id_client Liczba całkowita długa 4
name Tekst 50
surname Tekst 50
address Tekst 50
telephone Tekst 50
town Tekst 50
post code Tekst 50
country Tekst 50

Tabela: deals

Kolumny
Nazwa Typ Rozmiar
id_deal Liczba całkowita długa 4
source Liczba całkowita długa 4
destination Liczba całkowita długa 4
date Data/Godzina 8
client Liczba całkowita długa 4
price Liczba całkowita długa 4

Tabela: drivers

Kolumny
3r
Nazwa Typ Rozmiar
id_driver Liczba całkowita długa 4
name Tekst 50
surname Tekst 50
salary Waluta 8

Tabela: users

Kolumny
Nazwa Typ Rozmiar
id_user Liczba całkowita długa 4
login Tekst 50
password Tekst 50
type Liczba całkowita długa 4
client Liczba całkowita długa 4
4r

Kwerenda: q_add_car

SQL
SELECT cars.id_car, car_types.manufacturer, car_types.model, cars.color, cars.year,
car_types.[maximal speed], car_types.capacity
FROM car_types INNER JOIN cars ON car_types.id_car_type=cars.type;

Kolumny
Nazwa Typ Rozmiar
id_car Liczba całkowita długa 4
manufacturer Tekst 50
model Tekst 50
color Tekst 50
year Liczba całkowita długa 4
maximal speed Liczba całkowita długa 4
capacity Liczba całkowita długa 4

Kwerenda: q_car_types

SQL
SELECT cars.id_car, car_types.manufacturer, car_types.model, car_types.capacity,
car_types.[maximal speed], car_types.[combustion p/100]
FROM car_types INNER JOIN cars ON car_types.id_car_type = cars.type;

Kolumny
Nazwa Typ Rozmiar
id_car Liczba całkowita długa 4
manufacturer Tekst 50
model Tekst 50
capacity Liczba całkowita długa 4
maximal speed Liczba całkowita długa 4
combustion p/100 Liczba całkowita długa 4
5r
Kwerenda: q_cars

SQL
SELECT DISTINCT deals.id_deal, cars.color, cars.year, car_types.manufacturer, car_types.model,
car_types.[combustion p/100], car_types.[maximal speed], car_types.capacity
FROM car_types INNER JOIN (deals INNER JOIN (cars INNER JOIN [cars_drivers/deals] ON
cars.id_car=[cars_drivers/deals].car) ON deals.id_deal=[cars_drivers/deals].deal) ON
car_types.id_car_type=cars.type
ORDER BY deals.id_deal;

Kolumny
Nazwa Typ Rozmiar
id_deal Liczba całkowita długa 4
color Tekst 50
year Liczba całkowita długa 4
manufacturer Tekst 50
model Tekst 50
combustion p/100 Liczba całkowita długa 4
maximal speed Liczba całkowita długa 4
capacity Liczba całkowita długa 4

Kwerenda: q_cities

SQL
SELECT deals.id_deal, cs.name AS source, cd.name AS destination, Int(Sqr((cs.longitude-
cd.longitude)^2+(cs.latitude-cd.latitude)^2)) AS distance
FROM deals, cities AS cs, cities AS cd
WHERE (((deals.source)=cs.id_city) And ((deals.destination)=cd.id_city));

Kolumny
Nazwa Typ Rozmiar
id_deal Liczba całkowita długa 4
source Tekst 50
destination Tekst 50
distance Podwójna precyzja 8

Kwerenda: q_drivers
6r
SQL
SELECT DISTINCT deals.id_deal, drivers.name, drivers.surname, drivers.salary
FROM drivers INNER JOIN (deals INNER JOIN [cars_drivers/deals] ON
deals.id_deal=[cars_drivers/deals].deal) ON drivers.id_driver=[cars_drivers/deals].driver
ORDER BY deals.id_deal;

Kolumny
Nazwa Typ Rozmiar
id_deal Liczba całkowita długa 4
name Tekst 50
surname Tekst 50
salary Waluta 8

Kwerenda: q_id_deal

SQL
SELECT MAX(deals.id_deal) AS id_deal
FROM deals;

Kolumny
Nazwa Typ Rozmiar
id_deal Liczba całkowita długa 4

Kwerenda: q_rap_clients

SQL
SELECT clients.id_client, clients.name, clients.surname, clients.address, clients.telephone,
clients.town, clients.[post code], clients.country
FROM clients
ORDER BY clients.id_client;

Kolumny
Nazwa Typ Rozmiar
id_client Liczba całkowita długa 4
name Tekst 50
surname Tekst 50
address Tekst 50
telephone Tekst 50
town Tekst 50
post code Tekst 50
country Tekst 50
7r

Kwerenda: q_rap_deal

SQL
SELECT deals.id_deal, cs.name AS source, cd.name AS destination, deals.date, drivers.name & " " &
drivers.surname AS driver, car_types.manufacturer & " " & car_types.model AS car, clients.name & " "
& clients.surname AS client, [cars_drivers/deals].price
FROM cities AS cs, cities AS cd, car_types INNER JOIN (drivers INNER JOIN ((clients INNER JOIN deals
ON clients.id_client=deals.client) INNER JOIN (cars INNER JOIN [cars_drivers/deals] ON
cars.id_car=[cars_drivers/deals].car) ON deals.id_deal=[cars_drivers/deals].deal) ON
drivers.id_driver=[cars_drivers/deals].driver) ON car_types.id_car_type=cars.type
WHERE (((deals.source)=cs.id_city) And ((deals.destination)=cd.id_city))
ORDER BY deals.id_deal, deals.date DESC;

Kolumny
Nazwa Typ Rozmiar
id_deal Liczba całkowita długa 4
source Tekst 50
destination Tekst 50
date Data/Godzina 8
driver Tekst 0
car Tekst 0
client Tekst 0
price Liczba całkowita długa 4

Kwerenda: q_rap_drivers

SQL
SELECT drivers.id_driver, drivers.name, drivers.surname, drivers.salary AS [salary p/h],
Sum([cars_drivers/deals].hours) AS hours, Sum([cars_drivers/deals].hours)*drivers.salary AS total
FROM drivers INNER JOIN [cars_drivers/deals] ON drivers.id_driver=[cars_drivers/deals].driver
GROUP BY drivers.id_driver, drivers.name, drivers.surname, drivers.salary;

Kolumny
Nazwa Typ Rozmiar
id_driver Liczba całkowita długa 4
name Tekst 50
surname Tekst 50
salary p/h Waluta 8
hours Podwójna precyzja 8
total Podwójna precyzja 8
8r

Kwerenda: q_user

SQL
SELECT users.id_user
FROM users
WHERE (((users.login)=[Forms]![f_main]![i_login].[Text]) AND
((users.password)=[Forms]![f_main]![i_password].[Text]));

Parametry kwerendy
Nazwa Typ
[Forms]![f_main]![i_login].[Text] Tekst
[Forms]![f_main]![i_password].[Text] Tekst

Kolumny
Nazwa Typ Rozmiar
id_user Liczba całkowita długa 4

Kwerenda: q_view_deal

SQL
SELECT d.id_deal, cs.name AS source, cd.name AS destination, d.date,
Sum([cars_drivers/deals].price) AS Suma
FROM cities AS cs, cities AS cd, deals AS d INNER JOIN [cars_drivers/deals] ON
d.id_deal=[cars_drivers/deals].deal
WHERE cs.id_city=d.source And cd.id_city=d.destination
GROUP BY d.id_deal, cs.name, cd.name, d.date;

Kolumny
Nazwa Typ Rozmiar
id_deal Liczba całkowita długa 4
source Tekst 50
destination Tekst 50
date Data/Godzina 8
Suma Podwójna precyzja 8
9r

Kwerenda: q_view_deal_cars/drivers

SQL
SELECT deals.id_deal, cs.name AS source, cd.name AS destination, deals.date, deals.price,
drivers.name & " " & drivers.surname AS driver, car_types.manufacturer & " " & car_types.model AS
car, clients.name & " " & clients.surname AS client
FROM cities AS cs, cities AS cd, car_types INNER JOIN (drivers INNER JOIN ((clients INNER JOIN deals
ON clients.id_client=deals.client) INNER JOIN (cars INNER JOIN [cars_drivers/deals] ON
cars.id_car=[cars_drivers/deals].car) ON deals.id_deal=[cars_drivers/deals].deal) ON
drivers.id_driver=[cars_drivers/deals].driver) ON car_types.id_car_type=cars.type
WHERE (((deals.source)=cs.id_city) And ((deals.destination)=cd.id_city))
ORDER BY deals.id_deal, deals.date DESC;

Kolumny
Nazwa Typ Rozmiar
id_deal Liczba całkowita długa 4
source Tekst 50
destination Tekst 50
date Data/Godzina 8
price Liczba całkowita długa 4
driver Tekst 0
car Tekst 0
client Tekst 0

Kwerenda: q_view_drivers

SQL
SELECT dr.name, dr.surname, d.price, d.id_deal
FROM drivers AS dr, deals AS d, [cars_drivers/deals] AS cd
WHERE ((d.id_deal=cd.deal) And (cd.driver=dr.id_driver));

Kolumny
Nazwa Typ Rozmiar
name Tekst 50
surname Tekst 50
price Liczba całkowita długa 4
id_deal Liczba całkowita długa 4
10r

Formularz: f_add_deals

Obiekty

Etykieta: Cars_Etykieta

Etykieta: client_Etykieta

Etykieta: date_Etykieta

Etykieta: destination_Etykieta

Etykieta: Drivers_Etykieta

Pole tekstowe: i_client

Pole tekstowe: i_date

Pole kombi: i_dest

Pole tekstowe: i_price

Pole kombi: i_src

Pole listy: ls_cars

Pole listy: ls_drivers

Pole listy: ls_price

Etykieta: price_Etykieta

Etykieta: source_Etykieta

Pole tekstowe: tx_distance

Kod
1 VERSION 1.0 CLASS
2 BEGIN
3 MultiUse = -1 'True
4 END
5 Attribute VB_Name = "Form_f_add_deals"
6 Attribute VB_GlobalNameSpace = False
7 Attribute VB_Creatable = True
8 Attribute VB_PredeclaredId = True
9 Attribute VB_Exposed = False
10 Option Compare Database
11
12 Private Sub save_deal()
13 DoCmd.RunSQL "INSERT into deals ([source], [destination], [date], [client], [price])
VALUES " & _
14 "(" & i_src & "," & i_dest & "," & i_date & "," & i_client & "," & "0" & ")", False
15
16 Dim id As Integer
17 If Not IsNull(DLookup("id_deal", "q_id_deal")) Then
18 id = DLookup("id_deal", "q_id_deal")
19 'Else should never happen
20 End If
21
22 For i = 0 To ls_price.ListCount
23 If Not IsNull(ls_price.Column(0, i)) And Not IsNull(ls_price.Column(1, i)) And _
24 Not IsNull(ls_price.Column(3, 0)) And Not IsNull(ls_price.Column(5, 0)) Then
25
26 DoCmd.RunSQL "INSERT into [cars_drivers/deals] ([car], [driver], [deal],
[hours], [price]) VALUES " & _
27 "(" & ls_price.Column(5, i) & "," & ls_price.Column(3, i) & "," & id & "," & _
11r
28 ls_price.Column(1, i) & "," & ls_price.Column(0, i) & ")", False
29
30 End If
31 Next i
32
33 MsgBox "Deal added !", , "Info"
34 End Sub
35
36 Private Sub calc_distance()
37 If IsNull(i_src.Value) Or IsNull(i_dest.Value) Or i_src.Value = -1 Or i_dest.Value = -1
38 Exit Sub
39 End If
40
41 tx_distance.Value = 0
42
43 If i_src.Value = i_dest.Value Then
44 MsgBox "You have choosen the same cities", , "Warinng"
45 i_src.Value = -1
46 i_dest.Value = -1
47 Exit Sub
48 End If
49
50 Dim q As String
51 Dim s_latitude, s_longitude As Integer
52 Dim d_latitude, d_longitude As Integer
53
54 q = "[id_city] = " & i_src.Value
55 If Not IsNull(DLookup("latitude", "cities", q)) And _
56 Not IsNull(DLookup("longitude", "cities", q)) Then 'cannot be null
57 s_latitude = DLookup("latitude", "cities", q)
58 s_longitude = DLookup("longitude", "cities", q)
59
60 q = "[id_city] = " & i_dest.Value
61 If Not IsNull(DLookup("latitude", "cities", q)) And _
62 Not IsNull(DLookup("longitude", "cities", q)) Then 'cannot be null
63 d_latitude = DLookup("latitude", "cities", q)
64 d_longitude = DLookup("longitude", "cities", q)
65
66 tx_distance.Value = Int(Sqr((s_latitude - d_latitude) ^ 2 + (s_longitude -
d_longitude) ^ 2))
67 End If
68 End If
69 End Sub
70
71 Private Sub i_dest_AfterUpdate()
72 calc_distance
73 End Sub
74
75 Private Sub i_src_AfterUpdate()
76 calc_distance
77 End Sub
78
79 Private Sub clear_form()
80 ls_price.RowSource = ""
81 i_price = 0
82 i_dest = -1
83 i_src = -1
84 i_date = Now()
85 End Sub
86
87 Private Sub Polecenie26_Click()
88 On Error GoTo Err_Polecenie26_Click
89
90 clear_form
91
92 Forms![f_main]![FormantKarta].Pages.Item(2).SetFocus
93
94 Exit_Polecenie26_Click:
95 Exit Sub
96
97 Err_Polecenie26_Click:
98 MsgBox Err.Description
99 Resume Exit_Polecenie26_Click
12r
100
101 End Sub
102
103 Private Sub Polecenie29_Click()
104
105 If IsNull(ls_cars.Value) Then
106 MsgBox "Choose car !", , "Warning"
107 Exit Sub
108 End If
109 If IsNull(tx_distance.Value) Or tx_distance.Value = 0 Then
110 MsgBox "Choose source and destinaton", , "Warning"
111 Exit Sub
112 End If
113
114 Dim car_info As String
115 car_info = "Car " & ls_cars.Value
116 Dim maxsp As Integer
117 maxsp = 0
118
119 Dim q As String
120 q = "[id_car]=" & ls_cars.Value
121 If Not IsNull(DLookup("type", "cars", q)) Then
122 t = DLookup("type", "cars", q)
123 q = "[id_car_type]=" & t
124 If (Not IsNull(DLookup("[manufacturer]", "car_types", q))) And (Not
IsNull(DLookup("[model]", "car_types", q))) Then
125 car_info = DLookup("[manufacturer]", "car_types", q) & " " &
DLookup("[model]", "car_types", q)
126 End If
127 If Not IsNull(DLookup("[maximal speed]", "car_types", q)) Then 'can not be null
128 maxsp = DLookup("[maximal speed]", "car_types", q)
129 End If
130 End If
131
132 Dim hours As Integer
133 hours = Int(tx_distance.Value / (maxsp / 2))
134 If tx_distance.Value Mod maxsp <> 0 Then
135 hours = hours + 1
136 End If
137
138 Dim ok As Boolean
139 ok = False
140
141 Dim i As Integer
142 For i = 0 To ls_drivers.ListCount
143 If ls_drivers.Selected(i) Then
144 ok = True
145 q = "[id_driver]=" & ls_drivers.ItemData(i)
146 If Not IsNull(DLookup("salary", "drivers", q)) Then
147 salary = DLookup("salary", "drivers", q)
148
149 ls_price.RowSource = ls_price.RowSource & _
150 (hours * salary) & ";" & _
151 hours & ";" & _
152 DLookup("name", "drivers", q) & " " & _
153 DLookup("surname", "drivers", q) & ";" & _
154 ls_drivers.ItemData(i) & ";" & _
155 car_info & ";" & _
156 ls_cars.Value & ";"
157
158 i_price = i_price + (hours * salary)
159 End If
160 End If
161 Next i
162
163 If ok = False Then
164 MsgBox "Choose drivers !", , "Warning"
165 End If
166 End Sub
167
168 Private Sub Polecenie30_Click()
169 ls_price.RowSource = ""
13r
170 i_price = 0
171 End Sub
172
173 Private Sub Polecenie33_Click()
174 If ls_price.ListCount = 0 Then
175 MsgBox "Choose drivers and car", , "Warning"
176 Exit Sub
177 End If
178
179 Dim total As Integer
180 total = 0
181
182 Dim i As Integer
183 For i = 0 To ls_price.ListCount
184 If Not IsNull(ls_price.ItemData(i)) Then
185 total = total + ls_price.ItemData(i)
186 End If
187 Next i
188
189 price = total
190
191 End Sub
192 Private Sub Polecenie34_Click()

209 Private Sub Polecenie35_Click()


210 On Error GoTo Err_Polecenie35_Click
211
212 If ls_price.ListCount = 0 Then
213 MsgBox "Choose drivers and car", , "Waring"
214 Exit Sub
215 End If
216
217 If i_src = -1 Or i_dest = -1 Then
218 MsgBox "Choose source and destination", , "Waring"
219 Exit Sub
220 End If
221
222 If IsNull(i_date) Then
223 MsgBox "Enter date"
224 Exit Sub
225 End If
226
227 save_deal
228 clear_form
229 Forms![f_main]![FormantKarta].Pages.Item(2).SetFocus
230
231 Exit_Polecenie35_Click:
232 Exit Sub
233
234 Err_Polecenie35_Click:
235 MsgBox Err.Description
236 Resume Exit_Polecenie35_Click
237
238 End Sub
14r

Formularz: f_cars
Formularz: f_cities
Formularz: f_clients
Formularz: f_drivers
Są używane tylko do wyświetlania danych i nie zawierają żadnego kodu VBA.
15r
Formularz: f_edit_car_types

Formularz: f_edit_cars

Formularz: f_edit_cities

Formularz: f_edit_clients

Formularz: f_edit_drivers

Zawierają tylko przyciski do nawigacji pomiędzy rekordami oraz przyciski Add, Undo i Delete, wszystkie utworzone dzięki
kreatorom.

Formularz: f_main
16r
Obiekty

Przycisk polecenia: b_default_browse

Pole tekstowe: date

Etykieta: date_Etykieta

Podformularz/Podraport: f_add_deals

Podformularz/Podraport: f_cars

Etykieta: f_cars Etykieta

Podformularz/Podraport: f_cities

Etykieta: f_cities Etykieta

Podformularz/Podraport: f_clients

Etykieta: f_clients Etykieta

Podformularz/Podraport: f_drivers

Etykieta: f_drivers Etykieta

Podformularz/Podraport: f_edit_car_types

Podformularz/Podraport: f_edit_cars

Podformularz/Podraport: f_edit_cities

Podformularz/Podraport: f_edit_clients

Podformularz/Podraport: f_edit_drivers

Podformularz/Podraport: f_search_clients

Podformularz/Podraport: f_search_drivers

FormantKarta

Grupa opcji: fr_edit

Etykieta: fr_edit_l

Grupa opcji: fr_search

Etykieta: fr_search_l

Pole tekstowe: i_login

Pole tekstowe: i_password


17r
C:\rbd\transport.mdb 9 czerwca 2003
Formularz: f_main Strona: 56

Etykieta: id_deal_Etykieta

Etykieta: l_user_id

Pole listy: ls_deals

Pole wyboru: o_browse_car

Pole wyboru: o_browse_city

Pole wyboru: o_browse_client

Pole wyboru: o_browse_driver

Niezwiązana ramka obiektu: OLENiezwiązany11

Strona: p_add

Strona: p_browse

Strona: p_edit

Strona: p_help

Strona: p_home

Strona: p_login

Strona: p_main

Strona: p_options

Strona: p_reports

Strona: p_search

Strona: p_view

Kod
1 VERSION 1.0 CLASS
2 BEGIN
3 MultiUse = -1 'True
4 END
5 Attribute VB_Name = "Form_f_main"
6 Attribute VB_GlobalNameSpace = False
7 Attribute VB_Creatable = True
8 Attribute VB_PredeclaredId = True
9 Attribute VB_Exposed = False
10 Option Compare Database
11
18r
C:\rbd\transport.mdb 9 czerwca 2003
Formularz: f_main Strona: 58
12 Public g_user_id As Integer
13 Public g_user_login As String
14 Public g_user_type As Integer '0 == user, 1 == admin
15
16 Private Sub b_default_browse_Click()
17 o_browse_client.Value = True
18 o_browse_car.Value = True
19 o_browse_driver.Value = True
20 o_browse_city.Value = True
21
22 Me![f_cities].Visible = True
23 Me![f_cars].Visible = True
24 Me![f_drivers].Visible = True
25 Me![f_clients].Visible = True
26 End Sub
27
28

36
37
38 Private Sub o_browse_car_AfterUpdate()
39 f_cars.Visible = Not f_cars.Visible
40 End Sub
41
42 Private Sub o_browse_city_AfterUpdate()
43 f_cities.Visible = Not f_cities.Visible
44 End Sub
45
46 Private Sub o_browse_client_AfterUpdate()
47 Me![f_clients].Visible = Not Me![f_clients].Visible
48 End Sub
49
50 Private Sub o_browse_driver_AfterUpdate()
51 Me![f_drivers].Visible = Not Me![f_drivers].Visible
52 End Sub
53
54 Private Sub changeSearch(s As String)
55 fr_search_l.Caption = s
56
57 If s = "Client" Then
58 f_search_drivers.Visible = False
59 f_search_clients.Visible = True
60 ElseIf s = "Driver" Then
61 f_search_clients.Visible = False
62 f_search_drivers.Visible = True
63 End If
64 End Sub
19r
C:\rbd\transport.mdb 9 czerwca 2003
Formularz: f_main Strona: 59
65
66 Private Sub Polecenie115_Click()
67 changeSearch "Client"
68 End Sub
69
70 Private Sub Polecenie117_Click()
71 changeSearch "Driver"
72 End Sub
73
74
75 Private Sub changeEdit(s As String)
76 fr_edit_l.Caption = s
77
78 If s = "Client" Then
79 f_edit_cars.Visible = False
80 f_edit_car_types.Visible = False
81 f_edit_cities.Visible = False
82 f_edit_drivers.Visible = False
83 f_edit_clients.Visible = True
84 ElseIf s = "Driver" Then
85 f_edit_cars.Visible = False
86 f_edit_car_types.Visible = False
87 f_edit_cities.Visible = False
88 f_edit_drivers.Visible = True
89 f_edit_clients.Visible = False
90 ElseIf s = "Car" Then
91 f_edit_cars.Visible = True
92 f_edit_car_types.Visible = True
93 f_edit_cities.Visible = False
94 f_edit_drivers.Visible = False
95 f_edit_clients.Visible = False
96 ElseIf s = "Cities" Then
97 f_edit_cars.Visible = False
98 f_edit_car_types.Visible = False
99 f_edit_cities.Visible = True
100 f_edit_drivers.Visible = False
101 f_edit_clients.Visible = False
102 End If
103 End Sub
104
105 Private Sub Polecenie125_Click()
106 changeEdit "client"
107 End Sub
108
109 Private Sub Polecenie127_Click()
110 changeEdit "Driver"
111 End Sub
112
113 Private Sub Polecenie129_Click()
114 changeEdit "Car"
115 End Sub
116
117 Private Sub Polecenie208_Click()
20r
C:\rbd\transport.mdb 9 czerwca 2003
Formularz: f_main Strona: 60
118 changeEdit "Cities"
119 End Sub
120
121
122 Private Sub Polecenie147_Click()
123 If IsNull(i_password) Or IsNull(i_login) Then
124 MsgBox "Enter loginame and password", , "Warning"
125 Else
126 Dim q As String
127 q = "[login]='" & Me![i_login] & "' AND [password]='" & Me![i_password] & "'"
128 If IsNull(DLookup("id_user", "users", q)) Then
129 MsgBox "Wrong password or loginame", , "Error"
130 Else
131 g_user_type = DLookup("type", "users", q)
132
133 If g_user_type = 0 Then
134 g_user_id = DLookup("client", "users", q)
135 l_user_id.Caption = g_user_id
136 ls_deals.RowSource = "SELECT d.[id_deal], cs.[name] AS source, cd.[name]
AS destination, d.[date], Sum([cars_drivers/deals].[price]) AS Suma FROM cities AS
cs, cities AS cd, deals AS d INNER JOIN [cars_drivers/deals] ON
d.[id_deal]=[cars_drivers/deals].deal WHERE cs.[id_city] = d.[source] And
cd.[id_city] = d.[destination] And d.[client] = " & g_user_id & " GROUP BY d.[id_deal],
137 End If
138
139 g_user_login = Me![i_login]
140
141 'MsgBox "Welcome " & g_user_login & " (" & g_user_id & ") = " & g_user_type
142
143 p_help.Visible = True
144
145 If g_user_type = 0 Then
146 p_view.Visible = True
147 p_add.Visible = True
148 p_home.Visible = True
149
150 Me![f_add_deals]![i_client] = g_user_id
151
152 Me![FormantKarta].Pages.Item(2).SetFocus
153 ElseIf g_user_type = 1 Then
154 p_edit.Visible = True
155 p_browse.Visible = True
156 p_options.Visible = True
157 p_search.Visible = True
158 p_main.Visible = True
159 p_reports.Visible = True
160 Me![FormantKarta].Pages.Item(1).SetFocus
161 End If
162
163 p_login.Visible = False
164
165 End If
166 End If
167 End Sub
21r
C:\rbd\transport.mdb 9 czerwca 2003
Formularz: f_main Strona: 61
168
169 Private Sub Polecenie152_Click()
170 ls_deals.RowSource = "SELECT deals.id_deal, deals.source, deals.destination,
deals.date, deals.price FROM deals WHERE deals.client = " & g_user_id
171 End Sub
172

185
186 Private Sub Polecenie169_Click()
187 Me![FormantKarta].Pages.Item(7).SetFocus
188 End Sub
189
190 Private Sub Polecenie171_Click()
191 Me![FormantKarta].Pages.Item(8).SetFocus
192 End Sub
193
194 Private Sub Polecenie177_Click()
195 Me![FormantKarta].Pages.Item(10).SetFocus
196 End Sub
197

263
264 Private Sub Polecenie200_Click()
265 On Error GoTo Err_Polecenie200_Click
266
267 Dim stDocName As String
268
269 Dim name As String
270
271 Dim q As String
272 q = "[id_client] = " & g_user_id
22r
C:\rbd\transport.mdb 9 czerwca 2003
Formularz: f_main Strona: 63
273 If Not IsNull(DLookup("name", "clients", q)) And _
274 Not IsNull(DLookup("surname", "clients", q)) Then
275 name = DLookup("name", "clients", q) & " " & DLookup("surname", "clients", q)
276
277 stDocName = "r_client"
278 DoCmd.OpenReport stDocName, acPreview, , "[client] = '" & name & "'"
279
280 'else should never happend
281 End If
282
283 Exit_Polecenie200_Click:
284 Exit Sub
285
286 Err_Polecenie200_Click:
287 MsgBox Err.Description
288 Resume Exit_Polecenie200_Click
289 End Sub
290
291 Private Sub Polecenie202_Click()
292 Me![FormantKarta].Pages.Item(9).SetFocus
293 End Sub
294
295
296 Private Sub Polecenie91_Click()
297 Me![FormantKarta].Pages.Item(3).SetFocus
298
299 End Sub
300
301 Private Sub Polecenie93_Click()
302 Me![FormantKarta].Pages.Item(4).SetFocus
303 End Sub
304
305 Private Sub Polecenie95_Click()
306 Me![FormantKarta].Pages.Item(5).SetFocus
307 End Sub
308
309 Private Sub Polecenie97_Click()
310 Me![FormantKarta].Pages.Item(6).SetFocus
311 End Sub
312
313 Private Sub Polecenie99_Click()
314 Me![FormantKarta].Pages.Item(10).SetFocus
315 End Sub
316

373
374 Private Sub Zaznacz43_AfterUpdate()
375 f_cities.Visible = Not f_cities.Visible
376 End Sub
377 Private Sub Polecenie181_Click()
378 On Error GoTo Err_Polecenie181_Click
23r
C:\rbd\transport.mdb 9 czerwca 2003
Formularz: f_main Strona: 65
379
380 Dim stDocName As String
381
382 stDocName = "deals"
383 DoCmd.OpenReport stDocName, acPreview
384
385 Exit_Polecenie181_Click:
386 Exit Sub
387
388 Err_Polecenie181_Click:
389 MsgBox Err.Description
390 Resume Exit_Polecenie181_Click
391
392 End Sub
…………….
410 Private Sub Polecenie199_Click()
411 On Error GoTo Err_Polecenie199_Click
412
413 Dim stDocName As String
414
415 stDocName = "r_deals"
416 DoCmd.OpenReport stDocName, acPreview
417
418 Exit_Polecenie199_Click:
419 Exit Sub
420
421 Err_Polecenie199_Click:
422 MsgBox Err.Description
423 Resume Exit_Polecenie199_Click
424
425 End Sub
24r
C:\rbd\transport.mdb 9 czerwca 2003
Formularz: f_search_clients Strona: 66

Obiekty

Pole kombi: c_country

Pole tekstowe: c_name

Pole tekstowe: c_surname

Pole kombi: c_town

Pole listy: list

Kod
1 VERSION 1.0 CLASS
2 BEGIN
3 MultiUse = -1 'True
4 END
5 Attribute VB_Name = "Form_f_search_clients"
6 Attribute VB_GlobalNameSpace = False
7 Attribute VB_Creatable = True
8 Attribute VB_PredeclaredId = True
9 Attribute VB_Exposed = False
10 Option Compare Database
11
12 Private Sub changeList()
13 Dim q As String
14 q = "SELECT clients.id_client, clients.name, clients.surname, clients.address,
clients.telephone, clients.town, clients.[post code], clients.country FROM clients"
15
16 Dim first As Boolean
17 first = True
18
19 If Not IsNull(c_name) Then
20 If first = True Then
21 first = False
22 q = q & " WHERE "
23 Else
24 q = q & " And "
25r
C:\rbd\transport.mdb 9 czerwca 2003
Formularz: f_search_clients Strona: 67
25 End If
26 q = q & "clients.name = '" & c_name.Value & "'"
27 End If
28
29 If Not IsNull(c_surname) Then
30 If first = True Then
31 first = False
32 q = q & " WHERE "
33 Else
34 q = q & " And "
35 End If
36 q = q & "clients.surname = '" & c_surname.Value & "'"
37 End If
38
39 If Not IsNull(c_town) Then
40 If first = True Then
41 first = False
42 q = q & " WHERE "
43 Else
44 q = q & " And "
45 End If
46 q = q & "clients.town = '" & c_town.Value & "'"
47 End If
48
49 If Not IsNull(c_country) Then
50 If first = True Then
51 first = False
52 q = q & " WHERE "
53 Else
54 q = q & " And "
55 End If
56 q = q & "clients.country = '" & c_country.Value & "'"
57 End If
58
59 list.RowSource = q
60 End Sub
61
62 Private Sub c_country_AfterUpdate()
63 changeList
64 End Sub
65
66 Private Sub c_name_AfterUpdate()
67 changeList
68 End Sub
69
70 Private Sub c_surname_AfterUpdate()
71 changeList
72 End Sub
73
74 Private Sub c_town_AfterUpdate()
75 changeList
76 End Sub
77
26r
C:\rbd\transport.mdb 9 czerwca 2003
Formularz: f_search_drivers Strona: 69

Obiekty

Pole tekstowe: c_name

Pole kombi: c_salary

Pole tekstowe: c_surname

Pole listy: list

Kod
1 VERSION 1.0 CLASS
2 BEGIN
3 MultiUse = -1 'True
4 END
5 Attribute VB_Name = "Form_f_search_drivers"
6 Attribute VB_GlobalNameSpace = False
7 Attribute VB_Creatable = True
8 Attribute VB_PredeclaredId = True
9 Attribute VB_Exposed = False
10 Option Compare Database
11
12 Private Sub changeList()
13 Dim q As String
14 q = "SELECT drivers.id_driver, drivers.name, drivers.surname, drivers.salary FROM
15
16 Dim first As Boolean
17 first = True
18
19 If Not IsNull(c_name) Then
20 If first = True Then
21 first = False
22 q = q & " WHERE "
23 Else
24 q = q & " And "
25 End If
26 q = q & "drivers.name = '" & c_name.Value & "'"
27 End If
28
29 If Not IsNull(c_surname) Then
30 If first = True Then
31 first = False
32 q = q & " WHERE "
27r
C:\rbd\transport.mdb 9 czerwca 2003
Formularz: f_search_drivers Strona: 70
33 Else
34 q = q & " And "
35 End If
36 q = q & "drivers.surname = '" & c_surname.Value & "'"
37 End If
38
39 If Not IsNull(c_salary) Then
40 If first = True Then
41 first = False
42 q = q & " WHERE "
43 Else
44 q = q & " And "
45 End If
46 q = q & "drivers.salary = " & c_salary.Value
47 End If
48
49 list.RowSource = q
50 End Sub
51
52 Private Sub c_name_AfterUpdate()
53 changeList
54 End Sub
55
56 Private Sub c_salary_AfterUpdate()
57 changeList
58 End Sub
59
60 Private Sub c_surname_AfterUpdate()
61 changeList
62 End Sub