标签:des blog http io ar sp 2014 on cti
软件中写登录模块是为了防止软件的恶意传播,内测阶段可以忽略登录。
以下为登录模块主要源代码:
void CLoginDlg::OnBnClickedBtnLogin() { // TODO: Add your control notification handler code here CClerkDataSet lgDataSet; CString strSQL=L""; UpdateData(TRUE); CMFC_Library_RibbonView* pView; pView=((CMFC_Library_RibbonView*)((CMainFrame*)AfxGetMainWnd())->GetActiveView()); if (m_strName.IsEmpty()) { MessageBox(L"请输入用户名!",L"提示",MB_ICONWARNING); return; } else if(m_strPWD.IsEmpty()) { MessageBox(L"请输入密码!",L"提示",MB_ICONWARNING); return; } strSQL=L"SELECT * FROM CLERK WHERE NAME=‘"; strSQL=strSQL+m_strName; strSQL=strSQL+L"‘ AND PASSWORD=‘"; strSQL=strSQL+m_strPWD; strSQL=strSQL+L"‘"; if (!lgDataSet.Open(AFX_DB_USE_DEFAULT_TYPE,strSQL)) { MessageBox(L"打开CLERK表失败!",L"提示",MB_ICONWARNING); return; } if (m_strName=="rong"&&m_strPWD=="123456") { m_strUSERID=lgDataSet.m_CLERK_ID; m_bSuccess=TRUE; MessageBox(L"登陆成功!",L"成功"); pView->m_strUserId=m_strUSERID; pView->m_bLogin=m_bSuccess; pView->m_strUserName=m_strName; CString name=L"图书管理系统V1.0-当前登录用户:"+m_strName; ((CMainFrame *)AfxGetApp()-> m_pMainWnd)->SetWindowText(name); Invalidate(); CDialog::OnOK(); DestroyWindow(); } else { MessageBox(L"登录失败!用户名或密码不正确!",L"登录失败!",MB_ICONERROR); SetDlgItemText(IDC_EDIT_USERNAME,L""); SetDlgItemText(IDC_EDIT_PWD,L""); GetDlgItem(IDC_EDIT_USERNAME)->SetFocus(); pView->m_strUserName=L""; pView->m_bLogin=m_bSuccess; pView->m_strUserId=L""; return; } }
这是登录界面(丑陋版):
我的个人博客地址:http://ler.look.in
LER-Studio 产品官网:http://studio.look.in
标签:des blog http io ar sp 2014 on cti
原文地址:http://www.cnblogs.com/LER-Ever/p/4020215.html