pay.cpp

来自「C++ Builder数据库开发经典案例解析 示例程序都是在C++ Build」· C++ 代码 · 共 75 行

CPP
75
字号
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "pay.h"
#include "paymoney.h"

//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TfmPay *fmPay;
//---------------------------------------------------------------------------
__fastcall TfmPay::TfmPay(TComponent* Owner)
    : TForm(Owner)
{
    Edit1->Text = "";
    Edit2->Text = "";
    Edit3->Text = "";
    Edit4->Text = "";
}
//---------------------------------------------------------------------------
void __fastcall TfmPay::btSeekClick(TObject *Sender)
{
    AnsiString sql;
    sql = "select a.*,b.姓名,b.性别 from 门诊划价 as a, 门诊挂号 as b ";
    sql += " where a.挂号编号=b.编号 and a.是否收费='否'";
    AnsiString szFilter = "";
    if(Edit1->Text.Length()>0)
        szFilter = " and 编号 like '" + Edit1->Text + "%'";
    if(Edit2->Text.Length()>0)
    {
        szFilter += " and 姓名 like '" + Edit2->Text + "%'";
    }
    if(Edit3->Text.Length()>0)
    {
        szFilter += " and 划价时间 >= '" + Edit3->Text + "'";
    }
    if(Edit4->Text.Length()>0)
    {
        if(szFilter.Length()>0)
            szFilter += " and ";
        szFilter += " and 划价时间 <= '" + Edit4->Text + "'";
    }
    sql += szFilter;
    Query1->SQL->Clear();
    Query1->SQL->Add(sql);
    Query1->Close();
    Query1->Open();
}
//---------------------------------------------------------------------------
void __fastcall TfmPay::btSaveClick(TObject *Sender)
{
    TfmPayMoney* pForm = new TfmPayMoney(NULL);
    pForm->SetID(Query1->FieldByName("编号")->AsString);
    pForm->ShowModal();
    delete pForm;
    // 刷新显示
    btSeekClick(NULL);
}
//---------------------------------------------------------------------------
void __fastcall TfmPay::FormClose(TObject *Sender, TCloseAction &Action)
{
    // 删除窗体并回收空间
    Action = caFree;
}
//---------------------------------------------------------------------------

void __fastcall TfmPay::btExitClick(TObject *Sender)
{
    Close();
}
//---------------------------------------------------------------------------

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?