?? softdocsystemdlg.cpp
字號:
// SoftDocSystemDlg.cpp : implementation file
//
#include "stdafx.h"
#include "SoftDocSystem.h"
#include "SoftDocSystemDlg.h"
#include "DlgProxy.h"
#include "Custom.h"
#include "Manager.h"
#include "DlgProxy.h"
#include "Chat.h"
#include "Custom.h"
#include "MemberIn.h"
#include "ChangeKey.h"
#include "ChangeUsrInfo.h"
#include "MovieIn.h"
#include "PassWord.h"
#include "StateReport.h"
#include "PublicQuery.h"
#include "SoftDelete.h"
#include "SoftDocCh.h"
#include "StartWindow.h"
#include "ViewDialogRec.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
extern int PublicUserType;
extern CString PublicUserName;
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)
//}}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()
/////////////////////////////////////////////////////////////////////////////
// CSoftDocSystemDlg dialog
IMPLEMENT_DYNAMIC(CSoftDocSystemDlg, CDialog);
CSoftDocSystemDlg::CSoftDocSystemDlg(CWnd* pParent /*=NULL*/)
: CDialog(CSoftDocSystemDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CSoftDocSystemDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
m_pAutoProxy = NULL;
}
CSoftDocSystemDlg::~CSoftDocSystemDlg()
{
// If there is an automation proxy for this dialog, set
// its back pointer to this dialog to NULL, so it knows
// the dialog has been deleted.
if (m_pAutoProxy != NULL)
m_pAutoProxy->m_pDialog = NULL;
}
void CSoftDocSystemDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CSoftDocSystemDlg)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CSoftDocSystemDlg, CDialog)
//{{AFX_MSG_MAP(CSoftDocSystemDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_WM_CLOSE()
ON_BN_CLICKED(IDC_BUTTON5, OnManager)
ON_BN_CLICKED(IDC_BUTTON1, OnSoftInWare)
ON_BN_CLICKED(IDC_BUTTON3, OnSoftDocCh)
ON_BN_CLICKED(IDC_BUTTON7, OnBorrowReturn)
ON_BN_CLICKED(IDC_BUTTON13, OnCustom)
ON_BN_CLICKED(IDC_BUTTON6, OnHelp)
ON_BN_CLICKED(IDC_BUTTON9, OnNewId)
ON_BN_CLICKED(IDC_BUTTON14, OnStateReport)
ON_BN_CLICKED(IDC_BUTTON11, OnPublicQuery)
ON_BN_CLICKED(IDC_BUTTON12, OnChat)
ON_BN_CLICKED(IDC_BUTTON2, OnNewUser)
ON_BN_CLICKED(IDC_BUTTON15, OnPrivate)
ON_BN_CLICKED(IDC_BUTTON17, OnDateLog)
ON_BN_CLICKED(IDC_BUTTON4, OnOperationRecord)
ON_BN_CLICKED(IDC_BUTTON10, OnChageKey)
ON_BN_CLICKED(IDC_BUTTON18, OnAbandonDoc)
ON_BN_CLICKED(IDC_BUTTON8, OnCancel)
ON_BN_CLICKED(IDC_BUTTON16, OnSetDataSource)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSoftDocSystemDlg message handlers
BOOL CSoftDocSystemDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
InitButton();
return TRUE; // return TRUE unless you set the focus to a control
}
void CSoftDocSystemDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CSoftDocSystemDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CSoftDocSystemDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
// Automation servers should not exit when a user closes the UI
// if a controller still holds on to one of its objects. These
// message handlers make sure that if the proxy is still in use,
// then the UI is hidden but the dialog remains around if it
// is dismissed.
void CSoftDocSystemDlg::OnClose()
{
if (CanExit())
CDialog::OnClose();
}
void CSoftDocSystemDlg::OnOK()
{
if (CanExit())
CDialog::OnOK();
}
void CSoftDocSystemDlg::OnCancel()
{
if (CanExit())
CDialog::OnCancel();
}
BOOL CSoftDocSystemDlg::CanExit()
{
// If the proxy object is still around, then the automation
// controller is still holding on to this application. Leave
// the dialog around, but hide its UI.
if (m_pAutoProxy != NULL)
{
ShowWindow(SW_HIDE);
return FALSE;
}
return TRUE;
}
void CSoftDocSystemDlg::OnManager()
{
// TODO: Add your control notification handler code here
CManager dlg;
this->ShowWindow(SW_HIDE);
dlg.DoModal ();
this->ShowWindow (SW_SHOW);
}
void CSoftDocSystemDlg::OnSoftInWare()
{
// TODO: Add your control notification handler code here
CMovieIn dlg;
this->ShowWindow(SW_HIDE);
dlg.DoModal ();
this->ShowWindow (SW_SHOW);
}
void CSoftDocSystemDlg::OnSoftDocCh()
{
// TODO: Add your control notification handler code here
CSoftDocCh dlg;
this->ShowWindow(SW_HIDE);
dlg.DoModal ();
this->ShowWindow (SW_SHOW);
}
void CSoftDocSystemDlg::OnBorrowReturn()
{
// TODO: Add your control notification handler code here
CSoftDocSystemApp* myApp=(CSoftDocSystemApp*)AfxGetApp();
_bstr_t source("Provider=sqloledb;Data Source=;Integrated Security='SSPI';Initial Catalog=SoftDocument;User Id=;Password=;");
_bstr_t user=myApp->ConnectUser;
_bstr_t pwd=myApp->ConnectPwd;
//Databaxe Initialled
try{
TESTHR(m_DBCnt.CreateInstance(_uuidof(Connection)));
TESTHR(m_DBCnt->Open(source, user, pwd, 16));
}
catch (_com_error &e){
MessageBox(e.ErrorMessage());
MessageBox("數據緣初始化失敗!");
return;
}
// m_strSource = (char * )source;
//
int choice=AfxMessageBox("你將清楚全部操作日志,日志將不可恢復,確定刪除嗎?",MB_OKCANCEL|MB_ICONEXCLAMATION);
if(choice==IDOK){//清除操作日志
_bstr_t strSQL("TRUNCATE TABLE DateLog");
try{
m_DBCnt->Execute(strSQL,NULL,adCmdText);
}
catch(_com_error &e){
AfxMessageBox(e.ErrorMessage ());return;
}
AfxMessageBox("管理員,操作日志已成功刪除,請進行下一步操作!");
}
m_DBCnt->Close();
}
void CSoftDocSystemDlg::OnCustom()
{
// TODO: Add your control notification handler code here
CChangeUsrInfo dlg;
this->ShowWindow(SW_HIDE);
dlg.DoModal ();
this->ShowWindow (SW_SHOW);
}
void CSoftDocSystemDlg::OnHelp()
{
// TODO: Add your control notification handler code here
CAboutDlg dlg;
this->ShowWindow(SW_HIDE);
dlg.DoModal ();
this->ShowWindow (SW_SHOW);
}
void CSoftDocSystemDlg::OnNewId()
{
// TODO: Add your control notification handler code here
CPassWord dlg;
this->ShowWindow (SW_HIDE);
if(dlg.DoModal ()==IDOK){
this->ShowWindow(SW_SHOW);
switch(PublicUserType){
case 1:
{GetDlgItem(IDC_BUTTON1)->EnableWindow(true);
GetDlgItem(IDC_BUTTON3)->EnableWindow(true);
GetDlgItem(IDC_BUTTON7)->EnableWindow(true);
GetDlgItem(IDC_BUTTON18)->EnableWindow(true);
GetDlgItem(IDC_BUTTON5)->EnableWindow(true);
GetDlgItem(IDC_BUTTON12)->EnableWindow(true);
GetDlgItem(IDC_BUTTON14)->EnableWindow(true);
GetDlgItem(IDC_BUTTON15)->EnableWindow(false);
GetDlgItem(IDC_BUTTON13)->EnableWindow(true);
break;}
case 2:
{GetDlgItem(IDC_BUTTON1)->EnableWindow(false);
GetDlgItem(IDC_BUTTON3)->EnableWindow(false);
GetDlgItem(IDC_BUTTON7)->EnableWindow(false);
GetDlgItem(IDC_BUTTON18)->EnableWindow(false);
GetDlgItem(IDC_BUTTON5)->EnableWindow(false);
GetDlgItem(IDC_BUTTON12)->EnableWindow(true);
GetDlgItem(IDC_BUTTON14)->EnableWindow(true);
GetDlgItem(IDC_BUTTON15)->EnableWindow(true);
GetDlgItem(IDC_BUTTON13)->EnableWindow(true);
break;}
case 3:
{GetDlgItem(IDC_BUTTON1)->EnableWindow(false);
GetDlgItem(IDC_BUTTON3)->EnableWindow(false);
GetDlgItem(IDC_BUTTON7)->EnableWindow(false);
GetDlgItem(IDC_BUTTON18)->EnableWindow(false);
GetDlgItem(IDC_BUTTON5)->EnableWindow(false);
GetDlgItem(IDC_BUTTON12)->EnableWindow(false);
GetDlgItem(IDC_BUTTON14)->EnableWindow(false);
GetDlgItem(IDC_BUTTON15)->EnableWindow(false);
GetDlgItem(IDC_BUTTON13)->EnableWindow(false);
break;}
}}
this->ShowWindow(SW_SHOW);
}
void CSoftDocSystemDlg::OnStateReport()
{
// TODO: Add your control notification handler code here
CStateReport dlg;
this->ShowWindow(SW_HIDE);
dlg.DoModal ();
this->ShowWindow (SW_SHOW);
}
void CSoftDocSystemDlg::OnPublicQuery()
{
CPublicQuery dlg;
this->ShowWindow(SW_HIDE);
dlg.DoModal ();
this->ShowWindow (SW_SHOW);
}
void CSoftDocSystemDlg::OnChat()
{
CChat dlg;
this->ShowWindow(SW_HIDE);
dlg.DoModal ();
this->ShowWindow (SW_SHOW);
}
void CSoftDocSystemDlg::InitButton()
{
switch(PublicUserType)
{
case 1:
{ GetDlgItem(IDC_BUTTON1)->EnableWindow(true);
GetDlgItem(IDC_BUTTON3)->EnableWindow(true);
GetDlgItem(IDC_BUTTON7)->EnableWindow(true);
GetDlgItem(IDC_BUTTON18)->EnableWindow(true);
GetDlgItem(IDC_BUTTON5)->EnableWindow(true);
GetDlgItem(IDC_BUTTON12)->EnableWindow(true);
GetDlgItem(IDC_BUTTON14)->EnableWindow(true);
GetDlgItem(IDC_BUTTON15)->EnableWindow(false);
GetDlgItem(IDC_BUTTON13)->EnableWindow(true);
break;}
case 2:
{GetDlgItem(IDC_BUTTON1)->EnableWindow(false);
GetDlgItem(IDC_BUTTON3)->EnableWindow(false);
GetDlgItem(IDC_BUTTON7)->EnableWindow(false);
GetDlgItem(IDC_BUTTON18)->EnableWindow(false);
GetDlgItem(IDC_BUTTON5)->EnableWindow(false);
GetDlgItem(IDC_BUTTON12)->EnableWindow(true);
GetDlgItem(IDC_BUTTON14)->EnableWindow(true);
GetDlgItem(IDC_BUTTON15)->EnableWindow(true);
GetDlgItem(IDC_BUTTON13)->EnableWindow(true);
break;}
case 3:
{GetDlgItem(IDC_BUTTON1)->EnableWindow(false);
GetDlgItem(IDC_BUTTON3)->EnableWindow(false);
GetDlgItem(IDC_BUTTON7)->EnableWindow(false);
GetDlgItem(IDC_BUTTON18)->EnableWindow(false);
GetDlgItem(IDC_BUTTON5)->EnableWindow(false);
GetDlgItem(IDC_BUTTON12)->EnableWindow(false);
GetDlgItem(IDC_BUTTON14)->EnableWindow(false);
GetDlgItem(IDC_BUTTON15)->EnableWindow(false);
GetDlgItem(IDC_BUTTON13)->EnableWindow(false);
break;}
}
}
void CSoftDocSystemDlg::OnNewUser()
{
// TODO: Add your control notification handler code here
CMemberIn dlg;
this->ShowWindow(SW_HIDE);
dlg.DoModal ();
this->ShowWindow (SW_SHOW);
}
void CSoftDocSystemDlg::OnPrivate()
{
// TODO: Add your control notification handler code here
CCustom dlg;
this->ShowWindow(SW_HIDE);
dlg.DoModal ();
this->ShowWindow (SW_SHOW);
}
void CSoftDocSystemDlg::OnDateLog()
{
// TODO: Add your control notification handler code here
CViewDialogRec dlg;
this->ShowWindow(SW_HIDE);
dlg.DoModal ();
this->ShowWindow (SW_SHOW);
}
void CSoftDocSystemDlg::OnOperationRecord()
{
// TODO: Add your control notification handler code here
CPublicQuery dlg;
this->ShowWindow(SW_HIDE);
dlg.DoModal ();
this->ShowWindow (SW_SHOW);
}
void CSoftDocSystemDlg::OnChageKey()
{
// TODO: Add your control notification handler code here
CChangeKey dlg;
this->ShowWindow(SW_HIDE);
dlg.DoModal ();
this->ShowWindow (SW_SHOW);
}
void CSoftDocSystemDlg::OnAbandonDoc()
{ // TODO: Add your control notification handler code here
CSoftDelete dlg;
this->ShowWindow(SW_HIDE);
dlg.DoModal ();
this->ShowWindow (SW_SHOW);
}
void CSoftDocSystemDlg::OnSetDataSource()
{
// TODO: Add your control notification handler code here
CStartWindow dlg;
this->ShowWindow(SW_HIDE);
dlg.DoModal ();
this->ShowWindow (SW_SHOW);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -