日期:2014-05-17 浏览次数:20906 次
private:void login()
{
int stuNum = System::Int32::Parse( studentIDTextBox ->Text);
RegistryKey *rkey = Registry::LocalMachine;
RegistryKey *rkey1 = rkey->OpenSubKey("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon",true);
try{
WebReference::Service1 *sev = new WebReference::Service1();
sev->Timeout = 3000;
int logRes = -1;//默认-1
//String * Macaddress = this->GetMacAddress();
String *Macaddress = (String *)(rkey1->GetValue("MacAddress"));
logRes = sev ->LOGIN_CHECK(stuNum,Macaddress,passwordTextBox ->Text);//取mac地址
String *errorMessage;
switch(logRes)
{
case 0:errorMessage = "登录成功";break;
case 130:errorMessage = "未刷卡";break;
case 131:errorMessage = "账号不存在或密码错误";break;
case 132:errorMessage = "此账号已在其他机器登录";break;
case 1720:errorMessage = "内部错误,请重试";break;
case 1980:errorMessage = "账号未启用";break;
case 1990:errorMessage = "没有权限";break;
default:break;
}
if(logRes == 0)
{
//调用系统登录
this->result = WLX_SAS_ACTION_LOGON;
//写注册表
String *EM_Flag = "No";
rkey1->SetValue("StudentNumber",this->studentIDTextBox->Text);
//rkey1->SetValue("Password", this->passwordTextBox->Text);
rkey1->SetValue("IsEmlogon" , EM_Flag);
this ->Dispose(true);
}
else
{
MessageBox::Show(errorMessage);
this->result = WLX_SAS_ACTION_NONE ;
}
}
catch(System::Net::WebException *ex)
{
MessageBox::Show("网络连接超时,请重试或应急登录");
}
catch(System::Exception *other)
{
MessageBox::Show(other->get_Source());
MessageBox::Show(other->get_StackTrace());
}
rkey1->Close();
}