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

📄 employview.cpp.bak

📁 这是一折员工管理系统
💻 BAK
字号:
// EmployView.cpp : implementation of the CEmployView class
//

#include "stdafx.h"
#include "Employ.h"

#include "EmployDoc.h"
#include "EmployView.h"

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

/////////////////////////////////////////////////////////////////////////////
// CEmployView

IMPLEMENT_DYNCREATE(CEmployView, CFormView)

BEGIN_MESSAGE_MAP(CEmployView, CFormView)
	//{{AFX_MSG_MAP(CEmployView)
	ON_WM_SIZE()
	ON_BN_CLICKED(IDC_BUTTON_IN, OnButtonIn)
	ON_NOTIFY(NM_RELEASEDCAPTURE, IDC_SLIDERBAR, OnReleasedcaptureSliderbar)
	ON_BN_CLICKED(IDC_BUTTON_DEL, OnButtonDel)
	ON_WM_TIMER()
	ON_UPDATE_COMMAND_UI(IDM_SEARCH, OnUpdateSearch)
	ON_COMMAND(IDM_SEARCH, OnSearch)
	ON_COMMAND(IDM_SORT, OnSort)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CEmployView construction/destruction

CEmployView::CEmployView()
	: CFormView(CEmployView::IDD)
{
	//{{AFX_DATA_INIT(CEmployView)
	m_sNameIn = _T("");
	m_iSexIn = -1;
	m_sEducateIn = _T("");
	m_sDutyIn = _T("");
	m_sAddressIn = _T("");
	m_sPhoneIn = _T("");
	m_sMemoIn = _T("");
	m_sNameDel = _T("");
	m_sEducateDel = _T("");
	m_sDutyDel = _T("");
	m_sAddressDel = _T("");
	m_sPhoneDel = _T("");
	m_sMemoDel = _T("");
	m_uiBirthDayIn = 1;
	m_uiBirthMonthIn = 1;
	m_uiBirthYearIn = 1971;
	m_uiWorkDayIn = 1;
	m_uiWorkMonthIn = 1;
	m_uiWorkYearIn = 1971;
	m_sBirthDel = _T("");
	m_sWorkDel = _T("");
	m_sSexDel = _T("");
	//}}AFX_DATA_INIT
	// TODO: add construction code here
	m_IsTimer=false;
	m_sPrint=_T("就绪");
}

CEmployView::~CEmployView()
{
	
}

void CEmployView::DoDataExchange(CDataExchange* pDX)
{
	CFormView::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CEmployView)
	DDX_Control(pDX, IDC_SLIDERBAR, m_SlideBarCtrl);
	DDX_Control(pDX, IDC_SEX_IN, m_SexIn);
	DDX_Text(pDX, IDC_NAME_IN, m_sNameIn);
	DDX_CBIndex(pDX, IDC_SEX_IN, m_iSexIn);
	DDX_Text(pDX, IDC_EDU_IN, m_sEducateIn);
	DDX_Text(pDX, IDC_DUTY_IN, m_sDutyIn);
	DDX_Text(pDX, IDC_ADDRESS_IN, m_sAddressIn);
	DDX_Text(pDX, IDC_PHONE_IN, m_sPhoneIn);
	DDX_Text(pDX, IDC_MEMO_IN, m_sMemoIn);
	DDX_Text(pDX, IDC_NAME_DEL, m_sNameDel);
	DDX_Text(pDX, IDC_EDU_DEL, m_sEducateDel);
	DDX_Text(pDX, IDC_DUTY_DEL, m_sDutyDel);
	DDX_Text(pDX, IDC_ADDRESS_DEL, m_sAddressDel);
	DDX_Text(pDX, IDC_PHONE_DEL, m_sPhoneDel);
	DDX_Text(pDX, IDC_MEMO_DEL, m_sMemoDel);
	DDX_Text(pDX, IDC_BIRTHDAY_IN, m_uiBirthDayIn);
	DDV_MinMaxUInt(pDX, m_uiBirthDayIn, 1, 31);
	DDX_Text(pDX, IDC_BIRTHMONTH_IN, m_uiBirthMonthIn);
	DDV_MinMaxUInt(pDX, m_uiBirthMonthIn, 1, 12);
	DDX_Text(pDX, IDC_BIRTHYEAR_IN, m_uiBirthYearIn);
	DDX_Text(pDX, IDC_WORKDAY_IN, m_uiWorkDayIn);
	DDV_MinMaxUInt(pDX, m_uiWorkDayIn, 1, 31);
	DDX_Text(pDX, IDC_WORKMONTH_IN, m_uiWorkMonthIn);
	DDV_MinMaxUInt(pDX, m_uiWorkMonthIn, 1, 12);
	DDX_Text(pDX, IDC_WORKYEAR_IN, m_uiWorkYearIn);
	DDX_Text(pDX, IDC_BIRTH_DEL, m_sBirthDel);
	DDX_Text(pDX, IDC_WORK_DEL, m_sWorkDel);
	DDX_Text(pDX, IDC_SEX_DEL, m_sSexDel);
	DDV_MaxChars(pDX, m_sSexDel, 4);
	//}}AFX_DATA_MAP
}

BOOL CEmployView::PreCreateWindow(CREATESTRUCT& cs)
{
	// TODO: Modify the Window class or styles here by modifying
	//  the CREATESTRUCT cs

	return CFormView::PreCreateWindow(cs);
}

void CEmployView::OnInitialUpdate()
{
	CFormView::OnInitialUpdate();
	GetParentFrame()->RecalcLayout();
	ResizeParentToFit();
	m_SlideBarCtrl.SetRangeMin(0,TRUE);
	SetTimer(100,500,NULL);
}

/////////////////////////////////////////////////////////////////////////////
// CEmployView diagnostics

#ifdef _DEBUG
void CEmployView::AssertValid() const
{
	CFormView::AssertValid();
}

void CEmployView::Dump(CDumpContext& dc) const
{
	CFormView::Dump(dc);
}

CEmployDoc* CEmployView::GetDocument() // non-debug version is inline
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CEmployDoc)));
	return (CEmployDoc*)m_pDocument;
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CEmployView message handlers

void CEmployView::OnSize(UINT nType, int cx, int cy) 
{
	CFormView::OnSize(nType, cx, cy);
	
	// TODO: Add your message handler code here
}

void CEmployView::OnButtonIn() 
{
	// TODO: Add your control notification handler code here
	UpdateData();
	m_sEducateIn.TrimLeft();
	m_sEducateIn.TrimRight();
	m_sDutyIn.TrimLeft();
	m_sDutyIn.TrimRight();
	m_sAddressIn.TrimLeft();
	m_sAddressIn.TrimRight();
	m_sPhoneIn.TrimLeft();
	m_sPhoneIn.TrimRight();
	m_sMemoIn.TrimLeft();
	m_sMemoIn.TrimRight();
	m_sNameIn.TrimLeft();
	m_sNameIn.TrimRight();
	if(m_sNameIn.IsEmpty()||m_SexIn.GetCurSel()==CB_ERR||
		m_uiBirthYearIn<1970||m_uiBirthYearIn>2038||
		m_uiBirthMonthIn<1||m_uiBirthMonthIn>12||
		m_uiBirthDayIn<1||m_uiBirthDayIn>31||
		m_uiWorkYearIn<1970||m_uiWorkYearIn>2038||
		m_uiWorkMonthIn<1||m_uiWorkMonthIn>12||
		m_uiWorkDayIn<1||m_uiWorkDayIn>31)
	{
		MessageBox("姓名、性别、出生年月、工作年月\n未输入或则输入不合法!","输入错误!");
		return;
	}
	CTime tBirthIn((int)m_uiBirthYearIn,(int)m_uiBirthMonthIn,(int)m_uiBirthDayIn,0,0,0);
	CTime tWorkIn((int)m_uiWorkYearIn,(int)m_uiWorkMonthIn,(int)m_uiWorkDayIn,0,0,0);
	CEmploy tp;
	tp.m_iSex=m_iSexIn;
	tp.m_sAddress=m_sAddressIn;
	tp.m_sDuty=m_sDutyIn;
	tp.m_sEducate=m_sEducateIn;
	tp.m_sMemo=m_sMemoIn;
	tp.m_sName=m_sNameIn;
	tp.m_sPhone=m_sPhoneIn;
	tp.m_tBirth=tBirthIn;
	tp.m_tWork=tWorkIn;
	GetDocument()->m_Sys.AddEmploy(tp);
	GetDocument()->SetModifiedFlag();
	m_sEducateIn=_T("");
	m_sDutyIn=_T("");
	m_sAddressIn=_T("");
	m_sPhoneIn=_T("");
	m_sMemoIn=_T("");
	m_sNameIn=_T("");
	m_iSexIn=-1;
	m_uiBirthDayIn=1;
	m_uiBirthMonthIn=1;
	m_uiBirthYearIn=1971;
	m_uiWorkDayIn=1;
	m_uiWorkMonthIn=1;
	m_uiWorkYearIn=1971;
	UpdateData(FALSE);
	GetDocument()->UpdateAllViews(NULL);
	m_sPrint="数据添加成功!!!!!";
	m_IsTimer=true;
}

void CEmployView::OnReleasedcaptureSliderbar(NMHDR* pNMHDR, LRESULT* pResult) 
{
	// TODO: Add your control notification handler code here
	int pos=m_SlideBarCtrl.GetPos();
	GetDocument()->UpdateAllViews(NULL);
	*pResult = 0;
}

void CEmployView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint) 
{
	// TODO: Add your specialized code here and/or call the base class
	int count=GetDocument()->m_Sys.GetCount();
	if(count==0)
	{
		m_SlideBarCtrl.SetRangeMax(0,TRUE);
		m_sSexDel=_T("");
		m_sAddressDel=_T("");
		m_sBirthDel=_T("");
		m_sWorkDel=_T("");
		m_sDutyDel=_T("");
		m_sEducateDel=_T("");
		m_sMemoDel=_T("");
		m_sNameDel=_T("");
		m_sPhoneDel=_T("");
	}
	else
	{
		m_SlideBarCtrl.SetRangeMax(count-1,TRUE);
		int pos=m_SlideBarCtrl.GetPos();
		CEmploy temp;
		GetDocument()->m_Sys.GetEmploy(temp,pos);
		if(temp.m_iSex)
			m_sSexDel=_T("男");
		else
			m_sSexDel=_T("女");
		m_sAddressDel=temp.m_sAddress;
		m_sBirthDel=temp.m_tBirth.Format("%Y-%m-%d");
		m_sWorkDel=temp.m_tWork.Format("%Y-%m-%d");
		m_sDutyDel=temp.m_sDuty;
		m_sEducateDel=temp.m_sEducate;
		m_sMemoDel=temp.m_sMemo;
		m_sNameDel=temp.m_sName;
		m_sPhoneDel=temp.m_sPhone;
	}
	UpdateData(FALSE);
}

void CEmployView::OnButtonDel() 
{
	// TODO: Add your control notification handler code here
	if(GetDocument()->m_Sys.GetCount()==0)
	{
		MessageBox("无记录可删除","警告!!");
		return;
	}
	int pos=m_SlideBarCtrl.GetPos();
	CEmploy temp;
	GetDocument()->m_Sys.GetEmploy(temp,pos);
	if(GetDocument()->m_Sys.DelEmploy(temp))
	{
		GetDocument()->SetModifiedFlag();
		GetDocument()->UpdateAllViews(NULL);
		m_sPrint="数据删除成功!!!!!";
		m_IsTimer=true;
	}
	else
	{
		MessageBox("删除发生错误!","错误!!");
		return;
	}
}

BOOL CEmployView::DestroyWindow() 
{
	// TODO: Add your specialized code here and/or call the base class
	KillTimer(100);
	return CFormView::DestroyWindow();
}

void CEmployView::OnTimer(UINT nIDEvent) 
{
	// TODO: Add your message handler code here and/or call default
	CMainFrame * MainFramePt=(CMainFrame *)GetParentFrame();
	if(m_IsTimer)
	{
		MainFramePt->GetStatusBarPt()->SetPaneText(0,m_sPrint);
		m_sPrint="就绪";
		m_IsTimer=false;
	}
	else
	{
		if(MainFramePt->GetStatusBarPt()->GetPaneText(0)!=m_sPrint)
			MainFramePt->GetStatusBarPt()->SetPaneText(0,m_sPrint);
	}
	CFormView::OnTimer(nIDEvent);
}

void CEmployView::OnUpdateSearch(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	if(GetDocument()->m_Sys.GetCount()==0)
		pCmdUI->Enable(FALSE);
	else
		pCmdUI->Enable();
}

void CEmployView::OnSearch() 
{
	// TODO: Add your command handler code here
	CSearchDg m_Search;
	m_Search.DoModal();
}

void CEmployView::OnSort() 
{
	// TODO: Add your command handler code here
	CSortDg m_DgSort;
	if(m_DgSort.DoModal()==IDOK)
	{
		if(m_DgSort.m_iInWitch!=-1)
		{
			CEmploy ** ttp=NULL;
			GetDocument()->m_Sys.SortEmploy(ttp,m_DgSort.m_iInWitch);
			GetDocument()->m_Sys.InPutPtr(ttp);
			m_sPrint="数据排序成功";
			m_IsTimer=true;
			GetDocument()->SetModifiedFlag();
			GetDocument()->UpdateAllViews(NULL);
		}
	}
}

⌨️ 快捷键说明

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