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

📄 findaperson.cpp

📁 一个人事档案的数据库
💻 CPP
字号:
// FindAperson.cpp : implementation file
//

#include "stdafx.h"
#include "dangan.h"
#include "FindAperson.h"
#include "AllDlg.h"
//#include "hchang.h"
#include "fstream.h"
#include "hlinklist.h"
#include "AllDlg.h"

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

/////////////////////////////////////////////////////////////////////////////
// CFindAperson dialog


CFindAperson::CFindAperson(CWnd* pParent /*=NULL*/)
	: CDialog(CFindAperson::IDD, pParent)
{
	//{{AFX_DATA_INIT(CFindAperson)
	m_radio_name = -1;
	//}}AFX_DATA_INIT
}


void CFindAperson::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CFindAperson)
	DDX_Control(pDX, IDC_LIST_RESALT, m_resalt);
	DDX_Control(pDX, IDC_BUTTON_FIND, m_button_find);
	DDX_Control(pDX, IDC_STATIC_MATHOD, m_static_mathod);
	DDX_Control(pDX, IDC_EDIT_MATHOD, m_mathod);
	DDX_Radio(pDX, IDC_RADIO_NAME, m_radio_name);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CFindAperson, CDialog)
	//{{AFX_MSG_MAP(CFindAperson)
	ON_BN_CLICKED(IDC_BUTTON_FIND, OnButtonFind)
	ON_BN_CLICKED(IDC_RADIO_NAME, OnRadioName)
	ON_BN_CLICKED(IDC_RADIO_DUTY, OnRadioDuty)
	ON_BN_CLICKED(IDC_RADIO_LEVEL, OnRadioLevel)
	ON_BN_CLICKED(IDC_RADIO_COMPANY, OnRadioCompany)
	ON_EN_CHANGE(IDC_EDIT_MATHOD, OnChangeEditMathod)
	ON_BN_CLICKED(IDC_STATIC_MATHOD, OnStaticMathod)
	ON_LBN_DBLCLK(IDC_LIST_RESALT, OnDblclkListResalt)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CFindAperson message handlers
CString mmathod;
LinkList List;
CString resaltstring[50];

void CFindAperson::OnOK() 
{
	CDialog::OnOK();
	CAllDlg dlg;
	dlg.DoModal();
}
//void ResaltOfFind(LinkList mlist){
//	CString resaltstring[50];
//	CHANGETOSTRING(mlist,resaltstring);

void NCHANGETOCHAR(CString mchar[10],int num){
	int i=0;
	mchar[i]+=num%10+'0';
	while(num/=10){
		mchar[i]+=num%10+'0';
	}
	mchar[i].MakeReverse();
}

CString NCHANGETOSTRING(LinkList mlist,CString str[50]){
	CString str1[5],str2[6],str3[5],str4[9];
	int num=mlist->data.num;
	int year=mlist->data.year;
	int month=mlist->data.month;
	int pay=(int)mlist->data.pay;
	NCHANGETOCHAR(str1,num);
	NCHANGETOCHAR(str2,year);
	NCHANGETOCHAR(str3,month);
	NCHANGETOCHAR(str4,pay);
	int i=0;
//	int j=0;
	str[i]="";
	CString space;
	space="    ";
	str[i]+=str1[i];
	str[i]+=space;
	str[i]+=mlist->data.name;
	str[i]+=space;
	str[i]+=mlist->data.sex;
	str[i]+=space;
	str[i]+=str2[i];
	str[i]+=space;
	str[i]+=str3[i];
	str[i]+=space;
	str[i]+=mlist->data.birthplace;
	str[i]+=space;
	str[i]+=mlist->data.nation;
	str[i]+=space;
	str[i]+=mlist->data.duty;
	str[i]+=space;
	str[i]+=mlist->data.level;
	str[i]+=space;
	str[i]+=mlist->data.party;
	str[i]+=space;
	str[i]+=mlist->data.company;
	str[i]+=space;
	str[i]+=str4[i];
//	AfxMessageBox(str[i]);
	str[i]+='\0';
	return str[i];
}	
CString IndList=("编号 姓名  性别  出生年 月   籍贯   民族   职务  职称  党派  单位  工资"); 	
void CFindAperson::OnButtonFind() 
{
	int i=0;
	if(m_radio_name==0){
		m_resalt.ResetContent();
		m_resalt.AddString(IndList);
		LinkList p;
		p=new LNode;
		p=List;
		int flag=0;
		while(p->next){
	//		cout<<p->data.company<<findperson->data.company<<endl<<endl;
			if(p->data.name==mmathod){
				NCHANGETOSTRING(p,resaltstring);
				m_resalt.AddString(resaltstring[i]);
				flag=1;
			}
			p=p->next;
		}
		if(p->data.name==mmathod){
			flag=1;
			NCHANGETOSTRING(p,resaltstring);
			m_resalt.AddString(resaltstring[i]);
		}
		if(!flag)
			AfxMessageBox("档案中没有符合条件的人员");
		UpdateData(FALSE);
	}
	else if(m_radio_name==1){
		m_resalt.ResetContent();
		m_resalt.AddString(IndList);
		LinkList p;
		p=new LNode;
		p=List;
		int flag=0;
		while(p->next){
	//		cout<<p->data.company<<findperson->data.company<<endl<<endl;
			if(p->data.duty==mmathod){
				NCHANGETOSTRING(p,resaltstring);
				m_resalt.AddString(resaltstring[i]);
				flag=1;
			}
			p=p->next;
		}
		if(p->data.duty==mmathod){
			flag=1;
			NCHANGETOSTRING(p,resaltstring);
			m_resalt.AddString(resaltstring[i]);
		}
		if(!flag)
			AfxMessageBox("档案中没有符合条件的人员");
		UpdateData(FALSE);
	}
	else if(m_radio_name==2){
		m_resalt.ResetContent();
		m_resalt.AddString(IndList);
		LinkList p;
		p=new LNode;
		p=List;
		int flag=0;
		while(p->next){
	//		cout<<p->data.company<<findperson->data.company<<endl<<endl;
			if(p->data.level==mmathod){
				NCHANGETOSTRING(p,resaltstring);
				m_resalt.AddString(resaltstring[i]);
				flag=1;
			}
			p=p->next;
		}
		if(p->data.level==mmathod){
			flag=1;
			NCHANGETOSTRING(p,resaltstring);
			m_resalt.AddString(resaltstring[i]);
		}
		if(!flag)
			AfxMessageBox("档案中没有符合条件的人员");
		UpdateData(FALSE);
	}
	else{
		m_resalt.ResetContent();
		m_resalt.AddString(IndList);
		LinkList p;
		p=new LNode;
		p=List;
		int flag=0;
		while(p->next){
	//		cout<<p->data.company<<findperson->data.company<<endl<<endl;
			if(p->data.company==mmathod){
				NCHANGETOSTRING(p,resaltstring);
				m_resalt.AddString(resaltstring[i]);
				flag=1;
			}
			p=p->next;
		}
		if(p->data.company==mmathod){
			flag=1;
			NCHANGETOSTRING(p,resaltstring);
			m_resalt.AddString(resaltstring[i]);
		}
		if(!flag)
			AfxMessageBox("档案中没有符合条件的人员");
		UpdateData(FALSE);
	}
}

void CFindAperson::OnRadioName() 
{
	m_radio_name=0;
	m_static_mathod.SetWindowText("请输入其姓名");
	UpdateData(FALSE);
}

void CFindAperson::OnRadioDuty() 
{
	m_radio_name=1;
	m_static_mathod.SetWindowText("请输入其职务");
	UpdateData(FALSE);	
}

void CFindAperson::OnRadioLevel() 
{
	m_radio_name=2;
	m_static_mathod.SetWindowText("请输入其职称");
	UpdateData(FALSE);	
}

void CFindAperson::OnRadioCompany() 
{
	m_radio_name=3;
	m_static_mathod.SetWindowText("请输入其单位");
	UpdateData(FALSE);	
	
}

void CFindAperson::OnChangeEditMathod() 
{
	m_mathod.GetWindowText(mmathod);
	// 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.
	
	// TODO: Add your control notification handler code here
	
}

void CFindAperson::OnStaticMathod() 
{
}

BOOL CFindAperson::OnInitDialog() 
{
	CDialog::OnInitDialog();
	//*******************************Input()*****************
	ifstream in("persondatalist.txt");
	if(!in){
		AfxMessageBox("can not open file");
		return 0;
	}
	int i=1;
	LinkList p;
	List=new LNode;
	p=List;
	int num;
	in>>num;
	CString STR[50];
	int j=0;
	while(i<=num&&in){
		in>>p->data.num>>p->data.name>>p->data.sex>>p->data.year>>p->data.month>>p->data.birthplace>>p->data.nation>>p->data.duty>>p->data.level>>p->data.party>>p->data.company>>p->data.pay;
//		cout<<p->data.num<<"  "<<p->data.name<<"  "<<p->data.sex<<"  "<<p->data.year<<"  "<<p->data.month<<"  "<<p->data.birthplace<<"  "<<p->data.nation<<"  "<<p->data.duty<<"  "<<p->data.party<<"  "<<p->data.company<<"  "<<p->data.party<<"  "<<p->data.pay<<endl;
//		m_list.AddString(CHANGETOSTRING(p,STR));			
		if(i++<num){
			p->next=new LNode;
			p=p->next;
		}
	}
	p->next=NULL;
	in.close();	
	//*******************************Input()*****************
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CFindAperson::OnDblclkListResalt() 
{
	CString nresalt;
	int nSelection=m_resalt.GetCurSel();
	m_resalt.GetText(nSelection,nresalt);
	MessageBox(nresalt);
	UpdateData(FALSE);
}

void CFindAperson::OnCancel() 
{
	CDialog::OnCancel();
	CAllDlg dlg;
	dlg.DoModal();
}

⌨️ 快捷键说明

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