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

📄 findalldlg.cpp

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

#include "stdafx.h"
#include "dangan.h"
#include "FindallDlg.h"
#include "AllDlg.h"
#include <iostream.h>
#include <fstream.h>
#include <string.h>
#include "hlinklist.h"

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

/////////////////////////////////////////////////////////////////////////////
// CFindallDlg dialog


CFindallDlg::CFindallDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CFindallDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CFindallDlg)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}


void CFindallDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CFindallDlg)
	DDX_Control(pDX, IDC_LIST_ALL, m_list);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CFindallDlg, CDialog)
	//{{AFX_MSG_MAP(CFindallDlg)
	ON_LBN_DBLCLK(IDC_LIST_ALL, OnDblclkListAll)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CFindallDlg message handlers

void CHANGETOCHAR(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 CHANGETOSTRING(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;
	CHANGETOCHAR(str1,num);
	CHANGETOCHAR(str2,year);
	CHANGETOCHAR(str3,month);
	CHANGETOCHAR(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];
}	

BOOL CFindallDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
//	bool Input(LinkList List,int n){//从文件读入链表
	LinkList List;
	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();
//	return 1;
//}
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CFindallDlg::OnOK() 
{	
	CDialog::OnOK();
	CAllDlg dlg;
	dlg.DoModal();
}

void CFindallDlg::OnDblclkListAll() 
{
	CString nchar;
	int nSelection=m_list.GetCurSel();
	m_list.GetText(nSelection,nchar);
	MessageBox(nchar);
	UpdateData(FALSE);
}

⌨️ 快捷键说明

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