record.cpp

来自「for edge filter. yoy can combain the mat」· C++ 代码 · 共 71 行

CPP
71
字号
//---------------------------------------------------------------------------
#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 + =
减小字号Ctrl + -
显示快捷键?