StoreQuery.cpp
上传用户:tangpei45
上传日期:2013-07-14
资源大小:9104k
文件大小:2k
- //---------------------------------------------------------------------------
- #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;
- }
- //---------------------------------------------------------------------------