internal static User GetUserByUserName(string UserName)
{
User user = null;
using (SqlConnection sqlConnection = new SqlConnection(CMSCoreBase.CMSCoreConnectionString))
{
SqlCommand sqlCommand = new SqlCommand(SN_USER_GET_BY_NAME, sqlConnection);
sqlCommand.CommandType = System.Data.CommandType.StoredProcedure;
SqlParameter parameter = new SqlParameter(PN_USER_NAME, System.Data.SqlDbType.NVarChar);
parameter.Direction = System.Data.ParameterDirection.Input;
parameter.Value = UserName;
sqlCommand.Parameters.Add(parameter);
sqlCommand.Connection.Open();
using (SqlDataReader reader = sqlCommand.ExecuteReader(System.Data.CommandBehavior.CloseConnection))
{
while (reader.Read())
{
if (user == null)
user = new User();
FillFromReader(user, reader);
}
reader.Close();
sqlCommand.Connection.Close();
}
}
return user;
}