系统源代码.doc_第1页
系统源代码.doc_第2页
系统源代码.doc_第3页
系统源代码.doc_第4页
系统源代码.doc_第5页
已阅读5页,还剩13页未读 继续免费阅读

下载本文档

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

文档简介

namespace BookManage public partial class frmLogin : Form public frmLogin() InitializeComponent(); private void btnLogin_Click(object sender, EventArgs e) /验证通过 if (Validate() string state = this.cboUserType.Text; int num; if (state.Equals(管理员)/判断用户角色 num = 1; else if (state.Equals(后台管理) num = 2; else num = 3; /定义查询语句 string sql = string.Format(select * from userinfo where uname=0and upwd=1 and ustate=2, this.txName.Text.Trim(),this.txtPwd.Text.Trim(),num); DataSet ds = DataAccess.GetDataSetBySql(sql); if (ds.Tables0.Rows.Count 0) MessageBox.Show(登录成功); Constans.UserBookID = ds.Tables0.Rows0UBookID.ToString(); Constans.UserName = ds.Tables0.Rows0UName.ToString(); Constans.UserState = ds.Tables0.Rows0UState.ToString(); if(num=1) frmMain.result = DialogResult.OK; this.Hide(); frmMain main = new frmMain(); main.ShowDialog(); else if (num = 2) frmBookInStore store = new frmBookInStore(); store.ShowDialog(); else frmBookJY jy = new frmBookJY(); jy.ShowDialog(); else MessageBox.Show(用户名或密码错误); private void frmLogin_Load(object sender, EventArgs e) this.cboUserType.SelectedIndex = 0; /验证方法 private bool Vaildate() if (this.txName.Text != string.Empty & this.txtPwd.Text != string.Empty) return true; else MessageBox.Show(用户名或密码不能为空); return false; private void btnCancle_Click(object sender, EventArgs e) this.Close(); namespace BookManage public partial class frmMain : Form public static DialogResult result; public frmMain() InitializeComponent(); /查询子窗体是否存在 public bool checkchildfrm(string childfrmname) foreach (Form childFrm in this.MdiChildren) if (childFrm.Name = childfrmname) if (childFrm.WindowState = FormWindowState.Minimized) childFrm.WindowState = FormWindowState.Normal; childFrm.Activate(); return true; return false; /用户登录菜单的事件处理 private void 用户登录ToolStripMenuItem_Click(object sender, EventArgs e) /检测该窗口是否处于打开状态 if (this.checkchildfrm(frmLogin) = true) return; /窗口已经打开,返回 frmLogin user = new frmLogin();/实例化登录窗体 user.ShowDialog(); /登录窗体以模式对话框的方式的打开 /判断是否登录成功,登录成功则启用相应的菜单和按钮 if (result = DialogResult.OK) this.tsbtnAddBook.Enabled = true; this.mnuUpdateBook.Enabled = true; this.mnuAddBook.Enabled = true; /登录按钮事件处理 private void tsbtnLogin_Click(object sender, EventArgs e) if (this.checkchildfrm(frmLogin) = true) return; frmLogin user = new frmLogin(); user.ShowDialog(); if (result = DialogResult.OK) this.tsbtnAddBook.Enabled = true; this.mnuUpdateBook.Enabled = true; this.mnuAddBook.Enabled = true; /图书查询按钮Click事件处理 private void tsbtnSearch_Click(object sender, EventArgs e) frmBookSearch frmbs = new frmBookSearch(); frmbs.ShowDialog(); /图书检索菜单Click事件处理 private void 图书检索ToolStripMenuItem_Click(object sender, EventArgs e) frmBookSearch frmbs = new frmBookSearch(); frmbs.ShowDialog(); /图书入库菜单Click事件处理 private void 图书入库ToolStripMenuItem1_Click(object sender, EventArgs e) frmBookInStore bookinstore = new frmBookInStore(); bookinstore.ShowDialog(); /图书入库按钮Click事件处理 private void tsbtnAddBook_Click(object sender, EventArgs e) frmTsgx tsgx = new frmTsgx(); tsgx.ShowDialog(); /图书更新菜单Click事件处理 private void 图书修改ToolStripMenuItem_Click(object sender, EventArgs e) frmTsgx tsgx = new frmTsgx(); tsgx.ShowDialog(); /图书借阅按钮事件处理 private void tsbtnIssue_Click(object sender, EventArgs e) frmBookJY bookjy = new frmBookJY(); bookjy.ShowDialog(); 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; /在关闭主窗体的同时,关闭整个系统 private void frmMain_FormClosed(object sender, FormClosedEventArgs e) Application.Exit(); private void 图书借阅ToolStripMenuItem_Click(object sender, EventArgs e) frmBookJY bookJy = new frmBookJY(); bookJy.ShowDialog(); private void 图书归还ToolStripMenuItem_Click(object sender, EventArgs e) frmBookReturn frmreturn = new frmBookReturn(); frmreturn.ShowDialog(); private void 注册ToolStripMenuItem_Click(object sender, EventArgs e) frmUserZC zc = new frmUserZC(); zc.ShowDialog(); namespace BookManage public partial class frmBookInStore : Form public frmBookInStore() InitializeComponent(); private void BookInStore_Load(object sender, EventArgs e) DataSet Myds = DataAccess.GetDataSetBySql(select * from BookInfo); DataTable table = Myds.Tables0; this.dataGridView1.DataSource = table; private void btnExit_Click(object sender, EventArgs e) this.Close(); private void btnInsert_Click(object sender, EventArgs e) string bookname = this.txtBookName.Text; string booktype = this.txtBookType.Text; string author = this.txtAuthor.Text; string cbs = this.txtCBS.Text;/出版商 int kc =Convert.ToInt32( this.txtKC.Text);/库存 int kjysl =Convert.ToInt32( this.txtKJY.Text);/可借阅数量 string sql = string.Format(insert into BookInfo values(0,1,2,3,4,5), booktype,bookname, author, cbs, kc, kjysl); if (DataAccess.UpdateDataTable(sql) MessageBox.Show(添加成功!, 提示); else MessageBox.Show(添加失败!,提示,MessageBoxButtons.OK); DataSet Myds = DataAccess.GetDataSetBySql(select * from BookInfo); DataTable table=Myds.Tables0; this.dataGridView1.DataSource = table; public bool Validate() return true; namespace BookManage public partial class frmTsgx : Form public frmTsgx() InitializeComponent(); private void btnClose_Click(object sender, EventArgs e) this.Close(); private void frmTsgx_Load(object sender, EventArgs e) DataSet Myds = DataAccess.GetDataSetBySql(select * from BookInfo); DataTable table = Myds.Tables0; dataGridView1.DataSource = table; private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) int index = dataGridView1.CurrentCell.RowIndex; this.textBox1.Text = this.dataGridView1.Rowsindex.Cells0.Value.ToString().Trim();/图书编号 this.textBox2.Text = this.dataGridView1.Rowsindex.Cells2.Value.ToString().Trim();/图书名称 this.textBox3.Text = this.dataGridView1.Rowsindex.Cells1.Value.ToString().Trim();/图书类型 this.textBox4.Text = this.dataGridView1.Rowsindex.Cells3.Value.ToString().Trim();/图书作者 this.textBox5.Text = this.dataGridView1.Rowsindex.Cells4.Value.ToString().Trim();/出版商 this.textBox6.Text = this.dataGridView1.Rowsindex.Cells5.Value.ToString().Trim();/库存 this.textBox7.Text = this.dataGridView1.Rowsindex.Cells6.Value.ToString().Trim();/可借阅的数量 private void btnUpdate_Click(object sender, EventArgs e) string bookname = textBox2.Text.ToString().Trim(); string booktype = textBox3.Text.ToString().Trim(); string bookauthor = textBox4.Text.ToString().Trim(); string bookpublish = textBox5.Text.ToString().Trim(); int bookkc = Convert.ToInt32(textBox6.Text.Trim(); int bookjysl = Convert.ToInt32(textBox7.Text.Trim(); string sql = string.Format(update BookInfo set BookName=0,BookType=1,BookAuthor=2,BookPublish=3,BookKC=4,BookJYSL=5 where BookID=6,bookname,booktype,bookauthor,bookpublish,bookkc,bookjysl,Convert.ToInt32(textBox1.Text); if (DataAccess.UpdateDataTable(sql) MessageBox.Show(更新成功!, 提示, MessageBoxButtons.OK); else MessageBox.Show(更新失败!,提示,MessageBoxButtons.OK); private void btnSaveEdit_Click(object sender, EventArgs e) string sql = select * from BookInfo; DataSet ds = DataAccess.GetDataSetBySql(sql); DialogResult result = MessageBox.Show(您确实要将修改保存到数据库中吗?,操作提示,MessageBoxButtons.OKCancel,MessageBoxIcon.Question); if(result=DialogResult.OK) DataAccess.UpdateDataSet(ds,sql); MessageBox.Show(保存成功!); dataGridView1.DataSource = DataAccess.GetDataSetBySql(sql).Tables0; namespace BookManage public partial class frmBookSearch : Form public frmBookSearch() InitializeComponent(); private void btnClose_Click(object sender, EventArgs e) this.Close(); private void btnSearch_Click(object sender, EventArgs e) /string cbo1 = this.cboBookType.Text; string booktype = this.cboType2.Text; string bookname = this.txtBookName.Text; string sql=select * from BookInfo where BookType=+booktype+and BookName like %+bookname+%; DataSet Myds = DataAccess.GetDataSetBySql(sql); DataTable table = Myds.Tables0; this.dataGridView1.DataSource = table; private void frmBookSearch_Load(object sender, EventArgs e) DataSet Myds = DataAccess.GetDataSetBySql(select distinct BookType from BookInfo); DataTable table = Myds.Tables0; for (int i = 0; i table.Rows.Count; i+) /this.cboBookType.Items.Add(table.Rowsi0.ToString().Trim(); this.cboType2.Items.Add(table.Rowsi0.ToString().Trim(); / this.cboBookType.SelectedIndex = 0; this.cboType2.SelectedIndex = 0; namespace BookManage public partial class frmBookReturn : Form public frmBookReturn() InitializeComponent(); private void button2_Click(object sender, EventArgs e) this.Close(); private void btnSearch_Click(object sender, EventArgs e) string userbookid = textBox1.Text; string sql=string.Format(select * from IssueInfo where UserBookID=0,userbookid); DataSet Myds = DataAccess.GetDataSetBySql(sql); DataTable table = Myds.Tables0; dataGridView1.DataSource = table; private void button1_Click(object sender, EventArgs e) DateTime time = Convert.ToDateTime(this.textBox9.Text); string bo = boBox2.Text.ToString(); string sql =string.Format( update IssueInfo set ghDateTime=0,Bool=1 where IssID=2,time,bo,Convert.ToInt32(textBox15.Text); if (DataAccess.UpdateDataTable(sql) MessageBox.Show(还书成功!, 提示, MessageBoxButtons.OK); string sql2 = string.Format(update BookInfo set BookKC=BookKC+1 where BookID=0,Convert.ToInt32( this.textBox14.Text.ToString().Trim(); string sq = string.Format(update UserIssue set BookKC=BookKC-1 where UserBookID=0, this.textBox15.Text.ToString(); DataAccess.UpdateDataTable(sql2); DataAccess.UpdateDataTable(sq); else MessageBox.Show(还书失败!,提示,MessageBoxButtons.OK); private void dataGridView1_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e) int index = dataGridView1.CurrentCell.RowIndex; this.textBox15.Text = this.dataGridView1.Rowsindex.Cells0.Value.ToString().Trim();/借阅编号 this.textBox14.Text = this.dataGridView1.Rowsindex.Cells1.Value.ToString().Trim();/借书证号 this.textBox13.Text = this.dataGridView1.Rowsindex.Cells2.Value.ToString().Trim();/用户名 this.textBox12.Text = this.dataGridView1.Rowsindex.Cells3.Value.ToString().Trim();/图书编号 this.textBox11.Text = this.dataGridView1.Rowsindex.Cells4.Value.ToString().Trim();/图书名 this.textBox10.Text = this.dataGridView1.Rowsindex.Cells5.Value.ToString().Trim();/借阅时间 this.textBox9.Text = this.dataGridView1.Rowsindex.Cells6.Value.ToString().Trim();/归还时间 private void frmBookReturn_Load(object sender, EventArgs e) boBox2.SelectedIndex = 0; namespace BookManage public partial class frmBookJY : Form DataSet da = new DataSet(); public frmBookJY() InitializeComponent(); private void btnExit_Click(object sender, EventArgs e) this.Close(); private void frmBookJY_Load(object sender, EventArgs e) textBox1.Text = Constans.UserBookID; textBox2.Text = Constans.UserName; DataSet Myds = DataAccess.GetDataSetBySql(select * from IssueInfo); DataTable table = Myds.Tables0; dataGridView1.DataSource = table; da = DataAccess.GetDataSetBySql(select * from BookInfo); boBox1.DataSource = da.Tables0; boBox1.DisplayMember = BookName; boBox1.ValueMember = BookID; boBox2.DataSource = da.Tables0; boBox2.DisplayMember = BookID; boBox2.ValueMember = BookID; private void btnJY_Click(object sender, EventArgs e) string userbookid = textBox1.Text.ToString(); string username = textBox2.Text.ToString(); string bookname = comboBox1.Text.ToString(); string

温馨提示

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

评论

0/150

提交评论