📄 sampleproduct.cpp
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "SampleProduct.h"
#include "MainHead.h"
#include "DataModule.h"
#include "SampleProductRep.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TSampleProductForm *SampleProductForm;
//---------------------------------------------------------------------------
__fastcall TSampleProductForm::TSampleProductForm(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void TSampleProductForm::UpdateBitBtnState(TObject *Sender)
{
BitBtnInsert->Enabled =MastData->ProductSampleSource->State == dsBrowse;
BitBtnDelete->Enabled = MastData->ProductSampleSource->State == dsBrowse;
BitBtnPost->Enabled = MastData->ProductSampleSource->State == dsEdit ||
MastData->ProductSampleSource->State == dsInsert;
BitBtnCancel->Enabled = BitBtnPost->Enabled;
// BitBtnNext->Enabled=!BitBtnPost->Enabled;
// BitBtnPrior->Enabled=!BitBtnPost->Enabled;
BitBtnClose->Enabled=!BitBtnPost->Enabled;
BitBtnSearch->Enabled=!BitBtnPost->Enabled;
// MainMenuForm->UpdateMenu();
}
//----------------------------------------------------------------------
void __fastcall TSampleProductForm::SampleProductStateChange(TObject *Sender)
{
UpdateBitBtnState(Sender);
}
//---------------------------------------------------------------------------
void __fastcall TSampleProductForm::FormShow(TObject *Sender)
{
MastData->ProductSampleSource->OnStateChange =SampleProductStateChange;
MastData->ProductSample->Open();
MastData->ProductSample->Last();
SampleProductStateChange(Sender);
}
//---------------------------------------------------------------------------
void __fastcall TSampleProductForm::BitBtnSearchClick(TObject *Sender)
{
FindProductSampleForm->ShowModal();
if (FindProductSampleForm->ModalResult == mrOk)
{
MastData->ProductSample->CachedUpdates=false;
MastData->ProductSample->GotoCurrent(MastData->SampleNoLookup);
MastData->ProductSample->CachedUpdates=true;
}
}
//---------------------------------------------------------------------------
void __fastcall TSampleProductForm::FormClose(TObject *Sender,
TCloseAction &Action)
{
Action=caFree;
}
//---------------------------------------------------------------------------
void __fastcall TSampleProductForm::BitBtnPostClick(TObject *Sender)
{
MastData->ProductSample->Post();
}
//---------------------------------------------------------------------------
void __fastcall TSampleProductForm::BitBtnCancelClick(TObject *Sender)
{
MastData->ProductSample->Cancel();
}
//---------------------------------------------------------------------------
void __fastcall TSampleProductForm::BitBtn1Click(TObject *Sender)
{
if(MastData->ProductSampleDetail->Eof)
{
MastData->PartNoLookup->Open();
MastData->PartNoLookup->IndexName="PartNo";
if(MastData->PartNoLookup->FindKey(OPENARRAY(TVarRec,(Trim(MastData->ProductSamplePartNo->Value))))) //if(MastData->PartNoLookup->FindKey(&q, 0))
{
MastData->MIBaseLookup->Close();
MastData->MIBaseLookup->IndexName="PartNo";
MastData->MIBaseLookup->Open();
MastData->MIBaseLookup->First();
MastData->MIBaseLookup->GotoCurrent(MastData->PartNoLookup);
MastData->MIRouteLookup->Open();
MastData->MIRouteLookup->First();
while(!MastData->MIRouteLookup->Eof)
{
MastData->ProductSampleDetail->Append();
MastData->ProductSampleDetail->Edit();
MastData->ProductSampleDetailItemNo->Value=MastData->MIRouteLookupRouteNo->Value;
MastData->ProductSampleDetailRouteCode->Value=MastData->MIRouteLookupRouteCode->Value;
MastData->ProductSampleDetail->Post();
MastData->MIRouteLookup->Next();
}
}
else
{
Application->MessageBox("无此产品编号需要的流程信息","警告",MB_OK);
}
}
}
//---------------------------------------------------------------------------
void __fastcall TSampleProductForm::BitBtnInsertClick(TObject *Sender)
{
MastData->ProductSample->Insert();
}
//---------------------------------------------------------------------------
void __fastcall TSampleProductForm::BitBtnDeleteClick(TObject *Sender)
{
MastData->ProductSample->Delete();
}
//---------------------------------------------------------------------------
void __fastcall TSampleProductForm::BitBtnRefreshClick(TObject *Sender)
{
MastData->ProductSample->Refresh();
}
//---------------------------------------------------------------------------
void __fastcall TSampleProductForm::PreviewBtnClick(TObject *Sender)
{
SampleProductRepForm->QuickRep1->Preview();
}
//---------------------------------------------------------------------------
void __fastcall TSampleProductForm::PrintBtnClick(TObject *Sender)
{
SampleProductRepForm->QuickRep1->Print();
}
//---------------------------------------------------------------------------
void __fastcall TSampleProductForm::FormCloseQuery(TObject *Sender,
bool &CanClose)
{
if(BitBtnPost->Enabled)
{
if(MessageBox(NULL,"样板生产资料没有存盘,是否保存?", "警告", MB_YESNO) == IDYES)
MastData->ProductSampleAfterPost(MastData->ProductSample);
else
MastData->ProductSampleAfterCancel(MastData->ProductSample);
}
CanClose=true;
}
//---------------------------------------------------------------------------
void __fastcall TSampleProductForm::FormActivate(TObject *Sender)
{
MastData->ProductSampleSource->OnStateChange =SampleProductStateChange;
}
//---------------------------------------------------------------------------
void __fastcall TSampleProductForm::FormDeactivate(TObject *Sender)
{
MastData->ProductSampleSource->OnStateChange =NULL;
}
//---------------------------------------------------------------------------
void __fastcall TSampleProductForm::DBGrid1KeyPress(TObject *Sender,
char &Key)
{
int index;
if(int(Key)==13)
{
if(ActiveControl==DBGrid1)
{
index=DBGrid1->SelectedIndex;
DBGrid1->SelectedIndex=DBGrid1->SelectedIndex+1;
}
if(index==DBGrid1->SelectedIndex)
{
DBGrid1->SelectedIndex=0;
}
Key=char(0);
}
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -