📄 qdmanage.cpp
字号:
// QDManage.cpp : Defines the class behaviors for the application.
//
#include "stdafx.h"
#include "QDManage.h"
#include "MainFrm.h"
#include "QDManageDoc.h"
// include for varialbe in CQDManageView
// DlgMUSer中成员变量需要用到的定义
#include "gridctrl.h"
#include "OdbcDBGridFILE.h"
#include "TabSheet.h"
#include "DlgMUser.h"
#include "DlgMDepart.h"
#include "DlgTerminal.h"
#include "DlgMEvent.h"
#include "SimpleTime.h" //use in DlgMLoginout.h
#include "DlgMLoginout.h"
#include "QDManageView.h"
#include "DlgLog.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CQDManageApp
BEGIN_MESSAGE_MAP(CQDManageApp, CWinApp)
//{{AFX_MSG_MAP(CQDManageApp)
ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
// Standard print setup command
ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CQDManageApp construction
CQDManageApp::CQDManageApp()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
}
/////////////////////////////////////////////////////////////////////////////
// The one and only CQDManageApp object
CQDManageApp theApp;
/////////////////////////////////////////////////////////////////////////////
// CQDManageApp initialization
BOOL CQDManageApp::InitInstance()
{
if (!AfxSocketInit())
{
AfxMessageBox(IDP_SOCKETS_INIT_FAILED);
return FALSE;
}
AfxEnableControlContainer();
// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need.
#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif
// Change the registry key under which our settings are stored.
// TODO: You should modify this string to be something appropriate
// such as the name of your company or organization.
SetRegistryKey(_T("Local AppWizard-Generated Applications"));
LoadStdProfileSettings(); // Load standard INI file options (including MRU)
// Register the application's document templates. Document templates
// serve as the connection between documents, frame windows and views.
CSingleDocTemplate* pDocTemplate;
pDocTemplate = new CSingleDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(CQDManageDoc),
RUNTIME_CLASS(CMainFrame), // main SDI frame window
RUNTIME_CLASS(CQDManageView));
AddDocTemplate(pDocTemplate);
// Parse command line for standard shell commands, DDE, file open
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
//////////////////
// 打开数据库
CDlgLog DlgLog;
CString strConn;
do
{
if(DlgLog.DoModal() == IDOK)
{
m_User = DlgLog.m_LogDlgUser;
m_key = DlgLog.m_LogDlgKey;
}
else
{
_exit(0);
}
//"ODBC;DSN=%s;UID=%s;PWD=%s", m_strSource, m_strUser, m_strPass
strConn.Format("ODBC;DSN=QDSQLDataBase;UID=%s;PWD=%s", m_User, m_key);
}while(!m_DBDisplay.Open(strConn));
m_DBUser.Open(strConn);
m_DBTerminal.Open(strConn);
m_DBDepartment.Open(strConn);
m_DBEvent.Open(strConn);
m_DBEventType.Open(strConn);
m_DBEventFile.Open(strConn);
m_RSDeparment.m_pDatabase = &m_DBDepartment;
m_RSEvent.m_pDatabase = &m_DBEvent;
m_RSEventType.m_pDatabase = &m_DBEventType;
m_RSTerminal.m_pDatabase = &m_DBTerminal;
m_RSUser.m_pDatabase = &m_DBUser;
m_RSDeparment.Open();
m_RSEvent.Open();
m_RSEventType.Open();
m_RSTerminal.Open();
m_RSUser.Open();
//////////////
// ImageList
HICON hIcon[5];
int n;
m_ImageList.Create(22,22,0,6,0);
hIcon[SV_USER] = AfxGetApp()->LoadIcon(IDI_USER);
hIcon[SV_DEPART] = AfxGetApp()->LoadIcon(IDI_DEPART);
hIcon[SV_TERMINAL] = AfxGetApp()->LoadIcon(IDI_TERMINAL);
hIcon[SV_SHEARCH_EVENT] = AfxGetApp()->LoadIcon(IDI_SHEARCH_EVENT);
hIcon[SV_SHEARCH_LOGINOUT] = AfxGetApp()->LoadIcon(IDI_SHEARCH_LOGINOUT);
for(n = 0; n < 5; n++)
m_ImageList.Add(hIcon[n]);
// Dispatch commands specified on the command line
if (!ProcessShellCommand(cmdInfo))
return FALSE;
// The one and only window has been initialized, so show and update it.
// m_pMainWnd->ShowWindow(SW_SHOWMAXIMIZED);
m_pMainWnd->ShowWindow(SW_SHOWNORMAL);
m_pMainWnd->UpdateWindow();
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
// No message handlers
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
// App command to run the dialog
void CQDManageApp::OnAppAbout()
{
CAboutDlg aboutDlg;
aboutDlg.DoModal();
}
/////////////////////////////////////////////////////////////////////////////
// CQDManageApp message handlers
DWORD strToIP(const char *str)
{
DWORD IP = 0;
BYTE part = 0; /* example 192.168.2.14(192 or 168 or 2 or 14 is a part) */
for(;*str;str++)
{
if(*str == '.')
{
IP <<= 8;
IP += part;
part = 0;
}
else
{
if(*str <= '9' && *str >= '0')
{
part *= 10;
part += *str - '0';
}
}
}
IP <<= 8;
IP += part;
return IP;
}
// str buf >=16, exampel 192.168.2.14 to c0a8020e
void IPToStr(CString *pstr,DWORD IP)
{
BYTE part; // example 192.168.2.14(192 or 168 or 2 or 14 is a part)
int iPart;
CString partstr;
*pstr = "";
for(iPart = 3;;)
{
part = (BYTE)(IP>>(8 * iPart));
partstr.Format("%d",part);
*pstr += partstr;
if(iPart == 0) // VC6 有编译bug,这里iPart被认为是UNIT型,不能使用iPart < 0
break;
iPart--;
*pstr += ".";
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -