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

📄 staffrecord.cpp

📁 企业办公管理系统, 企业办公管理系统
💻 CPP
📖 第 1 页 / 共 2 页
字号:
// StaffRecord.cpp : implementation file
//

#include "stdafx.h"
#include "Office.h"
#include "StaffRecord.h"
#include "Staff.h"

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

/////////////////////////////////////////////////////////////////////////////
// CStaffRecord dialog


CStaffRecord::CStaffRecord(CWnd* pParent /*=NULL*/)
	: CDialog(CStaffRecord::IDD, pParent)
{
	//{{AFX_DATA_INIT(CStaffRecord)
	m_staffID = _T("");
	m_staffName = _T("");
	m_duty = _T("");
	m_contractID = _T("");
	m_contractTerm = 0;
	m_department = _T("");
	m_sex = _T("");
	m_address = _T("");
	m_birthday = COleDateTime::GetCurrentTime();
	m_marriageCondition = _T("");
	m_postcode = _T("");
	m_telephone = _T("");
	m_nationality = _T("");
	m_eMail = _T("");
	m_educationLevel = _T("");
	m_QQ = _T("");
	m_graduateSchool = _T("");
	m_major = _T("");
	m_identityNO = _T("");
	m_mobile = _T("");
	m_workType = _T("");
	m_remark = _T("");
	//}}AFX_DATA_INIT
}


void CStaffRecord::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CStaffRecord)
	DDX_Control(pDX, IDC_LIST, m_list);
	DDX_Text(pDX, IDC_STAFFID, m_staffID);
	DDX_Text(pDX, IDC_STAFFNAME, m_staffName);
	DDX_CBString(pDX, IDC_DUTY, m_duty);
	DDX_Text(pDX, IDC_CONTRACTID, m_contractID);
	DDX_Text(pDX, IDC_CONTRACTTERM, m_contractTerm);
	DDX_CBString(pDX, IDC_DEPARTMENT, m_department);
	DDX_CBString(pDX, IDC_SEX, m_sex);
	DDX_Text(pDX, IDC_ADDRESS, m_address);
	DDX_DateTimeCtrl(pDX, IDC_BIRTHDAY, m_birthday);
	DDX_CBString(pDX, IDC_MARRIAGECONDITION, m_marriageCondition);
	DDX_Text(pDX, IDC_POSTCODE, m_postcode);
	DDX_Text(pDX, IDC_TELEPHONE, m_telephone);
	DDX_CBString(pDX, IDC_NATIONALITY, m_nationality);
	DDX_Text(pDX, IDC_EMAIL, m_eMail);
	DDX_CBString(pDX, IDC_EDUCATIONLEVEL, m_educationLevel);
	DDX_Text(pDX, IDC_QQ, m_QQ);
	DDX_Text(pDX, IDC_GRADUATESCHOOL, m_graduateSchool);
	DDX_Text(pDX, IDC_MAJOR, m_major);
	DDX_Text(pDX, IDC_IDENTITYNO, m_identityNO);
	DDX_Text(pDX, IDC_MOBILE, m_mobile);
	DDX_Text(pDX, IDC_WORKTYPE, m_workType);
	DDX_Text(pDX, IDC_REMARK, m_remark);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CStaffRecord, CDialog)
	//{{AFX_MSG_MAP(CStaffRecord)
	ON_NOTIFY(NM_CLICK, IDC_LIST, OnClickList)
	ON_BN_CLICKED(IDC_ADD, OnAdd)
	ON_BN_CLICKED(IDC_DELETE, OnDelete)
	ON_BN_CLICKED(IDC_MODIFY, OnModify)
	ON_BN_CLICKED(IDC_SAVE, OnSave)
	ON_BN_CLICKED(IDC_CANCELLATION, OnCancellation)
	ON_BN_CLICKED(IDC_EXIT, OnExit)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CStaffRecord message handlers

void CStaffRecord::OnClickList(NMHDR* pNMHDR, LRESULT* pResult) 
{
	UpdateData(true);
	POSITION pos = m_list.GetFirstSelectedItemPosition();
	if(pos)
	{
		int nFirstSelItem = m_list.GetNextSelectedItem(pos);
		m_staffID=m_list.GetItemText(nFirstSelItem,0);
	}

	CStaff staff;
	staff.GetData(m_staffID);

	m_staffID = staff.GetStaffID();
	m_staffName = staff.GetStaffName();
	m_duty = staff.GetDuty();
	m_contractID = staff.GetContractID();
	m_contractTerm = staff.GetContractTerm();
	m_department = staff.GetDepartment();
	m_sex = staff.GetSex();
	m_address = staff.GetAddress();
	m_birthday = staff.GetBirthday();
	m_marriageCondition = staff.GetMarriageCondition();
	m_postcode = staff.GetPostCode();
	m_telephone = staff.GetTelephone();
	m_nationality = staff.GetNationality();
	m_eMail = staff.GetEMail();
	m_educationLevel = staff.GetEducationLevel();
	m_QQ = staff.GetQQ();
	m_graduateSchool = staff.GetGraduateSchool();
	m_major = staff.GetMajor();
	m_identityNO = staff.GetIdentityNO();
	m_mobile = staff.GetMobile();
	m_workType = staff.GetWorkType();
	m_remark = staff.GetRemark();

	cwnd_list->EnableWindow(true);
	cwnd_staffID->EnableWindow(false);
	cwnd_staffName->EnableWindow(false);
	cwnd_duty->EnableWindow(false);
	cwnd_contractID->EnableWindow(false);
	cwnd_contractTerm->EnableWindow(false);
	cwnd_department->EnableWindow(false);
	cwnd_sex->EnableWindow(false);
	cwnd_address->EnableWindow(false);
	cwnd_birthday->EnableWindow(false);
	cwnd_marriageCondition->EnableWindow(false);
	cwnd_postcode->EnableWindow(false);
	cwnd_telephone->EnableWindow(false);
	cwnd_nationality->EnableWindow(false);
	cwnd_eMail->EnableWindow(false);
	cwnd_educationLevel->EnableWindow(false);
	cwnd_QQ->EnableWindow(false);
	cwnd_graduateSchool->EnableWindow(false);
	cwnd_major->EnableWindow(false);
	cwnd_identityNO->EnableWindow(false);
	cwnd_mobile->EnableWindow(false);
	cwnd_workType->EnableWindow(false);
	cwnd_remark->EnableWindow(false);
	
	cwnd_add->EnableWindow(true);
	cwnd_cancel->EnableWindow(false);
	cwnd_delete->EnableWindow(true);
	cwnd_modify->EnableWindow(true);
	cwnd_save->EnableWindow(false);
	cwnd_exit->EnableWindow(true);

	UpdateData(false);
	
	*pResult = 0;
}

BOOL CStaffRecord::OnInitDialog() 
{
	CDialog::OnInitDialog();

	DWORD style;
	style=m_list.GetExStyle();
	style=(style|LVS_EX_GRIDLINES|LVS_EX_FULLROWSELECT)&(~LVS_EX_CHECKBOXES) ;
	m_list.SetExtendedStyle(style);
	
	m_list.InsertColumn(0,"员工编号",LVCFMT_LEFT,100);
	m_list.InsertColumn(1,"姓名",LVCFMT_LEFT,100);
	m_list.InsertColumn(2,"职务",LVCFMT_LEFT,100);
	
	cwnd_list = GetDlgItem(IDC_LIST);
	cwnd_staffID = GetDlgItem(IDC_STAFFID);
	cwnd_staffName = GetDlgItem(IDC_STAFFNAME);
	cwnd_duty = GetDlgItem(IDC_DUTY);
	cwnd_contractID = GetDlgItem(IDC_CONTRACTID);
	cwnd_contractTerm = GetDlgItem(IDC_CONTRACTTERM);
	cwnd_department = GetDlgItem(IDC_DEPARTMENT);
	cwnd_sex = GetDlgItem(IDC_SEX);
	cwnd_address = GetDlgItem(IDC_ADDRESS);
	cwnd_birthday = GetDlgItem(IDC_BIRTHDAY);
	cwnd_marriageCondition = GetDlgItem(IDC_MARRIAGECONDITION);
	cwnd_postcode = GetDlgItem(IDC_POSTCODE);
	cwnd_telephone = GetDlgItem(IDC_TELEPHONE);
	cwnd_nationality = GetDlgItem(IDC_NATIONALITY);
	cwnd_eMail = GetDlgItem(IDC_EMAIL);
	cwnd_educationLevel = GetDlgItem(IDC_EDUCATIONLEVEL);
	cwnd_QQ = GetDlgItem(IDC_QQ);
	cwnd_graduateSchool = GetDlgItem(IDC_GRADUATESCHOOL);
	cwnd_major = GetDlgItem(IDC_MAJOR);
	cwnd_identityNO = GetDlgItem(IDC_IDENTITYNO);
	cwnd_mobile = GetDlgItem(IDC_MOBILE);
	cwnd_workType = GetDlgItem(IDC_WORKTYPE);
	cwnd_remark = GetDlgItem(IDC_REMARK);
	
	cwnd_add = GetDlgItem(IDC_ADD);
	cwnd_cancel = GetDlgItem(IDC_CANCELLATION);
	cwnd_delete = GetDlgItem(IDC_DELETE);
	cwnd_modify = GetDlgItem(IDC_MODIFY);
	cwnd_save = GetDlgItem(IDC_SAVE);
	cwnd_exit = GetDlgItem(IDC_EXIT);

	flag = 0;

	_RecordsetPtr m_pRecordset;

	CString strSQL;
	strSQL="select * from staff";
	HRESULT hTRes;
	hTRes = m_pRecordset.CreateInstance(_T("ADODB.Recordset"));
	if (SUCCEEDED(hTRes))
	{
		hTRes = m_pRecordset->Open((LPTSTR)strSQL.GetBuffer(130),
			((COfficeApp*)AfxGetApp())->m_pConn.GetInterfacePtr(),
			adOpenDynamic,adLockPessimistic,adCmdText);
		int i=0;
		
		while(!(m_pRecordset->adoEOF))
		{
			m_list.InsertItem(i,((COfficeApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("staffID")));
			m_list.SetItemText(i,1,((COfficeApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("staffName")));
			m_list.SetItemText(i,2,((COfficeApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("duty")));
			
			i++;
			if(!(m_pRecordset->adoEOF))
				m_pRecordset->MoveNext();
		}
	}

	cwnd_list->EnableWindow(true);
	cwnd_staffID->EnableWindow(false);
	cwnd_staffName->EnableWindow(false);
	cwnd_duty->EnableWindow(false);
	cwnd_contractID->EnableWindow(false);
	cwnd_contractTerm->EnableWindow(false);
	cwnd_department->EnableWindow(false);
	cwnd_sex->EnableWindow(false);
	cwnd_address->EnableWindow(false);
	cwnd_birthday->EnableWindow(false);
	cwnd_marriageCondition->EnableWindow(false);
	cwnd_postcode->EnableWindow(false);
	cwnd_telephone->EnableWindow(false);
	cwnd_nationality->EnableWindow(false);
	cwnd_eMail->EnableWindow(false);
	cwnd_educationLevel->EnableWindow(false);
	cwnd_QQ->EnableWindow(false);
	cwnd_graduateSchool->EnableWindow(false);
	cwnd_major->EnableWindow(false);
	cwnd_identityNO->EnableWindow(false);
	cwnd_mobile->EnableWindow(false);
	cwnd_workType->EnableWindow(false);
	cwnd_remark->EnableWindow(false);
	
	cwnd_add->EnableWindow(true);
	cwnd_cancel->EnableWindow(false);
	cwnd_delete->EnableWindow(false);
	cwnd_modify->EnableWindow(false);
	cwnd_save->EnableWindow(false);
	cwnd_exit->EnableWindow(true);
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CStaffRecord::OnAdd() 
{
	m_staffID = _T("");
	m_staffName = _T("");
	m_duty = _T("");
	m_contractID = _T("");
	m_contractTerm = 0;
	m_department = _T("");
	m_sex = _T("");
	m_address = _T("");
	m_birthday = COleDateTime::GetCurrentTime();
	m_marriageCondition = _T("");
	m_postcode = _T("");
	m_telephone = _T("");
	m_nationality = _T("");
	m_eMail = _T("");
	m_educationLevel = _T("");
	m_QQ = _T("");
	m_graduateSchool = _T("");
	m_major = _T("");
	m_identityNO = _T("");
	m_mobile = _T("");
	m_workType = _T("");
	m_remark = _T("");

	cwnd_list->EnableWindow(true);
	cwnd_staffID->EnableWindow(true);
	cwnd_staffName->EnableWindow(true);
	cwnd_duty->EnableWindow(true);
	cwnd_contractID->EnableWindow(true);
	cwnd_contractTerm->EnableWindow(true);
	cwnd_department->EnableWindow(true);
	cwnd_sex->EnableWindow(true);
	cwnd_address->EnableWindow(true);
	cwnd_birthday->EnableWindow(true);
	cwnd_marriageCondition->EnableWindow(true);
	cwnd_postcode->EnableWindow(true);
	cwnd_telephone->EnableWindow(true);
	cwnd_nationality->EnableWindow(true);
	cwnd_eMail->EnableWindow(true);
	cwnd_educationLevel->EnableWindow(true);
	cwnd_QQ->EnableWindow(true);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -