【数据库】【keshe】图书馆借阅系统 系统+报告全家桶
代码:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using WpfApp1;
namespace 数据库课设
{
public partial class Form1 : Form
{
String bookid = null;
String userid = null;
String iden; //学生或者管理员
SQL sql = new SQL();
DataTable dt = new DataTable();//存返回结果
String s;//sql语句
public Form1()
{
InitializeComponent();
/*
foreach (DataRow myRow in myTable.Rows)
{
foreach (DataColumn myColumn in myTable.Columns)
{
//end+=(myRow[myColumn]); //遍历表中的每个单元格
}
}*/
}
private void bt_login_Click(object sender, EventArgs e) //登录按钮
{
String id = uname.Text; //对应数据库id
String psw = upass.Text; //password
if (radioButton1.Checked)
iden = "学生";
else
iden = "管理员";
dt=sql.ExecRt("exec login '"+id+"','"+psw+"','"+iden+"'");
if (dt.Rows.Count == 0)
{
notexist.Show();//标签提示失败
}
else
{
p_login.Hide();//登录成功,登录界面隐藏
userid = id;
p_loginsuccess.Show();
//初始化界面
t7.Text = "";
t8.Text = "";
t9.Text = "";
t10.Text = "";
t11.Text = "";
textBox6.Text = "";
if (iden == "学生")
{
dt = sql.ExecRt("select name from Students where id='" + userid + "'");
p_addbook.Hide();
button2.Hide();
button4.Hide();
label21.Show();
textBox6.Show();
button5.Show();
button6.Text = "个人中心";
}
else
{
p_addbook.Show();
button2.Show();
button4.Show();
label21.Hide();
textBox6.Hide();
button5.Hide();
button6.Text = "借书情况";
dt = sql.ExecRt("select name from Administrators where id='" + userid + "'");
}
label6.Text = "Welcome:" + userid + ", " + dt.Rows[0][0].ToString();
//初始化图书列表
dt = sql.ExecRt("select * from books");
dgv1.DataSource = dt.DefaultView;
dgv1.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
}
}
文档:
点击查看系统源代码