当前位置导航:炫浪网>>网络学院>>编程开发>>C++教程>>C++ Builder教程

TList,AnsiString和DynamicArray的妙用

  System::AnsiString LabPath=ExtractFilePath(\".\\\\\");
   TIniFile *LabIni=new TIniFile(LabPath+\"LabIni.ini\");

void myList::ReadList(AnsiString TS)
{
   System::AnsiString LabPath=ExtractFilePath(\".\\\\\");
   TIniFile *LabIni=new TIniFile(LabPath+\"LabIni.ini\");

   Form2->AddList();
   for(int i=0;i<Form2->LabelList->Count;i++)
    {
       TLabel *Lab;
       Lab=(TLabel *)Form2->LabelList->Items[i];
       Lab->Left=LabIni->ReadInteger(TS,\"Left\"+IntToStr(i), Lab->Left);
       Lab->Top=LabIni->ReadInteger(TS,\"Top\"+IntToStr(i),Lab->Top);
    }
}

//----------------------------------------------------------------------------
void myList::WriteList(AnsiString TS)
{
   System::AnsiString LabPath=ExtractFilePath(\".\\\\\");
   TIniFile *LabIni=new TIniFile(LabPath+\"LabIni.ini\");
   Form2->AddList();
   for(int i=0;i<Form2->LabelList->Count;i++)
    {
       TLabel *Lab;
       Lab=(TLabel *)Form2->LabelList->Items[i];
       LabIni->WriteInteger(TS,\"Left\"+IntToStr(i), Lab->Left);
       LabIni->WriteInteger(TS,\"Top\"+IntToStr(i),Lab->Top);
    }
}

file://----------------------------------------------------------------------------------------------------

struct mySEL {
  AnsiString PRUNO;
  int TOT_STK;//总进货
  int STK_PIN;//进货件数
  int STK_PBK;//退货件数
  int STK_PCS;//库存件数
  int STK_SAL;//销售件数
  int STK_PNT;//进货订货件数
  int STK_PONT;//销售订货件数
};
DynamicArray<mySEL>mySELArraymySELArray.Length=Query->RecordCount;
for(Query->First();!Query->Eof;Query->Next())
    {
      if(T){
         mySELArray[i].STK_SAL=Query->FieldByName(\"SAL\")->AsInteger;
         mySELArray[i].STK_PCS=Query->FieldByName(\"PCS\")->AsInteger;
         mySELArray[i].PRUNO=Query->FieldByName(\"PRUNO\")->AsString;
         }
      else
      {mySELArray[i].STK_PONT=Query->FieldByName(\"PNT\")->AsInteger;
         mySELArray[i].PRUNO=Query->FieldByName(\"PRUNO\")->AsString;
      }
    }

相关内容
赞助商链接