📄 pptt.cpp
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#include "Pptt.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"
TfrmPptt *frmPptt;
//---------------------------------------------------------------------------
__fastcall TfrmPptt::TfrmPptt(TComponent* Owner)
: TRecBaseForm(Owner,euSdPptt,"")
{
}
//---------------------------------------------------------------------------
__fastcall TfrmPptt::TfrmPptt(TComponent* Owner,AnsiString LocCode,AnsiString GoodsCode)
: TRecBaseForm(Owner,euSdPptt,"")
{
sgPptt->RowCount=1;
FLocCode=LocCode;
FGoodsCode=GoodsCode;
tbAddHead->Visible=false;
tbDeleteHead->Visible=false;
LabCurFmonth->Caption=g_sdIMonth;
LabPpttGoods->Caption=FGoodsCode;
if(g_sdRsGoods->LocateByKey(WideString(FGoodsCode))==0)
LabPpttGoodsName->Caption=GetGoodsValue("GoodsName");
LabPpt1->Caption=g_sdProperty1Name+":";
LabPpt2->Caption=g_sdProperty2Name+":";
sgPptt->Cells[0][0]=g_sdProperty1Name;
sgPptt->Cells[1][0]=g_sdProperty2Name;
AnsiString FilStr="PpttFmonth='"+g_sdIMonth+"' and PpttGoods='"+FGoodsCode+"' and PpttLoc='"+FLocCode+"'";
comServer->FilterString=WideString(FilStr);
comServer->Query();
if(comServer->RecordCount>0)
{
FillGridWithData();
comServer->MoveFirst();
GetDataFromComObject();
}
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmPptt::GetFieldValue(int FieldIndex)
{
return ReadFieldValue(comServer,FieldIndex);
}
//---------------------------------------------------------------------------
void __fastcall TfrmPptt::SetFieldValue(int iFieldIndex,AnsiString sFieldValue)
{
WriteFieldValue(comServer,iFieldIndex,sFieldValue);
}
//---------------------------------------------------------------------------
void __fastcall TfrmPptt::ClearControl(bool BringToNext)
{
if(!BringToNext)
{
sePptt1ID->Text = "";
sePptt2ID->Text = "";
scPpttLoc->ItemIndex = -1;
sePpttBoyQty->Text = "0";
sePpttBopQty->Text = "0";
sePpttIopQty->Text = "0";
sePpttOopQty->Text = "0";
sePpttIoyQty->Text = "0";
sePpttOoyQty->Text = "0";
sePpttAoyQty->Text = "0";
chePpttClose->Checked=false;
chePpttInit->Checked=false;
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmPptt::GetDataFromComObject()
{
sePptt1ID->Text = GetFieldValue(fiPptt1ID);
sePptt2ID->Text = GetFieldValue(fiPptt2ID);
scPpttLoc->LocateKey(GetFieldValue(fiPpttLoc));
sePpttBoyQty->Text = GetFieldValue(fiPpttBoyQty);
sePpttBopQty->Text = GetFieldValue(fiPpttBopQty);
sePpttIopQty->Text = GetFieldValue(fiPpttIopQty);
sePpttOopQty->Text = GetFieldValue(fiPpttOopQty);
sePpttIoyQty->Text = GetFieldValue(fiPpttIoyQty);
sePpttOoyQty->Text = GetFieldValue(fiPpttOoyQty);
sePpttAoyQty->Text = GetFieldValue(fiPpttAoyQty);
chePpttInit->Checked=GetFieldValue(fiPpttInit)=="1";
if(chePpttInit->Checked)
tbEditHead->Enabled=false;
else
tbEditHead->Enabled=true;
chePpttClose->Checked=GetFieldValue(fiPpttClose)=="1";
}
//---------------------------------------------------------------------------
void __fastcall TfrmPptt::SendDataToComObject()
{
SetFieldValue(fiPpttBoyQty,sePpttBoyQty->Text);
SetFieldValue(fiPpttBopQty,sePpttBopQty->Text);
SetFieldValue(fiPpttIoyQty,sePpttIoyQty->Text);
SetFieldValue(fiPpttOoyQty,sePpttOoyQty->Text);
SetFieldValue(fiPpttInit,chePpttInit->Checked?"1":"0");
}
//---------------------------------------------------------------------------
void __fastcall TfrmPptt::WaitUserInput()
{
sePpttBoyQty->SetFocus();
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmPptt::GetDataToGrid()
{
AnsiString tempS;
tempS = GetFieldValue(fiPptt1ID)+
"\t" + GetFieldValue(fiPptt2ID)+
"\t" + GetFieldValue(fiPpttLoc)+
"\t" + GetFieldValue(fiPpttBoyQty)+
"\t" + GetFieldValue(fiPpttBopQty);
return(tempS);
}
//---------------------------------------------------------------------------
void __fastcall TfrmPptt::RefreshGridData(int mAction)
{
AnsiString ItemStr;
ItemStr = GetDataToGrid();
GetDataFromComObject();
if(mAction == 0)
{
sgPptt->AddItem(ItemStr);
sgPptt->Row=sgPptt->RowCount-1;
}
else if(mAction == 1)
{
sgPptt->ChangeItem(ItemStr,sgPptt->Row);
}
else if(mAction == 2)
{
sgPptt->RemoveItem(sgPptt->Row);
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmPptt::FillGridWithData()
{
AnsiString ItemStr;
comServer->MoveFirst();
sgPptt->RowCount = 1;
while(comServer->Eof == 0)
{
ItemStr = GetDataToGrid();
sgPptt->AddItem(ItemStr);
comServer->MoveNext();
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmPptt::InitEditControl()
{
ClientGroup->AddComponent(2,false,false,true,fpPptt,fpPptt->Name);
ClientGroup->AddComponent(2,true,true,true,fpPptt1,fpPptt1->Name);
ClientGroup->AddComponent(2,true,true,true, sePptt1ID,sePptt1ID->Name);
ClientGroup->AddComponent(2,true,true,true, sePptt2ID,sePptt2ID->Name);
ClientGroup->AddComponent(2,true,true,true, sePpttIopQty,sePpttIopQty->Name);
ClientGroup->AddComponent(2,true,true,true, sePpttOopQty,sePpttOopQty->Name);
ClientGroup->AddComponent(2,true,true,true, sePpttAoyQty,sePpttAoyQty->Name);
ClientGroup->AddComponent(2,true,true,true, chePpttClose,chePpttClose->Name);
ClientGroup->AddComponent(2,true,false,true, chePpttInit,chePpttInit->Name);
ClientGroup->AddComponent(2,true,true,false, sgPptt,sgPptt->Name);
FillComboBox(scPpttLoc,"select LocCode,memo=LocCode+space(1)+LocName from sdLoc where LocType=1 order by LocCode","memo","LocCode");
}
//---------------------------------------------------------------------------
void __fastcall TfrmPptt::RefreshUpdateData(int MsgSrc,int MsgType)
{
try
{
switch (MsgSrc)
{
case euSdLoc:
if(ShowUpdateMessage(MsgSrc,MsgType)){
StartWaitForm("正在刷新引用数据!");
FillComboBox(scPpttLoc,"select LocCode,memo=LocCode+space(1)+LocName from sdLoc where LocType=1 order by LocCode","memo","LocCode");
EndWaitForm();
break;
}
}
}
__finally
{
//
}
}
//---------------------------------------------------------
void __fastcall TfrmPptt::FormClose(TObject *Sender, TCloseAction &Action)
{
TRecBaseForm::FormClose(Sender,Action);
/*
AnsiString FormIniFile = "D:\Test.Ini";
WriteGridWidth(Name,sgPg,FormIniFile);
*/
}
//---------------------------------------------------------------------------
void __fastcall TfrmPptt::FormCreate(TObject *Sender)
{
/*
AnsiString FormIniFile="D:\Test.Ini";
SetGridWidth(Name,sgPg,FormIniFile);
*/
}
//---------------------------------------------------------------------------
void __fastcall TfrmPptt::FormShow(TObject *Sender)
{
ClearControl(false);
}
//---------------------------------------------------------------------------
void __fastcall TfrmPptt::sgPpttClick(TObject *Sender)
{
int ARow;
ARow=sgPptt->Row;
if(ARow > 0)
{
AnsiString KeyStr=sgPptt->Cells[0][ARow]+sgPptt->Cells[1][ARow]+LabCurFmonth->Caption
+sgPptt->Cells[2][ARow]+LabPpttGoods->Caption;
comServer->LocateByKey(WideString(KeyStr));
}
if(!comServer->Eof)
GetDataFromComObject();
}
//---------------------------------------------------------------------------
void __fastcall TfrmPptt::muFirstClick(TObject *Sender)
{
if(sgPptt->RowCount > 1)
{
sgPptt->Row=1;
sgPpttClick(NULL);
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmPptt::muPreviousClick(TObject *Sender)
{
if(sgPptt->RowCount > 1 && sgPptt->Row > 1)
{
sgPptt->Row=sgPptt->Row-1;
sgPpttClick(NULL);
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmPptt::muNextClick(TObject *Sender)
{
if(sgPptt->RowCount > 1 && sgPptt->Row < sgPptt->RowCount-1)
{
sgPptt->Row=sgPptt->Row+1;
sgPpttClick(NULL);
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmPptt::muLastClick(TObject *Sender)
{
if(sgPptt->RowCount > 1)
{
sgPptt->Row=sgPptt->RowCount-1;
sgPpttClick(NULL);
}
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -