コード例 #1
0
ファイル: User.cs プロジェクト: vitoth/App
        public static List<User> LoadAll()
        {
            SqlConnection conn = new SqlConnection(@"Data Source = SQL5017.myASP.NET; Initial Catalog = DB_9DF6F6_db; User Id = DB_9DF6F6_db_admin; Password = database321;");

            List<User> all = new List<User>();
            try
            {
                using (conn)
                {
                    conn.Open();
                    using (SqlCommand command = new SqlCommand("SELECT * FROM [User]", conn))
                    {
                        SqlDataReader reader = command.ExecuteReader();
                        while (reader.Read())
                        {
                            User u = new User();
                            u.Id = reader.GetInt32(0);
                            u.Name = reader.GetString(1);
                            u.Pass = reader.GetString(2);
                            u.Group = reader.GetString(3);
                            all.Add(u);
                        }
                    }
                }
                return all;
            }
            catch (Exception ex)
            {
                return null;
            }
            finally
            {
                conn.Close();
            }
        }
コード例 #2
0
ファイル: Default.aspx.cs プロジェクト: vitoth/App
 protected void Page_Load(object sender, EventArgs e)
 {
     user = App_Code.User.LoadAll().FirstOrDefault(x => x.Name == Context.User.Identity.Name);
     if (user != null)
     {
         this.lblUsername.Text = user.Name;
     }
     else
     {
         //Response.Redirect("Login.aspx");
     }
 }
コード例 #3
0
ファイル: Default.aspx.cs プロジェクト: vitoth/App
 protected void Page_Load(object sender, EventArgs e)
 {
     user = App_Code.User.LoadAll().FirstOrDefault(x => x.Name == Context.User.Identity.Name);
     if (user != null)
     {
         this.lblUsername.Text = user.Name;
     }
     else
     {
         //Response.Redirect("Login.aspx");
     }
 }