📄 fof.cpp
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Fof.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "RecBaseForm"
#pragma link "fpanel"
#pragma link "SDEdit"
#pragma link "SDGrid"
#pragma link "SDComboBox"
#pragma resource "*.dfm"
TfrmFof *frmFof;
//---------------------------------------------------------------------------
__fastcall TfrmFof::TfrmFof(TComponent* Owner)
: TRecBaseForm(Owner,euSdFof,"")
{
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmFof::GetFieldValue(int iFieldIndex)
{
AnsiString S;
S=ReadFieldValue(comServer,iFieldIndex);
return S;
}
AnsiString __fastcall TfrmFof::GetDataToGrid()
{
AnsiString s;
s = "\t" +GetFieldValue(fiFofField) +
"\t" +GetFieldValue(fiFofForm);
return (s);
}
//------------------------------------------------------------------------------
void __fastcall TfrmFof::InitEditControl()
{
ClientGroup->AddComponent(2,false,false,true, FloatPanel1,FloatPanel1->Name);
ClientGroup->AddComponent(2,true,true,false, sgFof,sgFof->Name);
FillComboBox(scFofField,"Select FieldName+FieldDesc memo,FieldName,FieldDesc from sdField where FieldAutoNo=1 order by FieldName","memo","FieldName","FieldDesc");
FillComboBox(scFofForm,"select Formname+FormCaption Memo,Formname,FormCaption from sdForm where FormType=1 order by FormID","memo","FormName","FormCaption");
}
//------------------------------------------------------------------------------
void __fastcall TfrmFof::ClearControl(bool BringToNext)
{
if (!BringToNext)
{
scFofField->Text="";
scFofField->ItemIndex=-1;
scFofForm->Text="";
scFofForm->ItemIndex=-1;
}
}
//------------------------------------------------------------------------------
void __fastcall TfrmFof::WaitUserInput()
{
scFofField->SetFocus();
}
//------------------------------------------------------------------------------
void __fastcall TfrmFof::GetDataFromComObject()
{
scFofField->LocateKey(GetFieldValue(fiFofField));
scFofForm->LocateKey(GetFieldValue(fiFofForm));
sgFof->LocateGrid(2,GetFieldValue(fiFofForm));
}
//------------------------------------------------------------------------------
void __fastcall TfrmFof::SendDataToComObject()
{
WriteFieldValue(comServer,fiFofField,scFofField->ItemData[1]);
WriteFieldValue(comServer,fiFofForm,scFofForm->ItemData[1]);
}
//------------------------------------------------------------------------------
void __fastcall TfrmFof::RefreshGridData(int mAction)
{
AnsiString sGridItem;
sGridItem=GetDataToGrid();
int i;
switch(mAction)
{
case 0: //新增
sgFof->AddItem(sGridItem);
break;
case 1: //修改
i = sgFof->Row;
sgFof->ChangeItem(sGridItem,i);
break;
case 2: //删除
sgFof->RemoveItem(sgFof->Row);
} ;
}
//-------------------------------------------------------
void __fastcall TfrmFof::FillGridWithData()
{
AnsiString ItemStr;
comServer->MoveFirst();
sgFof->RowCount = 1;
while (comServer->Eof == 0)
{
ItemStr = GetDataToGrid();
sgFof->AddItem(ItemStr);
comServer->MoveNext();
}
}
void __fastcall TfrmFof::FormShow(TObject *Sender)
{
FillGridWithData();
comServer->MoveFirst();
GetDataFromComObject();
}
//---------------------------------------------------------------------------
void __fastcall TfrmFof::sgFofClick(TObject *Sender)
{
int ARow=sgFof->Row;
if (ARow > 0)
comServer->LocateByKey(WideString(sgFof->TextMatrix[ARow][1]+sgFof->TextMatrix[ARow][2]));
if (!comServer->Eof)
GetDataFromComObject();
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -