1. ホーム
  2. asp.net

ASP.NET図書館管理システム簡易実装ステップ

2022-02-20 06:26:19
<パス

I. データベース追加

1. ユーザー情報
2.書籍情報テーブル
3.ブックチェックアウトインフォメーションシート

2つ目は、バージョンページ

vs2010+sqlserver2008

<イグ

III. 機能の実装

1. user registration login
2. two identities: administrator and reader
3. readers can register their account and password and fill in their personal information
4. readers can check out and return books according to their needs
5. the administrator can add, subtract, check and change book information, and modify user information to be improved


IV. メインページ表示

1. ログインページ
<イグ 2.ユーザー登録
3.個人情報フォーム
4.ユーザーによる書籍の返却

5. ユーザーが本をチェックアウトする
6. ユーザーが書籍を検索する

7. 管理者ページ

V. シンプルなコード

1. 登録ページ(内容判定は含まれません)

try
        {
            //give sql string data
            string strsql1 = "insert into yhxx (zh,mima) values ('" + Tet_zh.Text + "','" + Tet_mima.Text + "')";
            // Create a string object
            mycom = new SqlCommand(strsql1, myconn);
            mycom.ExecuteNonQuery();
            // Close the database
            myconn.Close();
            Response.Write("<script>alert('Added successfully!!!') </script>");
            //save account
            //str = Tet_zh.Text;
            //save username
            Application["name"] = Tet_zh.Text;
            //If it succeeds, the application is successfully redirected to
            Response.Redirect("Useradd.aspx");
        }
        catch (Exception ex)
        {
            Response.Write("<script>alert('User already exists!!!') </script>");
        }


2. 個人情報ページ(内容判断は含まれません)

protected void tianjia()
    {
        //add user information
        try
        {
            //give sql string data
            
            string strsql1 = "update yhxx set xm='"+Tet_xm.Text+"',xb='"+tet_xb.Text+"',qq='"+Tet_qq.Text+"', Email='"+Tet_email.Text+"',dizhi='"+tet_home.Text+"',enjioy='"+Tet_enjoy.Text+"' where zh='"+ Application["name"]+"'";
            // Create a string object
            mycom = new SqlCommand(strsql1, myconn);
            mycom.ExecuteNonQuery();
            // Close the database
            myconn.Close();
            Response.Write("<script>alert('Added successfully!!!') </script>");
            Response.Redirect("denglu.aspx");
        }
        catch (Exception ex)
        {
            Response.Write("<script>alert('Failed to add!!!') </script>"+ex.Message.ToString());
        }
    }


3. ログインページ(内容判定は含まれません)

 // Normal user login, admin login is the same
        try
        {
            string sql = "select * from yhxx where zh='"+Tet_zh.Text+"' and mima='"+Tet_mm.Text+"' and yhlb='"+tet_dz.Text+& quot;'";
            // Create command object
            SqlCommand com = new SqlCommand(sql,myconn);
            //create the read object
            SqlDataReader dr = com.ExecuteReader();
            //successfully pop up the alert box
            //MessageBox.Show("Read Success!!! ");
            if (dr.Read())
            {
                dr.Close();
                myconn.Close();
                Application["name1"] = Tet_zh.Text;
                Response.Redirect("index.aspx");
            }
            else
            {
                Response.Write("<script>alert('Error in username or password!!!') </script>");
            }

        }
        catch (Exception ex)
        {
            Response.Write("<script>alert('Login failed!!!') </script>");
        }


4. 書籍検索

try
        {
            //open the database
            myconn.Open();
        }
        catch (Exception ex)
        {
            Response.Write("<script>alert('Database open failed')</script>");
        }
        try
        {
            //create data string
            if (tet_name.Text == "")
            {
                Response.Write("<script>alert('Name cannot be empty!') </script>");
            }
            else
            {
                string strsql3 = "select BookID as book number,BookName as book name,"
                                + "Booklb as book category,Bookzz as book author,Booklr as book content,"
                                + "Bookfm as book cover,Bookjg as book price,Bookzt as book lending status "
                                + " from Bookxx where BookName='" + tet_name.Text + "'";
                mycom = new SqlCommand(strsql3, myconn);
                //open the database
                //myconn.Open();
                //
                myread = mycom.ExecuteReader();
                GridView1.DataSource = myread;
                GridView1.DataBind();
            

5. 本のチェックアウト

1. Add the book first
 if (myread.Read())
        {
            if (tet_zt.Text == "0")
            {
                // Add the borrowing information table
                myread.Close();
                string strsql5 = "insert into Bookjyxx (ISBookID,ISBookname,ISBookzt,ISname,ISid) " +
               " values (" + Tet_Bookid.Text + ",'" + tet_Name.Text + "'," + tet_zt.Text + ",'" + Tet_xm.Text + "'," quot; + Tet_ID.Text + ")";
                mycom = new SqlCommand(strsql5, myconn);
                mycom.ExecuteNonQuery();
                //close
                myconn.Close();
                myread.Close();
        //
                xiugai();
                chaxun();
            }
            if (tet_zt.Text == "1")
            {
                Response.Write("<script>alert('The book is on loan')</script>");
                chaxun();
            }
 2. Then modify the borrowing status separately
             //create
        // first modify the book table status information
        string strsql7 = "update Bookxx set Bookzt='1' where BookID='" + Tet_Bookid.Text + "'";
        mycom = new SqlCommand(strsql7, myconn);
        myconn.Close();
        myconn.Open();
        mycom.ExecuteNonQuery();
        // then modify the borrowing status table information
        string strsql8 = "update Bookjyxx set ISBookzt='1' where ISBookID='" + Tet_Bookid.Text + "'";
        mycom = new SqlCommand(strsql8, myconn);
        mycom.ExecuteNonQuery();
        Response.Write("<script>alert('Borrowed successfully!') </script>");
        //close
        myconn.Close();


6. ブックリターン

 //delete his borrowed book information
        string strsql3="delete from bookjyxx where ISid='"+Tet_id.Text+"'";
        mycom = new SqlCommand(strsql3, myconn);
        myconn.Open();
        mycom.ExecuteNonQuery();
        //
       // Refresh the information
        // Query information
        string strsql4= "select ISname as borrower,ISid as borrower ID number,ISBookID as borrower book number,"
           + "ISBookname as borrowing data name,ISBookzt as borrowing status,ISdate as borrowing date from Bookjyxx where ISid='" + Tet_id.Text + "'";
        mydata = new SqlDataAdapter(stsql4, myconn);
        DataSet set = new DataSet();
        mydata.Fill(set);
        GridView1.DataSource = set.Tables[0];
        GridView1.DataBind();
        GridView1.Visible = true;
        //Modify the status
        //Modify the book table status information first
        string strsql7 = "update Bookxx set Bookzt='0' where BookID='" +tet_Bookid.Text+ "'";
        mycom = new SqlCommand(strsql7, myconn);
        mycom.ExecuteNonQuery();
        Response.Write("<script>alert('Returned successfully!') </script>");
        //close
        myconn.Close();
        set.Clear();


VI. 概要

私は初めてブログを書いて、私は神々が教えることを望む任意の間違いがあり、私はまた、asp.netの人々の助けとの唯一の接触を与えることを望む、直接私を追加する必要があります。1076396021(何のためではない)どんな質問は、読んでサポートしていただきありがとうございますデバッグするために、私に尋ねることができ、あなたは私の成長のステップでもある助けをもたらすことができる!私は、このブログの最初の時間を書いている。
直接追加する