本文整理汇总了C#中Security.setUserName方法的典型用法代码示例。如果您正苦于以下问题:C# Security.setUserName方法的具体用法?C# Security.setUserName怎么用?C# Security.setUserName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Security
的用法示例。
在下文中一共展示了Security.setUserName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: loginButton_Click
protected void loginButton_Click( object sender , EventArgs e )
{
dbModule dm = new dbModule();
pbModule pm = new pbModule();
string uCode = ucodeTextbox.Text.Trim();
string uPass = upassTextbox.Text.Trim();
if ( !pm.isValidString( uCode) || !pm.isValidString( uPass ) )
{
errors.Text = Resources.Resource.strNotValidString;
return;
}
int result = dm.adminLogin( uCode , uPass );
switch ( result )
{
case -1 :
errors.Text = Resources.Resource.strWrongPasswordString;
break;
case 0:
errors.Text = Resources.Resource.strWrongUsernameString;
break;
case 1:
Security s = new Security();
s.setSecurity( priCode.xtgly );
s.setUserCode(ucodeTextbox.Text.Trim());
s.setUserName( dm.getUnameByUcode(uCode, priCode.xtgly ) );
Session["sec"] = s;
Session["usercode"] = s.getUserCode();
Response.Redirect( "adminDefault.aspx" );
break;
default:
errors.Text = Resources.Resource.strDuplicateUserNameString;
break;
}
}
示例2: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
Security s = new Security();
s.setSecurity( priCode.none );
s.setUserName("");
s.setUserCode("");
Session["sec"] = s;
Response.Redirect( "login.aspx" );
}
示例3: loginButton_Click
protected void loginButton_Click( object sender , EventArgs e )
{
dbModule dm = new dbModule();
pbModule pm = new pbModule();
string uCode = ucodeTextbox.Text.Trim();
string uPass = upassTextbox.Text.Trim();
if ( !pm.isValidString( uCode) || !pm.isValidString( uPass ) )
{
errors.Text = Resources.Resource.strNotValidString;
return;
}
int result = 0;
Security s = new Security();
string url = "";
switch (Convert.ToInt32(lb_DropList.SelectedValue))
{
case 0://学生
result = dm.xsLogin(uCode, uPass);
url = "stuDefault.aspx";
s.setSecurity(priCode.xs);
s.setUserName(dm.getUnameByUcode(uCode, priCode.xs));
s.setUserXy(dm.getUxyByUcode(uCode, priCode.xs));
break;
case 1://任课教师
result = dm.jsLogin(uCode, uPass);
url = "teaDefault.aspx";
s.setUserName(dm.getUnameByUcode(uCode, priCode.js));
s.setUserXy(dm.getUxyByUcode(uCode, priCode.js));
s.setSecurity(priCode.js);
break;
case 2://实验教师
result = dm.eadmLogin(uCode, uPass);
url = "eadmDefault.aspx";
s.setSecurity(priCode.sygly);
s.setUserName(dm.getUnameByUcode(uCode, priCode.sygly));
s.setUserXy(dm.getUxyByUcode(uCode, priCode.sygly));
break;
case 3://管理员
result = dm.adminLogin(uCode, uPass);
url = "adminDefault.aspx";
s.setSecurity(priCode.xtgly);
s.setUserName(dm.getUnameByUcode(uCode, priCode.xtgly));
s.setUserXy(dm.getUxyByUcode(uCode, priCode.xtgly));
break;
case 4://教务管理员
result = dm.aadmLogin(uCode, uPass);
url = "aadmDefault.aspx";
s.setSecurity(priCode.jwgly);
s.setUserName(dm.getUnameByUcode(uCode, priCode.jwgly));
s.setUserXy(dm.getUxyByUcode(uCode, priCode.jwgly));
break;
}
switch ( result )
{
case -1 :
errors.Text = Resources.Resource.strWrongPasswordString;
break;
case 0:
errors.Text = Resources.Resource.strWrongUsernameString;
break;
case 1:
s.setUserCode(ucodeTextbox.Text.Trim());
Session["sec"] = s;
Session["usercode"] = s.getUserCode();
Response.Redirect(url);
break;
default:
errors.Text = Resources.Resource.strDuplicateUserNameString;
break;
}
}