⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unit3.cpp

📁 本书所有案例均需要单独配置
💻 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("手机号")->Value =  Form4->Table1->Fields->FieldByName("手机号")->Value;
        phonenumber = Form1->Table1->Fields->FieldByName("手机号")->Value;
        Form1->Table1->Fields->FieldByName("工号")->Value =  Form4->Table1->Fields->FieldByName("工号")->Value;
        if (RadioButton1->Checked)
          Form1->Table1->Fields->FieldByName("前进方向")->Value = "起点站" ;
        else if (RadioButton2->Checked)
          Form1->Table1->Fields->FieldByName("前进方向")->Value = "终点站" ;

        Form1->Table1->Post();



   //向图上点入公车信息
       IMoRectangleDisp r,s;
       IMoPointDisp testPt,point;
       IMoSymbolDisp sym;


       IMoTrackingLayerDisp tl;

       IMoPointPtr point1 = (IDispatch*)CreateOleObject("MapObjects2.Point"); //终点站
       IMoPointPtr point2 = (IDispatch*)CreateOleObject("MapObjects2.Point"); //起点站
       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();
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -