📄 shop.cpp
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#include "Shop.h"
//---------------------------------------------------------------------------
#pragma hdrstop
#pragma package(smart_init)
#pragma link "RecBaseForm"
#pragma link "fpanel"
#pragma link "SDComboBox"
#pragma link "SDEdit"
#pragma link "SDGrid"
#pragma resource "*.dfm"
TfrmShop *frmShop;
//---------------------------------------------------------------------------
__fastcall TfrmShop::TfrmShop(TComponent* Owner)
: TRecBaseForm(Owner,euSdShop,"")
{
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmShop::GetFieldValue(int iFieldIndex)
{
return ReadFieldValue(comServer,iFieldIndex);
}
//---------------------------------------------------------------------------
void __fastcall TfrmShop::SetFieldValue(int iFieldIndex,AnsiString sFieldValue)
{
WriteFieldValue(comServer,iFieldIndex,sFieldValue);
}
//---------------------------------------------------------------------------
void __fastcall TfrmShop::ClearControl(bool BringToNext)
{
if (!BringToNext)
{
seShopCode->Text="";
seShopName->Text="";
scShopDeptCode->ItemIndex=-1;
scShopDeptCode->Text="";
cbShopFitting->Checked=false;
cbShopAssis->Checked=false;
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmShop::WaitUserInput()
{
seShopCode->SetFocus();
}
//---------------------------------------------------------------------------
void __fastcall TfrmShop::InitEditControl()
{
ClientGroup->AddComponent(2,false,false,true, FloatPanel1,FloatPanel1->Name);
ClientGroup->AddComponent(2,true,true,false, sgShop,sgShop->Name);
FillComboBox(scShopDeptCode,"SELECT DeptCode,DeptName FROM sdDept where DeptEnd=1 order by DeptCode","DeptName","DeptCode");
}
//---------------------------------------------------------------------------
void __fastcall TfrmShop::RefreshUpdateData(int MsgSrc,int MsgType)
{
try
{
if(MsgSrc==euSdDept)
{
if(ShowUpdateMessage(MsgSrc,MsgType)){
StartWaitForm("正在刷新引用数据!");
FillComboBox(scShopDeptCode,"SELECT DeptCode,DeptName FROM sdDept where DeptEnd=1 order by DeptCode","DeptName","DeptCode");
EndWaitForm();
}
}
}
__finally
{
//AddCode;
}
}
//---------------------------------------------------------------------
void __fastcall TfrmShop::GetDataFromComObject()
{
seShopCode->Text=GetFieldValue(fiShopCode);
//MoveFirst,MovePrority,MoveNext,MoveLast
sgShop->LocateGrid(0,seShopCode->Text);
seShopName->Text=GetFieldValue(fiShopName);
scShopDeptCode->LocateKey(GetFieldValue(fiShopDeptCode));
cbShopFitting->Checked=(GetFieldValue(fiShopFitting)=="1");
cbShopAssis->Checked=(GetFieldValue(fiShopAssis)=="1");
}
//---------------------------------------------------------------------------
void __fastcall TfrmShop::SendDataToComObject()
{
SetFieldValue(fiShopCode,seShopCode->Text);
SetFieldValue(fiShopName,seShopName->Text);
SetFieldValue(fiShopDeptCode,scShopDeptCode->ItemData[cbItem2]);
SetFieldValue(fiShopFitting,cbShopFitting->Checked ? "1":"0");
SetFieldValue(fiShopAssis,cbShopAssis->Checked ? "1":"0");
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmShop::GetDataToGrid()
{
AnsiString s,s1;
s1 = GetFieldValue(fiShopDeptCode);
scShopDeptCode->LocateKey(s1);
s =GetFieldValue(fiShopCode)+
"\t"+GetFieldValue(fiShopName)+
"\t"+scShopDeptCode->ItemData[0];
return s;
}
//---------------------------------------------------------------------------
void __fastcall TfrmShop::RefreshGridData(int mAction)
{
AnsiString sGridItem;
sGridItem=GetDataToGrid();
switch(mAction)
{
case 0: //新增
sgShop->AddItem(sGridItem);
sgShop->Row=sgShop->RowCount-1;
break;
case 1: //修改
sgShop->ChangeItem(sGridItem,sgShop->Row);
break;
case 2: //删除
sgShop->RemoveItem(sgShop->Row);
}
}
//---------------------------------------------------------------
void __fastcall TfrmShop::FillGridWithData()
{
AnsiString ItemStr;
comServer->MoveFirst();
sgShop->RowCount=1;
while (comServer->Eof == 0)
{
ItemStr = GetDataToGrid();
sgShop->AddItem(ItemStr);
comServer->MoveNext();
}
}
//---------------------------------------------------------------
void __fastcall TfrmShop::FormShow(TObject *Sender)
{
if(comServer->RecordCount>0)
{
FillGridWithData();
comServer->MoveFirst();
GetDataFromComObject();
}
else
{
ClearControl(false);
sgShop->RowCount=1;
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmShop::FormCreate(TObject *Sender)
{
FormIniFile="D:\Test.Ini";
SetGridWidth(Name,sgShop,FormIniFile);
}
//---------------------------------------------------------------------------
void __fastcall TfrmShop::FormClose(TObject *Sender, TCloseAction &Action)
{
TRecBaseForm::FormClose(Sender,Action);
WriteGridWidth(Name,sgShop,FormIniFile);
}
//---------------------------------------------------------------------------
void __fastcall TfrmShop::sgShopClick(TObject *Sender)
{
int ARow;
ARow=sgShop->Row;
if(ARow > 0)
comServer->LocateByKey(sgShop->TextMatrix[ARow][0]);
if(!comServer->Eof)
GetDataFromComObject();
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -