📄 ptype.cpp
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Ptype.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "RecBaseForm"
#pragma link "fpanel"
#pragma link "SDEdit"
#pragma link "SDGrid"
#pragma resource "*.dfm"
TfrmPtype *frmPtype;
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmPtype::GetFieldValue(int FieldIndex)
{
WideString S;
S = ReadFieldValue(comServer,FieldIndex);
return(S);
}
//---------------------------------------------------------------------------
void __fastcall TfrmPtype::ClearControl(bool BringToNext)
{
if(BringToNext)
{
return;
}
sePtypeCode->Text = "";
sePtypeName->Text = "";
sePtypeDesc->Text = "";
}
//---------------------------------------------------------------------------
void __fastcall TfrmPtype::GetDataFromComObject()
{
sePtypeCode->Text = GetFieldValue(fiPTypeCode);
sgPtype->LocateGrid(1, GetFieldValue(fiPTypeCode));
sePtypeName->Text = GetFieldValue(fiPTypeName);
sePtypeDesc->Text = GetFieldValue(fiPTypeDesc);
}
//---------------------------------------------------------------------------
void __fastcall TfrmPtype::SendDataToComObject()
{
WriteFieldValue(comServer,fiPTypeCode,WideString(sePtypeCode->Text));
WriteFieldValue(comServer,fiPTypeName,WideString(sePtypeName->Text));
WriteFieldValue(comServer,fiPTypeDesc,WideString(sePtypeDesc->Text));
}
//---------------------------------------------------------------------------
void __fastcall TfrmPtype::WaitUserInput()
{
sePtypeCode->SetFocus();
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmPtype::GetDataToGrid()
{
AnsiString s;
s = "\t" + GetFieldValue(fiPTypeCode) +
"\t" + GetFieldValue(fiPTypeName) +
"\t" + GetFieldValue(fiPTypeDesc);
return(s);
}
//---------------------------------------------------------------------------
void __fastcall TfrmPtype::RefreshGridData(int mAction)
{
AnsiString ItemStr;
ItemStr = GetDataToGrid();
// 新增
if (mAction == 0)
{
sgPtype->AddItem(ItemStr);
}
// 修改
else if(mAction == 1)
{
int i = sgPtype->Row;
sgPtype->ChangeItem(ItemStr,i);
}
// 删除
else if(mAction == 2)
{
sgPtype->RemoveItem(sgPtype->Row);
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmPtype::FillGridWithData()
{
AnsiString ItemStr;
comServer->MoveFirst();
sgPtype->RowCount = 1;
while (comServer->Eof == 0)
{
ItemStr = GetDataToGrid();
sgPtype->AddItem(ItemStr);
comServer->MoveNext();
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmPtype::InitEditControl()
{
ClientGroup->AddComponent(2,true,true,false, sgPtype,sgPtype->Name);
ClientGroup->AddComponent(2,false,false,true, FloatPanel1,FloatPanel1->Name);
// ClientGroup->AddComponent(2,false,false,false, sePtypeCode,sePtypeCode->Name);
}
//---------------------------------------------------------------------------
__fastcall TfrmPtype::TfrmPtype(TComponent* Owner)
: TRecBaseForm(Owner,euSdPtype,"")
{
}
//---------------------------------------------------------------------------
void __fastcall TfrmPtype::FormClose(TObject *Sender, TCloseAction &Action)
{
TRecBaseForm::FormClose(Sender,Action);
//AnsiString FormIniFile = "D:\Test.Ini";
//WriteGridWidth(Name,sgPtype,FormIniFile);
}
//---------------------------------------------------------------------------
void __fastcall TfrmPtype::FormCreate(TObject *Sender)
{
//AnsiString FormIniFile="D:\Test.Ini";
//SetGridWidth(Name,sgPtype,FormIniFile);
}
//---------------------------------------------------------------------------
void __fastcall TfrmPtype::FormShow(TObject *Sender)
{
FillGridWithData();
comServer->MoveFirst();
GetDataFromComObject();
}
//---------------------------------------------------------------------------
void __fastcall TfrmPtype::sgPtypeClick(TObject *Sender)
{
int ARow=sgPtype->Row;
if (ARow > 0)
comServer->LocateByKey(WideString(sgPtype->TextMatrix[ARow][1]));
if (!comServer->Eof)
GetDataFromComObject();
}
//---------------------------------------------------------------------------
void __fastcall TfrmPtype::sePtypeCodeKeyDown(TObject *Sender, WORD &Key,
TShiftState Shift)
{
if(Key==13 && CurrentState==caNormal)
{
comServer->LocateByKey(WideString(sePtypeCode->Text));
GetDataFromComObject();
}
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -