C# ASP.NET Dynamic Webpage Course Design-NBA Player Management System

Home page 

Please click the download link

 

User Registration Module

 

1.1 System Development Background and Significance

With the rapid development of society, science and technology are advancing by leaps and bounds, and economic knowledge and information industry are beginning to take shape. The more profound impact is also changing people's work, life, study and communication methods. The ability to acquire, process, communicate and apply information has become one of the most important abilities of people.

Through the construction of this website, we hope that more people will know about NBA, and those who knew NBA before will pay more attention to NBA. On this website, you can know the information management of the players of each team at the first time, helping people to quickly understand the latest information, so that people can feel his playing level without seeing the player himself. As an advanced information transmission medium, computer network is characterized by fast information transmission speed, wide information coverage and low cost. Therefore, many companies have begun to use websites to carry out business activities, such as publishing corporate information on the Internet, advertising products, and using emails for information exchange. Not only can business activities be carried out on the Internet, but also various latest sports trends and entertainment news can be uploaded.
    The design of a website includes its look and feel, but also considers all elements of a web page: audience information, intent and goal descriptions, domain information, page specifications.

A convenient and fast player information management website can not only facilitate understanding of teams and players, but also allow us to maintain our unchanging love for basketball.

Users of this system can be divided into ordinary users and administrators. After investigation and research, ordinary users and administrators have different requirements for the system. The main requirement of administrators is to manage player information and common user information. The needs of ordinary users for the website are mainly for information management of players. According to the different needs of users, different permissions are set for different users, and different user operation interfaces are provided.

According to the different needs of different users, it is determined that the system needs to set up two types of users:

(1) Ordinary users: Enter the homepage of the website, and allow to view team profile information, player demeanor, manage players (involving adding, deleting, modifying and checking), and modify user personal passwords when logging in.

(2) Administrator: The administrator side checks the team profile information, player demeanor, manages players (involving adding, deleting, modifying and checking), manages ordinary user information (adding, deleting, and modifying ordinary user information), and modifies administrator passwords, etc.

1.2  Development and running environment

OS: Windows 10

Development tools: Visual Studio 2010

Database server: SQL Server 2012

Development language: C#

1.3  System function module design

During the development and design process of the management system website, the website is divided into common user modules and administrator modules mainly according to the different needs of users. The functional structure of the system is shown in Figure 3.1 below:

1.4  Database design

The database management system used in this system is SQL Server 2012, and the tables in the database include administrator information table, common user information table, player information table of each team, etc.

Common user basic information table Users , as shown in Table 3.1:

Table 1.1 Common user table (Users)

serial number

field name

type

length

illustrate

primary key (Y/N)

Empty allowed (Y/N)

1

username

varchar

20

common username

Y

N

2

password

varchar

20

common user password

N

N

3

Name

varchar

10

common user name

N

N

4

Telephone

varchar

11

Ordinary user phone

N

N

Administrator information table Manager , as shown in Table 3.2:

Table 1.2 Administrator table (Manager)

serial number

field name

type

length

illustrate

primary key (Y/N)

Empty allowed (Y/N)

1

I'm happy

varchar

20

administrator name

Y

N

2

Mpwd

varchar

20

administrator password

N

N

Player information table Lakers, Warriors, Clippers, Celtics , as shown in Table 3.3:

Table 1.3 Team table (Lakers, Warriors, Clippers, Celtics)

serial number

field name

type

length

illustrate

primary key (Y/N)

Empty allowed (Y/N)

1

Number

varchar

5

player jersey number

Y

N

2

Name

varchar

20

player name

N

N

3

Location

varchar

20

player's position in the team

N

N

4

Birthday

varchar

20

player birthday

N

N

5

height

varchar

20

player height

N

N

6

body weight

varchar

10

player weight

N

N

Core code:

Web.config网站配置文件数据库链接定义:
<add name="NetTestConnectionString" connectionString="Data Source=.;Initial Catalog=NetTest;Integrated Security=True"
数据库访问类DBHelper中数据库访问相关函数代码如下:
public static string GetConnStr()// 获得数据库连接字符串
  { 
return ConfigurationManager.ConnectionStrings["KeCheng"]. ConnectionString;
   }
public static DataSet GetDataSet(string sql)// 由sql变量(select语句)得到DataSet类型查询记录集合
{
     SqlConnection myconn = new SqlConnection();
            SqlCommand ld = new SqlCommand();
            string mystr = "Data Source = .;Initial Catalog = NBA ;Integrated Security = True";
            myconn.ConnectionString = mystr;
            myconn.Open();
            SqlDataReader dr;
     conn.Close();
     return ds;
  }

用户登录功能代码如下:
 protected void Button1_Click(object sender, EventArgs e)
    {
        if (this.TextBox3.Text == Request.Cookies["ValidateCode"].Value.ToString())
        {
            string mystr = "Data Source=.;Initial Catalog=NBA; Integrated Security=true";
            SqlConnection conn = new SqlConnection();
            conn.ConnectionString = mystr;
            try
            {
                conn.Open();
                SqlCommand cmd = new SqlCommand();
                SqlDataReader dr;
                if (this.RadioButtonList1.SelectedIndex == 0)
                {
                    cmd.CommandText = "select * from Manager where Mname=@Mname";
                    cmd.Connection = conn;
                    cmd.Parameters.AddWithValue("@Mname", this.TextBox1.Text.Trim());
                    dr = cmd.ExecuteReader();
                    if (dr.Read())
                    {
                        if (dr["Mpwd"].ToString().Trim() == this.TextBox2.Text.Trim())
                        {
                            Session["Mname"] = this.TextBox1.Text.Trim();
                            Response.Redirect("Main.aspx");
                        }
                        else
                        {
                            Response.Write("<script>alert('密码不正确,请重新输入!')</script>");
                        }
                    }
                    else
                    {
                        Response.Write("<script>alert('该管理员不存在,请检查用户名是否输入正确!')</script>");
                    }
                    dr.Close();
                }
                else
                {
                    cmd.CommandText = "select * from Users where 用户名=@用户名";
                    cmd.Connection = conn;
                    cmd.Parameters.AddWithValue("@用户名", this.TextBox1.Text.Trim());
                    dr = cmd.ExecuteReader();
                    if (dr.Read())
                    {
                        if (dr["密码"].ToString().Trim() == this.TextBox2.Text.Trim())
                        {
                            Session["用户名"] = this.TextBox1.Text.Trim();
                            Response.Redirect("Main-1.aspx");
                        }
                        else
                        {
                            Response.Write("<script>alert('密码不正确,请重新输入!')</script>");
                        }
                    }
                    else
                    {
                        Response.Write("<script>alert('该用户不存在,请检查用户名是否输入正确!')</script>");
                    }
                    dr.Close();
                }
            }
            catch (Exception ex)
            {
                // Response.Write("<script>alert('登录失败,请重试!')</script>");
                Response.Write(ex.Message);
            }
            finally
            {
                conn.Close();
            }
        }
}

用户注册功能代码如下: 
protected void Button1_Click(object sender, EventArgs e)
    {
        {
            SqlConnection myconn = new SqlConnection();
            SqlCommand ld = new SqlCommand();
            string mystr = "Data Source = .;Initial Catalog = NBA ;Integrated Security = True";
            myconn.ConnectionString = mystr;
            myconn.Open();
            SqlDataReader dr;
            ld.CommandText = "select * from Users where 用户名='" + this.TextBox1.Text.Trim() + "'";
            ld.Connection = myconn;
            dr = ld.ExecuteReader();
            if (!dr.Read())
            {
                dr.Close();
                ld.Parameters.Add("@用户名", System.Data.SqlDbType.VarChar, 20).Value = TextBox1.Text.Trim().ToString();
                ld.Parameters.Add("@密码", System.Data.SqlDbType.VarChar, 20).Value = TextBox2.Text.Trim().ToString();
                ld.Parameters.Add("@姓名", System.Data.SqlDbType.VarChar, 10).Value = TextBox4.Text.Trim().ToString();
                ld.Parameters.Add("@电话", System.Data.SqlDbType.VarChar, 11).Value = TextBox5.Text.Trim().ToString();
                ld.CommandText = "insert into Users values(@用户名,@密码,@姓名,@电话)";
                ld.Connection = myconn;
                ld.ExecuteNonQuery();
                myconn.Close();
                Response.Write("<script>alert('注册成功!请登录!');location.href='login.aspx'</script>");
            }
            else
                Response.Write("<script>alert('用户已存在!')</script>");
            dr.Close();
        }
}

添加球员核心代码如下:
{
            SqlConnection myconn = new SqlConnection();
            SqlCommand ld = new SqlCommand();
            string mystr = "Data Source = .;Initial Catalog = NBA ;Integrated Security = True";
            myconn.ConnectionString = mystr;
            myconn.Open();
            SqlDataReader dr;
            ld.CommandText = "select * from Lakers where 号码='" + this.TextBox2.Text.Trim() + "'";
            ld.Connection = myconn;
            dr = ld.ExecuteReader();
            if (!dr.Read())
            {
                dr.Close();
                ld.Parameters.Add("@号码", System.Data.SqlDbType.VarChar, 5).Value = TextBox2.Text.Trim().ToString();
                ld.Parameters.Add("@姓名", System.Data.SqlDbType.VarChar, 20).Value = TextBox3.Text.Trim().ToString();
                ld.Parameters.Add("@位置", System.Data.SqlDbType.VarChar, 20).Value = TextBox4.Text.Trim().ToString();
                ld.Parameters.Add("@生日", System.Data.SqlDbType.VarChar, 20).Value = TextBox5.Text.Trim().ToString();
                ld.Parameters.Add("@身高", System.Data.SqlDbType.VarChar, 20).Value = TextBox6.Text.Trim().ToString();
                ld.Parameters.Add("@体重", System.Data.SqlDbType.VarChar, 10).Value = TextBox7.Text.Trim().ToString();
                ld.CommandText = "insert into Lakers values(@号码,@姓名,@位置,@生日,@身高,@体重)";
                ld.Connection = myconn;
                ld.ExecuteNonQuery();
                myconn.Close();
                Response.Write("<script>alert('添加成功!');location.href='湖人队球员管理.aspx'</script>");
            }
            else
                Response.Write("<script>alert('已存在!')</script>");
            dr.Close();
        }

 

Guess you like

Origin blog.csdn.net/xiexie17/article/details/122380048