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

📄 maindm.cpp

📁 醫院管理 還不錯 醫院管理 還不錯 醫院管理 還不錯
💻 CPP
字号:
//---------------------------------------------------------------------------

#include <vcl.h>
#include <inifiles.hpp>
#pragma hdrstop

#include "MainDm.h"
#include "LogonFrm.h"
#include "TableManFrm.h"
#include "ConstUnt.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TdmMain *dmMain;
//---------------------------------------------------------------------------
__fastcall TdmMain::TdmMain(TComponent* Owner)
        : TDataModule(Owner)
{}
//---------------------------------------------------------------------------
void __fastcall TdmMain::DataModuleCreate(TObject *Sender)
{
    tagDBConnPara DBConn;
    TIniFile * pIniFile;
    String strCurPath = ExtractFilePath(ParamStr(0));

    pIniFile = new TIniFile(strCurPath + "syscfg.ini");
    DBConn.strDB = pIniFile->ReadString("normal", "db", "");
    delete pIniFile;

    AnsiString strConn;
    //Connect string
    // SQL:    SQLOLEDB.1
    // ACCESS: Microsoft.Jet.OLEDB.4.0;
    //
    char * pszConn = "Provider=Microsoft.Jet.OLEDB.4.0;"
                     "Password=\"\";"
                     "Persist Security Info=True;"
                     "Data Source=%s";
    strConn.sprintf(pszConn, DBConn.strDB);
#ifdef _DEBUB

    ShowMessage(strConn);
#endif

    cnnDB->ConnectionString = strConn;
    try
    {
        cnnDB->Connected = true;
#if 1

        frmLogon = new TfrmLogon(this);
        if (mrOk == frmLogon->ShowModal())
        {}
        else
        {
            Application->Terminate();
        }

#else
        cnnDB->Connected = true;
        frmTableMan = new TfrmTableMan(this);
        if (mrOk == frmTableMan->ShowModal())
        {}
        else
        {
            Application->Terminate();
        }
#endif

    }

    catch (const Exception &E)
    {
        MessageBox(NULL, "数据库连接失败,请检查系统配置!",
                   "警告", MB_OK | MB_ICONWARNING);
        Application->Terminate();
    }


}
//---------------------------------------------------------------------------


bool TdmMain::OpenClientInfo(AnsiString strCondition)
{
    TADOQuery * qryEx = qryClientInfo;

    qryEx->Close();
    qryEx->SQL->Clear();
    qryEx->SQL->Add("select Id,Name,(iif(Sex=0,'男','女')) as Sex,"
                    "Birth,PlaceOfBirth,MaritalStatus,Profession,Department,"
                    "SuprName,EmployeeNo,Height,Weight,Zip,Addr,Tele,EmergencyName,"
                    "EmergencyTele, Remark from EmployeeInf");

    qryEx->SQL->Add(strCondition);
    //ShowMessage(qryEx->SQL->Text);
    qryEx->Open();

    return true;
}

bool TdmMain::DeleteEmployee(int nEmployeeId)
{
    TADOQuery * qryEx = qrySQLPlus;

    qryEx->SQL->Clear();
    qryEx->SQL->Add("delete from EmployeeInf where id=" + IntToStr(nEmployeeId));
    qryEx->ExecSQL();

    qryClientInfo->Close();
    qryClientInfo->Open();
    
    return true;
}















⌨️ 快捷键说明

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