📄 wrsm.cpp
字号:
// WrSm.cpp : implementation file
//
#include "stdafx.h"
#include "IcDemo.h"
#include "WrSm.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CWrSm dialog
CWrSm::CWrSm(CWnd* pParent /*=NULL*/)
: CDialog(CWrSm::IDD, pParent)
{
//{{AFX_DATA_INIT(CWrSm)
m_newpwd = _T("");
m_oldpwd = _T("");
m_azp = _T("");
//}}AFX_DATA_INIT
}
void CWrSm::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CWrSm)
DDX_Control(pDX, IDLOOP, m_loop);
DDX_Control(pDX, IDC_EDIT1, m_coldpwd);
DDX_Control(pDX, IDC_EDIT2, m_cnewpwd);
DDX_Text(pDX, IDC_EDIT2, m_newpwd);
DDV_MaxChars(pDX, m_newpwd, 6);
DDX_Text(pDX, IDC_EDIT1, m_oldpwd);
DDV_MaxChars(pDX, m_oldpwd, 6);
DDX_Text(pDX, IDC_EDIT3, m_azp);
DDV_MaxChars(pDX, m_azp, 2);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CWrSm, CDialog)
//{{AFX_MSG_MAP(CWrSm)
ON_WM_SHOWWINDOW()
ON_BN_CLICKED(IDLOOP, OnLoop)
ON_WM_TIMER()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CWrSm message handlers
extern CIcDemoApp theApp;
void CWrSm::OnOK()
{
// TODO: Add extra validation here
WrPassword();
CDialog::OnOK();
}
void CWrSm::OnShowWindow(BOOL bShow, UINT nStatus)
{
CDialog::OnShowWindow(bShow, nStatus);
// TODO: Add your message handler code here
m_cnewpwd.SetFocus();
}
BOOL CWrSm::OnInitDialog()
{
//int Rn;
//char rdpwd[32];
CDialog::OnInitDialog();
IsStop=0;
/*
Rn=theApp.surerd_sm(rdpwd);
if(Rn!=0)
theApp.ReadWriteError(Rn);
else
{
m_oldpwd=rdpwd;
m_oldpwd=m_oldpwd.Mid(2,6);
m_newpwd="791023";
UpdateData(FALSE);
}
*/
m_azp="0";
if(theApp.intType==42)
{
m_oldpwd="FFFFFF";
m_newpwd="FFFFFF";
}
else
{
m_oldpwd="FFFF";
m_newpwd="FFFF";
}
UpdateData(FALSE);
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CWrSm::WrPassword()
{
char* chkPwdstr=NULL;
CString str;
char* pwdstr=NULL;
if(theApp.surepower_on()!=0) return;
UpdateData(TRUE);
if(m_azp.IsEmpty()) return;
if(m_oldpwd.IsEmpty()) return;
if(m_newpwd.IsEmpty()) return;
switch(theApp.intType)
{
case 42:
chkPwdstr=new char[10];
memset(chkPwdstr,' ',10);
if(theApp.surerd_asc(0,0,2,chkPwdstr)!=0)
{
MessageBox("读卡失败!","信息提示",MB_ICONERROR|MB_OK);
return;
}
str=chkPwdstr;
str=str.Mid(0,4);
if(str!="A213")
{
MessageBox("读卡失败!","信息提示",MB_ICONERROR|MB_OK);
return;
}
pwdstr=new char[6];
strcpy(pwdstr,m_oldpwd);
if(theApp.surechk_sc(atoi(m_azp),3,pwdstr)!=0)
{
MessageBox("核对密码失败!","信息提示",MB_ICONERROR|MB_OK);
// pwdstr=NULL;
return;
}
memset(pwdstr,' ',6);
strcpy(pwdstr,m_newpwd);
if(theApp.surewr_sc(pwdstr)!=0)
{
MessageBox("写入密码失败!","信息提示",MB_ICONERROR|MB_OK);
return;
}
// pwdstr=NULL;
memset(chkPwdstr,' ',10);
if(theApp.surerd_sm(chkPwdstr)!=0)
{
MessageBox("写入密码失败!","信息提示",MB_ICONERROR|MB_OK);
return;
}
str=chkPwdstr;
str=str.Mid(2,6);
str="密码:" + str;
theApp.m_Pwd=str;
str=chkPwdstr;
str=str.Mid(0,2);
str="校验码:" + str;
theApp.m_ChkP=str;
str=chkPwdstr;
str=str.Mid(2,6);
if(str!=m_newpwd)
{
MessageBox("写入密码失败!","信息提示",MB_ICONERROR|MB_OK);
return;
}
else
MessageBox("修改密码成功!","信息提示",MB_ICONINFORMATION|MB_OK);
break;
case 43:
chkPwdstr=new char[10];
memset(chkPwdstr,' ',10);
if(theApp.surerd_asc(0,0,2,chkPwdstr)!=0)
{
MessageBox("读卡失败!","信息提示",MB_ICONERROR|MB_OK);
return;
}
str=chkPwdstr;
str=str.Mid(0,4);
if(str!="9223")
{
MessageBox("读卡失败!","信息提示",MB_ICONERROR|MB_OK);
return;
}
pwdstr=new char[4];
strcpy(pwdstr,m_oldpwd);
if(theApp.surechk_sc(atoi(m_azp),2,pwdstr)!=0)
{
MessageBox("核对密码失败!","信息提示",MB_ICONERROR|MB_OK);
return;
}
memset(pwdstr,' ',4);
strcpy(pwdstr,m_newpwd);
if(theApp.surewr_asc(atoi(m_azp),1022, 2,pwdstr)!=0)
{
MessageBox("写入密码失败!","信息提示",MB_ICONERROR|MB_OK);
return;
}
memset(chkPwdstr,' ',10);
if(theApp.surerd_asc(atoi(m_azp),1021, 3,chkPwdstr)!=0)
{
MessageBox("写入密码失败!","信息提示",MB_ICONERROR|MB_OK);
return;
}
str=chkPwdstr;
str=str.Mid(2,4);
str="密码:" + str;
theApp.m_Pwd=str;
str=chkPwdstr;
str=str.Mid(0,2);
str="校验码:" + str;
theApp.m_ChkP=str;
str=chkPwdstr;
str=str.Mid(2,4);
m_newpwd.MakeUpper();
if(str!=m_newpwd)
{
MessageBox("写入密码失败!","信息提示",MB_ICONERROR|MB_OK);
return;
}
else
MessageBox("修改密码成功!","信息提示",MB_ICONINFORMATION|MB_OK);
}
theApp.surepower_off();
}
void CWrSm::OnLoop()
{
// TODO: Add your control notification handler code here
CButton but;
if(IsStop==0)
{
m_loop.SetWindowText("停止(&S)");
SetTimer(1,300,NULL);
IsStop=1;
IsEnd=1;
}
else
{
m_loop.SetWindowText("循环(&L)");
KillTimer(1);
IsStop=0;
IsEnd=0;
}
}
void CWrSm::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
if(IsStop!=1)return;
IsStop=0;
if(nIDEvent==1)
WrPassword();
IsStop=1;
CDialog::OnTimer(nIDEvent);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -