当前位置:文档之家› 图书馆管理系统设计附带源代码

图书馆管理系统设计附带源代码

毕业设计_图书管理系统一、数据库设计数据库设CREATE DATABASE TSGLGOUSE TSGLGOCREATE TABLE Bmanage(bId varchar(10) PRIMARY KEY,bName varchar(50), --添加图书--图书编号--书名bNumber varchar(10), --书数目)GO bSore varchar(50) --分类CREATE TABLE Madmin(mName varchar(10)PRIMARY KEY,mPwd varchar(25),mAge varchar(8),mSex varchar(4),mNumber varchar(15),mrole varchar(8))GO--图书员管理--图书管理员姓名--图书管理员密码--图书管理员年龄--图书管理员性别--图书管理员电话--图书管理员角色CREATE TABLE Reader (rSno varchar (10) PRIMARY KEY , rName varchar (10), rPwd varchar (25), rAge varchar (8), rSex varchar (4), rState varchar (8), rNumber varchar (15), rEmail varchar (25), --读者信息表reader --读者号 --姓名 --密码 --年龄 --性别--状态 --电话号码--电子邮件rAdress varChar (50), --地址)GOrGrade varChar (15), rClass varchar (15),rRole varchar (8) --年级 --班级 --角色CREATE TABLE Rrecord (rSno varchar (10) PRIMARY KEY , rName varChar (10), bId varchar (10), bName varChar (50), bTime varchar (10), bBackTime varchar (10) ) GOCREATE TABLE SysSet (rRole varchar (8)PRIMARY KEY , rState varchar (8),Fine float (25),rDay varchar (8)--读者编号学号 --读者姓名 --图书编号--图书名称 --借书时间 --还书时间 --读者角色 --读者可借书数 --过期罚款设置 --可借书天数)二、界面截图及说明1) 登录窗口(实现管理员与馆长的登陆)2) 管理员窗口3) 馆长窗口4) 关于窗口5) 新增图书窗口6) 新增管理员、查找及修改窗口7) 新增读者、查找及修改窗口8) 图书的查找及修改窗口9) 借阅窗口10)系统设置窗口三、主要代码主要代1) 登录窗口(实现管理员与馆长的登陆)登陆检查:using System;using System、Collections、Generic;using System、Linq;using System、Text;using System、Data;using prjTSGL、ClassLib、DBAccess;namespace prjTSGL、ClassLib、Logic{class clsLoginCheck{public static DataTable CheckLogin(string UserId, string PWD){{string SQLstmt = "select mName,mPwd,mRole from Madmin where mName= '" + UserId + "'and mPwd= '" + PWD + "'";DataTable dt = clsGlobalVar、GetDataTable(SQLstmt);return dt;}}}}登陆: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 prjTSGL、ClassLib、Logic;namespace prjTSGL、TSGL_UI{public partial class frmLogin : Form{public frmLogin(){InitializeComponent();}private void btnLogin_Click(object sender, EventArgs e){string strUserID = loginid、Text、Trim();string strPWD = loginpwd、Text、Trim();string type = "";try{DataTable dt = clsLoginCheck、CheckLogin(strUserID, strPWD);if (dt、Rows、Count == 0){MessageBox、Show("登陆失败,请重新输入!");loginpwd、Focus();return;}else{type = dt、Rows[0]["mRole"]、ToString()、Trim();if (cboLT、Text、Trim()=="馆长" ){if (type == "馆长"){this、Hide();frmManager objManager = new frmManager();objManager、Show();}else{MessageBox、Show("您没有权限!");loginpwd、Focus();return;}}else{if (type =="管理员"){this、Hide();frmAdmin objAdmin = new frmAdmin();objAdmin、Show();}else{MessageBox、Show("您没有权限!");loginpwd、Focus();return;}}}}catch (Exception ex){throw ex;}}private void btnExit_Click(object sender, EventArgs e){this、Close();}}}2) 管理员窗口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 prjTSGL、TSGL_UI{public partial class frmAdmin : Form{public frmAdmin(){InitializeComponent();}private void ShowForm(Form frmToShow){this、Cursor = Cursors、WaitCursor;foreach (Form frmChild in this、MdiChildren){if (frmChild、GetType() == frmToShow、GetType()){frmToShow、Dispose();frmChild、Activate();this、Cursor = Cursors、Default;return;}}frmToShow、MdiParent = this;frmToShow、Show();this、Cursor = Cursors、Default;}private void读者信息修改ToolStripMenuItem_Click(object sender, EventArgs e){ShowForm(new f rmUpdateReader());}private void新增图书ToolStripMenuItem_Click(object sender, EventArgs e){ShowForm(new f rmAddNewBook());}private void图书的查找与修改ToolStripMenuItem_Click(object sender, EventArgs e) {ShowForm(new f rmUpdateBook());}private void流通管理ToolStripMenuItem_Click(object sender, EventArgs e){ShowForm(new f rmBorrow());}private void帮助ToolStripMenuItem_Click(object sender, EventArgs e){ShowForm(new f rmAbout());}private void退出ToolStripMenuItem_Click(object sender, EventArgs e){Application、Exit();}}}3) 馆长窗口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 prjTSGL、TSGL_UI{public partial class frmManager : Form{public frmManager(){InitializeComponent();}private void ShowForm(Form frmToShow){this、Cursor = Cursors、WaitCursor;foreach (Form frmChild in this、MdiChildren){if (frmChild、GetType() == frmToShow、GetType()){frmToShow、Dispose();frmChild、Activate();this、Cursor = Cursors、Default;return;}}frmToShow、MdiParent = this;frmToShow、Show();this、Cursor = Cursors、Default;}private void frmManager_FormClosed(object sender, FormClosedEventArgs e){Application、Exit();}private void管理员信息管理ToolStripMenuItem_Click_1(object sender, EventArgs e) {ShowForm(new f rmSelectAdmin());}private void系统设置ToolStripMenuItem_Click_1(object sender, EventArgs e){ShowForm(new f rmSys());}private void关于ToolStripMenuItem_Click(object sender, EventArgs e){ShowForm(new f rmAbout());}private void退出ToolStripMenuItem_Click_1(object sender, EventArgs e){Application、Exit();}}}4) 关于窗口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 prjTSGL、TSGL_UI{public partial class frmAbout : Form{public frmAbout(){InitializeComponent();}private void button1_Click(object sender, EventArgs e){this、Close();}}}5) 新增图书窗口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 prjTSGL、ClassLib、DBAccess;namespace prjTSGL、TSGL_UI{public partial class frmAddNewBook : Form{public frmAddNewBook(){InitializeComponent();}private bool ValidatInput(){if (textBox1、Text == ""){MessageBox、Show("请输入图书编号!", "输入提示", MessageBoxButtons、OK, MessageBoxIcon、Information);textBox1、Focus();return false;}if (textBox2、Text == ""){MessageBox、Show("请输入图书名称!", "输入提示", MessageBoxButtons、OK, MessageBoxIcon、Information);textBox2、Focus();return false;}if (textBox3、Text == ""){MessageBox、Show("请输入图书数目!", "输入提示", MessageBoxButtons、OK,MessageBoxIcon、Information);textBox3、Focus();return false;}if (comboBox1、Text == ""){MessageBox、Show("请选择图书类别!", "输入提示", MessageBoxButtons、OK, MessageBoxIcon、Information);textBox3、Focus();return false;}return true;}private void btnOK_Click_1(object sender, EventArgs e){if (ValidatInput()){//string id = textBox1、Text;//string name = textBox2、Text;//string Number = textBox3、Text;//string sore = comboBox1、Text;string sql = "SELECT *FROM Bmanage WHERE bId='" + textBox1、Text、Trim() + " '";DataTable dt = clsGlobalVar、GetDataTable(sql);if (dt、Rows、Count == 0){string SQL = "insert into Bmanage(bId,bName,bNumber,bSore)values('" +textBox1、Text、Trim() + " ','" + textBox2、Text、Trim() + " ','" + textBox3、Text、Trim() + " ','"+ comboBox1、Text、Trim() + " ')";try{bool result = clsGlobalVar、ExecSQL(SQL);if (result){MessageBox、Show("添加成功!", "操作提示", MessageBoxButtons、OK, MessageBoxIcon、Information);textBox1、Text = "";textBox2、Text = "";textBox3、Text = "";comboBox1、Text = "";textBox1、Focus();}else{MessageBox、Show("添加失败!", "操作提示", MessageBoxButtons、OK, MessageBoxIcon、Error);}}catch (Exception ex){MessageBox、Show("操作数据库出错!", "操作演示", MessageBoxButtons、OK, MessageBoxIcon、Error);Console、WriteLine(ex、Message);}}else{MessageBox、Show("图书编号已存在!", "操作提示", MessageBoxButtons、OK, MessageBoxIcon、Information);textBox1、Focus();}}}private void btnCancel_Click(object sender, EventArgs e){this、Close();}}}6) 新增管理员、查找及修改窗口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 prjTSGL、ClassLib、DBAccess;namespace prjTSGL、TSGL_UI{public partial class frmSelectAdmin : Form{public frmSelectAdmin(){InitializeComponent();}string name = "";string SQL = "";string PWD = "";string Age = "";string Sex = "";string Tel = "";string Role = "";private void SelectAdmin(){string strfilter = "";string SQL = "select mName AS 用户名,mPwd AS 密码,mAge AS 年龄,mSex AS 性别,mNumber AS 电话,mRole AS 角色from Madmin ";if (txtName、Text == "")strfilter = "";elsestrfilter = "where mName='" + txtName、Text、Trim() + "'";try{DataTable dt = clsGlobalVar、GetDataTable(SQL + strfilter);int intIndex = 0;if (dt、Rows、Count == 0){MessageBox、Show("抱歉,没有您要找的用户!", "结果提示", MessageBoxButtons、OK, MessageBoxIcon、Information);txtName、Text = "";txtPWD、Text = "";txtAge、Text = "";cboSex、Text = "";txtTel、Text = "";cboRole、Text = "";}else{{LV、Columns、Clear();LV、Items、Clear();LV、Columns、Add("序号", 100, HorizontalAlignment、Center);for (int intJ = 0; intJ < dt、Columns、Count; intJ++){LV、Columns、Add(dt、Columns[intJ]、ColumnName, 200, HorizontalAlignment、Center);}for (int intI = 0; intI < dt、Rows、Count; intI++){intIndex = intI + 1;LV、Items、Add(intIndex、ToString());LV、Items[intI]、SubItems、Add(dt、Rows[intI]["用户名"]、ToString()、Trim());LV、Items[intI]、SubItems、Add(dt、Rows[intI]["密码"]、ToString()、Trim());LV、Items[intI]、SubItems、Add(dt、Rows[intI]["年龄"]、ToString()、Trim());LV、Items[intI]、SubItems、Add(dt、Rows[intI]["性别"]、ToString()、Trim());LV、Items[intI]、SubItems、Add(dt、Rows[intI]["电话"]、ToString()、Trim());LV、Items[intI]、SubItems、Add(dt、Rows[intI]["角色"]、ToString()、Trim());}}}}//连接数据库,将数据读取出放入MadminDatacatch (Exception ex){MessageBox、Show("查询数据库出错!", "提示", MessageBoxButtons、OK, MessageBoxIcon、Error);Console、WriteLine(ex、Message);}}private void btnSearch_Click(object sender, EventArgs e){SelectAdmin();//调用函数}//实现修改功能private void btnUpdata_Click(object sender, EventArgs e){if (txtName、Text == "" || cboRole、Text==""){MessageBox、Show("请选择要修改的用户!");}else{SQL = "UPDATE Madmin SET mName='" + txtName、Text、Trim() + "',mPwd='" + txtPWD、Text、Trim() + "',mAge='" + txtAge、Text、Trim() + "',mSex='" + cboSex、Text、Trim() +"',mNumber='" + txtTel、Text、Trim() + "',mRole='" + cboRole、Text、Trim() + "' where mName='" + name+ "'AND mPwd='" + PWD + "'AND mAge='" + Age + "'AND mSex='" + Sex + "'AND mNumber='" + Tel + "'AND mRole='" + Role + "'";try{bool result = clsGlobalVar、ExecSQL(SQL);if (result){//txtName、Text = "";txtPWD、Text = "";txtAge、Text = "";cboSex、Text = "";txtTel、Text = "";cboRole、Text = "";MessageBox、Show("修改已成功");SelectAdmin();}else{MessageBox、Show("更新失败!", "操作提示", MessageBoxButtons、OK, MessageBoxIcon、Error);}}catch (Exception ex){MessageBox、Show("操作数据库出错!", "操作演示", MessageBoxButtons、OK, MessageBoxIcon、Error);Console、WriteLine(ex、Message);}}}private void btnExit_Click(object sender, EventArgs e){this、Close();}private void LV_SelectedIndexChanged_1(object sender, EventArgs e){txtName、Text = LV、FocusedItem、SubItems[1]、Text、Trim();txtPWD、Text = LV、FocusedItem、SubItems[2]、Text、Trim();txtAge、Text = LV、FocusedItem、SubItems[3]、Text、Trim();cboSex、Text = LV、FocusedItem、SubItems[4]、Text、Trim();txtTel、Text = LV、FocusedItem、SubItems[5]、Text、Trim();cboRole、Text = LV、FocusedItem、SubItems[6]、Text、Trim();name = LV、FocusedItem、SubItems[1]、Text、Trim();PWD = LV、FocusedItem、SubItems[2]、Text、Trim();Age = LV、FocusedItem、SubItems[3]、Text、Trim();Sex = LV、FocusedItem、SubItems[4]、Text、Trim();Tel = LV、FocusedItem、SubItems[5]、Text、Trim();Role = LV、FocusedItem、SubItems[6]、Text、Trim();}private void frmSelectAdmin_Load(object sender, EventArgs e){this、btnSearch_Click(sender, e);}private void btnAdd_Click(object sender, EventArgs e){if (txtName、Text == "" || txtPWD、Text == "" || txtAge、Text == "" ||cboSex、Text == "" || txtTel、Text=="" ||cboRole、Text == ""){} MessageBox、Show("请至少输入用户名,密码与角色!");else{SQL = "SELECT mName,mPwd,mAge ,mSex,mNumber,mRole from Madmin WHERE mName='" + txtName、Text、Trim() + "' ";DataTable dt = clsGlobalVar、GetDataTable(SQL);if (dt、Rows、Count == 0){SQL = "INSERT INTO Madmin VALUES ('" + txtName、Text、Trim() + "','" +txtPWD、Text、Trim() + "','" + txtAge、Text、Trim() + "','" + cboSex、Text、Trim() + "','" +txtTel、Text、Trim() + "','" + cboRole、Text、Trim() + "')";if (clsGlobalVar、ExecSQL(SQL) == true){//txtName、Text = "";txtPWD、Text = "";txtAge、Text = "";cboSex、Text = "";txtTel、Text = "";cboRole、Text = "";MessageBox、Show("成功添加新管理员!");SelectAdmin();}else{Exception ex = new Exception();MessageBox、Show(ex、Message、ToString());}}else{MessageBox、Show("用户名已存在,请选择其她用户名!", "结果提示", MessageBoxButtons、OK, MessageBoxIcon、Information);txtName、Text = "";}}}private void btnDelete_Click(object sender, EventArgs e){if (txtName、Text == "" || cboRole、Text == ""){MessageBox、Show("请选择要删除的管理员用户!");}else{DialogResult dr = MessageBox、Show("此操作不可撤销,确定要删除此用户信息不?", "提示", MessageBoxButtons、YesNo, MessageBoxIcon、Question);if (dr == DialogResult、Yes){SQL = "DELETE FROM Madmin WHERE mName='" + name + "'AND mPwd='" + PWD + "'ANDmAge='" + Age + "'AND mSex='" + Sex + "'AND mNumber='" + Tel + "'AND mRole='" + Role + "'";if (clsGlobalVar、ExecSQL(SQL) == true){MessageBox、Show("成功删除此管理信息!");SelectAdmin();}else{Exception ex = new Exception();MessageBox、Show(ex、Message、ToString());}}}}private void btnReset_Click(object sender, EventArgs e){txtName、Text = "";txtPWD、Text = "";txtAge、Text = "";cboSex、Text = "";txtTel、Text = "";cboRole、Text = "";}}}7) 新增读者、查找及修改窗口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 prjTSGL、ClassLib、DBAccess;namespace prjTSGL、TSGL_UI{public partial class frmUpdateReader : Form{public frmUpdateReader(){InitializeComponent();}string Sno = "";string Pwd = "";string Age = "";string name = "";string Sex = "";string State = "";string Adress = "";string Number = "";string Email = "";string Grade = "";string Class = "";string Role = "";//查找学生读者private void SelectStudent(){string strfilter = "";string SQL = "select rSno AS 读者编号,rName AS 读者姓名,rPwd AS 密码,rAge AS 年龄,rSex AS 性别,rState AS 借书状态,rAdress AS 地址,rNumber AS 电话,rEmail AS 邮箱,rGrade AS 年级,rClass AS 班级,rRole AS 角色from Reader ";if (txtReaderName、Text == "")strfilter = "";elsestrfilter = "where rName='" + txtReaderName、Text、Trim() + "'";try{DataTable dt = clsGlobalVar、GetDataTable(SQL + strfilter);int intIndex = 0;if (dt、Rows、Count==0){MessageBox、Show("抱歉,没有您要找的读者信息!", "结果提示", MessageBoxButtons、OK, MessageBoxIcon、Information);}else{LV、Columns、Clear();LV、Items、Clear();LV、Columns、Add("序号", 100, HorizontalAlignment、Center);for (int intJ = 0; intJ < dt、Columns、Count; intJ++){LV、Columns、Add(dt、Columns[intJ]、ColumnName, 200, HorizontalAlignment、Center);}for (int intI = 0; intI < dt、Rows、Count; intI++){intIndex = intI + 1;LV、Items、Add(intIndex、ToString());for (int j=1; j < dt、Columns、Count; j++){LV、Items[intI]、SubItems、Add(dt、Rows[intI][j]、ToString());}//LV、Items[intI]、SubItems、Add(dt、Rows[intI]["读者编号"]、ToString());//LV、Items[intI]、SubItems、Add(dt、Rows[intI]["读者姓名"]、ToString());//LV、Items[intI]、SubItems、Add(dt、Rows[intI]["密码"]、ToString());//LV、Items[intI]、SubItems、Add(dt、Rows[intI]["年龄"]、ToString());//LV、Items[intI]、SubItems、Add(dt、Rows[intI]["性别"]、ToString());//LV、Items[intI]、SubItems、Add(dt、Rows[intI]["借书状态"]、ToString());//LV、Items[intI]、SubItems、Add(dt、Rows[intI]["地址"]、ToString());//LV、Items[intI]、SubItems、Add(dt、Rows[intI]["电话"]、ToString());//LV、Items[intI]、SubItems、Add(dt、Rows[intI]["邮箱"]、ToString());//LV、Items[intI]、SubItems、Add(dt、Rows[intI]["年级"]、ToString());//LV、Items[intI]、SubItems、Add(dt、Rows[intI]["班级"]、ToString());//LV、Items[intI]、SubItems、Add(dt、Rows[intI]["角色"]、ToString());}}}catch (Exception ex){MessageBox、Show("查询数据库出错!", "提示", MessageBoxButtons、OK, MessageBoxIcon、Error);Console、WriteLine(ex、Message);}}//实现查找功能private void btnSearch_Click(object sender, EventArgs e){SelectStudent();}//实现修改功能private void btnUpdata_Click(object sender, EventArgs e){if (textBox2、Text == ""){MessageBox、Show("请选择要修改的用户!");}else//string sql = "SELECT * from Reader WHERE rSno='" + textBox2、Text、Trim() + "' ";//DataTable dt = clsGlobalVar、GetDataTable(sql);//if (dt、Rows、Count == 0)//{{string SQL = "UPDATE Reader SET rSno='" + textBox2、Text、Trim() + "',rPwd='" + textBox3、Text、Trim() + "',rAge='" + textBox1、Text、Trim() + "',rName='" +txtReaderName、Text、Trim() + "',rSex='" + cboSex、Text、Trim() + "',rState='" + textBox4、Text、Trim() + "',rAdress='" + textBox5、Text、Trim() + "',rNumber='" + textBox6、Text、Trim() + "',rEmail='" + textBox7、Text、Trim() + "',rGrade='" + textBox8、Text、Trim() + "',rClass='" + textBox9、Text、Trim() + "' ,rRole='" + cboRole、Text、Trim() + "'";string strfilter = "where rSno='" + Sno + "'";try{bool result = clsGlobalVar、ExecSQL(SQL + strfilter);if (result){textBox2、Text = "";textBox3、Text = "";textBox1、Text = "";cboSex、Text = "";textBox4、Text = "";textBox5、Text = "";textBox6、Text = "";textBox7、Text = "";textBox8、Text = "";textBox9、Text = "";cboRole、Text = "";MessageBox、Show("修改已成功");SelectStudent();}else{MessageBox、Show("读者信息不存在!", "操作提示", MessageBoxButtons、OK, MessageBoxIcon、Error);}}catch (Exception ex){MessageBox、Show("操作数据库出错!", "操作演示", MessageBoxButtons、OK, MessageBoxIcon、Error);Console、WriteLine(ex、Message);}}//}//else//{// MessageBox、Show("用户名已存在,请选择其她用户名!", "结果提示", MessageBoxButtons、OK, MessageBoxIcon、Information);// textBox2、Text = "";//}}private void btnExit_Click(object sender, EventArgs e){} this、Close();private void LV_SelectedIndexChanged(object sender, EventArgs e) {textBox2、Text = LV、FocusedItem、SubItems[1]、Text、Trim();txtReaderName、Text = LV、FocusedItem、SubItems[2]、Text、Trim();textBox3、Text = LV、FocusedItem、SubItems[3]、Text、Trim();textBox1、Text = LV、FocusedItem、SubItems[4]、Text、Trim();cboSex、Text = LV、FocusedItem、SubItems[5]、Text、Trim();textBox4、Text = LV、FocusedItem、SubItems[6]、Text、Trim();textBox5、Text = LV、FocusedItem、SubItems[7]、Text、Trim();textBox6、Text = LV、FocusedItem、SubItems[8]、Text、Trim();textBox7、Text = LV、FocusedItem、SubItems[9]、Text、Trim();textBox8、Text = LV、FocusedItem、SubItems[10]、Text、Trim();textBox9、Text = LV、FocusedItem、SubItems[11]、Text、Trim();cboRole、Text = LV、FocusedItem、SubItems[12]、Text、Trim();Sno = LV、FocusedItem、SubItems[1]、Text、Trim();name = LV、FocusedItem、SubItems[2]、Text、Trim();Pwd = LV、FocusedItem、SubItems[3]、Text、Trim();Age = LV、FocusedItem、SubItems[4]、Text、Trim();Sex = LV、FocusedItem、SubItems[5]、Text、Trim();State = LV、FocusedItem、SubItems[6]、Text、Trim();Adress = LV、FocusedItem、SubItems[7]、Text、Trim();Number = LV、FocusedItem、SubItems[8]、Text、Trim();Email = LV、FocusedItem、SubItems[9]、Text、Trim();Grade = LV、FocusedItem、SubItems[10]、Text、Trim();Class= LV、FocusedItem、SubItems[11]、Text、Trim();Role = LV、FocusedItem、SubItems[12]、Text、Trim();}private void btnReset_Click(object sender, EventArgs e){textBox2、Text = "";textBox3、Text = "";txtReaderName、Text = "";textBox1、Text = "";cboSex、Text = "";textBox4、Text = "";textBox5、Text = "";textBox6、Text = "";textBox7、Text = "";textBox8、Text = "";textBox9、Text = "";cboRole、Text = "";}private void btnAdd_Click(object sender, EventArgs e){string SQL="";if (textBox2、Text == "" || textBox3、Text == "" || txtReaderName、Text == "" ||textBox4、Text == "" || textBox5、Text == ""){MessageBox、Show("请至少输入读者姓名,用户名,密码,借书状态与角色!");}else{string sql = "SELECT * from Reader WHERE rSno='" + textBox2、Text、Trim() + "' ";DataTable dt = clsGlobalVar、GetDataTable(sql);if (dt、Rows、Count == 0){if(cboRole、Text、Trim()=="教师")SQL = "INSERT INTO Reader(rSno,rPwd,rName,rAge,rSex,rState,rAdress,rNumber,rEmail,rGrade,rClass,rRole)VALUES ('" +textBox2、Text、Trim() + "','" + textBox3、Text、Trim() + "','" + txtReaderName、Text、Trim() + "','" + textBox1、Text、Trim() + "','" + cboSex、Text、Trim() + "','" + textBox4、Text、Trim() + "','" + textBox5、Text、Trim() + "','" + textBox6、Text、Trim() + "','" + textBox7、Text、Trim() + "','" + "NULL"+ "','" + "NULL" + "','" + cboRole、Text、Trim() + "')";elseSQL = "INSERT INTO Reader(rSno,rPwd,rName,rAge,rSex,rState,rAdress,rNumber,rEmail,rGrade,rClass,rRole)VALUES ('" +textBox2、Text、Trim() + "','" + textBox3、Text、Trim() + "','" + txtReaderName、Text、Trim() + "','" + textBox1、Text、Trim() + "','" + cboSex、Text、Trim() + "','" + textBox4、Text、Trim() + "','" + textBox5、Text、Trim() + "','" + textBox6、Text、Trim() + "','" + textBox7、Text、Trim() + "','" + textBox8、Text、Trim() + "','" + textBox9、Text、Trim() + "','" + cboRole、Text、Trim() + "')";if (clsGlobalVar、ExecSQL(SQL) == true){textBox2、Text = "";textBox3、Text = "";textBox1、Text = "";cboSex、Text = "";textBox4、Text = "";textBox5、Text = "";textBox6、Text = "";textBox7、Text = "";textBox8、Text = "";textBox9、Text = "";cboRole、Text = "";MessageBox、Show("成功添加此用户!");SelectStudent();}else{Exception ex = new Exception();MessageBox、Show(ex、Message、ToString());}}else{MessageBox、Show("用户名已存在,请选择其她用户名!", "结果提示", MessageBoxButtons、OK, MessageBoxIcon、Information);textBox2、Text = "";}}}private void btnDel_Click(object sender, EventArgs e){if (textBox2、Text == ""){MessageBox、Show("请选择要删除的用户!");}else{DialogResult dt= MessageBox、Show("此操作不可撤销,确定要删除此用户信息不?", " 提示", MessageBoxButtons、YesNo, MessageBoxIcon、Question);if (dt == DialogResult、Yes){string SQL = "DELETE FROM Reader where rSno='" + Sno + "'";if (clsGlobalVar、ExecSQL(SQL) == true){textBox2、Text = "";textBox3、Text = "";textBox1、Text = "";cboSex、Text = "";textBox4、Text = "";textBox5、Text = "";textBox6、Text = "";textBox7、Text = "";textBox8、Text = "";textBox9、Text = "";cboRole、Text = "";MessageBox、Show("删除此用户成功!");SelectStudent();}else{Exception ex = new Exception();MessageBox、Show(ex、Message、ToString());}}}}private void frmUpdateReader_Load(object sender, EventArgs e){SelectStudent();}}}8) 图书的查找及修改窗口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 prjTSGL、ClassLib、DBAccess;namespace prjTSGL、TSGL_UI{。

相关主题