本人刚刚学习C++,弄了一个工资管理的源程序,希望高手赐教。
如题,我把源程序的一部分帖出来,希望高手能帮忙把注释部分以及重要的地方给解释一下,不胜感激。
---record.h----------------
#if !defined(AFX_RECORD_H__7D6420A9_79B0_4733_85F0_AC9015BA3239__INCLUDED_)
#define AFX_RECORD_H__7D6420A9_79B0_4733_85F0_AC9015BA3239__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// Record.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CRecord dialog
class CRecord : public CDialog
{
// Construction
public:
CRecord(CWnd* pParent = NULL); // standard constructor
BOOL m_flags;
void UpdateChange();
// Dialog Data
//{{AFX_DATA(CRecord)
enum { IDD = IDD_RECODE };
CEdit m_wname;
CButton m_action;
int m_age;
double m_alldays;
double m_allmoney;
double m_effectdays;
double m_expanddays;
double m_extramoney;
double m_fakedays;
COleDateTime m_firstdate;
double m_leftdays;
CString m_name;
CString m_phone;
long m_treat;
int m_sex;
CString m_work;
long m_number;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CRecord)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CRecord)
afx_msg void OnAction();
virtual BOOL OnInitDialog();
afx_msg void OnChangeTreat();
afx_msg void OnChangeFirstdate();
afx_msg void OnChangeFakedays();
afx_msg void OnChangeExtramoney();
afx_msg void OnChangeExpanddays();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_RECORD_H__7D6420A9_79B0_4733_85F0_AC9015BA3239__INCLUDED_)
------record.cpp-------------------
// Record.cpp : implementation file
//
#include "stdafx.h"
#include "Laborage.h"
#include "Record.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CRecord dialog
CRecord::CRecord(CWnd* pParent /*=NULL*/)
: CDialog(CRecord::IDD, pParent)
{
//{{AFX_DATA_INIT(CRecord)
m_age = 0;
m_alldays = 0.0;
m_allmoney = 0.0;
m_effectdays = 0.0;
m_expanddays = 0.0;
m_extramoney = 0.0;
m_fakedays = 0.0;
m_firstdate = COleDateTime::GetCurrentTime();
m_leftdays = 0.0;
m_name = _T("");
m_phone = _T("");
m_treat = 0;
m_sex = 0;
m_work = _T("");
m_number = 0;
//}}AFX_DATA_INIT
m_flags=0;
}
void CRecord::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CRecord)
DDX_Control(pDX, IDC_NAME, m_wname);
DDX_Control(pDX, IDC_ACTION, m_action);
DDX_Text(pDX, IDC_AGE, m_age);
DDV_MinMaxInt(pDX, m_age, 0, 999);
DDX_Text(pDX, IDC_ALLDAYS, m_alldays);
DDX_Text(pDX, IDC_ALLMONEY, m_allmoney);
DDX_Text(pDX, IDC_EFFECTDAYS, m_effectdays);
DDX_Text(pDX, IDC_EXPANDDAYS, m_expanddays);
DDV_MinMaxDouble(pDX, m_expanddays, 0., 10000.);
DDX_Text(pDX, IDC_EXTRAMONEY, m_extramoney);
DDX_Text(pDX, IDC_FAKEDAYS, m_fakedays);
DDV_MinMaxDouble(pDX, m_fakedays, 0., 10000.);
DDX_Text(pDX, IDC_FIRSTDATE, m_firstdate);
DDX_Text(pDX, IDC_LEFTDAYS, m_leftdays);
DDX_Text(pDX, IDC_NAME, m_name);
DDV_MaxChars(pDX, m_name, 64);
DDX_Text(pDX, IDC_PHONE, m_phone);
DDV_MaxChars(pDX, m_phone, 32);
DDX_Text(pDX, IDC_TREAT, m_treat);
DDV_MinMaxLong(pDX, m_treat, 0, 10000);
DDX_CBIndex(pDX, IDC_SEX, m_sex);
DDX_Text(pDX, IDC_WORK, m_work);
DDV_MaxChars(pDX, m_work, 64);
DDX_Text(pDX, IDC_NUMBER, m_number);
DDV_MinMaxLong(pDX, m_number, 0, 1000000);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CRecord, CDialog)
//{{AFX_MSG_MAP(CRecord)
ON_BN_CLICKED(IDC_ACTION, OnAction)
ON_EN_CHANGE(IDC_TREAT, OnChangeTreat)
ON_EN_CHANGE(IDC_FIRSTDATE, OnChangeFirstdate)
ON_EN_CHANGE(IDC_FAKEDAYS, OnChangeFakedays)
ON_EN_CHANGE(IDC_EXTRAMONEY, OnChangeExtramoney)
ON_EN_CHANGE(IDC_EXPANDDAYS, OnChangeExpanddays)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CRecord message handlers
BOOL CRecord::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
if(m_flags)
{
this->m_action.SetWindowText("修改");
this->SetWindowText("修改记录");
m_wname.SetReadOnly();
}
else
{
this->m_action.SetWindowText("新增");
this->SetWindowText("新增记录");
}
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CRecord::UpdateChange()
{
UpdateData();
CTime time=CTime::GetCurrentTime();
int total=(time.GetYear()-m_firstdate.GetYear())*366+(time.GetMonth()-m_firstdate.GetMonth())*31+time.GetDay()-m_firstdate.GetDay();
m_alldays=total;
m_effectdays=total-m_fakedays;
m_leftdays=m_effectdays-m_expanddays;
m_allmoney=m_leftdays*m_treat+m_extramoney;
UpdateData(FALSE);
}
void CRecord::OnChangeTreat()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
UpdateChange();
// TODO: Add your control notification handler code here
}
void CRecord::OnChangeFirstdate()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
UpdateChange();
// TODO: Add your control notification handler code here
}
void CRecord::OnChangeFakedays()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
UpdateChange();
// TODO: Add your control notification handler code here
}
void CRecord::OnChangeExtramoney()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
UpdateChange();
// TODO: Add your control notification handler code here
}
void CRecord::OnChangeExpanddays()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
UpdateChange();
// TODO: Add your control notification handler code here
}
void CRecord::OnAction()
{
// TODO: Add your control notification handler code here
UpdateData();
if(this->m_name=="")
{
MessageBox("您还没有填写姓名!");
return;
}
if(this->m_treat==0)
{
MessageBox("待遇不能为零!");
return;
}
if(this->m_age<=0)
{
MessageBox("年龄必需大于零!");
return;
}
this->OnOK();
}
问题点数:0、回复次数:0Top




