📄 stuinfor.cpp
字号:
// StuInfor.cpp : implementation file
//
#include "stdafx.h"
#include "教学管理系统.h"
#include "StuInfor.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// StuInfor dialog
StuInfor::StuInfor(CWnd* pParent /*=NULL*/)
: CDialog(StuInfor::IDD, pParent)
{
//{{AFX_DATA_INIT(StuInfor)
number = _T("");
name = _T("");
pw = _T("");
date = _T("");
sdept = _T("");
sex = _T("");
//}}AFX_DATA_INIT
}
void StuInfor::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(StuInfor)
DDX_Text(pDX, IDC_EDIT_NO, number);
DDX_Text(pDX, IDC_EDIT_NAME, name);
DDX_Text(pDX, IDC_EDIT_PWD, pw);
DDX_Text(pDX, IDC_EDIT_BIRTHDAY, date);
DDX_Text(pDX, IDC_EDIT_SDEPT, sdept);
DDX_Text(pDX, IDC_EDIT_SEX, sex);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(StuInfor, CDialog)
//{{AFX_MSG_MAP(StuInfor)
ON_BN_CLICKED(IDC_BUTTON_MODIFY, OnButtonModify)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// StuInfor message handlers
BOOL StuInfor::OnInitDialog()
{
CDialog::OnInitDialog();
connection.Initialize();
CString student;
student.Format("select * from 学生 where 学号='%s'",number);
connection.Connect(student);
connection.m_pRecordset->MoveFirst();
while(!connection.m_pRecordset->adoEOF)
{
_variant_t TheValue;
TheValue = connection.m_pRecordset->Fields->GetItem("学号")->Value;
number=TheValue.bstrVal;
TheValue = connection.m_pRecordset->Fields->GetItem("姓名")->Value;
name=TheValue.bstrVal;
TheValue = connection.m_pRecordset->Fields->GetItem("性别")->Value;
sex=TheValue.bstrVal;
TheValue = connection.m_pRecordset->Fields->GetItem("出生日期")->Value;
date=TheValue.bstrVal;
TheValue = connection.m_pRecordset->Fields->GetItem("所在系号")->Value;
sdept=TheValue.bstrVal;
UpdateData(FALSE);
connection.m_pRecordset->MoveNext();
}
connection.Unitialize();
return TRUE; // return TRUE unless you set the focus to a control
// 异常: OCX 属性页应返回 FALSE
}
void StuInfor::OnCancel()
{
// TODO: Add extra cleanup here
EndDialog(0);
}
void StuInfor::OnButtonModify()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
if(pw.IsEmpty())
{
AfxMessageBox("请输入登录密码!");
return;
}
connection.Initialize();
CString student;
student.Format("select * from 学生 where 学号='%s'",number);
connection.Connect(student);
connection.m_pRecordset->Fields->GetItem(_variant_t("出生日期"))->Value=_bstr_t(date);
connection.m_pRecordset->Update();
connection.Unitialize();
connection.Initialize();
student.Format("select * from 学生登录 where 学生id='%s'",number);
connection.Connect(student);
connection.m_pRecordset->Fields->GetItem(_variant_t("密码"))->Value=_bstr_t(pw);
connection.m_pRecordset->Update();
connection.Unitialize();
MessageBox("资料修改成功");
}
BOOL StuInfor::OnCommand(WPARAM wParam, LPARAM lParam)
{
// TODO: Add your specialized code here and/or call the base class
return CDialog::OnCommand(wParam, lParam);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -