📄 dlgea.cpp
字号:
// DlgEA.cpp : implementation file
//
#include "stdafx.h"
#include "stdio.h"
#include "finalhomework.h"
#include "DlgEA.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDlgEA dialog
CDlgEA::CDlgEA(CString a): CDialog(CDlgEA::IDD)
{
m_bday = _T("");
m_bmonth = _T("");
m_byear = _T("");
m_score = _T("");
m_finish = _T("");
m_address = _T("");
m_name = _T("");
m_report = _T("");
m_user=a;
m_olduser=m_user;
m_oldpassword="0";
m_man = 0;
FILE *fp;
char *t;
char temp[200];
if(a!=_T("")){
t=(char *)(LPCSTR)(a+"5"+".dat");
strcpy(temp,t);
strcpy(temp,(LPCSTR)(a+"5"+".dat"));
if((fp=fopen(temp,"r"))!=NULL){
fscanf(fp,"%s",temp);
m_user=temp;
fscanf(fp,"%s",temp);
m_password=temp;
m_oldpassword=m_password;
fscanf(fp,"%s",temp);
m_name=temp;
fscanf(fp,"%d",&m_man);
fscanf(fp,"%s",temp);
m_address=temp;
fscanf(fp,"%s",temp);
m_byear=temp;
fscanf(fp,"%s",temp);
m_bmonth=temp;
fscanf(fp,"%s",temp);
m_bday=temp;
fscanf(fp,"%s",temp);
m_itemdistributed=temp;
fscanf(fp,"%s",temp);
m_valuation=temp;
fscanf(fp,"%s",temp);
m_finish=temp;
fscanf(fp,"%s",temp);
m_score=temp;
fscanf(fp,"%s",temp);
m_report=temp;
fclose(fp);
}
}
}
void CDlgEA::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDlgEA)
DDX_CBString(pDX, IDC_BDAY, m_bday);
DDX_CBString(pDX, IDC_BMONTH, m_bmonth);
DDX_CBString(pDX, IDC_BYEAR, m_byear);
DDX_Text(pDX, IDC_EADDRESS, m_address);
DDX_CBString(pDX, IDC_EFINSH, m_finish);
DDX_Text(pDX, IDC_EITEMDISTRIBUTED, m_itemdistributed);
DDX_Text(pDX, IDC_EMEVALUTION, m_valuation);
DDX_Text(pDX, IDC_ENAME, m_name);
DDX_Text(pDX, IDC_EREPORT, m_report);
DDX_CBString(pDX, IDC_ESCORE, m_score);
DDX_Radio(pDX, IDC_RADIO1, m_man);
DDX_Text(pDX, IDC_EPASSWORD, m_password);
DDX_Text(pDX, IDC_EUSER, m_user);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDlgEA, CDialog)
//{{AFX_MSG_MAP(CDlgEA)
ON_EN_CHANGE(IDC_ENAME, OnChangeEname)
ON_CBN_EDITCHANGE(IDC_BYEAR, OnEditchangeByear)
ON_CBN_EDITCHANGE(IDC_BDAY, OnEditchangeBday)
ON_CBN_EDITCHANGE(IDC_BMONTH, OnEditchangeBmonth)
ON_EN_CHANGE(IDC_EADDRESS, OnChangeEaddress)
ON_CBN_EDITCHANGE(IDC_EFINSH, OnEditchangeEfinsh)
ON_EN_CHANGE(IDC_EITEMDISTRIBUTED, OnChangeEitemdistributed)
ON_EN_CHANGE(IDC_EMEVALUTION, OnChangeEmevalution)
ON_EN_CHANGE(IDC_EREPORT, OnChangeEreport)
ON_CBN_EDITCHANGE(IDC_ESCORE, OnEditchangeEscore)
ON_BN_CLICKED(IDC_RADIO1, OnRadio1)
ON_BN_CLICKED(IDC_SAVECHANGE, OnSavechange)
ON_EN_CHANGE(IDC_EUSER, OnChangeEuser)
ON_EN_CHANGE(IDC_EPASSWORD, OnChangeEpassword)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDlgEA message handlers
void CDlgEA::OnChangeEname()
{
// 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
UpdateData(TRUE);
}
void CDlgEA::OnEditchangeByear()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
}
void CDlgEA::OnEditchangeBday()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
}
void CDlgEA::OnEditchangeBmonth()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
}
void CDlgEA::OnChangeEaddress()
{
// 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
UpdateData(TRUE);
}
void CDlgEA::OnEditchangeEfinsh()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
}
void CDlgEA::OnChangeEitemdistributed()
{
// 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
UpdateData(TRUE);
}
void CDlgEA::OnChangeEmevalution()
{
// 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
UpdateData(TRUE);
}
void CDlgEA::OnChangeEreport()
{
// 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
UpdateData(TRUE);
}
void CDlgEA::OnEditchangeEscore()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
}
void CDlgEA::OnRadio1()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
}
void CDlgEA::OnSavechange()
{
// TODO: Add your control notification handler code here
FILE *fp;
char *t;
char temp[200];
if(m_user!=_T("")){
if(m_user!=m_olduser)
{
t=(char *)(LPCSTR)(m_olduser+"5"+".dat");
strcpy(temp,t);
strcpy(temp,(LPCSTR)(m_olduser+"5"+".dat"));
remove(temp);
}
t=(char *)(LPCSTR)(m_user+"5"+".dat");
strcpy(temp,t);
strcpy(temp,(LPCSTR)(m_user+"5"+".dat"));
fp=fopen(temp,"w+");
fprintf(fp,"%s\n",m_user);
fprintf(fp,"%s\n",m_password);
fprintf(fp,"%s\n",m_name);
fprintf(fp,"%d\n",m_man);
fprintf(fp,"%s\n",m_address);
fprintf(fp,"%s\n",m_byear);
fprintf(fp,"%s\n",m_bmonth);
fprintf(fp,"%s\n",m_bday);
fprintf(fp,"%s\n",m_itemdistributed);
fprintf(fp,"%s\n",m_valuation);
fprintf(fp,"%s\n",m_finish);
fprintf(fp,"%s\n",m_score);
fprintf(fp,"%s\n",m_report);
fclose(fp);
}
if(m_oldpassword!=m_password||m_olduser!=m_user){
int N;
fp=fopen("DataN5.dat","r");
fscanf(fp,"%d",&N);
fclose(fp);
fp=fopen("Data5.dat","r");
for(int i=0;i<N;i++)
{
fscanf(fp,"%s",temp);
user[i].user=temp;
if(user[i].user==m_olduser)
{
fscanf(fp,"%s",temp);
user[i].password=temp;
if(user[i].password==m_oldpassword)
{
user[i].user=m_user;
user[i].password=m_password;
}
}
}
fclose(fp);
fp=fopen("Data5.dat","w+");
for(i=0;i<N;i++)
{
fprintf(fp,"%s\n",user[i].user);
fprintf(fp,"%s\n",user[i].password);
}
fclose(fp);
}
// DestroyWindow();
}
void CDlgEA::OnChangeEuser()
{
// 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
UpdateData(TRUE);
}
void CDlgEA::OnChangeEpassword()
{
// 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
UpdateData(TRUE);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -