-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUnit7.~cpp
224 lines (175 loc) · 6.54 KB
/
Unit7.~cpp
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit7.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm7 *Form7;
//---------------------------------------------------------------------------
__fastcall TForm7::TForm7(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void TForm7::ShowData(int i){
ListBox1->ItemIndex=i;
ListBox2->ItemIndex=i;
ListBox3->ItemIndex=i;
ListBox4->ItemIndex=i;
ComboBox3->ItemIndex=i;
Edit7->Text=Form1->Rozklad->ShowNamePoint(i);
if(!i){
Edit3->Enabled=0;
Edit4->Enabled=0;
Edit3->Text="-";
Edit4->Text="-";
}
else {
Edit3->Enabled=1;
Edit4->Enabled=1;
Edit3->Text=Form1->Rozklad->ShowTime1(i);
Edit4->Text=Form1->Rozklad->ShowTime2(i);
}
if(Form1->Rozklad->ShowStop(i)!="-"){
Edit5->Enabled=1;
Edit6->Enabled=1;
Edit5->Text=Form1->Rozklad->ShowStop1(i);
Edit6->Text=Form1->Rozklad->ShowStop2(i);
}
else {
Edit5->Enabled=0;
Edit6->Enabled=0;
Edit5->Text="-";
Edit6->Text="-";
}
}
void TForm7::ShowTimeTable(TimeTable* t, TimeTable* pt){
Form7->ListBox1->Clear();
Form7->ListBox2->Clear();
Form7->ListBox3->Clear();
Form7->ListBox4->Clear();
Form7->ComboBox1->Clear();
Form7->ComboBox3->Clear();
int reserve=0;
for(int i=0;i<t->CountSection();i++){
Form7->ListBox2->Items->Add(t->ShowEnd(i));
Form7->ListBox3->Items->Add(t->ShowTime(i) + "("+pt->ShowTime(i)+")");
Form7->ListBox1->Items->Add(t->ShowStop(i) + "("+pt->ShowStop(i)+")");
Form7->ListBox4->Items->Add(t->ShowSchedule(i));
Form7->ComboBox1->Items->Add(t->ShowEnd(i));
Form7->ComboBox3->Items->Add(t->ShowEnd(i));
reserve = reserve + t->ReserveTime(i,pt);
}
int mreserve = reserve/60;
reserve = reserve - mreserve*60;
Label16->Caption = "Suma rezerw:" + ((mreserve<10)? "0"+CurrToStr(mreserve):CurrToStr(mreserve)) + ":" + ((reserve<10)? "0"+CurrToStr(reserve):CurrToStr(reserve));
}
void TForm7::CreateTemplate(TimeTable *templ){
pt = new TimeTable(*templ);
// PrimaryTimeTable = &pt;
}
void __fastcall TForm7::Button3Click(TObject *Sender)
{
bool deparr;
if(ComboBox2->ItemIndex==0){deparr=1;}
else {deparr=0;}
Form1->Rozklad->ChangeStartTime(atof(Edit1->Text.c_str())*3600 + atof(Edit2->Text.c_str())*60,ComboBox1->ItemIndex,deparr);;
ShowTimeTable(Form1->Rozklad,pt);
}
//---------------------------------------------------------------------------
void __fastcall TForm7::ListBox1Click(TObject *Sender)
{
/*
if(ListBox1->Items->operator [](ListBox1->ItemIndex)!="-"){
POINT p;
GetCursorPos(&p);
PopupMenu1->Popup(p.x,p.y);
}
*/
ShowData(ListBox1->ItemIndex);
}
//---------------------------------------------------------------------------
void __fastcall TForm7::ListBox2Click(TObject *Sender)
{
/* //if(){
ShowMessage();
POINT p;
GetCursorPos(&p);
PopupMenu1->Popup(p.x,p.y);
//}
*/
ShowData(ListBox2->ItemIndex);
}
//---------------------------------------------------------------------------
void __fastcall TForm7::FormCreate(TObject *Sender)
{
ComboBox1->Clear();
}
//---------------------------------------------------------------------------
void __fastcall TForm7::ComboBox1Change(TObject *Sender)
{
if(ComboBox1->ItemIndex==0){
ComboBox2->ItemIndex=1;
ComboBox2->Enabled=0;
}
else if(ComboBox1->ItemIndex==Form1->Rozklad->CountSection()-1){
ComboBox2->ItemIndex=0;
ComboBox2->Enabled=0;
}
else {
ComboBox2->Enabled=1;
}
}
//---------------------------------------------------------------------------
void __fastcall TForm7::ListBox4Click(TObject*Sender)
{
ShowData(ListBox4->ItemIndex);
}
//---------------------------------------------------------------------------
void __fastcall TForm7::ListBox3Click(TObject *Sender)
{
ShowData(ListBox3->ItemIndex);
}
//---------------------------------------------------------------------------
void __fastcall TForm7::ComboBox3Change(TObject *Sender)
{
ShowData(ComboBox3->ItemIndex);
}
//---------------------------------------------------------------------------
void __fastcall TForm7::Button4Click(TObject *Sender)
{
int nr_section = ComboBox3->ItemIndex;
int a = Form1->Rozklad->ChangeSection(pt,nr_section,Edit7->Text,atoi(Edit3->Text.c_str())*60+atoi(Edit4->Text.c_str()),atoi(Edit5->Text.c_str())*60+atoi(Edit6->Text.c_str()));
// ShowMessage(pt->ShowTime(2));
ShowTimeTable(Form1->Rozklad,pt);
if(a){
AnsiString aa = "Oreslony czas przejazdu jest krótszy od surowego czasu jazdy: " + pt->ShowTime(nr_section);
if(a==1){Application->MessageBoxA(aa.c_str(),"B³¹d", MB_ICONWARNING);}
}
}
//---------------------------------------------------------------------------
void __fastcall TForm7::Button5Click(TObject *Sender)
{
Form1->Rozklad->RoundTimes();
ShowTimeTable(Form1->Rozklad,pt);
}
//---------------------------------------------------------------------------
void __fastcall TForm7::Button1Click(TObject *Sender)
{
try{
char myPath[_MAX_PATH+1];
GetModuleFileName(NULL,myPath,_MAX_PATH);
String path = AnsiString(myPath);
path = path.SubString(0,path.Length()-13)+"\\Reports\\";
SaveDialog1->InitialDir = path;
if(SaveDialog1->Execute()){
TStringList *wynik = new TStringList;
wynik = Form1 -> Rozklad -> FinalReport(pt);
wynik -> SaveToFile(SaveDialog1->FileName);
}
}
catch (...){
}
}
//---------------------------------------------------------------------------