📄 mainfrm.cpp
字号:
//退出系统
else
{
if(MessageBox(_T("您确定要退出系统吗?"), theApp.strSystemName,
MB_OKCANCEL)==IDCANCEL)
{
return;
}
CFrameWnd::OnClose();
}
}
void CMainFrame::OnBasmanBook()
{
// TODO: Add your command handler code here
CSettingDlg dlg;
dlg.SetType(BOOK);
dlg.DoModal();
}
void CMainFrame::OnBasmanPunish()
{
// TODO: Add your command handler code here
CSettingDlg dlg;
dlg.SetType(PUNISH);
dlg.DoModal();
}
void CMainFrame::OnBasmanReader()
{
// TODO: Add your command handler code here
CSettingDlg dlg;
dlg.SetType(READER);
dlg.DoModal();
}
void CMainFrame::OnBookmanNew()
{
// TODO: Add your command handler code here
CBookRegDlg dlg;
dlg.SetAdd(TRUE);
dlg.DoModal();
}
void CMainFrame::OnUpdateBookmanNew(CCmdUI *pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->Enable(theApp.IsManager());
}
void CMainFrame::OnBookmanLost()
{
// TODO: Add your command handler code here
CBookRegDlg dlg;
dlg.SetSignOff(TRUE);
dlg.DoModal();
}
void CMainFrame::OnUpdateBookmanLost(CCmdUI *pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->Enable(theApp.IsManager());
}
void CMainFrame::OnBookmanMod()
{
// TODO: Add your command handler code here
CBookRegDlg dlg;
dlg.SetModify(TRUE);
dlg.DoModal();
}
void CMainFrame::OnUpdateBookmanMod(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->Enable(theApp.IsManager());
}
void CMainFrame::OnBookmanQuery()
{
// TODO: Add your command handler code here
CQueryDlg dlg;
dlg.SetQueryType(QBOOK);
dlg.DoModal();
}
void CMainFrame::OnReadermanNew()
{
// TODO: Add your command handler code here
CReaderRegDlg dlg;
dlg.DoModal();
}
void CMainFrame::OnUpdateReadermanNew(CCmdUI *pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->Enable(theApp.IsManager());
}
void CMainFrame::OnReadermanLost()
{
// TODO: Add your command handler code here
CReaderRegDlg dlg;
dlg.SetSignOff(TRUE);
dlg.SetModify(FALSE);
dlg.DoModal();
}
void CMainFrame::OnUpdateReadermanLost(CCmdUI *pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->Enable(theApp.IsManager());
}
void CMainFrame::OnReadermanMod()
{
// TODO: Add your command handler code here
CReaderRegDlg dlg;
dlg.SetSignOff(FALSE);
dlg.SetModify(TRUE);
dlg.DoModal();
}
void CMainFrame::OnUpdateReadermanMod(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->Enable(theApp.IsManager());
}
void CMainFrame::OnReadermanQuery()
{
// TODO: Add your command handler code here
CQueryDlg dlg;
dlg.SetQueryType(QREADER);
dlg.DoModal();
}
void CMainFrame::OnBormanBorrow()
{
// TODO: Add your command handler code here
CBorrowManageDlg dlg;
dlg.SetBWType(BORROW);
dlg.DoModal();
}
void CMainFrame::OnUpdateBormanBorrow(CCmdUI *pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->Enable(theApp.IsManager());
}
void CMainFrame::OnBormanRenew()
{
// TODO: Add your command handler code here
CBorrowManageDlg dlg;
dlg.SetBWType(RENEW);
dlg.DoModal();
}
void CMainFrame::OnUpdateBormanRenew(CCmdUI *pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->Enable(theApp.IsManager());
}
void CMainFrame::OnBormanReturn()
{
// TODO: Add your command handler code here
CBorrowManageDlg dlg;
dlg.SetBWType(RETURN);
dlg.DoModal();
}
void CMainFrame::OnUpdateBormanReturn(CCmdUI *pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->Enable(theApp.IsManager());
}
void CMainFrame::OnBormanPay()
{
// TODO: Add your command handler code here
CInputDlg dlg;
dlg.SetBPunish(TRUE);
dlg.strWindowTitle = _T("缴纳罚款");
dlg.strType = _T("读者ID");
dlg.strContent = _T("实缴罚款");
dlg.strMarks = _T("应缴罚款");
dlg.DoModal();
}
void CMainFrame::OnUpdateBormanPay(CCmdUI *pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->Enable(theApp.IsManager());
}
void CMainFrame::OnBormanQuery()
{
// TODO: Add your command handler code here
CQueryDlg dlg;
dlg.SetQueryType(QBORROW);
dlg.DoModal();
}
// TODO: Add your command handler code here
void CMainFrame::OnDbmanInitialize()
{
int ret = AfxMessageBox(_T("这将删除数据库中原有的所有数据,你确定要这么做?"),
MB_YESNOCANCEL | MB_DEFBUTTON2 | MB_ICONQUESTION);
if (IDYES != ret) return;
CDatabase *pDB = theApp.GetDatabase();
if (pDB->IsOpen())
pDB->Close();
if (pDB->OpenEx(theApp.GetStrConnection(), CDatabase::noOdbcDialog))
{
// 删除所有记录
BOOL ret = DeleteData(pDB);
if (FALSE == ret)
AfxMessageBox("部分数据删除失败!");
// 添加几条关键的数据
BOOL ret1 = InitializeData(pDB);
if (FALSE == ret1)
AfxMessageBox("部分数据插入失败!");
pDB->Close();
if (ret1 && ret)
AfxMessageBox("全部数据数据已初始化成功!");
if (TRUE == ret && theApp.GetOperator() != OMNIPUSER)
{// 当前登陆用户不是万能用户,为保证登陆用户在数据库中存在需要重新登录
AfxMessageBox("当前登陆用户已经被注销,请重新登陆!");
CLoginDlg dlg;
INT_PTR nRes = dlg.DoModal();
if(nRes != IDOK)
{
AfxMessageBox("程序将退出!");
CFrameWnd::OnClose();
}
}
}
}
void CMainFrame::OnUpdateDbmanInitialize(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->Enable(theApp.IsAdmin());
}
void CMainFrame::OnDbmanBackup()
{
// TODO: Add your command handler code here
int idRet = MessageBox(_T("您确定要备份数据库吗?"), theApp.strSystemName,
MB_OKCANCEL | MB_ICONQUESTION);
if (IDOK != idRet)
return;
if (CopyDatabaseToFile(_T(".\\BackUp\\")))
MessageBox(_T("数据库备份成功!"), theApp.strSystemName);
else
MessageBox(_T("数据库备份失败!"), theApp.strSystemName);
}
void CMainFrame::OnUpdateDbmanBackup(CCmdUI *pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->Enable(theApp.IsAdmin());
}
void CMainFrame::OnDbmanReload()
{
if (IDOK != MessageBox(_T("还原数据库将覆盖修改后的数据库。\n\n您确定要还原吗?"),
theApp.strSystemName, MB_OKCANCEL | MB_ICONQUESTION))
return;
CFileFind filefind;
if (!filefind.FindFile(".\\BackUp\\*.bak"))// 查找备份文件
{
MessageBox(_T("没有找到备份文件,无法完成系统还原!"), theApp.strSystemName);
return ;
}
CDatabase *pDB = theApp.GetDatabase();
if (pDB->IsOpen())pDB->Close();
if (pDB->OpenEx(theApp.GetStrConnection(), CDatabase::noOdbcDialog))
{// 数据库打开成功
if (!DeleteData(theApp.GetDatabase()))
{
MessageBox(_T("数据库原始数据删除失败!"), theApp.strSystemName);
pDB->Close();
return;
}
if (CopyFileToDatabase(_T(".\\BackUp\\")))
{
MessageBox(_T("数据库还原成功!"), theApp.strSystemName);
AfxMessageBox("用户由于数据库还原而注销,请重新登陆!");
pDB->Close();
CLoginDlg dlg;
if(dlg.DoModal() != IDOK)
{
AfxMessageBox("程序将退出!");
CFrameWnd::OnClose();
}
}
else
{
MessageBox(_T("数据库还原失败!\n请使用F9来初始化数据库!"), theApp.strSystemName);
pDB->Close();
}
}
}
void CMainFrame::OnUpdateDbmanReload(CCmdUI *pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->Enable(theApp.IsAdmin());
}
void CMainFrame::OnHelpContent()
{
// TODO: Add your command handler code here
CHelpDlg* pDlg = new CHelpDlg;
pDlg->Create(IDD_HELPDIALOG);
pDlg->SetWindowPos(this, 600, 100, 0, 0, SWP_NOSIZE);
pDlg->ShowWindow(SW_NORMAL);
}
void CMainFrame::OnWndMax()
{
// TODO: Add your command handler code here
if (m_bShow)return ;
CSystemTray::MaximiseFromTray(this);
m_SysTray.SetMenuDefaultItem (ID_WND_MIN,FALSE);
m_bShow = TRUE;
}
void CMainFrame::OnWndMin()
{
// TODO: Add your command handler code here
if (!m_bShow)return ;
CSystemTray::MinimiseToTray(this);
m_SysTray.SetMenuDefaultItem (ID_WND_MAX,FALSE);
m_bShow = FALSE;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -