?? unit3.cpp
字號:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit3.h"
#include "Unit1.h"
#include "Unit4.h"
#include "Info.h"
#include "stdio.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm3 *Form3;
extern CInfo m_info;
//---------------------------------------------------------------------------
__fastcall TForm3::TForm3(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm3::Button1Click(TObject *Sender)
{
long phonenumber;
int RecordCount = ListBox1->Items->Count;
int runcount = 0;
for (int i=0;i<RecordCount;i++ )
{
if(ListBox1->Selected[i] == true)
runcount++;
}
int *selected = new int[runcount];
int j=0;
for (int i=0;i<RecordCount;i++ )
{
if(ListBox1->Selected[i] == true)
selected[j++] = StrToInt(ListBox1->Items->Strings[i]);
}
for (int i=0;i<runcount;i++ )
{
Form1->Table1->Insert();
Form4->Table1->EditKey();
Form4->Table1->FieldByName("車號")->AsString = IntToStr(selected[i]);
Form4->Table1->GotoKey();
//Form1->Table1->Fields->FieldByName("ID")->Value =times+i;
Form1->Table1->Fields->FieldByName("車號")->Value = Form4->Table1->Fields->FieldByName("車號")->Value;
Form1->Table1->Fields->FieldByName("手機(jī)號")->Value = Form4->Table1->Fields->FieldByName("手機(jī)號")->Value;
phonenumber = Form1->Table1->Fields->FieldByName("手機(jī)號")->Value;
Form1->Table1->Fields->FieldByName("工號")->Value = Form4->Table1->Fields->FieldByName("工號")->Value;
if (RadioButton1->Checked)
Form1->Table1->Fields->FieldByName("前進(jìn)方向")->Value = "起點(diǎn)站" ;
else if (RadioButton2->Checked)
Form1->Table1->Fields->FieldByName("前進(jìn)方向")->Value = "終點(diǎn)站" ;
Form1->Table1->Post();
//向圖上點(diǎn)入公車信息
IMoRectangleDisp r,s;
IMoPointDisp testPt,point;
IMoSymbolDisp sym;
IMoTrackingLayerDisp tl;
IMoPointPtr point1 = (IDispatch*)CreateOleObject("MapObjects2.Point"); //終點(diǎn)站
IMoPointPtr point2 = (IDispatch*)CreateOleObject("MapObjects2.Point"); //起點(diǎn)站
IMoGeoEventDisp evt;
int nEventCounter;
int i;
tl=Form1->Map1->TrackingLayer;
sym = tl->get_Symbol(0);
TFont* stdFont;
_di_IFontDisp olefont;
stdFont = new TFont();
stdFont->Name = "Wingdings";
GetOleFont(stdFont, olefont);
delete stdFont;
sym->Font = (IDispatch*)olefont;
//sym->SymbolType = moPointSymbol;
sym->Style = moTrueTypeMarker;
sym->CharacterIndex = 81;
sym->Size = 12;
sym->Color = moRed;
point=Form1->Map1->ToMapPoint(300,300);
point1->set_X(120.152713682682);
point1->set_Y(30.2620975160097);
point2->set_X(120.200639167317);
point2->set_Y(30.2728341605917);
if (RadioButton1->Checked)
{
tl.AddEvent(point1,0);
char buffer[22];
sprintf(buffer,"0571%ld",phonenumber);
m_info.AddMobile(buffer);
}
else if (RadioButton2->Checked)
{
tl.AddEvent(point2,0);
char buffer[22];
sprintf(buffer,"0571%ld",phonenumber);
m_info.AddMobile(buffer);
}
}
times = times+runcount;
ListBox1->Clear();
ListBuses();
}
//---------------------------------------------------------------------------
void __fastcall TForm3::Button2Click(TObject *Sender)
{
Form4->Table1->Close();
Form4->Table1->Open();
int RecordCount = ListBox1->Items->Count;
for (int i=0;i<RecordCount;i++ )
ListBox1->Selected[i] = true;
}
//---------------------------------------------------------------------------
void __fastcall TForm3::FormShow(TObject *Sender)
{
/*Form4->Table1->Close();
Form4->Table1->Open();
int j;
int RecordCount = Form4->Table1->RecordCount;
for (int i=0;i<RecordCount;i++ )
{
Form1->Table1->Close();
Form1->Table1->Open();
for ( j=0;j<Form1->Table1->RecordCount;j++ )
if (Form4->Table1->Fields->FieldByName("車號")->Value==Form1->Table1->Fields->FieldByName("車號")->Value)
break;
else
Form1->Table1->Next();
if (j==Form1->Table1->RecordCount)
{
ListBox1->Items->Add(Form4->Table1->Fields->FieldByName("車號")->Value);
}
Form4->Table1->Next();
} */
ListBuses();
}
//---------------------------------------------------------------------------
void __fastcall TForm3::FormClose(TObject *Sender, TCloseAction &Action)
{
ListBox1->Clear();
}
//---------------------------------------------------------------------------
void __fastcall TForm3::ListBuses()
{
Form4->Table1->Close();
Form4->Table1->Open();
int j;
int RecordCount = Form4->Table1->RecordCount;
for (int i=0;i<RecordCount;i++ )
{
Form1->Table1->Close();
Form1->Table1->Open();
for ( j=0;j<Form1->Table1->RecordCount;j++ )
if (Form4->Table1->Fields->FieldByName("車號")->Value==Form1->Table1->Fields->FieldByName("車號")->Value)
break;
else
Form1->Table1->Next();
if (j==Form1->Table1->RecordCount)
{
ListBox1->Items->Add(Form4->Table1->Fields->FieldByName("車號")->AsString);
}
Form4->Table1->Next();
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -