⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 storequery.cpp

📁 一个简单的企业进销存管理系统,对于新手学习c++builder很有帮助的,用的是BC++6.0,数据库是sql server 2000
💻 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 + -