📄 storequery.cpp
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "StoreQuery.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TfmStoreQuery *fmStoreQuery;
//---------------------------------------------------------------------------
__fastcall TfmStoreQuery::TfmStoreQuery(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TfmStoreQuery::FormCreate(TObject *Sender)
{
// 初始化仓库下拉选项
TQuery* pQuery = new TQuery(NULL);
pQuery->DatabaseName = "db";
pQuery->SQL->Clear();
pQuery->SQL->Add("select 仓库名 from 仓库清单");
pQuery->Open();
while(!pQuery->Eof)
{
cboStore->Items->Add(pQuery->FieldByName("仓库名")->AsString);
pQuery->Next();
}
pQuery->Close();
delete pQuery;
cboStore->Text = "";
edGoodCode->Text = "";
edGoodPY->Text = "";
}
//---------------------------------------------------------------------------
void __fastcall TfmStoreQuery::btQueryClick(TObject *Sender)
{
Query1->Filtered = false;
// 设置Query控件的filter属性可以起到查询条件的作用
AnsiString szCon;
if(edGoodCode->Text.Length()>0) szCon = "货号='" + edGoodCode->Text + "'";
if(edGoodPY->Text.Length()>0)
{
if(szCon.Length()>0 ) szCon += " and 拼音编码 = '" + edGoodPY->Text + "*'";
else szCon = "拼音编码 = '" + edGoodPY->Text + "*'";
}
if(cboStore->Text.Length()>0)
{
if(szCon.Length()>0 ) szCon += " and 仓库 = '" + cboStore->Text + "'";
else szCon = "仓库 = '" + cboStore->Text + "'";
}
Query1->Filter = szCon;
Query1->Filtered = true;
}
//---------------------------------------------------------------------------
void __fastcall TfmStoreQuery::FormClose(TObject *Sender,
TCloseAction &Action)
{
// 删除窗体并回收空间
Action = caFree;
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -