OAM.CPP
上传用户:lvjun8202
上传日期:2013-04-30
资源大小:797k
文件大小:8k
- // OAM.cpp : Defines the class behaviors for the application.
- //
- #include "stdafx.h"
- #include "OAM.h"
- //#include "CmdTreeSetup.h"
- #include "MainFrm.h"
- #include "OAMDoc.h"
- //#include "OAMView.h"
- //#include "snmp_cwdmView.h"
- //#include "StaProDlg.h"
- #include "Splash.h"
- #include <locale.h>
- #include "CreditStatic.h"
- #include "CoolControlsManager.h"
- #include "Agent.h"
- #include "MainView.h"
- #include "loginDialog.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // COAMApp
- BEGIN_MESSAGE_MAP(COAMApp, CWinApp)
- //{{AFX_MSG_MAP(COAMApp)
- ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
- //}}AFX_MSG_MAP
- // Standard file based document commands
- // ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
- ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
- // Standard print setup command
- ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // COAMApp construction
- COAMApp::COAMApp()
- {
- // TODO: add construction code here,
- // Place all significant initialization in InitInstance
- }
- /////////////////////////////////////////////////////////////////////////////
- // The one and only COAMApp object
- COAMApp theApp;
- /////////////////////////////////////////////////////////////////////////////
- // COAMApp initialization
- BOOL COAMApp::InitInstance()
- {
-
-
- INITCOMMONCONTROLSEX icex;
- icex.dwSize = sizeof( icex );
- icex.dwICC = ICC_DATE_CLASSES | ICC_INTERNET_CLASSES;
- VERIFY( InitCommonControlsEx( &icex ) );
- AfxOleInit();
- AfxInitRichEdit();
- AfxEnableControlContainer();
- // Install the CoolControls
- GetCtrlManager().InstallHook(-1,TRUE);
-
- // CG: The following block was inserted by 'Status Bar' component.
- {
- //Set up date and time defaults so they're the same as system defaults
- setlocale(LC_ALL, "");
- }
- // CG: The following block was added by the Splash Screen component.
{
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
CSplashWnd::EnableSplashScreen(cmdInfo.m_bShowSplash);
}
- /* if (!AfxSocketInit())
- {
- AfxMessageBox(IDP_SOCKETS_INIT_FAILED);
- return FALSE;
- }*/
- AfxEnableControlContainer();
-
-
-
- /*connect database*/
- ////////////连接数据库//////////////
- HRESULT hr;
- try
- {
- hr = m_pConnection.CreateInstance("ADODB.Connection");///创建Connection对象
- if(SUCCEEDED(hr))
- {
- hr = m_pConnection->Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=test.mdb","","",adModeUnknown);///连接数据库
-
- }
- }
- catch(_com_error e)///捕捉异常
- {
- CString errormessage;
- errormessage.Format("连接数据库失败!rn错误信息:%s",e.ErrorMessage());
- AfxMessageBox(errormessage);///显示错误信息
- return FALSE;
- }
- #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(0); // 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.
- CLoginDialog dlg_login; /*登录*/
- if(dlg_login.DoModal()==IDCANCEL)
- {
- exit(0);
- }
- //
- CSingleDocTemplate* pDocTemplate;
- pDocTemplate = new CSingleDocTemplate(
- IDR_MAINFRAME,
- RUNTIME_CLASS(COAMDoc),
- RUNTIME_CLASS(CMainFrame), // main SDI frame window
- RUNTIME_CLASS(CMainView));
- AddDocTemplate(pDocTemplate);
- // Parse command line for standard shell commands, DDE, file open
- CCommandLineInfo cmdInfo;
- ParseCommandLine(cmdInfo);
- // 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_SHOW);//MAXIMIZED);
- m_pMainWnd->CenterWindow();
-
- if(::IsWindow(((CMainFrame*)m_pMainWnd)->m_wndReportBar.m_hWnd))
- ((CMainFrame*)m_pMainWnd)->m_wndReportBar.WriteReportLine("启动介质转换器管理系统", 0);
-
-
- ((CMainFrame*)m_pMainWnd)->m_wndReportBar.WriteReportLine("欢迎进入snmp管理系统", 0);
- ((CMainFrame*)m_pMainWnd)->m_wndReportBar.WriteReportLine("当前您登录的用户名为", 0);
- ((CMainFrame*)m_pMainWnd)->m_wndReportBar.WriteReportLine(dlg_login.m_user, 0);
- ((CMainFrame*)m_pMainWnd)->m_wndReportBar.WriteReportLine("*******************", 0);
-
- if (dlg_login.power=="超级用户") /*用于权限管理*/
- ((CMainFrame*)m_pMainWnd)->m_power= 1;
- else
- ((CMainFrame*)m_pMainWnd)->m_power=0;
- CAgent dlg;
- ((CMainFrame*)m_pMainWnd)->m_agent =dlg.m_agent;
- // DWORD IpAddress;
- if(dlg.DoModal()==IDCANCEL)
- {
- ((CMainFrame*)m_pMainWnd)->m_wndReportBar.WriteReportLine("请设置代理相应的信息", 0);
- }
- else
- {
-
-
- ((CMainFrame*)m_pMainWnd)->m_wndReportBar.WriteReportLine("当前管理代理设备ip", 0);
- ((CMainFrame*)m_pMainWnd)->m_wndReportBar.WriteReportLine(dlg.m_agent, 0);
- ((CMainFrame*)m_pMainWnd)->m_wndReportBar.WriteReportLine("当前管理社区标志", 0);
- ((CMainFrame*)m_pMainWnd)->m_wndReportBar.WriteReportLine(dlg.m_community, 0);
- ((CMainFrame*)m_pMainWnd)->m_agent =dlg.m_agent;
- ((CMainFrame*)m_pMainWnd)->m_community =dlg.m_community;
- if (!(dlg.m_agent)||!(dlg.m_community))
- ((CMainFrame*)m_pMainWnd)->m_wndReportBar.WriteReportLine("请输入代理设备的信息", 0);
- }
-
- return TRUE;
- }
- /////////////////////////////////////////////////////////////////////////////
- // CAboutDlg dialog used for App About
- class CAboutDlg : public CDialog
- {
- public:
- CAboutDlg();
- // Dialog Data
- //{{AFX_DATA(CAboutDlg)
- enum { IDD = IDD_ABOUTBOX };
- CCreditStatic m_wndCredit;
- //}}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)
- virtual BOOL OnInitDialog();
- //}}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)
- DDX_Control(pDX, IDC_STATIC_CREDIT, m_wndCredit);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
- //{{AFX_MSG_MAP(CAboutDlg)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- // App command to run the dialog
- void COAMApp::OnAppAbout()
- {
- CAboutDlg aboutDlg;
- aboutDlg.DoModal();
- }
- /////////////////////////////////////////////////////////////////////////////
- // COAMApp message handlers
- BOOL CAboutDlg::OnInitDialog()
- {
- CDialog::OnInitDialog();
-
- // TODO: Add extra initialization here
-
- m_wndCredit.SetCredits(IDS_CREDIT);
- m_wndCredit.SetSpeed(DISPLAY_SLOW);
- m_wndCredit.SetColor(BACKGROUND_COLOR, RGB(192,192,192));
- m_wndCredit.SetColor(NORMAL_TEXT_COLOR, RGB(0,0,255));
- m_wndCredit.StartScrolling();
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }
- int COAMApp::ExitInstance()
- {
- if(m_pConnection->State)
- m_pConnection->Close();
- return CWinApp::ExitInstance();
- }