本文整理汇总了C#中UserRole.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# UserRole.ToString方法的具体用法?C# UserRole.ToString怎么用?C# UserRole.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserRole
的用法示例。
在下文中一共展示了UserRole.ToString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetAccounts
public IEnumerable<vw_Account> GetAccounts(string firstOrLastName, string accountNumber, string creditorName, string accountOriginal, string roleEntityValue, string phone, int? pageNo, int? pageSize, UserRole role)
{
IEnumerable<vw_Account> accounts = null;
try
{
IUnitOfWork uow = new UnitOfWork("CCATDBEntities");
accounts = (uow as UnitOfWork).AccountRepository.AccountSearch(firstOrLastName, accountNumber, creditorName, accountOriginal, roleEntityValue, role.ToString(), phone, pageNo, pageSize);
}
catch (Exception ex)
{
throw ex;
}
return accounts;
}
示例2: CreateUser
public bool CreateUser(string userName, string passWord, UserRole role)
{
int rowsUpdated = 0;
if (ValidateCredentialData(userName, passWord)) {
SqlConnection conn = new SqlConnection("Data Source = (LocalDB)\\MSSQLLocalDB; AttachDbFilename = " + System.Web.HttpContext.Current.Server.MapPath(privilegesDatabase));
conn.Open();
SqlCommand checkExistance = new SqlCommand("SELECT * FROM Users WHERE [email protected]", conn);
checkExistance.Parameters.Add("@userName", SqlDbType.VarChar, 35);
checkExistance.Parameters["@userName"].Value = userName;
var reader = checkExistance.ExecuteReader();
if (!reader.HasRows) {
reader.Close();
checkExistance.Dispose();
SqlCommand cmd = new SqlCommand("INSERT INTO Users (logonName,password,userRole) values(@userName,@passWord,@userRole)", conn);
cmd.Parameters.Add("@userName", SqlDbType.VarChar, 35);
cmd.Parameters["@userName"].Value = userName;
string hashedPassword = String.Empty;
using (MD5 md5Hash = MD5.Create()) {
hashedPassword = GetMd5Hash(md5Hash, passWord);
}
cmd.Parameters.Add("@passWord", SqlDbType.VarChar, 35);
cmd.Parameters["@passWord"].Value = hashedPassword;
cmd.Parameters.Add("@userRole", SqlDbType.VarChar, 35);
cmd.Parameters["@userRole"].Value = role.ToString();
rowsUpdated = cmd.ExecuteNonQuery();
cmd.Dispose();
}
else {
reader.Close();
checkExistance.Dispose();
}
conn.Dispose();
}
return rowsUpdated == 0 ? false : true;
}
示例3: UpdateUser
public bool UpdateUser(string logonName, UserRole userRole, string firstName = "",
string lastName = "", string phoneMobile = "", int age = 0,
string address = "", string nationalIdentity = "", string gender = "male",
string phoneWork = "", string phonePrivate = "", string eMail = "")
{
if (gender.ToLower() != "male" && gender.ToLower() != "female") {
throw new NotSupportedException("Gender must be male or female, '" + gender + "' is not allowed");
}
int rowsUpdated = 0;
SqlConnection conn = new SqlConnection("Data Source = (LocalDB)\\MSSQLLocalDB; AttachDbFilename = " + System.Web.HttpContext.Current.Server.MapPath(privilegesDatabase));
conn.Open();
SqlCommand cmd = new SqlCommand("UPDATE Users SET [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected] WHERE [email protected]", conn);
cmd.Parameters.Add("@logonName", SqlDbType.VarChar, 35);
cmd.Parameters["@logonName"].Value = logonName;
cmd.Parameters.Add("@userRole", SqlDbType.VarChar, 35);
cmd.Parameters["@userRole"].Value = userRole.ToString();
cmd.Parameters.Add("@firstName", SqlDbType.VarChar, 35);
cmd.Parameters["@firstName"].Value = firstName;
cmd.Parameters.Add("@lastName", SqlDbType.VarChar, 35);
cmd.Parameters["@lastName"].Value = lastName;
cmd.Parameters.Add("@phoneMobile", SqlDbType.VarChar, 8);
cmd.Parameters["@phoneMobile"].Value = phoneMobile;
cmd.Parameters.Add("@age", SqlDbType.Int);
cmd.Parameters["@age"].Value = age;
cmd.Parameters.Add("@address", SqlDbType.VarChar, 400);
cmd.Parameters["@address"].Value = address;
cmd.Parameters.Add("@nationalIdentity", SqlDbType.VarChar, 11);
cmd.Parameters["@nationalIdentity"].Value = nationalIdentity;
/*cmd.Parameters.Add("@persInfoConsent", SqlDbType.Int);
cmd.Parameters["@persInfoConsent"].Value = persInfoConsent ? 1 : 0;
cmd.Parameters.Add("@eMailConsent", SqlDbType.Int);
cmd.Parameters["@eMailConsent"].Value = eMailConsent ? 1 : 0;
cmd.Parameters.Add("@phoneConsent", SqlDbType.Int);
cmd.Parameters["@phoneConsent"].Value = phoneConsent ? 1 : 0;*/
cmd.Parameters.Add("@gender", SqlDbType.VarChar, 6);
cmd.Parameters["@gender"].Value = gender.ToLower();
cmd.Parameters.Add("@phoneWork", SqlDbType.VarChar, 8);
cmd.Parameters["@phoneWork"].Value = phoneWork;
cmd.Parameters.Add("@phonePrivate", SqlDbType.VarChar, 8);
cmd.Parameters["@phonePrivate"].Value = phonePrivate;
cmd.Parameters.Add("@eMail", SqlDbType.VarChar, 100);
cmd.Parameters["@eMail"].Value = eMail;
rowsUpdated = cmd.ExecuteNonQuery();
cmd.Dispose();
conn.Dispose();
return rowsUpdated == 0 ? false : true;
}