一. 首页
代码如下;
using System;
using ric;
using onentModel;
using ;
using ing;
using ;
using s;
namespace WindowsApplication1
{
public partial class Form5 : Form {
public Form5()
{
InitializeComponent();
}
private void button1_Click(object sender, {
logo from = new logo();
(); EventArgs e)
}
private void button2_Click(object sender, EventArgs e) {
Form2 from = new Form2();
();
}
private void button3_Click(object sender, EventArgs e) 试卷 {
Form3 from = new Form3();
();
}
private void button4_Click(object sender, EventArgs e) {
Form4 from = new Form4();
();
}
}
}
二. 登录模块
代码如下:
using System;
using ric;
using onentModel;
using ;
using
lient;
using ing;
using ;
using s;
namespace WindowsApplication1
{
public partial class logo : Form
{
public logo()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e) {
string connstring = @"Data Source=panlunzhao;Initial Catalog=;Integrated Security=True";
SqlConnection conn = new SqlConnection(connstring); ();
string username = ring(); string password = ring(); SqlCommand comm = teCommand();
andText = "select * from manage where username='" + username + "' and password='" + password + "'";
SqlDataReader sqlda = uteReader();
if (())
{
if 工作报告 (sqlda["password"]ring()() == password) {
//("恭喜您登陆成功!", "登陆成功!", , rmation);
//Form2 f = new Form2();
//();
Form3 from = new Form3();
();
}
else { ("密码错误,请重新输入!", "错误
", , rmation); }
}
else { ("此用户不存在,请您注册!", "注册", , rmation); }
e(); 党团工作总结
e();
}
private void button2_Click(object sender, EventArgs e) {
= "";
= "";
}
}
}
三. 会员管理模块
代码如下:
using System;
using ric;
using onentModel;
using ;
using lient;
using ing;
using ;
using s;
namespace WindowsApplication1
{
public partial class Form2 :
Form
{
protected SqlConnection conn;
protected SqlCommand cmd;
string connstring = @"Data Sou 述职报告rce=panlunzhao;Initial Catalog=;Integrated Security=True";
public Form2()
{
InitializeComponent();
}
private void Form2_Load(object sender, EventArgs e)
{
load1();
load();
}
protected void load1()
{
string sql = "select *from customer";
conn = new SqlConnection(connstring);
();
SqlDataAdapter da = new SqlDataAdapter(sql, conn); DataSet ds = new DataSet();
(ds, "book");
Source = es["book"];
}
protected void load()
{
conn = new SqlConnection(connstring);
();
string sql_select = "SELECT ID FROM customer "; cmd = new SqlCommand(sql_select, conn);
SqlDataReader dr = uteReader();
r();
while (())
(dr[0]);
e();
}
private DataTable BindData(string sql)
{
string sql_select = sql;
conn = new SqlConnection(connstring);
SqlDataAdapter ad = new SqlDataAdapter(sql_select, conn); DataSet ds = new DataSet();
(ds, "customer");
return es["customer"];
}
private void button1_Click(object sender, EventArgs e) {
string sql = "select * from customer where ID='" + ring() + "'";
conn = new SqlConnection(connstring);
();
SqlCommand cmd = new SqlCommand(sql, conn);
SqlDataReader ds = uteReader();
();
= ds["name"]ring();
学校工作总结 = ds["Levels"]ring();
= ds["Birthday"]ring();
= ds["Degree"]ring();
= ds["Address"]ring();
= ds["Telephone"]ring();
= ds["Email"]ring();
= ds["Score"]ring();
ked = (bool)ds["Gender"];
}
private void update_Click(object sender, EventArgs e) {
string sql = "customer set
name=@name,Levels=@Levels,Birthday=@Birthday,Degree=@Degree,Address=@Address,Telephone=@Telephone,Email=@Email,Score=@Score where ID=@ID"; conn = new SqlConnection(connstring);
();
cmd = new SqlCommand(sql, conn);
("@ID", )e = ring();
("@name", Char, 20)e = ();
("@Levels", lInt)e = ();
("@Birthday",
lDateTime)e = ();
("@Degree", Char,
20)e = ();
("@Address", Char, 256)e = ();
("@Telephone", Char,
50)e = ();
("@Email", Char, 50)e = ();
(" 运动会演讲稿 @Gender", )e = (bool)ked;
("@Score", )e = ();
uteNonQuery();
SqlDataReader ds = uteReader();
();
load1();
}
private void _Click(object sender, EventArgs e) {
string sql_ = " into
customer(Name,Levels,Gender,Birthday,Degree,Address,Telephone,Email,Score)
values(@Name,@Levels,@Gender,@Birthday,@Degree,@Address,@Telephone,@Email,@Score)";
cmd = new SqlCommand(sql_, conn);
try
{
();
("@Name", Char,
20)e = ();
("@Levels",
lInt)e = uble(()); ("@Birthday",
lDateTime)e =
teTime(());
("@Degree", Char,
20)e = ();
("@Address", Char, 256)e = ();
("@Telephone", Char,
50)e = ();
("@Email", Char,
50)e = ();
("@Score", )e = uble(());
if (ked)
{
("@Gender",
)e = "true";
}
else
{
("@Gender",
) 月工作总结 e = "false";
}
int count = uteNonQuery();
if (count == 1)
{
if (("确认添加读者吗?", "提示", o, tion) == ) return;
("添加成功!!", "提示!"); }
else
{
("添加失败", "提示",
yCancel, rmation);
}
}
catch (Exception ex)
{
(age);
}
finally
{
e();
}
}
}
}
四.增加、删除、修改图书模块
代码如下:
using System;
using ric;
using onentModel;
using ;
using lient;
using ing;
using ;
using s;
namespace WindowsApplication1
{
public partial class Form3 : Form
{
protected SqlConnection conn;
protected SqlCom 事迹材料mand cmd;
string connstring = @"Data Source=panlunzhao;Initial Catalog=;Integrated Security=True";
public Form3()
{
InitializeComponent();
}
private void textBox7_TextChanged(object sender, EventArgs e) {
}
private void label6_Click(object sender, EventArgs e) {
}
private void select_Click(object sender, EventArgs e) {
string book_name = ();
string press = ring();
string Author = ();
StringBuilder sb1 = new StringBuilder();
nd("select * from book where ");
if (ked)
nd(at("Name LIKE '%{0}%'", book_name));
if (ked && ked) nd("AND ");
if (ked)
{
nd(at("Press = '{0}'", press)); }
if (ked && ked) nd("AND ");
if (ked)
{
nd(at("Author LIKE '%{0}%'", Author));
}
Source = Bin 班主任工作计划 dData(ring()); }
private void reset_Click(object sender, EventArgs e) {
ked = true;
ked = false;
ked = false;
= "";
= "";
= "";
}
private void button1_Click(object sender, EventArgs e) {
string sql = "select * from book where ISBN='" + ring() + "'";
conn = new SqlConnection(connstring);
();
SqlCommand cmd = new SqlCommand(sql, conn);
SqlDataReader ds = uteReader();
();
= ds["ISBN"]ring();
= ds["name"]ring();
= ds["author"]ring();
= ds["press"]ring();
= ds["publishdate"]ring( 试用期工作总结 );
= ds["price"]ring();
= ds["pages"]ring();
= ds["barcode"]ring();
ked = (bool)ds["cd"];
= ds["storage"]ring();
}
private void button2_Click(object sender, EventArgs e) {
string sql = " into
book(ISBN,name,author,press,publishdate,price,pages,barcode,cd,storage)
values(@ISBN,@name,@author,@press,@publishdate,@price,@pages,@barcode,@cd,@storage)";
conn = new SqlConnection(connstring);
();
cmd = new SqlCommand(sql, conn);
("@isbn", r, 10)e = ring();
("@name", Char, 256)e = ();
("@author", Char, 100)e = ();
("@press", Char, 50)e = ();
("@publishdate", Char,
50)e = ();
("@price", Char, 50)e = ();
("@pages", Char, 50)e
= ();
("@barcode", SqlDbType 党校学习心得体会 Char,
50)e = ();
("@cd", Char, 50)e = (bool)ked;
("@storage", Char,
50)e = ();
uteNonQuery();
load1();
load();
}
private void save_Click(object sender, EventArgs e)
{
string sql = "book set
name=@name,author=@author,press=@press,publishdate=@publishdate,price=@price,pages=@pages,barcode=@barcode,cd=@cd,Storage=@Storage where ISBN=@ISBN";
conn = new SqlConnection(connstring);
();
cmd = new SqlCommand(sql, conn);
("@isbn", r, 10)e = ring();
("@name", Char, 256)e = ();
("@author", Char, 100)e = ();
("@press", Char, 50)e = ();
("@publishdate", Char,
50)e = ();
("@price", Char, 50)e = ();
("@pages", Char, 50)e = ();
("@barcode", Char,
50)e = ();
("@cd", Char, 50)e = (bool)ked;
("@storage", Char,
50)e = ();
uteNonQuery();
SqlDataReader ds = uteReader();
();
load1();
}
private void quxiaosave_Click(object sender, EventArgs e) {
= "";
= "";
= "";
= "";
= "& 申报材料quot;;
= "";
= "";
= "";
ked = false;
= "";
}
private void _Click(object sender, EventArgs e) {
string sql = " from book where isbn=@isbn"; conn = new SqlConnection(connstring);
cmd = new SqlCommand(sql, conn);
();
("@isbn", r, 10)e = ring();
uteNonQuery();
load1();
load();
}
private void Form3_Load(object sender, EventArgs e) {
load();
load1();
}
protected void load()
{
conn = new SqlConnection(connstring);
();
string sql_select = "SELECT DISTINCT [PRESS] FROM [BOOK] ORDER BY [PRESS]";
cmd = new SqlCommand(sql_select, conn);
SqlDataReader dr = uteReader();
r();
while (())
(dr[0]);
e();
andText = "SELECT DISTINCT [Barcode] FROM [Book] ORDER BY [Barcode]";
SqlDataReader ds = uteReader();
r();
while (())
(ds[0]);
e();
andText = "SELECT DISTINCT [ISBN] FROM [Book] ORDER BY [ISBN]";
SqlDataReader st = uteReader();
r();
while (())
(st[0]);
e();
}
protected void load1()
{
string sql = "select *from book";
conn = new SqlConnection(connstring);
();
SqlDataAdapter da = 情况报告new SqlDataAdapter(sql, conn); DataSet ds = new DataSet();
(ds, "book");
Source = es["book"];
}
private DataTable BindData(string sql)
{
string sql_select = sql;
conn = new SqlConnection(connstring);
SqlDataAdapter ad = new SqlDataAdapter(sql_select, conn); DataSet ds = new DataSet();
(ds, "Book");
return es["Book"];
}
private void all_Click(object sender, EventArgs e)
{
string sql = "select *from book";
conn = new SqlConnection(connstring);
();
SqlDataAdapter da = new SqlDataAdapter(sql, conn);
DataSet ds = new DataSet();
(ds, "book");
Source = es["book"]; }
}
}
五.借书模块
代码如下:
using System;
using ric;
using onentModel;
using ;
using lient;
using ing;
using ;
using s;
namespace WindowsApplication1
{
public partial class Form4 : Form
{
protected SqlConnection conn;
protected SqlCommand cmd;
string connstring = @"Data Source=panlunzhao;Initial Catalog=tp:// 班级工作计划 F;Integrated Security=True";
public Form4()
{
InitializeComponent();
}
private void Form4_Load(object sender, EventArgs e)
{
try
{
conn = new SqlConnection(@"Data
Source=panlunzhao;Initial Catalog=;Integrated
Security=True");
();
Data();
}
catch (Exception exp)
{
("无法建立数据连接:" + age); e();
}
}
protected void InitData()
{
cmd = new SqlCommand("select distinct [ID] from Book order By [ID]", conn);
SqlDataReader reader1 = uteReader();
r();
while (())
(reader1[0]);
e();
cmd = new SqlCommand("select id from reader order by[ID]",conn);
SqlDataReader reader2 = uteReader();
r();
while (())
(reader2[0]);
e();
}
private void select_Click(object sender, EventArgs e) 诚信演讲稿 {
string sql = "select * from book where ID='" +
ring() + "'";
conn = new SqlConnection(connstring);
();
SqlCommand cmd = new SqlCommand(sql, conn);
SqlDataReader ds = uteReader();
();
= ds["ISBN"]ring();
= ds["name"]ring();
= ds["author"]ring();
= ds["press"]ring();
= ds["publishdate"]ring();
= ds["price"]ring();
= ds["pages"]ring();
= ds["barcode"]ring();
ked = (bool)ds["cd"];
= ds["storage"]ring();
}
private void jieshu_Click(object sender, EventArgs e) {
string sql = "select * from reader where ID='" + ring() + "'";
conn = new SqlConnection(connstring);
();
SqlDataAdapter da = new SqlDataAdapter(sql, conn); DataSet ds = new DataSet();
(ds, "book");
Source = es["book"];
string sql_up = "book set Storage=Storage-1 where ID='" + ring() + "'";
cmd = new SqlCommand(sql_up, conn);
uteNonQuery();
DataSet hs = new DataSet();
(hs, "book");
Source = es["book"];
if ( == "")
return;
andText = "SELECT * FROM [reader] WHERE [ID]=" + ;
SqlDataReader reader1 = null;
try
{
reader1 = uteReader();
if (())
{
textB 个人工作计划 = reader1["Name"]ring();
}
else
{
("没有符合条件的记录", "提示", , risk);
}
}
catch (Exception exp)
{
("数据访问错误:" + age +
kTrace, "错误", , r); }
finally
{
if (reader1 != null && !osed)
e();
}
}
}
}
总结
此次实训综合考查了所学的c#知识,让我知道一个项目从构思、设计、实结题报告现、测试的过程。在实训中也综合运用了所学的`知识,也涵盖了数据库的知识,用数据库存放数据,用脚本实现功能。