图书管理系统的简单功能实现C#+Access

使用Microsoft Visual Studio 2010和C#,通过Access数据库创建了包含登录、注册、借还书和图书管理界面的简单图书管理系统。代码部分包括登录、注册、借书、还书及图书信息管理等模块。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

目录

一、界面设计

二、代码部分


项目开发用的是Microsoft Visual Studio 2010语言是C#连接Access数据库,第一次做代码有些不简洁希望各位大佬理解

一、界面设计

登录界面

注册界面

借还界面

图书管理界面

二、代码部分

1.登录模块: 为了判断用户和管理员身份代码有重复部分,看起来有点复杂

 private void button1_Click(object sender, EventArgs e)
        {
            string oleCon = "provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:DataBase Password='';User Id='admin';Data source=|DataDirectory|Database2.mdb";
            OleDbConnection conn = new OleDbConnection(oleCon);
            conn.Open();
            string judna = "select `userna` from `user_table` where `userna`='" + this.textBox1.Text + "'";
            OleDbCommand cmd = new OleDbCommand(judna, conn);
            OleDbDataReader read = cmd.ExecuteReader();
              
            if (read.Read() == true)
            {
                read.Close();
                if (this.radioButton1.Checked == true)//用户登录界面
                {
                    string judid = "select `userna`,`uid` from `user_table` where `userna`='"+this.textBox1.Text +"' and   `uid`='"+this.radioButton1.Text+"'";
                    OleDbCommand cmd1 = new OleDbCommand(judid, conn);
                    OleDbDataReader readid = cmd1.ExecuteReader();
                    if (readid.Read() == true)
                    {
                        string judpa = "select `userna`,`userpa` from `user_table` where `userna`='"+this.textBox1.Text+"' and `userpa`='" + this.textBox2.Text + "'";
                        OleDbCommand cmd2 = new OleDbCommand(judpa, conn);
                        OleDbDataReader read1 = cmd2.ExecuteReader();
                        if (read1.Read() == true)
                        {
                            string sname = "select `uname`,`uid` from `user_table` where `userna`='" + this.textBox1.Text + "' ";
                            OleDbCommand cmd5 = new OleDbCommand(sname, conn);

                            Class1.username = Convert.ToString(cmd5.ExecuteScalar().ToString());
                            Class1.useracc = Convert.ToString(this.textBox1.Text);
                            Form f1 = new Form1();      
                            this.Hide();
                            f1.ShowDialog();          
                        }
                        else
                        {
                            MessageBox.Show("密码错误,请重新输入");
                            this.textBox2.Focus();
                        }
                    }
                    else
                    {
                        MessageBox.Show("身份错误");
                    }
                }
                else {

                    string judid1 = "select `userna`,`uid` from `user_table` where `userna`='" + this.textBox1.Text + "' and   `uid`='" + this.radioButton2.Text + "'";
                    OleDbCommand cmd3 = new OleDbCommand(judid1, conn);
                    OleDbDataReader readid1 = cmd3.ExecuteReader();
                    if (readid1.Read() == true)
                    {
                        string judpa1 = "select `userna`,`userpa` from `user_table` where `userna`='" + this.textBox1.Text + "' and `userpa`='" + this.textBox2.Text + "'";
                        OleDbCommand c
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值