📄 changep.cpp
字号:
// ChangeP.cpp : implementation file
//
#include "stdafx.h"
#include "work.h"
#include "ChangeP.h"
#include "CommonData.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CChangeP dialog
CChangeP::CChangeP(CWnd* pParent /*=NULL*/)
: CDialog(CChangeP::IDD, pParent)
{
//{{AFX_DATA_INIT(CChangeP)
m_ChMobile_Edit = _T("");
m_ChEmail_Edit = _T("");
m_ChNumber_Edit = _T("");
m_ChPassword_Edit = _T("");
m_ChTel_Edit = _T("");
m_ChUserName_Edit = _T("");
m_ChPasswordA_Edit = _T("");
//}}AFX_DATA_INIT
CString number,tel,mobile,email,QueryString;
number=CCommonData::userNumber;
QueryString="SELECT * FROM Stu_Infor WHERE SNumber='"+number+"'";
_RecordsetPtr m_pRecordset;
m_pRecordset.CreateInstance("ADODB.Recordset");
try
{
m_pRecordset->Open((LPCTSTR)QueryString,_variant_t((IDispatch *)m_pConnection,true),adOpenStatic,adLockOptimistic,adCmdText);
}
catch(_com_error& e)
{
MessageBox(e.Description());
}
m_pRecordset->MoveFirst();
m_ChUserName_Edit=CCommonData::UserName;
m_ChNumber_Edit=CCommonData::userNumber;
m_ChPassword_Edit=(LPCTSTR)_bstr_t(m_pRecordset->GetCollect("SPassword"));
m_ChPasswordA_Edit=m_ChPassword_Edit;
tel=(LPCTSTR)_bstr_t(m_pRecordset->GetCollect("STel"));
if(tel!="0")
{
m_ChTel_Edit=tel;
}
mobile=(LPCTSTR)_bstr_t(m_pRecordset->GetCollect("SMobile"));
if(mobile!="0")
{
m_ChMobile_Edit=mobile;
}
email=(LPCTSTR)_bstr_t(m_pRecordset->GetCollect("SEmail"));
if(email!="0")
{
m_ChEmail_Edit=email;
}
m_pRecordset->Close();
}
void CChangeP::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CChangeP)
DDX_Text(pDX, IDC_CHMOBILE_EDIT, m_ChMobile_Edit);
DDV_MaxChars(pDX, m_ChMobile_Edit, 11);
DDX_Text(pDX, IDC_CHEMAIL_EDIT, m_ChEmail_Edit);
DDV_MaxChars(pDX, m_ChEmail_Edit, 50);
DDX_Text(pDX, IDC_CHNUMBER_EDIT, m_ChNumber_Edit);
DDX_Text(pDX, IDC_CHTEL_EDIT, m_ChTel_Edit);
DDV_MaxChars(pDX, m_ChTel_Edit, 7);
DDX_Text(pDX, IDC_CHUSERNAME_EDIT, m_ChUserName_Edit);
DDV_MaxChars(pDX, m_ChUserName_Edit, 30);
DDX_Text(pDX, IDC_CHPASSWORDA_EDIT, m_ChPasswordA_Edit);
DDV_MaxChars(pDX, m_ChPasswordA_Edit, 6);
DDX_Text(pDX, IDC_CHPASSWORD_EDIT, m_ChPassword_Edit);
DDV_MaxChars(pDX, m_ChPassword_Edit, 6);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CChangeP, CDialog)
//{{AFX_MSG_MAP(CChangeP)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CChangeP message handlers
void CChangeP::OnOK()
{
// TODO: Add extra validation here
CString number,password,passworda,tel,mobile,email,QueryString;
char pass[7],tel1[8],mob[12],ema[51];
memset(pass,0,7);
memset(tel1,0,8);
memset(mob,0,12);
memset(ema,0,51);
int i;
number=CCommonData::userNumber;
QueryString="SELECT * FROM Stu_Infor WHERE SNumber='"+number+"'";
_RecordsetPtr m_pRecordset;
m_pRecordset.CreateInstance("ADODB.Recordset");
try
{
m_pRecordset->Open((LPCTSTR)QueryString,_variant_t((IDispatch *)m_pConnection,true),adOpenStatic,adLockOptimistic,adCmdText);
}
catch(_com_error& e)
{
MessageBox(e.Description());
}
m_pRecordset->MoveFirst();
GetDlgItemText(IDC_CHPASSWORD_EDIT,password);
GetDlgItemText(IDC_CHPASSWORDA_EDIT,passworda);
password.TrimLeft();
password.TrimRight();
if(password.IsEmpty())
{
MessageBox("密码不能为空!");
m_pRecordset->Close();
return;
}
if(password!=passworda)
{
MessageBox("密码重复错误");
m_pRecordset->Close();
return;
}
for(i=0;i<password.GetLength();i++)
{
pass[i]=password[i];
}
m_pRecordset->PutCollect("SPassword",(LPCTSTR)password);
GetDlgItemText(IDC_CHTEL_EDIT,tel);
tel.TrimLeft();tel.TrimRight();
if(tel.IsEmpty())
{
tel="0";
}
for(i=0;i<tel.GetLength();i++)
{
tel1[i]=tel[i];
}
m_pRecordset->PutCollect("STel",(LPCTSTR)tel);
GetDlgItemText(IDC_CHMOBILE_EDIT,mobile);
mobile.TrimLeft();mobile.TrimRight();
if(mobile.IsEmpty())
{
mobile="0";
}
for(i=0;i<mobile.GetLength();i++)
{
mob[i]=mobile[i];
}
m_pRecordset->PutCollect("SMobile",(LPCTSTR)mobile);
GetDlgItemText(IDC_CHEMAIL_EDIT,email);
email.TrimLeft();email.TrimRight();
if(email.IsEmpty())
{
email="0";
}
for(i=0;i<email.GetLength();i++)
{
ema[i]=email[i];
}
m_pRecordset->PutCollect("SEmail",(LPCTSTR)email);
m_pRecordset->Update();
MessageBox("个人资料更新成功");
m_pRecordset->Close();
CDialog::OnOK();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -