📄 stuchgmanagerdlg.cpp
字号:
// StuChgManagerDlg.cpp : implementation file
//
#include "stdafx.h"
#include "StuChgManager.h"
#include "StuChgManagerDlg.h"
#include "Department.h"
#include "DepaTels.h"
#include "Speciality.h"
#include "Student.h"
#include "ChargeItem.h"
#include "StudyIn.h"
#include "StuCharge.h"
#include "Users.h"
#include "Usermanager.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern CStuChgManagerApp theApp; //引入外部变量
/////////////////////////////////////////////////////////////////////////////
// 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)
//}}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()
/////////////////////////////////////////////////////////////////////////////
// CStuChgManagerDlg dialog
CStuChgManagerDlg::CStuChgManagerDlg(CWnd* pParent /*=NULL*/)
: CDialog(CStuChgManagerDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CStuChgManagerDlg)
// 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);
}
void CStuChgManagerDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CStuChgManagerDlg)
DDX_Control(pDX, IDC_TAB, m_tab);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CStuChgManagerDlg, CDialog)
//{{AFX_MSG_MAP(CStuChgManagerDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_NOTIFY(TCN_SELCHANGE, IDC_TAB, OnSelchangeTab)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CStuChgManagerDlg message handlers
BOOL CStuChgManagerDlg::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
//连接数据库
theApp.connection.CreateInstance(_uuidof(Connection));
theApp.record.CreateInstance(_uuidof(Recordset));
theApp.record1.CreateInstance(_uuidof(Recordset));
theApp.connection->ConnectionString="Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=StudentChargeManage";
theApp.connection->Open("","","",adConnectUnspecified);
CUsers dlg; //用户登录
if(dlg.DoModal() != IDOK)
exit(0);
//加载位图
imagelist.Create(32, 32, ILC_COLOR24, 8, 1);
CBitmap bmp;
bmp.LoadBitmap(IDB_DEPARTMENT);
imagelist.Add(&bmp,RGB(255,255,255));
bmp.DeleteObject();
bmp.LoadBitmap(IDB_DEPTELS);
imagelist.Add(&bmp,RGB(255,255,255));
bmp.DeleteObject();
bmp.LoadBitmap(IDB_SPECIALITY);
imagelist.Add(&bmp,RGB(255,255,255));
bmp.DeleteObject();
bmp.LoadBitmap(IDB_CHARGEITEM);
imagelist.Add(&bmp,RGB(255,255,255));
bmp.DeleteObject();
bmp.LoadBitmap(IDB_STUDENT);
imagelist.Add(&bmp,RGB(255,255,255));
bmp.DeleteObject();
bmp.LoadBitmap(IDB_STUDYIN);
imagelist.Add(&bmp,RGB(0,0,0));
bmp.DeleteObject();
//
bmp.LoadBitmap(IDB_STUCHARGE);
imagelist.Add(&bmp,RGB(0,0,0));
bmp.DeleteObject();
bmp.LoadBitmap(IDB_USERMANAGE);
imagelist.Add(&bmp,RGB(0,0,0));
bmp.DeleteObject();
bmp.LoadBitmap(IDB_EXIT);
imagelist.Add(&bmp,RGB(0,0,0));
bmp.DeleteObject();
/**/
m_tab.SetImageList(&imagelist);
CString name;
//创建Tab 框
TCITEM item;
item.mask = TCIF_TEXT|TCIF_IMAGE;//创建tab页
item.iImage=0;
name.Format("学院管理");
item.pszText = name.GetBuffer(name.GetLength());
m_tab.InsertItem(0,&item);
item.iImage=1;
name.Format("学院通信管理");
item.pszText = name.GetBuffer(name.GetLength());
m_tab.InsertItem(1,&item);
item.iImage=2;
name.Format("专业管理");
item.pszText = name.GetBuffer(name.GetLength());
m_tab.InsertItem(2,&item);
item.iImage=3;
name.Format("专业收费项目管理");
item.pszText = name.GetBuffer(name.GetLength());
m_tab.InsertItem(3,&item);
item.iImage=4;
name.Format("学生管理");
item.pszText = name.GetBuffer(name.GetLength());
m_tab.InsertItem(4,&item);
item.iImage=5;
name.Format("学生学习管理");
item.pszText = name.GetBuffer(name.GetLength());
m_tab.InsertItem(5,&item);
item.iImage=6;
name.Format("学生收费信息管理");
item.pszText = name.GetBuffer(name.GetLength());
m_tab.InsertItem(6,&item);
item.iImage=7;
name.Format("用户管理");
item.pszText = name.GetBuffer(name.GetLength());
m_tab.InsertItem(7,&item);
item.iImage=8;
name.Format("退出系统");
item.pszText = name.GetBuffer(name.GetLength());
m_tab.InsertItem(8,&item);
//创建对话框
depadlg.Create(IDD_DEPARTMENT,this);
depateldlg.Create(IDD_DEPATELS,this);
speciadlg.Create(IDD_SPECIALITY,this);
chaitemdlg.Create(IDD_CHARGEITEM,this);
studlg.Create(IDD_STUDENT,this);
stuindlg.Create(IDD_STUDYIN,this);
stuchgdlg.Create(IDD_STUCHARGE,this);
usermanadlg.Create(IDD_USERMANAGE,this);
userdlg.Create(IDD_USER,this);
// this->ShowWindow(SW_MAXIMIZE);
CRect rect; //对话框显示位置
m_tab.GetWindowRect(&rect);
ScreenToClient(&rect);
rect.top+=50;
rect.left=rect.left;
rect.right=rect.right-50;
rect.bottom=rect.bottom-20;
//ClientToScreen(&rect);
depadlg.MoveWindow(&rect);
depateldlg.MoveWindow(&rect);
speciadlg.MoveWindow(&rect);
studlg.MoveWindow(&rect);
stuchgdlg.MoveWindow(&rect);
chaitemdlg.MoveWindow(&rect);
stuindlg.MoveWindow(&rect);
usermanadlg.MoveWindow(&rect);
/**/
depadlg.ShowWindow(SW_SHOW); //初始显示
return TRUE; // return TRUE unless you set the focus to a control
}
void CStuChgManagerDlg::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 CStuChgManagerDlg::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 CStuChgManagerDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CStuChgManagerDlg::OnSelchangeTab(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here
switch(m_tab.GetCurSel())
{
case 0:
depateldlg.ShowWindow(SW_HIDE); //显示学院对话框
speciadlg.ShowWindow(SW_HIDE);
chaitemdlg.ShowWindow(SW_HIDE);
studlg.ShowWindow(SW_HIDE);
stuindlg.ShowWindow(SW_HIDE);
stuchgdlg.ShowWindow(SW_HIDE);
usermanadlg.ShowWindow(SW_HIDE);
depadlg.ShowWindow(SW_SHOW); //一定要保证要显示的对话框最后显示
break;
case 1:
depadlg.ShowWindow(SW_HIDE); //显示学院通信对话框
speciadlg.ShowWindow(SW_HIDE);
chaitemdlg.ShowWindow(SW_HIDE);
studlg.ShowWindow(SW_HIDE);
stuindlg.ShowWindow(SW_HIDE);
stuchgdlg.ShowWindow(SW_HIDE);
usermanadlg.ShowWindow(SW_HIDE);
depateldlg.ShowWindow(SW_SHOW);
break;
case 2:
depadlg.ShowWindow(SW_HIDE); //显示专业对话框
depateldlg.ShowWindow(SW_HIDE);
chaitemdlg.ShowWindow(SW_HIDE);
studlg.ShowWindow(SW_HIDE);
stuindlg.ShowWindow(SW_HIDE);
stuchgdlg.ShowWindow(SW_HIDE);
usermanadlg.ShowWindow(SW_HIDE);
speciadlg.ShowWindow(SW_SHOW);
break;
case 3:
depadlg.ShowWindow(SW_HIDE); //显示专业收费对话框
depateldlg.ShowWindow(SW_HIDE);
studlg.ShowWindow(SW_HIDE);
speciadlg.ShowWindow(SW_HIDE);
stuindlg.ShowWindow(SW_HIDE);
stuchgdlg.ShowWindow(SW_HIDE);
usermanadlg.ShowWindow(SW_HIDE);
chaitemdlg.ShowWindow(SW_SHOW);
break;
case 4:
depadlg.ShowWindow(SW_HIDE);//显示学生信息对话框
depateldlg.ShowWindow(SW_HIDE);
chaitemdlg.ShowWindow(SW_HIDE);
speciadlg.ShowWindow(SW_HIDE);
stuindlg.ShowWindow(SW_HIDE);
stuchgdlg.ShowWindow(SW_HIDE);
usermanadlg.ShowWindow(SW_HIDE);
studlg.ShowWindow(SW_SHOW);
break;
case 5:
depadlg.ShowWindow(SW_HIDE); //显示学生学习对话框
depateldlg.ShowWindow(SW_HIDE);
chaitemdlg.ShowWindow(SW_HIDE);
speciadlg.ShowWindow(SW_HIDE);
studlg.ShowWindow(SW_HIDE);
stuchgdlg.ShowWindow(SW_HIDE);
usermanadlg.ShowWindow(SW_HIDE);
stuindlg.ShowWindow(SW_SHOW);
break;
case 6:
depadlg.ShowWindow(SW_HIDE); //显示学生收费对话框
depateldlg.ShowWindow(SW_HIDE);
chaitemdlg.ShowWindow(SW_HIDE);
speciadlg.ShowWindow(SW_HIDE);
studlg.ShowWindow(SW_HIDE);
stuindlg.ShowWindow(SW_HIDE);
usermanadlg.ShowWindow(SW_HIDE);
stuchgdlg.ShowWindow(SW_SHOW);
break;
case 7:
depadlg.ShowWindow(SW_HIDE); //显示用户管理对话框
depateldlg.ShowWindow(SW_HIDE);
chaitemdlg.ShowWindow(SW_HIDE);
speciadlg.ShowWindow(SW_HIDE);
studlg.ShowWindow(SW_HIDE);
stuchgdlg.ShowWindow(SW_HIDE);
stuindlg.ShowWindow(SW_HIDE);
usermanadlg.ShowWindow(SW_SHOW);
break;
case 8: //退出系统
if(MessageBox("真的要退出吗!",NULL,MB_OKCANCEL)==IDOK)
CDialog::OnOK();
break;
}
*pResult = 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -