📄 employodlg.cpp
字号:
// EmployOdlg.cpp : implementation file
//
#include "stdafx.h"
#include "salarly.h"
#include "EmployOdlg.h"
#include "DepartmentSet.h"
#include "EmploySet.h"
#include "SexSet.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CEmployOdlg dialog
CEmployOdlg::CEmployOdlg(CWnd* pParent /*=NULL*/)
: CDialog(CEmployOdlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CEmployOdlg)
m_strAddress = _T("");
m_strID = _T("");
m_strJob = _T("");
m_strName = _T("");
m_strTel = _T("");
m_Birthday = 0;
m_strDepartment = _T("人事部");
m_strSex = _T("男");
//}}AFX_DATA_INIT
}
void CEmployOdlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CEmployOdlg)
DDX_Control(pDX, IDC_COMBO_SEX, m_strSexctrl);
DDX_Control(pDX, IDC_COMBO_DEPARTMENT, m_strDepartmentctrl);
DDX_Text(pDX, IDC_ADDRESS, m_strAddress);
DDX_Text(pDX, IDC_ID, m_strID);
DDX_Text(pDX, IDC_JOB, m_strJob);
DDX_Text(pDX, IDC_NAME, m_strName);
DDX_Text(pDX, IDC_TEL, m_strTel);
DDX_DateTimeCtrl(pDX, IDC_DATETIMEPICKER, m_Birthday);
DDX_CBString(pDX, IDC_COMBO_DEPARTMENT, m_strDepartment);
DDX_CBString(pDX, IDC_COMBO_SEX, m_strSex);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CEmployOdlg, CDialog)
//{{AFX_MSG_MAP(CEmployOdlg)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CEmployOdlg message handlers
void CEmployOdlg::OnOK()
{
// TODO: Add extra validation here
UpdateData(); //更新数据库
CString str;
m_strID.TrimLeft(); //函数从给定的字符串中删除首部的空格及控制字符
if(m_strID.IsEmpty()) //当员工号为空
MessageBox("员工号不能为空!"); //为空弹出系统对话框
else
if(m_strDepartment.IsEmpty()) //否则判断部门是否为空
MessageBox("部门不能为空!"); //为空弹出系统对话框
else
CDialog::OnOK();
}
void CEmployOdlg::OnCancel()
{
// TODO: Add extra cleanup here
CDialog::OnCancel();
}
BOOL CEmployOdlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
CDepartmentSet cSet;
cSet.Open();
while(!cSet.IsEOF()){
m_strDepartmentctrl.AddString(cSet.m_department); //将部门表的内容添加到组合框中
cSet.MoveNext();
}
if(cSet.IsOpen())cSet.Close();
CSexSet pSet;
pSet.Open();
while(!pSet.IsEOF()){
m_strSexctrl.AddString(pSet.m_sex); ////将性别表的内容添加到组合框中
pSet.MoveNext();
}
if(pSet.IsOpen())pSet.Close();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -