currency.cpp
来自「一个以前收集的基于C/S架构的ERP客户端源代码」· C++ 代码 · 共 174 行
CPP
174 行
//---------------------------------------------------------------------------
#include <vcl.h>
#include "Currency.h"
//---------------------------------------------------------------------------
#pragma hdrstop
#pragma package(smart_init)
#pragma link "fpanel"
#pragma link "RecBaseForm"
#pragma link "SDEdit"
#pragma link "SDGrid"
#pragma link "SDComboBox"
#pragma resource "*.dfm"
TfrmCurrency *frmCurrency;
//---------------------------------------------------------------------------
void __fastcall TfrmCurrency::ClearControl(bool BringToNext)
{
if(!BringToNext)
{
seCode->Text = "";
seName->Text = "";
seSym->Text = "";
scPos->Text = "";
seAmtDec->Text = "0";
sePriceDec->Text = "0";
scCarry->Text = "";
cbLocal->Checked = false;
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmCurrency::GetDataFromComObject()
{
seCode->Text = GetFieldValue("CurrencyCode");
sgCurrency->LocateGrid(1,seCode->Text);
seName->Text = GetFieldValue("CurrencyName");
seSym->Text = GetFieldValue("CurrencySym");
scPos->LocateKey(GetFieldValue("CurrencyPos"));
scPos->Text =scPos->ItemData[0];
seAmtDec->Text = GetFieldValue("CurrencyAmtDec");
sePriceDec->Text = GetFieldValue("CurrencyPriceDec");
scCarry->LocateKey(GetFieldValue("CurrencyCarry"));
scCarry->Text =scCarry->ItemData[0];
cbLocal->Checked = (GetFieldValue("CurrencyLocal") == "1");
}
//---------------------------------------------------------------------------
void __fastcall TfrmCurrency::SendDataToComObject()
{
SetFieldValue("CurrencyCode",seCode->Text);
SetFieldValue("CurrencyName",seName->Text);
SetFieldValue("CurrencySym",seSym->Text);
SetFieldValue("CurrencyPos",scPos->ItemData[1]);
if(seAmtDec->Text.IsEmpty())
SetFieldValue("CurrencyAmtDec",("0"));
else
SetFieldValue("CurrencyAmtDec",seAmtDec->Text);
if(sePriceDec->Text.IsEmpty())
SetFieldValue("CurrencyPriceDec","0");
else
SetFieldValue("CurrencyPriceDec",sePriceDec->Text);
SetFieldValue("CurrencyCarry",scCarry->ItemData[1]);
SetFieldValue("CurrencyLocal",cbLocal->Checked ? "1":"0");
}
//---------------------------------------------------------------------------
void __fastcall TfrmCurrency::WaitUserInput()
{
seCode->SetFocus();
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmCurrency::GetDataToGrid()
{
AnsiString s;
s = "\t" + GetFieldValue("CurrencyCode") +
"\t" + GetFieldValue("CurrencyName") +
"\t" + GetFieldValue("CurrencyAmtDec") +
"\t" + GetFieldValue("CurrencyPriceDec");
return(s);
}
//---------------------------------------------------------------------------
void __fastcall TfrmCurrency::RefreshGridData(int mAction)
{
AnsiString ItemStr;
ItemStr = GetDataToGrid();
if (mAction == 0) //Add
{
sgCurrency->AddItem(ItemStr);
}
else if(mAction == 1) //Edit
{
int i = sgCurrency->Row;
sgCurrency->RemoveItem(i);
sgCurrency->AddItem(ItemStr,i);
}
else if(mAction == 2) //Del
{
sgCurrency->RemoveItem(sgCurrency->Row);
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmCurrency::FillGridWithData()
{
AnsiString ItemStr;
comServer->MoveFirst();
sgCurrency->RowCount = 1;
while (comServer->Eof == 0)
{
ItemStr = GetDataToGrid();
sgCurrency->AddItem(ItemStr);
comServer->MoveNext();
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmCurrency::InitEditControl()
{
ClientGroup->AddComponent(2,false,false,true, FloatPanel1,FloatPanel1->Name);
ClientGroup->AddComponent(2,true,true,false, sgCurrency,sgCurrency->Name);
ClientGroup->AddComponent(2,false,false,false,seCode,seCode->Name);
scPos->AddItems("首位","1");
scPos->AddItems("末位","2");
scCarry->AddItems("四舍五入","1");
scCarry->AddItems("取整","2");
scCarry->AddItems("向上取整","3");
}
//---------------------------------------------------------------------------
__fastcall TfrmCurrency::TfrmCurrency(TComponent* Owner, HWND chWnd, AnsiString MidCode,AnsiString WhereStr)
: TRecBaseForm(Owner,chWnd,MidCode,WhereStr)
{
}
//---------------------------------------------------------------------------
void __fastcall TfrmCurrency::FormClose(TObject *Sender,
TCloseAction &Action)
{
TRecBaseForm::FormClose(Sender,Action);
}
//---------------------------------------------------------------------------
void __fastcall TfrmCurrency::FormShow(TObject *Sender)
{
FillGridWithData();
comServer->MoveFirst();
GetDataFromComObject();
}
//---------------------------------------------------------------------------
void __fastcall TfrmCurrency::seCodeKeyDown(TObject *Sender, WORD &Key,
TShiftState Shift)
{
if(Key==13 && CurrentState==caNormal)
{
comServer->LocateByKey(seCode->Text);
GetDataFromComObject();
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmCurrency::sgCurrencyClick(TObject *Sender)
{
if (sgCurrency->Row > 0)
comServer->LocateByKey(sgCurrency->TextMatrix[sgCurrency->Row][1]);
if (!comServer->Eof)
GetDataFromComObject();
}
//-------------------------------------------------------
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?