云题海 - 专业文章范例文档资料分享平台

当前位置:首页 > C#课程设计图书馆信息管理系统

C#课程设计图书馆信息管理系统

  • 62 次阅读
  • 3 次下载
  • 2025/6/15 10:56:28

frmIssueBook issuebook = new frmIssueBook(); issuebook.MdiParent= this; issuebook.Show(); }

private void tsbtnExit_Click(object sender, EventArgs e) { Application.Exit(); }

private void 退出ToolStripMenuItem1_Click(object sender, EventArgs e)

{ Application.Exit(); }

private void 退出ToolStripMenuItem_Click(object sender, EventArgs e)

{ Application.Exit(); }

//窗体载入时事件处理

private void FrmMain_Load(object sender, EventArgs e) { this.tsbtnAddBook.Enabled = false; this.mnuAddBook.Enabled = false;

this.mnuUpdateBook.Enabled = false;}}}

附录B 图书查询实现代码

using System;

using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text;

using System.Windows.Forms; namespace BookManage

{ public partial class frmSearchBook : Form { public frmSearchBook()

{ InitializeComponent(); }

private void btnSerch_Click(object sender, EventArgs e) { string cbo1 = this.cboOR.Text; string cbo2 = this.cboAnd.Text; string booktype = cboType.Text;

string bookname = this.txtName.Text;

string bookcontent = this.txtContent.Text; //定义sql语句

string sql = \ +

20

booktype + \ + cbo1 + \ + bookname + \ + cbo2 + \ + bookcontent + \; //调用DataAccess.GetDataSetBySql方法

DataSet Myds = DataAccess.GetDataSetBySql(sql); DataTable table = Myds.Tables[0]; //指定数据源

this.dgvSearchBook.DataSource = table; }

private void frmSearchBook_Load(object sender, EventArgs e) { //图书类别组合框初始化

DataSet Myds = DataAccess.GetDataSetBySql(\BookType from bookInfo\);

DataTable table = Myds.Tables[0];

for (int i = 0; i < table.Rows.Count; i++)

{ this.cboType.Items.Add(table.Rows[i][0].ToString().Trim()); }

cboType.SelectedIndex = 0; this.cboOR.SelectedIndex = 0; this.cboAnd.SelectedIndex = 0; }

private void btnClose_Click(object sender, EventArgs e) { this.Close(); }}}

附录C 图书更新实现代码

using System;

using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text;

using System.Windows.Forms; using System.Data.SqlClient; namespace BookManage

{ public partial class frmUpdateBook : Form { DataSet ds = new DataSet(); public frmUpdateBook()

{ InitializeComponent(); }

private void frmUpdateBook_Load(object sender, EventArgs e) { string sql = \; ds = DataAccess.GetDataSetBySql(sql);

21

this.dgvBookInfo.DataSource=ds.Tables[0]; this.txtbID.Enabled = false; }

private void txtbPic_TextChanged(object sender, EventArgs e) { }

private void btnUpdate_Click(object sender, EventArgs e) { string booktype = this.txtbType.Text.ToString(); string bookname = this.txtbName.Text.ToString(); string bookauthor = this.txtAuthor.Text.ToString();

Double bookprice = Convert.ToDouble(this.txtbPrice.Text); string bookpic = this.txtbPic.Text.ToString();

string bookcontent = this.txtbContent.Text.ToString(); int bookissue = Convert.ToInt32(this.txtIssueID.Text); string sql = string.Format(\

BookType='{0}',BookName='{1}',BookAuthor='{2}',BookPrice={3},BookPic='{4}',BookContent='{5}',BookIssue={6} where BookID={7}\, booktype, bookname, bookauthor, bookprice, bookpic, bookcontent, bookissue,Convert.ToInt32(this.txtbID.Text)); if (DataAccess.UpdateDataTable(sql)) { MessageBox.Show(\更新成功\, \提示\, MessageBoxButtons.OK); } else

{ MessageBox.Show(\更新失败\, \提示\, MessageBoxButtons.OK); } }

private void btnSave_Click(object sender, EventArgs e) { string sql = \;

DialogResult result = MessageBox.Show(\确实要将修改保存到数据库吗?\, \操作提示\, MessageBoxButtons.OKCancel, MessageBoxIcon.Question);

if (result == DialogResult.OK)

{ DataAccess.UpdateDataSet(ds, sql); MessageBox.Show(\保存成功\); }

this.dgvBookInfo.DataSource = DataAccess.GetDataSetBySql(sql).Tables[0]; }

private void dgvBookInfo_CellClick(object sender, DataGridViewCellEventArgs e)

{ //获得当前鼠标单击时的行索引号

int index = this.dgvBookInfo.CurrentCell.RowIndex; //通过索引号获得值并赋予相应的文本框显示

22

this.txtbID.Text =

this.dgvBookInfo.Rows[index].Cells[0].Value.ToString().Trim(); this.txtbType.Text =

this.dgvBookInfo.Rows[index].Cells[1].Value.ToString().Trim(); this.txtbName.Text =

this.dgvBookInfo.Rows[index].Cells[2].Value.ToString().Trim(); this.txtAuthor.Text =

this.dgvBookInfo.Rows[index].Cells[3].Value.ToString().Trim(); this.txtbPrice.Text =

this.dgvBookInfo.Rows[index].Cells[4].Value.ToString().Trim(); this.txtbPic.Text =

this.dgvBookInfo.Rows[index].Cells[5].Value.ToString().Trim(); this.txtbContent.Text =

this.dgvBookInfo.Rows[index].Cells[6].Value.ToString(); this.txtIssueID.Text =

this.dgvBookInfo.Rows[index].Cells[7].Value.ToString(); }

private void btnUpdatePic_Click(object sender, EventArgs e) { string pic = this.txtbPic.Text.ToString();

int bookid = Convert.ToInt32(this.txtbID.Text); frmBookPic bookpic = new frmBookPic(); bookpic.ShowContent(bookid,pic); bookpic.ShowDialog(); }

private void btnDel_Click(object sender, EventArgs e) { DataSet ds = DataAccess.GetDataSetBySql(\IssueInfo where BookID=\+Convert.ToInt32(this.txtbID.Text)+\); if (ds.Tables[0].Rows.Count > 0)

{ MessageBox.Show(\此书有借阅,不能删除\); return; } else

{ string sql = \ + this.txtbID.Text + \;

if (DataAccess.UpdateDataTable(sql)) { MessageBox.Show(\删除成功\, \提示\, MessageBoxButtons.OK); } else

{ MessageBox.Show(\删除失败\, \提示\, MessageBoxButtons.OK); }}

this.txtAuthor.Text = \; this.txtbContent.Text = \;

23

搜索更多关于: C#课程设计图书馆信息管理系统 的文档
  • 收藏
  • 违规举报
  • 版权认领
下载文档10.00 元 加入VIP免费下载
推荐下载
本文作者:...

共分享92篇相关文档

文档简介:

frmIssueBook issuebook = new frmIssueBook(); issuebook.MdiParent= this; issuebook.Show(); } private void tsbtnExit_Click(object sender, EventArgs e) { Application.Exit(); } private void 退出ToolStripMenuItem1_Click(object sender, EventArgs e) { Application.Exit(); } p

× 游客快捷下载通道(下载后可以自由复制和排版)
单篇付费下载
限时特价:10 元/份 原价:20元
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219
Copyright © 云题海 All Rights Reserved. 苏ICP备16052595号-3 网站地图 客服QQ:370150219 邮箱:370150219@qq.com