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

📄 adddlg.cpp

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

#include "stdafx.h"
#include "dangan.h"
#include "AddDlg.h"
#include "AllDlg.h"
#include "fstream.h"
#include "hlinklist.h"

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

/////////////////////////////////////////////////////////////////////////////
// CAddDlg dialog


CAddDlg::CAddDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CAddDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CAddDlg)
	m_year = 0;
	m_pay = 0.0f;
	m_month = 0;
	//}}AFX_DATA_INIT
//mname="";
}


void CAddDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CAddDlg)
	DDX_Control(pDX, IDC_EDIT_BIRTHPLACE, m_birthplace);
	DDX_Control(pDX, IDC_EDIT_COMPANY, m_company);
	DDX_Control(pDX, IDC_EDIT_DUTY, m_duty);
	DDX_Control(pDX, IDC_EDIT_LEVEL, m_level);
	DDX_Control(pDX, IDC_EDIT_NATION, m_nation);
	DDX_Control(pDX, IDC_EDIT_PARTY, m_party);
	DDX_Control(pDX, IDC_COMBO_SEX, m_sex);
	DDX_Control(pDX, IDC_EDIT_NAME, m_name);
	DDX_Text(pDX, IDC_EDIT_YEAR, m_year);
	DDV_MinMaxInt(pDX, m_year, 1900, 2002);
	DDX_Text(pDX, IDC_EDIT_PAY, m_pay);
	DDX_Text(pDX, IDC_EDIT_MONTH, m_month);
	DDV_MinMaxInt(pDX, m_month, 1, 12);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CAddDlg, CDialog)
	//{{AFX_MSG_MAP(CAddDlg)
	ON_EN_CHANGE(IDC_EDIT_NAME, OnChangeEditName)
	ON_CBN_EDITCHANGE(IDC_COMBO_SEX, OnEditchangeComboSex)
	ON_EN_CHANGE(IDC_EDIT_DUTY, OnChangeEditDuty)
	ON_EN_CHANGE(IDC_EDIT_BIRTHPLACE, OnChangeEditBirthplace)
	ON_EN_CHANGE(IDC_EDIT_NATION, OnChangeEditNation)
	ON_EN_CHANGE(IDC_EDIT_LEVEL, OnChangeEditLevel)
	ON_EN_CHANGE(IDC_EDIT_PARTY, OnChangeEditParty)
	ON_EN_CHANGE(IDC_EDIT_COMPANY, OnChangeEditCompany)
	ON_CBN_SELCHANGE(IDC_COMBO_SEX, OnSelchangeComboSex)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CAddDlg message handlers

//CString nname;
//char *mname;

void CAddDlg::OnChangeEditName() 
{
	m_name.GetWindowText(mname);
	// 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
	
}

BOOL CAddDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();	
	m_sex.SetCurSel(0);
//	m_month=1;
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CAddDlg::OnCancel() 
{
	// TODO: Add extra cleanup here
	CDialog::OnCancel();
	CAllDlg dlg;
	dlg.DoModal();
}
LinkList mList;
int mmnum;

bool IInput(){
	ifstream in("persondatalist.txt");
	if(!in){
		AfxMessageBox("can not open file");
		return 0;
	}
	int i=1;
	LinkList p;
	mList=new LNode;
	p=mList;
	in>>mmnum;
	CString STR[50];
	int j=0;
	while(i<=mmnum&&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++<mmnum){
			p->next=new LNode;
			p=p->next;
		}
	}
	p->next=NULL;
	in.close();
	return 1;
}
void CAddDlg::OnOK() 
{	
	IInput();
	LinkList pp;
//	pp=new LNode;
	pp=mList;
	while(pp->next){
		pp=pp->next;
	}
	pp->next=new LNode;
	pp=pp->next;
	CDialog::OnOK();
	CAllDlg dlg;
	dlg.DoModal();
	strcpy(pp->data.name,(char*) LPCTSTR(mname));
	strcpy(pp->data.birthplace,(char*)LPCTSTR(mbirthplace));
	strcpy(pp->data.duty,(char*)LPCTSTR(mduty));
	strcpy(pp->data.level,(char*)LPCTSTR(mlevel));
	strcpy(pp->data.nation,(char*)LPCTSTR(mnation));
	strcpy(pp->data.party,(char*)LPCTSTR(mparty));
	strcpy(pp->data.sex,(char*)LPCTSTR(msex));
	strcpy(pp->data.company,(char*)LPCTSTR(mcompany));
	pp->data.year=m_year;
	pp->data.month=m_month;
	pp->data.pay=m_pay;
	pp->data.num=mmnum;
	pp->next=NULL;
	ofstream out("tt.txt");
//	out<<pp->data.pay;
	out<<++mmnum<<endl;
	LinkList q=new LNode;
	q=mList;
	while(q->next){
		out<<q->data.num<<"  "<<q->data.name<<"  "<<q->data.sex<<"  "<<q->data.year<<"  "<<q->data.month<<"  "<<q->data.birthplace<<"  "<<q->data.nation<<"  "<<q->data.duty<<"  "<<q->data.level<<"  "<<q->data.party<<"  "<<q->data.company<<"  "<<q->data.pay<<endl;
		q=q->next;
	}
	out<<q->data.num<<"  "<<q->data.name<<"  "<<q->data.sex<<"  "<<q->data.year<<"  "<<q->data.month<<"  "<<q->data.birthplace<<"  "<<q->data.nation<<"  "<<q->data.duty<<"  "<<q->data.level<<"  "<<q->data.party<<"  "<<q->data.company<<"  "<<q->data.pay<<endl;
	out.close();
}

void CAddDlg::OnEditchangeComboSex() 
{
/*	int nSelection=m_sex.GetCurSel();
	m_sex.GetLBText(nSelection,msex);
//	MessageBox(msex);
	UpdateData(FALSE);*/
}



void CAddDlg::OnChangeEditDuty() 
{
	m_duty.GetWindowText(mduty);
//	UpdateData(FALSE);
	// 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 CAddDlg::OnChangeEditBirthplace() 
{
	m_birthplace.GetWindowText(mbirthplace);
//	UpdateData(TRUE);
	// 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 CAddDlg::OnChangeEditNation() 
{
	m_nation.GetWindowText(mnation);
//	UpdateData(TRUE);
	// 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 CAddDlg::OnChangeEditLevel() 
{	
	m_level.GetWindowText(mlevel);
//	UpdateData(TRUE);

	// 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 CAddDlg::OnChangeEditParty() 
{
	m_party.GetWindowText(mparty);
//	UpdateData(TRUE);
		// 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 CAddDlg::OnChangeEditCompany() 
{
	m_company.GetWindowText(mcompany);
//	UpdateData(TRUE);
	// 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 CAddDlg::OnSelchangeComboSex() 
{
	int nSelection=m_sex.GetCurSel();
	m_sex.GetLBText(nSelection,msex);
	UpdateData(FALSE);
}

/*void CAddDlg::OnChangeEditYear() 
{
	myear=(int)GetDlgItemInt(IDC_EDIT_YEAR);
	// 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 CAddDlg::OnChangeEditMonth() 
{
	mmonth=(int)GetDlgItemInt(IDC_EDIT_MONTH);
	// 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 CAddDlg::OnChangeEditPay() 
{
//	mpay=(float)GetDlgItemInt(IDC_EDIT_PAY);
//	mpay=m_pay;
//	UpdateWindow();
	// 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
	
}
*/

⌨️ 快捷键说明

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