📄 record.cpp
字号:
//---------------------------------------------------------------------------
#include "Record.h"
BaseRecord::BaseRecord()
{
Table=new TTable(NULL);// free the Table object until delete record object
}
//---------------------------------------------------------------------------
/*
Create a new table
NOte: The existence table will be update
Usage:
BaseField A[]={
{"test",(TFieldType)3,0,false},
NULL
};
BaseRecord Table;
Table.CreateTable("Result","NewTable",A);
*/
void BaseRecord::CreateTable(char *argDataBaseName,char *argTableName,BaseField argField[])
{
Table->DatabaseName=argDataBaseName;
Table->TableName=argTableName;
Table->Active = false; // The Table component must not be active
Table->FieldDefs->Clear(); //delete all fields
// Adding the fields
int i=0;
while(argField[i].Name!=NULL)
{
Table->FieldDefs->Add(argField[i].Name,argField[i].Type,argField[i].S,argField[i].Required);
i++;
}
Table->CreateTable();
Table->Open();
}
/*
Open a existence Table
*/
BaseRecord::BaseRecord(char *argDataBaseName,char *argTableName)
{
Table=new TTable(NULL);// free the Table object until delete record object
Table->DatabaseName=argDataBaseName;
Table->TableName=argTableName;
Table->Open();
}
/*
Quick method
Usage:
BaseRecord *BR=CreateIntTable("Result");
InsertInt(BR->Table,12345);
*/
BaseRecord* CreateIntTable(char *argDataBaseName)
{
BaseField Fields[]={
{"IntData",ftInteger,0,false},
NULL
};
BaseRecord *Table=new BaseRecord();
Table->CreateTable(argDataBaseName,"IntTable",Fields);
return Table;
}
void InsertInt(TTable *Table,int argDATA)
{
Table->Insert();
Table->FieldByName("IntData")->Value=argDATA;
Table->Post();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -