?? unit2.cpp
字號:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit2.h"
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm2 *Form2;
extern CInfo m_info;
//---------------------------------------------------------------------------
__fastcall TForm2::TForm2(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm2::FormShow(TObject *Sender)
{
Form1->Table1->Close();
Form1->Table1->Open();
int RecordCount = Form1->Table1->RecordCount;
for (int i=0;i<RecordCount;i++ )
{
ListBox1->Items->Add(Form1->Table1->Fields->FieldByName("車號")->Value);
Form1->Table1->Next();
}
}
//---------------------------------------------------------------------------
void __fastcall TForm2::FormClose(TObject *Sender, TCloseAction &Action)
{
ListBox1->Clear();
}
//---------------------------------------------------------------------------
void __fastcall TForm2::Button2Click(TObject *Sender)
{
Form1->Table1->Close();
Form1->Table1->Open();
int RecordCount = Form1->Table1->RecordCount;
for (int i=0;i<RecordCount;i++ )
{ ListBox1->Selected[i] = true; }
}
//---------------------------------------------------------------------------
void __fastcall TForm2::Button1Click(TObject *Sender)
{
char* phonenumber;
int stopcount=0;
int RecordCount = Form1->Table1->RecordCount;
for (int i=0;i<RecordCount;i++ )
{
if(ListBox1->Selected[i] == true)
stopcount++;
}
int *selected = new int[stopcount];
int j=0;
for (int i=0;i<RecordCount;i++ )
{
if(ListBox1->Selected[i] == true)
selected[j++] = StrToInt(ListBox1->Items->Strings[i]);
}
Form1->Table1->Edit();
for (int i=0;i<stopcount;i++ )
{
int jj;
TLocateOptions Opts;
Opts.Clear();
Opts<<loCaseInsensitive;
Variant test;
test = Variant(selected[i]);
/* for ( jj = 0;jj<Form1->Table1->RecordCount;jj++)
{ Form1->Table1->Close();
Form1->Table1->Open();
if (Form1->Table1->Fields->FieldByName("車號")->AsInteger != selected[i])
Form1->Table1->Next();
else break;
} */
if(Form1->Table1->Locate("車號",test,Opts))
{
int id = Form1->Table1->RecNo-1;
phonenumber = (Form1->Table1->Fields->FieldByName("手機號")->AsString).c_str();
Form1->Table1->Delete();
//Form1->Table1->Post();
//在圖上消去公車信息
IMoTrackingLayerDisp tl;
tl=Form1->Map1->TrackingLayer;
//if (tl.EventCount >0)
tl.RemoveEvent(id);
m_info.RemoveMobile(phonenumber);
// ListBox1->Clear();
// ListBuses();
// long kk = Form1->Map1->TrackingLayer->EventCount;
Form1->Map1->TrackingLayer->Refresh(false);
}
}
// long ll = Form1->Map1->TrackingLayer->EventCount;
ListBox1->Clear();
ListBuses();
}
//---------------------------------------------------------------------------
void __fastcall TForm2::ListBuses()
{
Form1->Table1->Close();
Form1->Table1->Open();
int RecordCount = Form1->Table1->RecordCount;
for (int i=0;i<RecordCount;i++ )
{
ListBox1->Items->Add(Form1->Table1->Fields->FieldByName("車號")->Value);
Form1->Table1->Next();
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -