C#图书馆管理系统_第1页
C#图书馆管理系统_第2页
C#图书馆管理系统_第3页
C#图书馆管理系统_第4页
C#图书馆管理系统_第5页
已阅读5页,还剩13页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、 目录1、绪论22、数据库设计32。1 数据库分析32。1创建数据库43、界面设计43。1 登陆界面43。2 图书管理系统界面83。3 图书信息界面93。4 图书归还界面113。5 图书借阅界面133。6 用户信息界面153.7管理员界面163。8注册界面183。9添加图书界面194、系统测试214。1 登陆功能214.2 借阅图书功能224.3 归还图书库功能224.4 图书信息功能23amtt22321 5731 圱4。5 管理员登陆功能234。6 添加图书功能 244.7 用户信息245 、连接数据库245。1连接数据库255.2操作数据库中的数据256 、总结271、绪论2、数据库设计

2、2.1 数据库分析本系统利用Visual Studio 2010处理数据库的功能,实现对图书馆信息的管理。主要功能为管理有关用户、管理员、书籍和借阅的信息等。本系统的结构分为用户信息管理模块、书籍信息管理模块、借阅信息管理模块、管理者管理信息模块和查询处理模块。图书馆管理系统框图如图所示 进入图书馆管理系统借阅图书查询图书23661 5C6D 屭29912 74D8 瓘|21875 5573 啳+35801 8BD9 诙26424 6738 朸增加图书查询图书图书管理登录 用户 管理员失败成功2.2创建数据库3、界面设计3.1登陆界面amespace 图书管理系统 public partial

3、 class Form1 : Form public Form1() InitializeComponent();+26340 66E4 曤38926 980E 頎33653 8375 荵F2 public static Form fm = null; private static int ErrorTimes = 0; private void button3_Click(object sender, EventArgs e) this.Close(); private void textBox1_TextChanged(object sender, EventArgs e) private

4、 void button1_Click(object sender, EventArgs e) if (textBox1.Text = ” | textBox2。Text = "") MessageBox.Show(”提示:请输入用户名和密码!", ”警告”); SqlConnection conn = new SqlConnection("Server=PC_201402131602;Integrated Security=true;DataBase=图书管理系统”); conn。Open(); SqlCommand cmd = new SqlComm

5、and(”select * from Table_1 where id='" + textBox1。Text。Trim() + ”' and us='" + textBox2.Text。Trim() + ”'”, conn);6=22768 58F0 声27679 6C1F 氟30081 7581 疁x28657 6FF1 濱40181 9CF5 鳵 SqlDataReader sdr = cmd。ExecuteReader(); sdr.Read(); if (sdr.HasRows) MessageBox。Show("登录成功!

6、”, ”提示"); Form2 fm = new Form2(); fm.Show(); this。Hide(); else ErrorTimes+; MessageBox。Show("用户名或密码不正确!您还有” + (3 - ErrorTimes) + ”次输入密码的机会,请重新输入!如果超过3次,系统将自动关闭”); if (ErrorTimes >= 3) ErrorTimes = 0; conn。Close(); 32675 7FA3 羣Z37502 927E 鉾25085 61FD 懽23383 5B57 字 private void Form1_Load

7、(object sender, EventArgs e) private void button4_Click(object sender, EventArgs e) if (textBox1。Text = "" | textBox2。Text = ”") MessageBox.Show(”提示:请输入用户名和密码!", "警告"); SqlConnection conn = new SqlConnection("Server=PC_201402131602;Integrated Security=true;DataBase

8、=图书管理系统"); conn.Open(); SqlCommand cmd = new SqlCommand(”select from Table_2 where uid='" + textBox1。Text。Trim() + "' and usr=" + textBox2。Text。Trim() + ”'”, conn); SqlDataReader sdr = cmd.ExecuteReader(); sdr.Read(); if (sdr。HasRows) MessageBox.Show("登录成功!"

9、, ”提示"); Form7 fm = new Form7();421428 53B4 厴30974 78FE 磾20535 5037 倷20704 50E0 僠33037 810D 脍 fm。Show(); this。Hide(); else ErrorTimes+; MessageBox.Show("用户名或密码不正确!您还有" + (3 ErrorTimes) + ”次输入密码的机会,请重新输入!如果超过3次,系统将自动关闭"); if (ErrorTimes >= 3) ErrorTimes = 0; conn。Close(); priva

10、te void button2_Click(object sender, EventArgs e) Form8 f1=new Form8(); f1.Show();21151 529F 功25531 63BB 掻27402 6B0A 權b30358 7696 皖Vh private void button5_Click(object sender, EventArgs e) this.Hide(); Form10 f2 = new Form10(); f2.Show(); 3。2图书管理系统界面namespace 图书管理系统 public partial class Form2 : Form

11、 public Form2() InitializeComponent(); 38480 9650 限29634 73C2 珂23830 5D16 崖36694 8F56 轖34461 869D 蚝|( private void button5_Click(object sender, EventArgs e) this.Close(); private void button3_Click(object sender, EventArgs e) Form3 f2 = new Form3(); f2.Show(); this.Close(); MessageBox。Show(”您已成功进入-图

12、书信息!”); private void button2_Click(object sender, EventArgs e) Form4 f4 = new Form4(); f4。Show(); this.Close(); MessageBox。Show(”您已成功进入-还书系统!"); 34908 885C 衜V20258 4F22 伢33122 8162 腢or private void button1_Click(object sender, EventArgs e) Form5 f5 = new Form5(); f5。Show(); this。Close(); Messag

13、eBox.Show(”您已成功进入-借书系统!”); 3。3图书信息namespace 图书管理系统 public partial class Form3 : Form public Form3() InitializeComponent();31336 7A68 穨21597 545D 呝29550 736E 獮 rf private void Form3_Load(object sender, EventArgs e) / TODO: 这行代码将数据加载到表“图书管理系统DataSet.Table_3"中。您可以根据需要移动或删除它。 this.table_3TableAdapt

14、er。Fill(this.图书管理系统DataSet.Table_3); private void textBox1_TextChanged(object sender, EventArgs e) private void button1_Click(object sender, EventArgs e) this。Close(); 3。4归还图书namespace 图书管理系统27764 6C74 汴934015 84DF 蓟31251 7A13 稓25978 657A 敺Q24554 5FEA 忪22852 5944 奄 public partial class Form4 : Form

15、public Form4() InitializeComponent(); private void button1_Click(object sender, EventArgs e) if (textBox1。Text = ”") MessageBox.Show("提示:请输入所借书籍编号!”, ”警告”); SqlConnection conn = new SqlConnection(”Server=PC_201402131602;Integrated Security=true;DataBase=图书管理系统”); conn.Open(); SqlCommand cm

16、d = new SqlCommand("select * from Table_4 where sid='" + textBox1.Text.Trim() + "' ", conn); SqlDataReader sdr = cmd.ExecuteReader(); sdr。Read(); if (sdr。HasRows) MessageBox。Show(”该书已还”, "提示"); else36247 8D97 趗cu20173 4ECD 仍20982 51F6 凶26955 694B 楋 sdr.Close();

17、string myinsert = ”insert into Table_4 (sid) values ('” + textBox1。Text + ") ”; SqlCommand mycom = new SqlCommand(myinsert, conn); mycom。ExecuteNonQuery(); conn。Close(); conn。Dispose(); MessageBox.Show("您已还书成功!"); private void Form4_Load(object sender, EventArgs e) / TODO: 这行代码将数据

18、加载到表“图书管理系统DataSet。Table_4”中。您可以根据需要移动或删除它。 this。table_4TableAdapter.Fill(this.图书管理系统DataSet。Table_4); / TODO: 这行代码将数据加载到表“图书管理系统DataSet。Table_3”中。您可以根据需要移动或删除它。 this.table_3TableAdapter。Fill(this。图书管理系统DataSet。Table_3); 25000 61A8 憨 24107 5E2B 師39735 9B37 鬷24276 5ED4 廔32760 7FF8 翸36609 8F01 輁 priva

19、te void button2_Click(object sender, EventArgs e) this.Close(); Form2 f2 = new Form2(); f2。Show(); 3。5已借图书namespace 图书管理系统 public partial class Form5 : Form public Form5() InitializeComponent(); private void button1_Click(object sender, EventArgs e)?8x33930 848A 蒊40712 9F08 鼈 this。Close(); Form2 f2

20、= new Form2(); f2.Show(); private void Form5_Load(object sender, EventArgs e) / TODO: 这行代码将数据加载到表“图书管理系统DataSet。Table_4”中。您可以根据需要移动或删除它。 this.table_4TableAdapter.Fill(this。图书管理系统DataSet。Table_4); / TODO: 这行代码将数据加载到表“图书管理系统DataSet.Table_3”中。您可以根据需要移动或删除它。 this.table_3TableAdapter.Fill(this。图书管理系统Data

21、Set。Table_3); private void button2_Click(object sender, EventArgs e) if (textBox1.Text = ”") MessageBox。Show(”提示:请输入所借书籍编号!", ”警告"); SqlConnection conn = new SqlConnection(”Server=PC_201402131602;Integrated Security=true;DataBase=图书管理系统”); conn.Open();34377 8649 虉33206 81B6 膶40628 9EB

22、4 麴h32591 7F4F 罏38033 9491 钑K29465 7319 猙 SqlCommand cmd = new SqlCommand(”select from Table_4 where sid='” + textBox1。Text.Trim() + ” ", conn); SqlDataReader sdr = cmd。ExecuteReader(); sdr。Read(); if (sdr。HasRows) MessageBox.Show("该书已借", "提示”); else sdr.Close(); string myins

23、ert = ”insert into Table_4 (sid) values ('” + textBox1。Text + ”') "; SqlCommand mycom = new SqlCommand(myinsert, conn); mycom.ExecuteNonQuery(); conn.Close(); conn.Dispose(); MessageBox。Show(”您已借书成功!”); private void textBox2_TextChanged(object sender, EventArgs e) 30805 7855 硕21959 55C7

24、 嗇37056 90C0 郀29019 715B 煛26786 68A2 梢33568 8320 茠 3.6用户信息namespace 图书管理系统 public partial class Form6 : Form public Form6() InitializeComponent(); private void Form6_Load(object sender, EventArgs e) / TODO: 这行代码将数据加载到表“图书管理系统DataSet.Table_1"中.您可以根据需要移动或删除它。 this.table_1TableAdapter.Fill(this.图书

25、管理系统DataSet.Table_1); private void button1_Click(object sender, EventArgs e) 27233 6A61 橡a25169 6251 扑30889 78A9 碩.22321 5731 圱 this。Close(); 3。7 管理员主界面namespace 图书管理系统 public partial class Form7 : Form public Form7() InitializeComponent(); private void button2_Click(object sender, EventArgs e) Form

26、6 f1 = new Form6(); f1。Show(); MessageBox.Show("您已成功进入-用户信息!”);23661 5C6D 屭29912 74D8 瓘|21875 5573 啳+35801 8BD9 诙26424 6738 朸 private void button3_Click(object sender, EventArgs e) Form3 f2 = new Form3(); f2.Show(); MessageBox。Show(”您已成功进入图书信息!”); private void button1_Click(object sender, Event

27、Args e) Form9 f2 = new Form9(); f2。Show(); MessageBox。Show("您已成功进入-添加图书系统!"); private void button4_Click(object sender, EventArgs e) this。Close(); +26340 66E4 曤38926 980E 頎33653 8375 荵F2<3。8注册界面namespace 图书管理系统 public partial class Form8 : Form public Form8() InitializeComponent(); priv

28、ate void button1_Click(object sender, EventArgs e) if (textBox1.Text = ”" textBox2。Text = ”") MessageBox.Show(”提示:请输入用户名和密码!", "警告”); SqlConnection conn = new SqlConnection(”Server=PC_201402131602;Integrated Security=true;DataBase=图书管理系统”); conn。Open(); SqlCommand cmd = new SqlCo

29、mmand("select from table_1 where id=” + textBox1.Text.Trim() + ” and us=" + textBox2.Text。Trim() + ”, conn);6=22768 58F0 声27679 6C1F 氟30081 7581 疁x28657 6FF1 濱40181 9CF5 鳵 SqlDataReader sdr = cmd.ExecuteReader(); sdr.Read(); if (sdr。HasRows) MessageBox。Show("该用户已注册,请使用其他用户名", ”提示

30、”); else sdr.Close(); string myinsert = "insert into table_1(id,us) values ('" + textBox1。Text + ”,” + textBox2。Text + ”')”; SqlCommand mycom = new SqlCommand(myinsert, conn); mycom.ExecuteNonQuery(); conn。Close(); conn。Dispose(); MessageBox.Show("您已注册成功!”); private void butto

31、n2_Click(object sender, EventArgs e) this.Close();32675 7FA3 羣Z37502 927E 鉾25085 61FD 懽23383 5B57 字 private void Form8_Load(object sender, EventArgs e) 3.9 添加图书namespace 图书管理系统 public partial class Form9 : Form public Form9() InitializeComponent(); private void button2_Click(object sender, EventArgs

32、 e) 421428 53B4 厴30974 78FE 磾20535 5037 倷20704 50E0 僠33037 810D 脍 private void button1_Click(object sender, EventArgs e) SqlConnection conn = new SqlConnection(”server=PC_201402131602;database=图书管理系统;integrated Security=true"); string sql = ”insert into Table_3 (sid,sdata,sname) values('” +

33、 textBox1.Text + ”','" + textBox2.Text + ”,” + textBox3.Text + "')" conn。Open(); SqlCommand comm = new SqlCommand(sql, conn); if (conn.State = ConnectionState。Closed) conn.Open(); if (Convert.ToInt32(comm。ExecuteNonQuery()) > 0) label4。Text = ”成功!"; MessageBox。Show

34、(”您已成功添加数据!”); else label4。Text = ”失败!"21151 529F 功25531 63BB 掻27402 6B0A 權b30358 7696 皖Vh 4、 系统测试登陆借阅图书归还图书图书信息管理员登陆添加图书用户信息5、连接数据库为数据库BookManage和本系统之间建立一个数据连接.(1)在服务器资源管理器中右击“数据连接"节点(VS 2008中操作)。在弹出的快捷菜单中执行“添加连接"命令,打开Data Link Properties对话框。切换到Provider选项卡,选中列表框中的Microsoft OLE DB Pro

35、vider for SQL Server项。单击“下一步”切换到Connection选项卡。(2)在其中的第一个下拉列表框中选择数据库所在服务器名称.输入登录服务器信息后选择数据库BookManage,然后单击测试按钮.如果测试成功,单击“确定”按钮。5。1 连接数据库(1)定义数据库连接字符串,代码如下:38480 9650 限29634 73C2 珂23830 5D16 崖36694 8F56 轖34461 869D 蚝(Private static string ConnectString = "Data Source= (local)sqlexpress;DataBase=B

36、ookManage。mdf”;(2)创建Connection对象,代码如下:SqlConnection con = new SqlConnection(ConnectString);(3)打开连接,代码如下:con.Open();(4)关闭连接,代码如下:con。Close();5。2操作数据库中的数据using System;using System。Collections。Generic;using System.Linq;using System。Text;using System.Data;using System.Data。SqlClient;namespace BookManage

37、 class DataAccess private static string ConnectString = "Data Source =SQLEXPRESS;AttachDbFilename=F:BookManagedataBookManage。mdf;Integrated Security=False";/数据库连接字符串 / summary>34908 885C 衜V20258 4F22 伢33122 8162 腢or / 根据表名获取数据集的表 / /summary> / param name=”table”/param> / <retur

38、ns></returns>public static DataTable GetDataSetByTableName(string table) using (SqlConnection con = new SqlConnection(ConnectString)/创建数据库连接对象 string sql = "select * from ” + table + ”"/查询sql语句try SqlDataAdapter adapter = new SqlDataAdapter(sql, con);/创建适配器对象 DataSet ds = new DataSet();/创建数据集对象 adapter。Fill(ds, "table”);/填充数据集 return ds.Tables0;/返回数据表 catch (SqlException ex) throw new Exception(ex.Message); ; public static DataSet GetDataSetBySql(string sql) using (SqlConnection con = new SqlConnection(ConnectString)/创建数

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论