📄 paymode.cpp
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#include "PayMode.h"
//---------------------------------------------------------------------------
#pragma hdrstop
#pragma package(smart_init)
#pragma link "RecBaseForm"
#pragma link "fpanel"
#pragma link "SDEdit"
#pragma link "SDGrid"
#pragma resource "*.dfm"
TfrmPayMode *frmPayMode;
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmPayMode::GetFieldValue(int FieldIndex)
{
WideString S;
S = ReadFieldValue(comServer,FieldIndex);
return(S);
}
//---------------------------------------------------------------------------
void __fastcall TfrmPayMode::ClearControl(bool BringToNext)
{
if(!BringToNext)
{
sePayModeCode->Text = "";
sePayModeName->Text = "";
memPayModeDesc->Text = "";
sePayModeTerm->Text = "0";
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmPayMode::GetDataFromComObject()
{
sePayModeCode->Text = GetFieldValue(fiPayModeCode);
sgPayMode->LocateGrid(1,sePayModeCode->Text);
sePayModeName->Text = GetFieldValue(fiPayModeName);
memPayModeDesc->Text = GetFieldValue(fiPayModeDesc);
sePayModeTerm->Text = GetFieldValue(fiPayModeTerm);
}
//---------------------------------------------------------------------------
void __fastcall TfrmPayMode::SendDataToComObject()
{
WriteFieldValue(comServer,fiPayModeCode,sePayModeCode->Text);
WriteFieldValue(comServer,fiPayModeName,sePayModeName->Text);
WriteFieldValue(comServer,fiPayModeDesc,memPayModeDesc->Text);
WriteFieldValue(comServer,fiPayModeTerm,sePayModeTerm->Text);
}
//---------------------------------------------------------------------------
void __fastcall TfrmPayMode::WaitUserInput()
{
sePayModeCode->SetFocus();
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmPayMode::GetDataToGrid()
{
AnsiString s;
s = "\t" + GetFieldValue(fiPayModeCode) +
"\t" + GetFieldValue(fiPayModeName) ;
return(s);
}
//---------------------------------------------------------------------------
void __fastcall TfrmPayMode::RefreshGridData(int mAction)
{
AnsiString ItemStr;
ItemStr = GetDataToGrid();
if (mAction == 0) //Add
{
sgPayMode->AddItem(ItemStr);
}
else if(mAction == 1) //Edit
{
int i = sgPayMode->Row;
sgPayMode->RemoveItem(i);
sgPayMode->AddItem(ItemStr,i);
}
else if(mAction == 2)//Del
{
sgPayMode->RemoveItem(sgPayMode->Row);
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmPayMode::FillGridWithData()
{
AnsiString ItemStr;
comServer->MoveFirst();
sgPayMode->RowCount = 1;
while (comServer->Eof == 0)
{
ItemStr = GetDataToGrid();
sgPayMode->AddItem(ItemStr);
comServer->MoveNext();
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmPayMode::InitEditControl()
{
ClientGroup->AddComponent(2,false,false,true, FloatPanel1,FloatPanel1->Name);
ClientGroup->AddComponent(2,true,true,false, sgPayMode,sgPayMode->Name);
ClientGroup->AddComponent(2,false,false,false,sePayModeCode,sePayModeCode->Name);
}
//---------------------------------------------------------------------------
__fastcall TfrmPayMode::TfrmPayMode(TComponent* Owner)
: TRecBaseForm(Owner,euSdPayMode,"")
{
}
//---------------------------------------------------------------------------
void __fastcall TfrmPayMode::FormShow(TObject *Sender)
{
comServer->MoveFirst();
GetDataFromComObject();
FillGridWithData();
}
//---------------------------------------------------------------------------
void __fastcall TfrmPayMode::sePayModeCodeKeyDown(TObject *Sender,
WORD &Key, TShiftState Shift)
{
if(Key==13 && CurrentState==caNormal)
{
comServer->LocateByKey(sePayModeCode->Text);
GetDataFromComObject();
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmPayMode::sgPayModeClick(TObject *Sender)
{
if (sgPayMode->Row > 0)
comServer->LocateByKey(sgPayMode->TextMatrix[sgPayMode->Row][1]);
if (!comServer->Eof)
GetDataFromComObject();
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -