4,018
社区成员




UpdateData(true);
static int input_Qty=0;
int perm_temp;
if(m_Username.IsEmpty()||m_Password.IsEmpty())
{
MessageBox("注意:用户名或密码不能为空" );
}
input_Qty++; //计算登录次数
CString SQLstr ,SQLtemp; //数据库查询
//创建Recordset实例,连接Recordset记录集
theApp.m_pRecordset.CreateInstance(_uuidof(Recordset));
//建立SQL查询字符串
SQLstr.Format("select*from tb_User_info where User_name='%s' and Password ='%s'",m_Username,m_Password);
//查询Recordset记录集,并返回Recordset记录指针
theApp.m_pRecordset=theApp.m_pConnection->Execute(_bstr_t(SQLstr),NULL,adCmdText);
//判断Recordset记录集指针是否到表尾,是:表明登录信息匹配失败;否:表明登录信息匹配成功;
if(!theApp.m_pRecordset->adoEOF)//
{
//保存用户名
m_user=m_Username;
Username=m_Username;
//获取用户登录权限
_variant_t var=(_variant_t)theApp.m_pRecordset->GetCollect("Permissions");
//change _variant_t to int
var.ChangeType(VT_I4);
perm_temp = var.lVal;//用户权限转换为int后,传递给临时变量
perm=perm_temp;
CDialog::OnOK();//关闭登录框,进入主对话框
}
else
{
CProduct_ManageSystemDlg dlg;
if (3==input_Qty)
{
MessageBox("密码3次输入错误!");
CDialog::OnCancel();//连续三次输错密码,关闭登录窗口;
//dlg.OnCancel;
//dlg.CloseWindow();
}
else
{
MessageBox("用户名或密码不正确!");
m_Username="";
m_Password="";
UpdateData(false);
}
}