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

📄 unit2.cpp

📁 本书所有案例均需要单独配置
💻 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 + -