📄 controlbase.cpp
字号:
//---------------------------------------------------------------------------
#pragma hdrstop
#include "ControlBase.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
//---------------------------------------------------------------------------
// 提示对话框
//---------------------------------------------------------------------------
//编写时间: 2002.07.18
//说明:提示对话框
//作者:李舸
//---------------------------------------------------------------------------
bool __fastcall MsgYN(String sText,String sCaption)
{
bool bRetVal;
bRetVal =Application->MessageBox(sText.c_str(),sCaption.c_str(),MB_OKCANCEL+MB_ICONINFORMATION)==ID_OK;
return bRetVal;
}
//---------------------------------------------------------------------------
//编写日期: 2002.10.8
//作者:李舸
//作用:根据传入的Query 和SQL语句生成结果值
bool __fastcall OpenSQL(TADOQuery * Query,String sSQL)
{
bool bRetVal;
try
{
bRetVal = false;
if(sSQL.IsEmpty())
{
Query->Active = false;
Query->Prepared = true;
Query->Active = true;
bRetVal = true;
}
else
{
Query->DisableControls();
Query->Active=false;
Query->Close();
Query->SQL->Clear();
Query->SQL->Add(sSQL);
Query->Prepared = true;
Query->Open();
Query->EnableControls();
bRetVal=true;
}
return bRetVal;
}
catch(...)
{
return bRetVal;
}
}
//-----------------------------------------------------------------------------
//编写日期: 2002.10.23
//作者:李舸
//作用:无事务操作,sSQL执行
bool __fastcall ExecSQL_Tra(TADOConnection * Connection,String sSQL)
{
bool bRetVal;
TADOQuery * Query;
try
{
Query = new TADOQuery(Application);
bRetVal = false;
if(Connection == NULL)
{
MsgShow("Connection is NULL!");
return bRetVal;//没有成功查询
}
Query->DisableControls();
Query->Connection = Connection;
Query->Close();
Query->SQL->Clear(); //李舸添加 2002。10。10
Query->SQL->Add(sSQL);
Query->Prepared = true;
Query->ExecSQL();
Query->EnableControls();
if(Query!=NULL) {delete Query;Query = NULL;}
bRetVal = true;
return bRetVal;
}
catch(...)
{
if(Query!=NULL) {delete Query;Query = NULL;}
return bRetVal;
}
}
//---------------------------------------------------------------------------
//编写时间: 2002.07.18
//说明:显示对话框
//例如: MsgShow("sfs");
void __fastcall MsgShow(String sText,String sCaption)
{
Application->MessageBox(sText.c_str(),sCaption.c_str(),MB_OK+MB_ICONEXCLAMATION);
}
//---------------------------------------------------------------------------
//编写日期: 2002.8.8
//作用:根据传入的Connection 和SQL语句生成结果值,取出最大值类型为String
bool __fastcall sMaxSQL(TADOConnection * Connection,const String sSQL,String &sMax)
{
bool bRetVal;
TADOQuery * Query;
try
{
bRetVal = false;
Query = new TADOQuery(Application);
if(Connection == NULL)
{
MsgShow("Connection is NULL!");
return bRetVal;//没有成功查询
}
Query->Connection = Connection;
Query->SQL->Add(sSQL);
Query->Prepared = true;
Query->Open();
if(Query->Fields->Fields[0]->IsNull)
{
sMax = "" ;
}
else
{
sMax = Query->Fields->Fields[0]->AsString;
}
if(Query!=NULL) {delete Query;Query = NULL;}
bRetVal = true;
return bRetVal;
}
catch(...)
{
if(Query!=NULL) {delete Query;Query = NULL;}
return bRetVal;
}
}
//编写日期: 2002.8.8
//作用:读取注册表信息获得程序路径
String __fastcall ReturnPath()
{
TRegistry *Reg;
Reg = new TRegistry; //新建一个注册类;
Reg->RootKey = HKEY_CURRENT_USER;
String RegPath;
try
{
String sKeyName = "\\Software\\Microsoft\\Shell Explorer\\";
sKeyName = sKeyName+"shell";
Reg->OpenKey(sKeyName,true);
RegPath=Reg->ReadString("Path");
return RegPath;
}
catch(...)
{
Application->MessageBox("注册表路径不正确!", "提示", MB_OK );
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -