📄 btht.cpp
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#include "Btht.h"
//---------------------------------------------------------------------------
#pragma hdrstop
#pragma package(smart_init)
#pragma link "fpanel"
#pragma link "RecBaseForm"
#pragma link "SDComboBox"
#pragma link "SDEdit"
#pragma link "SDGrid"
#pragma resource "*.dfm"
TfrmBtht *frmBtht;
//---------------------------------------------------------------------------
__fastcall TfrmBtht::TfrmBtht(TComponent* Owner)
: TRecBaseForm(Owner,euSdBtht,"")
{
}
//---------------------------------------------------------------------------
__fastcall TfrmBtht::TfrmBtht(TComponent* Owner,AnsiString LocCode,AnsiString GoodsCode)
: TRecBaseForm(Owner,euSdBtht,"")
{
ClearControl(false);
FLocCode=LocCode;
FGoodsCode=GoodsCode;
sgBtht->RowCount=1;
LabCurFmonth->Caption=g_sdIMonth;
LabBthtGoods->Caption=FGoodsCode;
if(g_sdRsGoods->LocateByKey(WideString(FGoodsCode))==0)
LabBthtGoodsName->Caption=GetGoodsValue("GoodsName");
scBthtLoc->LocateKey(FLocCode);
AnsiString FilStr="BthtFmonth='"+g_sdIMonth+"' and BthtGoods='"+FGoodsCode+"' and BthtLoc='"+FLocCode+"'";
comServer->FilterString=WideString(FilStr);
comServer->Query();
if(comServer->RecordCount>0)
{
FillGridWithData();
comServer->MoveFirst();
GetDataFromComObject();
}
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmBtht::GetFieldValue(int FieldIndex)
{
return ReadFieldValue(comServer,FieldIndex);
}
//---------------------------------------------------------------------------
void __fastcall TfrmBtht::SetFieldValue(int iFieldIndex,AnsiString sFieldValue)
{
WriteFieldValue(comServer,iFieldIndex,sFieldValue);
}
//---------------------------------------------------------------------------
void __fastcall TfrmBtht::ClearControl(bool BringToNext)
{
if(!BringToNext)
{
scBthtBatch->ItemIndex = -1;
seBthtBoyQty->Text = "0";
seBthtBopQty->Text = "0";
seBthtIopQty->Text = "0";
seBthtOopQty->Text = "0";
seBthtIoyQty->Text = "0";
seBthtOoyQty->Text = "0";
seBthtAoyQty->Text = "0";
cheBthtClose->Checked=false;
cheBthtInit->Checked=false;
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmBtht::GetDataFromComObject()
{
// scBthtLoc->LocateKey(GetFieldValue(fiBthtLoc));
scBthtBatch->LocateKey(GetFieldValue(fiBthtBatch));
seBthtBoyQty->Text = GetFieldValue(fiBthtBoyQty);
seBthtBopQty->Text = GetFieldValue(fiBthtBopQty);
seBthtIopQty->Text = GetFieldValue(fiBthtIopQty);
seBthtOopQty->Text = GetFieldValue(fiBthtOopQty);
seBthtIoyQty->Text = GetFieldValue(fiBthtIoyQty);
seBthtOoyQty->Text = GetFieldValue(fiBthtOoyQty);
seBthtAoyQty->Text = GetFieldValue(fiBthtAoyQty);
cheBthtInit->Checked=GetFieldValue(fiBthtInit)=="1";
if(cheBthtInit->Checked)
{
tbEditHead->Enabled=false;
tbDeleteHead->Enabled=false;
}
else
{
tbEditHead->Enabled=true;
tbDeleteHead->Enabled=true;
}
cheBthtClose->Checked=GetFieldValue(fiBthtClose)=="1";
}
//---------------------------------------------------------------------------
void __fastcall TfrmBtht::SendDataToComObject()
{
SetFieldValue(fiBthtFmonth,g_sdIMonth);
SetFieldValue(fiBthtGoods,FGoodsCode);
SetFieldValue(fiBthtLoc,FLocCode);
SetFieldValue(fiBthtBatch,scBthtBatch->ItemData[1]);
SetFieldValue(fiBthtBoyQty,seBthtBoyQty->Text);
SetFieldValue(fiBthtBopQty,seBthtBopQty->Text);
SetFieldValue(fiBthtIoyQty,seBthtIoyQty->Text);
SetFieldValue(fiBthtOopQty,seBthtOopQty->Text);
SetFieldValue(fiBthtInit,cheBthtInit->Checked?"1":"0");
}
//---------------------------------------------------------------------------
void __fastcall TfrmBtht::WaitUserInput()
{
scBthtBatch->SetFocus();
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmBtht::GetDataToGrid()
{
AnsiString tempS;
tempS = GetFieldValue(fiBthtBatch)+
"\t" + GetFieldValue(fiBthtBoyQty)+
"\t" + GetFieldValue(fiBthtBopQty);
return(tempS);
}
//---------------------------------------------------------------------------
void __fastcall TfrmBtht::RefreshGridData(int mAction)
{
AnsiString ItemStr;
ItemStr = GetDataToGrid();
GetDataFromComObject();
if(mAction == 0)
{
sgBtht->AddItem(ItemStr);
sgBtht->Row=sgBtht->RowCount-1;
}
else if(mAction == 1)
{
sgBtht->ChangeItem(ItemStr,sgBtht->Row);
}
else if(mAction == 2)
{
sgBtht->RemoveItem(sgBtht->Row);
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmBtht::FillGridWithData()
{
AnsiString ItemStr;
comServer->MoveFirst();
sgBtht->RowCount = 1;
while(comServer->Eof == 0)
{
ItemStr = GetDataToGrid();
sgBtht->AddItem(ItemStr);
comServer->MoveNext();
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmBtht::InitEditControl()
{
ClientGroup->AddComponent(2,false,false,true,fpBtht,fpBtht->Name);
ClientGroup->AddComponent(2,true,true,true,fpBtht1,fpBtht1->Name);
ClientGroup->AddComponent(2,true,true,true, scBthtLoc,scBthtLoc->Name);
ClientGroup->AddComponent(2,true,true,true, seBthtIopQty,seBthtIopQty->Name);
ClientGroup->AddComponent(2,true,true,true, seBthtOopQty,seBthtOopQty->Name);
ClientGroup->AddComponent(2,true,true,true, seBthtAoyQty,seBthtAoyQty->Name);
ClientGroup->AddComponent(2,true,true,true, cheBthtClose,cheBthtClose->Name);
ClientGroup->AddComponent(2,false,false,true, cheBthtInit,cheBthtInit->Name);
ClientGroup->AddComponent(2,true,true,false, sgBtht,sgBtht->Name);
FillComboBox(scBthtLoc,"select LocCode,memo=LocCode+space(1)+LocName from sdLoc where LocType=1 order by LocCode","memo","LocCode");
FillComboBox(scBthtBatch,"select BatchCode,memo=BatchCode+space(1)+BatchDesc from sdBatch order by BatchCode","memo","BatchCode");
}
//---------------------------------------------------------------------------
void __fastcall TfrmBtht::RefreshUpdateData(int MsgSrc,int MsgType)
{
try
{
switch (MsgSrc)
{
case euSdLoc:
if(ShowUpdateMessage(MsgSrc,MsgType)){
StartWaitForm("正在刷新引用数据!");
FillComboBox(scBthtLoc,"select LocCode,memo=LocCode+space(1)+LocName from sdLoc where LocType=1 order by LocCode","memo","LocCode");
EndWaitForm();
break;
}
case euSdBatch:
if(ShowUpdateMessage(MsgSrc,MsgType)){
StartWaitForm("正在刷新引用数据!");
FillComboBox(scBthtBatch,"select BatchCode,memo=BatchCode+space(1)+BatchDesc from sdBatch order by BatchCode","memo","BatchCode");
EndWaitForm();
break;
}
default:
break;
}
}
__finally
{
//AddCode;
}
}
//---------------------------------------------------------
void __fastcall TfrmBtht::FormClose(TObject *Sender, TCloseAction &Action)
{
TRecBaseForm::FormClose(Sender,Action);
/*
AnsiString FormIniFile = "D:\Test.Ini";
WriteGridWidth(Name,sgPg,FormIniFile);
*/
}
//---------------------------------------------------------------------------
void __fastcall TfrmBtht::FormCreate(TObject *Sender)
{
/*
AnsiString FormIniFile="D:\Test.Ini";
SetGridWidth(Name,sgPg,FormIniFile);
*/
}
//---------------------------------------------------------------------------
void __fastcall TfrmBtht::sgBthtClick(TObject *Sender)
{
int ARow;
ARow=sgBtht->Row;
if(ARow > 0)
{
AnsiString KeyStr=sgBtht->Cells[0][ARow]+LabCurFmonth->Caption
+FLocCode+LabBthtGoods->Caption;
comServer->LocateByKey(WideString(KeyStr));
}
if(!comServer->Eof)
GetDataFromComObject();
}
//---------------------------------------------------------------------------
void __fastcall TfrmBtht::muFirstClick(TObject *Sender)
{
if(sgBtht->RowCount > 1)
{
sgBtht->Row=1;
sgBthtClick(NULL);
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmBtht::muPreviousClick(TObject *Sender)
{
if(sgBtht->RowCount > 1 && sgBtht->Row > 1)
{
sgBtht->Row=sgBtht->Row-1;
sgBthtClick(NULL);
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmBtht::muNextClick(TObject *Sender)
{
if(sgBtht->RowCount > 1 && sgBtht->Row < sgBtht->RowCount-1)
{
sgBtht->Row=sgBtht->Row+1;
sgBthtClick(NULL);
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmBtht::muLastClick(TObject *Sender)
{
if(sgBtht->RowCount > 1)
{
sgBtht->Row=sgBtht->RowCount-1;
sgBthtClick(NULL);
}
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -