Video presentation

Video link

I. Purpose of the experiment

In VisualStudio development platform, using C# language for Web development, able to skillfully use and master. NET development tools.Copy the code

Ii. Equipment and environment

(1) hardware equipment: one PC (2) software environment: Windows operating system, database management system Mysql, VisualStudio, etc.

3. Experiment content

1. Demand analysis:

The library, as the main place used by students in the university, is bound to be the busiest place. When books and files by people to watch, registration, modification, addition and deletion, query, low efficiency, and prone to error, data insecurity, and a long time after the increase in the amount of data will lead to data retrieval difficulties and many other problems. When the library develops, too much data makes the library management problem prominent. We write procedures for library information management, books lending, books registration, user registration, add and delete books and other services, using these technologies can improve the library work efficiency, so that the library to provide better services to students, is the main purpose of system development.Copy the code

2. Logical structure:

The system involves a number of interfaces, including login, registration, the administrator of personnel, books add, delete, change and check. Users add, delete, change and check their borrowed books, as well as the modification of personal information. A total of 4 data tables are used in the database, which are user table (falg attribute 1 is administrator, and falg attribute 0 is common user), user borrowing table, book classification table and book table.

3. System design

(1) E-R diagram of the system

(2) System framework diagram

4. Project Demonstration (1) Display the main interface of the administrator

(2) Display of user’s main interface

(3) Librarian library management interface

(4) User management interface

(5) Administrator book management interface

(6) User login and registration:

(7) Change user information

(8) Relevant program codes

A. Database connection operation <connectionStrings> <add name="MySQLConnectionString" connectionString="server=localhost; user id=root; password=root; persistsecurityinfo=True; database=netcourse" providerName="MySql.Data.MySqlClient"/>
  </connectionStrings>
Copy the code

B. MySQL binding (example)

conn = DBOperation.GetMySqlConnection();
                conn.Open();
                MySqlCommand sql = new MySqlCommand();
                sql.Connection = conn;
                sql.CommandText = "select * from user where ID=@ID";
                sql.Parameters.AddWithValue("@ID", ID);
                MySqlDataReader reader = sql.ExecuteReader();
Copy the code

C. User login operations

 public User Login(string userName, string password)
        {
            User user = userDao.queryByID(userName);
            if(user == null)
            {
                Console.WriteLine("The userName wrong");
                return null;
            }
            else{
                if(user.passWord == password)
                {
                    return user;
                }
                else
                {
                    Console.WriteLine("Wrong password.");
                    return null; }}}public User queryByID(String ID)
        {
 // try
 / / {
                conn = DBOperation.GetMySqlConnection();
                conn.Open();
                MySqlCommand sql = new MySqlCommand();
                sql.Connection = conn;
                sql.CommandText = "select * from user where ID=@ID";
                sql.Parameters.AddWithValue("@ID", ID);
                MySqlDataReader reader = sql.ExecuteReader();
                User user = null;
                if (reader.Read())
                {
                    user = new User(reader.GetString("ID"), reader.GetString("userName"), reader.GetInt32("age"), reader.GetString("passWord"), reader.GetInt32("flag"));
                }
                reader.Close();
                return user;
 / /}
      
        }
Copy the code

D. User Query (example) :

public List<User> queryByUserName(String userName)
        {
            try
            {
                conn = DBOperation.GetMySqlConnection();
                conn.Open();
                MySqlCommand sql = new MySqlCommand();
                sql.Connection = conn;
                sql.CommandText = "select * from user where userName=@userName";
                sql.Parameters.AddWithValue("@userName", userName);
                MySqlDataReader reader = sql.ExecuteReader();
                List<User> userList = null;
                if (reader.Read())
                {
                    userList = new List<User>();
                    User user = new User(reader.GetString("ID"), reader.GetString("userName"), reader.GetInt32("age"), reader.GetString("passWord"), reader.GetInt32("flag"));
                    userList.Add(user);
                    while (reader.Read())
                    {
                        user = new User(reader.GetString("ID"), reader.GetString("userName"), reader.GetInt32("age"), reader.GetString("passWord"), reader.GetInt32("flag"));
                        userList.Add(user);
                    }
                }
                reader.Close();
                return userList;
            }
            catch (Exception e)
            {
                
                return null;
            }
            finally{ conn.Close(); }}Copy the code

9. Database related table information a. Book information table

B. User information table

C. classification table

D. book table

4. Experimental results and analysis

This experiment is the most difficult one since I entered the school, because I did not learn the basic syntax of C# language in detail during the writing process, although the writing method is very similar to Java, I also encountered many difficulties in the actual operation process. In the case of a large number of data query, it is reluctantly completed the realization of most functions. When I first started, I didn’t know how to do data binding, but I found tutorials on the Internet and modified the project bit by bit. The logical structure of this project is very simple design patterns or use the MVC structure, the design time and specific function simplifies the business logic such as login example, users in the after losing the ID and password, the background reading input from the user’s information, then its value as an object of SQl query to query database after operation, if the test result is true, If the login succeeds, the system returns a message to the front-end interface if the login fails. Although the experiment was completed, I also learned a lot of shortcomings in this experiment, such as the use of controls and style Settings, I think it is directly related to my usual practice. I hope I can master it more thoroughly in the future. NET language, the system to do a bit more perfect.