本文整理汇总了C#中UserIdentity.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# UserIdentity.ToString方法的具体用法?C# UserIdentity.ToString怎么用?C# UserIdentity.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserIdentity
的用法示例。
在下文中一共展示了UserIdentity.ToString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Welcome
public Welcome(UserIdentity.Role role)
{
_role = role.ToString();
SqlConnection con=new SqlConnection(DealData.constring);
if (role == UserIdentity.Role.Admin)
{
SqlCommand cmd = new SqlCommand("usp_AWelcome", con);
cmd.CommandType = CommandType.StoredProcedure;
SqlDataReader reader;
//cmd.Parameters.Add(new SqlParameter("@member", SqlDbType.Int)).Direction = ParameterDirection.ReturnValue;
try
{
con.Open();
reader = cmd.ExecuteReader();
reader.Read();
_member = reader[0].ToString();
reader.Close();
}
catch (SqlException err)
{
eMessage.Message(err);
}
finally
{
if (con != null)
con.Close();
}
}
if (role == UserIdentity.Role.Teacher)
{
SqlCommand cmd = new SqlCommand("usp_TWelcome", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add(new SqlParameter("@UserId", SqlDbType.Int)).Value =Convert.ToInt32( HttpContext.Current.Session["UserId"].ToString());
cmd.Parameters.Add(new SqlParameter("@UserName", SqlDbType.NVarChar, 50)).Value = HttpContext.Current.Session["UserName"].ToString();
SqlDataReader reader;
try
{
con.Open();
reader = cmd.ExecuteReader();
reader.Read();
_topic = reader["TopicCount"].ToString();
_correct = reader["QuestionCount"].ToString();
_member = reader["MemberCount"].ToString();
_inform = reader["InformCount"].ToString();
reader.Close();
}
catch (SqlException err)
{
eMessage.Message(err);
}
finally
{
if (con != null)
con.Close();
}
}
if (role == UserIdentity.Role.Student)
{
SqlCommand cmd = new SqlCommand("usp_UWelcome", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add(new SqlParameter("@UserId", SqlDbType.Int)).Value = Convert.ToInt32(HttpContext.Current.Session["UserId"].ToString());
cmd.Parameters.Add(new SqlParameter("@UserName", SqlDbType.NVarChar, 50)).Value = HttpContext.Current.Session["UserName"].ToString();
SqlDataReader reader;
try
{
con.Open();
reader = cmd.ExecuteReader();
reader.Read();
_exam = reader["ExamCount"].ToString();
_inform = reader["InformCount"].ToString();
reader.Close();
}
catch (SqlException err)
{
eMessage.Message(err);
}
finally
{
if (con != null)
con.Close();
}
}
}