📄 maindlg.cpp
字号:
// MainDlg.cpp : implementation file
//
#include "stdafx.h"
#include "SalaryManagement.h"
#include "MainDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// 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()
/////////////////////////////////////////////////////////////////////////////
// CMainDlg dialog
CMainDlg::CMainDlg(CWnd* pParent /*=NULL*/)
: CDialog(CMainDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CMainDlg)
m_year = _T("");
m_month = _T("");
m_departmentname = _T("");
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CMainDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CMainDlg)
DDX_Text(pDX, IDC_YEAR_EDIT, m_year);
DDX_Text(pDX, IDC_MONTH_EDIT, m_month);
DDX_Text(pDX, IDC_DEPARTMENT_EDIT, m_departmentname);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CMainDlg, CDialog)
//{{AFX_MSG_MAP(CMainDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_PERSONNEL_BUTTON, OnPersonnelButton)
ON_BN_CLICKED(IDC_INITIALISITION_BUTTON, OnInitialisitionButton)
ON_BN_CLICKED(IDC_SELLAMOUNT_BUTTON, OnSellamountButton)
ON_BN_CLICKED(IDC_SALARYSET_BUTTON, OnSalarysetButton)
ON_BN_CLICKED(IDC_GENERATELIST_BUTTON, OnGeneratelistButton)
ON_BN_CLICKED(IDC_MODIFY_PASSWORD, OnModifyPassword)
ON_BN_CLICKED(IDC_EXIT_BUTTON, OnExitButton)
ON_BN_CLICKED(IDC_AWARD_BUTTON, OnAwardButton)
ON_BN_CLICKED(IDC_OLDRECORD_BUTTON, OnOldrecordButton)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMainDlg message handlers
BOOL CMainDlg::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
///////////////////////////////////////////////////////////////////////
CLoginDlg LoginDialog; //登陆对话框的对象
if(LoginDialog.DoModal()==IDCANCEL){ //模式对话框
EndDialog(IDCANCEL); //如果登陆不成功,就关闭主对话框
return TRUE;
}
else
pDepartment->InitDepartment(); //登录成功
if(pDepartment->GetDepartmentName()!="Root"){ //不是Root的话,就不能使用Root的功能
CButton *pButton=(CButton *)GetDlgItem(IDC_PERSONNEL_BUTTON);
pButton->EnableWindow(FALSE); //禁用 各部门职工信息按钮
pButton=(CButton *)GetDlgItem(IDC_MODIFY_PASSWORD);
pButton->EnableWindow(FALSE); //禁用 更改密码按钮
pButton=(CButton *)GetDlgItem(IDC_OLDRECORD_BUTTON);
pButton->EnableWindow(FALSE); //禁用 各部门工资记录按钮
pButton=(CButton *)GetDlgItem(IDC_INITIALISITION_BUTTON);
pButton->EnableWindow(FALSE); //禁用 初始化系统按钮
}
else{
CButton *pButton=(CButton *)GetDlgItem(IDC_SELLAMOUNT_BUTTON);
pButton->EnableWindow(FALSE); //禁用录入本月销售额
pButton=(CButton *)GetDlgItem(IDC_SALARYSET_BUTTON);
pButton->EnableWindow(FALSE); //禁用工资设定
pButton=(CButton *)GetDlgItem(IDC_GENERATELIST_BUTTON);
pButton->EnableWindow(FALSE); //生成本月工资表
pButton=(CButton *)GetDlgItem(IDC_AWARD_BUTTON);
pButton->EnableWindow(FALSE); //年终销售奖
}
DisplayDate();
///////////////////////////////////////////////////////////////////////
CDialog::OnInitDialog();
return TRUE; // return TRUE unless you set the focus to a control
}
void CMainDlg::DisplayDate(){ //显示日期
CString SQL; //建立用来查询的SQL语句
SQL="select * from zNext"; //得到下一个要输入销售额的日期
database.GetRecordset(SQL);
if(database.m_pRecordset->adoEOF==0){ //如果查询出结果
m_year=(LPCTSTR)(_bstr_t)database.m_pRecordset->GetCollect("年"); //从数据库得到年份
m_month=(LPCTSTR)(_bstr_t)database.m_pRecordset->GetCollect("月"); //从数据库得到月份
}
m_departmentname=pDepartment->GetDepartmentName();
UpdateData(FALSE);
}
void CMainDlg::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 CMainDlg::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 CMainDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
//------------Root专区--------------------------------------------
void CMainDlg::OnPersonnelButton(){ //进入职工信息的对话框
CPersonnelDlg dlg;
dlg.DoModal();
}
void CMainDlg::OnInitialisitionButton(){ //进入初始化系统的对话框
MessageBox("警告!本操作会修改数据库中的重要数据!请先备份数据库","初始化系统日期",0);
CInitialisitionDlg dlg; //初始化系统日期的对话框
dlg.DoModal(); //模式对话框
DisplayDate(); //显示日期
}
//-----------部门-------------------------------------------------
void CMainDlg::OnSellamountButton(){ //录入销售额
CSellamountDlg dlg; //录入销售额的对话框
dlg.DoModal(); //模式对话框
}
void CMainDlg::OnSalarysetButton(){ //工资设定
CSalarySetDlg dlg;
dlg.DoModal(); //模式对话框
}
void CMainDlg::OnGeneratelistButton(){ //生成工资表
CSalaryTableDlg dlg;
dlg.DoModal(); //模式对话框
}
void CMainDlg::OnModifyPassword(){ //修改密码
CModifyPasswordDlg dlg;
dlg.DoModal(); //模式对话框
}
void CMainDlg::OnExitButton(){ //退出
EndDialog(IDCANCEL);
}
void CMainDlg::OnAwardButton(){ //年终销售奖
CAwardDlg dlg;
dlg.DoModal(); //模式对话框
}
void CMainDlg::OnOldrecordButton(){ //各部门的工资记录
CSalaryRecordsDlg dlg;
dlg.DoModal(); //模式对话框
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -