⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 usereditdlg.cpp

📁 软件外包人事综合管理系统,对员工的管理,部门管理,以及考勤管理和薪资管理.总得来说功能完全.
💻 CPP
字号:
// UserEditDlg.cpp : implementation file
//

#include "stdafx.h"
#include "HrSys.h"
#include "UserEditDlg.h"
#include "Users.h"
#include "EmpSelDlg.h"

extern CUsers curUser;

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CUserEditDlg dialog


CUserEditDlg::CUserEditDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CUserEditDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CUserEditDlg)
	m_UserName = _T("");
	m_DepName = _T("");
	m_EmpName = _T("");
	//}}AFX_DATA_INIT
}


void CUserEditDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CUserEditDlg)
	DDX_Control(pDX, IDC_TYPE_COMBO, m_UserType);
	DDX_Text(pDX, IDC_USERNAME_EDIT, m_UserName);
	DDX_Text(pDX, IDC_DEPNAME_STATIC, m_DepName);
	DDX_Text(pDX, IDC_EMPNAME_STATIC, m_EmpName);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CUserEditDlg, CDialog)
	//{{AFX_MSG_MAP(CUserEditDlg)
	ON_BN_CLICKED(IDC_SELEMP_BUTTON, OnSelempButton)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CUserEditDlg message handlers
void CUserEditDlg::OnOK() 
{
	// TODO: Add extra validation here
	UpdateData(TRUE);
	//域校验
	if(m_UserName=="")
	{
		MessageBox("请输入用户名");
		return;
	}
	if(lEmpId<=0)
	{
		MessageBox("请选择员工");
		return;
	}
	//定义用户对象
	CUsers usr;
	usr.UserName = m_UserName;
	usr.EmpId = lEmpId;
	if(m_UserType.GetCurSel() == 0)
		usr.UserType = "系统管理员";
	else
		usr.UserType = "普通用户";
	
	if (cUserName=="")//插入用户记录
	{
		//判断用户名是否已存在
		if (usr.HaveRecord(m_UserName)) 
		{
			MessageBox("当前用户名已存在");
			return;
		}		
		usr.sql_insert();
	}
	else
		usr.sql_update(cUserName);//更新用户信息

	CDialog::OnOK();
}
//打开选择员工对话框
void CUserEditDlg::OnSelempButton() 
{
	// TODO: Add your control notification handler code here
	CEmpSelDlg dlg;
	if(dlg.DoModal()==IDOK)
	{
		//根据用户选择设置员工信息
		lEmpId = dlg.EmpId;
		m_EmpName = dlg.EmpName;
		m_DepName = dlg.DepName;

		UpdateData(FALSE);	
	}	
}

BOOL CUserEditDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	m_UserType.SetCurSel(iUserType - 1);
	
	if (curUser.UserName != "Admin")
		GetDlgItem(IDC_TYPE_COMBO)->EnableWindow(FALSE);
	if (lEmpId>0)
		GetDlgItem(IDC_USERNAME_EDIT)->EnableWindow(FALSE);
	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 + -