📄 modify.cpp
字号:
// Modify.cpp : implementation file
//
#include "stdafx.h"
#include "CTSClient.h"
#include "Modify.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern SOCKET clientSocket;
extern CString username;
extern CString password;
/////////////////////////////////////////////////////////////////////////////
extern BOOL socketconnect;
extern char recvbuf2[3072];
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// Modify dialog
Modify::Modify(CWnd* pParent /*=NULL*/)
: CDialog(Modify::IDD, pParent)
{
//{{AFX_DATA_INIT(Modify)
m_newPassword = _T("");
m_newPasswordAgain = _T("");
oldUserName = _T("");
oldPassword = _T("");
//}}AFX_DATA_INIT
}
void Modify::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(Modify)
DDX_Text(pDX, IDC_EDIT1, m_newPassword);
DDX_Text(pDX, IDC_EDIT2, m_newPasswordAgain);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(Modify, CDialog)
//{{AFX_MSG_MAP(Modify)
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
ON_BN_CLICKED(IDC_BUTTON4, OnButton4)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// Modify message handlers
void Modify::OnButton1()
{
// TODO: Add your control notification handler code here
/////////////////////////////////////////////////////////////////////////////////////
if (!socketconnect)
{
MessageBox(_T("与服务器连接中断,请检查网络后重新登录该系统!"),_T("出错提示"));
return;
}
/////////////////////////////////////////////////////////////////////////////////////
UpdateData(true);
if(m_newPassword == VT_EMPTY){
MessageBox(_T("密码不能为空,请重新输入!!!"),_T("出错提示"));
return;
}
if(m_newPasswordAgain == VT_EMPTY){
MessageBox(_T("确认密码不能为空,请重新输入!!!"),_T("出错提示"));
return;
}
if(m_newPassword != m_newPasswordAgain){
MessageBox(_T("两次输入的密码不一致,请确认后重新输入!!!"),_T("出错提示"));
m_newPassword = "";
m_newPasswordAgain = "";
return;
}
CString MSQL = _T("");
MSQL = "update ctsuser set password = '"+m_newPassword+"' where userId = '"+username+"' and password = '"+password+"'";
MSQL=" "+MSQL+'\0';
int iSize;
char* pszMultiByte;
iSize = WideCharToMultiByte(CP_ACP, 0, MSQL, -1, NULL, 0, NULL, NULL);
pszMultiByte = (char*)malloc((iSize+1)*sizeof(char));
WideCharToMultiByte(CP_ACP, 0, MSQL, -1, pszMultiByte, iSize, NULL, NULL);
*pszMultiByte=1;
pszMultiByte++;
*pszMultiByte=iSize/256;
pszMultiByte++;
*pszMultiByte=iSize%256;
pszMultiByte=pszMultiByte-2;
send(clientSocket,pszMultiByte,iSize,0);
free(pszMultiByte);
delete pszMultiByte;
int retint=recv(clientSocket,recvbuf2,sizeof(recvbuf2), 0);
if (recvbuf2[0]==8 && retint==1)
{
MessageBox(_T("网络传输出错,请重新点击按钮再试一次!!!"),_T("提示"));
return;
}
//if (sBuf[0]==3)
//{
// MessageBox(_T("用户密码已经成功修改!!!"));
//}
CDialog::OnOK();
}
void Modify::OnButton4()
{
// TODO: Add your control notification handler code here
CDialog::OnCancel();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -