欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

C++核心技术登录实现

程序员文章站 2022-10-25 23:09:34
void CLMSDlg::OnButtonlogin() { // TODO: Add your control notification handler code here CMainsystem dlg; CADOConn adoconn; CString sqlstr,str; int co ......
void clmsdlg::onbuttonlogin()
{
 // todo: add your control notification handler code here
 cmainsystem dlg;
 cadoconn adoconn;
 cstring sqlstr,str;
 int countcleck;
 countcleck=((ccombobox*)getdlgitem(idc_combocleck))->getcursel();
 ((ccombobox*)getdlgitem(idc_combocleck))->getlbtext(countcleck,str);
 
 updatedata(true);
 if(m_user.isempty())
 {
  messagebox("用户名不能为空","错误",mb_iconerror);
  getdlgitem(idc_edituser)->setfocus();
 }
 try
 {
  sqlstr.format("select *from usertable where uusername='%s' and uuserpassword='%s' and uusercleck='%s'",m_user,m_password,str);
  _bstr_t vsql;
  vsql=(_bstr_t)sqlstr;
  _recordsetptr m_recordset;  
  m_recordset=adoconn.getrecordset(vsql);
  
  cstring str1,str2,str3;
  str1=(lpcstr)(_bstr_t)(m_recordset->getcollect("uusername"));
  str2=(lpcstr)(_bstr_t)(m_recordset->getcollect("uuserpassword"));
  str3=(lpcstr)(_bstr_t)(m_recordset->getcollect("uusercleck"));
  str1.trimright();
  str2.trimright();
  str3.trimright();
  if(str1==m_user || str2==m_password || str3==str)
  {
   messagebox("恭喜你,登录成功!","正确",mb_iconquestion);
   this->enddialog(1);
   dlg.domodal();
  }
 }
 catch(...)
 {
  messagebox("操作失败","错误",mb_iconerror);
  m_user="";
  m_password="";
  getdlgitem(idc_edituser)->setfocus();
  updatedata(false);
 }
}