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

this.txtbID.Text = \; this.txtbName.Text = \; this.txtbPic.Text = \; this.txtbPrice.Text = \; this.txtbType.Text = \; }

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

附录D 图书借阅功能实现代码

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 frmIssueBook : Form { DataSet da;

public frmIssueBook() { nitializeComponent(); }

private void frmIssueBook_Load(object sender, EventArgs e) { DataSet ds = DataAccess.GetDataSetBySql(\BookInfo.BookID,BookName,IssUBookID,IssDateTime from

IssueInfo,BookInfo where BookInfo.BookID=IssueInfo.BookID\); this.dgvIssInfo.DataSource = ds.Tables[0];

da = DataAccess.GetDataSetBySql(\); this.cboBookName.DataSource = da.Tables[0]; this.cboBookName.DisplayMember = \; this.cboBookName.ValueMember = \; }

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

private void cboBookName_SelectedIndexChanged(object sender, EventArgs e)

{ foreach (DataRow objRow in da.Tables[0].Rows) { if (string.Compare(cboBookName.Text, objRow[\].ToString(), true) == 0)

{ this.txtBookAccessCode.Text =

24

objRow[\].ToString();

this.txtAuthor.Text = objRow[\].ToString(); }}}

private void btnIssueBook_Click(object sender, EventArgs e) { int bookid =

Convert.ToInt32(this.cboBookName.SelectedValue);

int issid = Convert.ToInt32(this.txtIssID.Text); DateTime date =

Convert.ToDateTime(this.dateTimePicker1.Text);

string sql = string.Format(\values({0},{1},'{2}')\, bookid, issid, date); if (DataAccess.UpdateDataTable(sql)) { MessageBox.Show(\借阅成功\); }

DataSet data = DataAccess.GetDataSetBySql(\BookInfo.BookID,BookName,IssUBookID,IssDateTime from

IssueInfo,BookInfo where BookInfo.BookID=IssueInfo.BookID\); this.dgvIssInfo.DataSource = data.Tables[0]; }}}

25

参考文献

1 刘丽霞 等编著,零基础学 C#3.0. 北京:机械工业出版社,2009.3

2 刘辉 等编著,零基础学 SQL Server 2005. 北京:机械工业出版社,2008.1

26

联系客服:779662525#qq.com(#替换为@)