- 相關(guān)推薦
上機(jī)實(shí)習(xí)報(bào)告總結(jié)結(jié)尾
一. 首頁
代碼如下;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication1
{
public partial class Form5 : Form {
public Form5()
{
InitializeComponent();
}
private void button1_Click(object sender, {
logo from = new logo();
from.Show(); EventArgs e)
}
private void button2_Click(object sender, EventArgs e) {
Form2 from = new Form2();
from.Show();
}
private void button3_Click(object sender, EventArgs e)http://www.xielw.cn/shijuan/ 試卷 {
Form3 from = new Form3();
from.Show();
}
private void button4_Click(object sender, EventArgs e) {
Form4 from = new Form4();
from.Show();
}
}
}
二. 登錄模塊
代碼如下:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using
System.Data.SqlClient;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
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=BOOKSTORE.MDF;Integrated Security=True";
SqlConnection conn = new SqlConnection(connstring); conn.Open();
string username = this.username.Text.ToString(); string password = this.password.Text.ToString(); SqlCommand comm = conn.CreateCommand();
comm.CommandText = "select * from manage where username='" + username + "' and password='" + password + "'";
SqlDataReader sqlda = comm.ExecuteReader();
if (sqlda.Read())
{
ifhttp://www.xielw.cn/gongzuobaogao/ 工作報(bào)告 (sqlda["password"].ToString().Trim() == password) {
//MessageBox.Show("恭喜您登陸成功!", "登陸成功!", MessageBoxButtons.OK, MessageBoxIcon.Information);
//Form2 f = new Form2();
//f.Show();
Form3 from = new Form3();
from.Show();
}
else { MessageBox.Show("密碼錯誤,請重新輸入!", "錯誤
", MessageBoxButtons.OK, MessageBoxIcon.Information); }
}
else { MessageBox.Show("此用戶不存在,請您注冊!", "注冊", MessageBoxButtons.OK, MessageBoxIcon.Information); }
conn.Close();http://www.xielw.cn/dangtuangongzuozongjie/ 黨團(tuán)工作總結(jié)
sqlda.Close();
}
private void button2_Click(object sender, EventArgs e) {
username.Text = "";
password.Text = "";
}
}
}
三. 會員管理模塊
代碼如下:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication1
{
public partial class Form2 :
Form
{
protected SqlConnection conn;
protected SqlCommand cmd;
string connstring = @"Data Souhttp://ahxkjx.com/article/ 述職報(bào)告rce=panlunzhao;Initial Catalog=BOOKSTORE.MDF;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);
conn.Open();
SqlDataAdapter da = new SqlDataAdapter(sql, conn); DataSet ds = new DataSet();
da.Fill(ds, "book");
dataGridView1.DataSource = ds.Tables["book"];
}
protected void load()
{
conn = new SqlConnection(connstring);
conn.Open();
string sql_select = "SELECT ID FROM customer "; cmd = new SqlCommand(sql_select, conn);
SqlDataReader dr = cmd.ExecuteReader();
id.Items.Clear();
while (dr.Read())
id.Items.Add(dr[0]);
dr.Close();
}
private DataTable BindData(string sql)
{
string sql_select = sql;
conn = new SqlConnection(connstring);
SqlDataAdapter ad = new SqlDataAdapter(sql_select, conn); DataSet ds = new DataSet();
ad.Fill(ds, "customer");
return ds.Tables["customer"];
}
private void button1_Click(object sender, EventArgs e) {
string sql = "select * from customer where ID='" + id.Text.ToString() + "'";
conn = new SqlConnection(connstring);
conn.Open();
SqlCommand cmd = new SqlCommand(sql, conn);
SqlDataReader ds = cmd.ExecuteReader();
ds.Read();
textBox1.Text = ds["name"].ToString();
textBox2.Text http://www.xielw.cn/xuexiaogongzuozongjie/ 學(xué)校工作總結(jié) = ds["Levels"].ToString();
textBox3.Text = ds["Birthday"].ToString();
textBox4.Text = ds["Degree"].ToString();
textBox5.Text = ds["Address"].ToString();
textBox6.Text = ds["Telephone"].ToString();
textBox7.Text = ds["Email"].ToString();
textBox8.Text = ds["Score"].ToString();
radioButton1.Checked = (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);
conn.Open();
cmd = new SqlCommand(sql, conn);
cmd.Parameters.Add("@ID", SqlDbType.Int).Value = id.Text.ToString();
cmd.Parameters.Add("@name", SqlDbType.NVarChar, 20).Value = textBox1.Text.Trim();
cmd.Parameters.Add("@Levels", SqlDbType.SmallInt).Value = textBox2.Text.Trim();
cmd.Parameters.Add("@Birthday",
SqlDbType.SmallDateTime).Value = textBox3.Text.Trim();
cmd.Parameters.Add("@Degree", SqlDbType.NVarChar,
20).Value = textBox4.Text.Trim();
cmd.Parameters.Add("@Address", SqlDbType.NVarChar, 256).Value = textBox5.Text.Trim();
cmd.Parameters.Add("@Telephone", SqlDbType.NVarChar,
50).Value = textBox6.Text.Trim();
cmd.Parameters.Add("@Email", SqlDbType.NVarChar, 50).Value = textBox7.Text.Trim();
cmd.Parameters.Add("http://www.xielw.cn/yundonghuiyanjianggao/ 運(yùn)動會演講稿 @Gender", SqlDbType.Bit).Value = (bool)radioButton1.Checked;
cmd.Parameters.Add("@Score", SqlDbType.Int).Value = textBox8.Text.Trim();
cmd.ExecuteNonQuery();
SqlDataReader ds = cmd.ExecuteReader();
ds.Read();
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
{
conn.Open();
cmd.Parameters.Add("@Name", SqlDbType.NVarChar,
20).Value = textBox1.Text.Trim();
cmd.Parameters.Add("@Levels",
SqlDbType.SmallInt).Value = Convert.ToDouble(textBox2.Text.Trim()); cmd.Parameters.Add("@Birthday",
SqlDbType.SmallDateTime).Value =
Convert.ToDateTime(textBox3.Text.Trim());
cmd.Parameters.Add("@Degree", SqlDbType.NVarChar,
20).Value = textBox4.Text.Trim();
cmd.Parameters.Add("@Address", SqlDbType.NVarChar, 256).Value = textBox5.Text.Trim();
cmd.Parameters.Add("@Telephone", SqlDbType.NVarChar,
50).Value = textBox6.Text.Trim();
cmd.Parameters.Add("@Email", SqlDbType.NVarChar,
50).Value = textBox7.Text.Trim();
cmd.Parameters.Add("@Score", SqlDbType.Int).Value = Convert.ToDouble(textBox8.Text.Trim());
if (radioButton1.Checked)
{
cmd.Parameters.Add("@Gender",
SqlDbType.Bit).Value = "true";
}
else
{
cmd.Parameters.Add("@Gender",
SqlDbType.Bit).Valuhttp://www.xielw.cn/yuegongzuozongjie/ 月工作總結(jié) e = "false";
}
int count = cmd.ExecuteNonQuery();
if (count == 1)
{
if (MessageBox.Show("確認(rèn)添加讀者嗎?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) return;
MessageBox.Show("添加成功!!", "提示!"); }
else
{
MessageBox.Show("添加失敗", "提示",
MessageBoxButtons.RetryCancel, MessageBoxIcon.Information);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
conn.Close();
}
}
}
}
四.增加、刪除、修改圖書模塊
代碼如下:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication1
{
public partial class Form3 : Form
{
protected SqlConnection conn;
protected SqlComhttp://www.xielw.cn/shijicailiao/ 事跡材料mand cmd;
string connstring = @"Data Source=panlunzhao;Initial Catalog=BOOKSTORE.MDF;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 = shuming.Text.Trim();
string press = chubanshe.Text.ToString();
string Author = duzhe.Text.Trim();
StringBuilder sb1 = new StringBuilder();
sb1.Append("select * from book where ");
if (checkBox1.Checked)
sb1.Append(string.Format("Name LIKE '%{0}%'", book_name));
if (checkBox1.Checked && checkBox2.Checked) sb1.Append("AND ");
if (checkBox2.Checked)
{
sb1.Append(string.Format("Press = '{0}'", press)); }
if (checkBox3.Checked && checkBox2.Checked) sb1.Append("AND ");
if (checkBox3.Checked)
{
sb1.Append(string.Format("Author LIKE '%{0}%'", Author));
}
dataGridView1.DataSource = Binhttp://www.xielw.cn/banzhurengongzuojihua/ 班主任工作計(jì)劃 dData(sb1.ToString()); }
private void reset_Click(object sender, EventArgs e) {
checkBox1.Checked = true;
checkBox2.Checked = false;
checkBox3.Checked = false;
shuming.Text = "";
chubanshe.Text = "";
duzhe.Text = "";
}
private void button1_Click(object sender, EventArgs e) {
string sql = "select * from book where ISBN='" + comboBox1.Text.ToString() + "'";
conn = new SqlConnection(connstring);
conn.Open();
SqlCommand cmd = new SqlCommand(sql, conn);
SqlDataReader ds = cmd.ExecuteReader();
ds.Read();
textBox1.Text = ds["ISBN"].ToString();
textBox2.Text = ds["name"].ToString();
textBox3.Text = ds["author"].ToString();
textBox4.Text = ds["press"].ToString();
textBox5.Text = ds["publishdate"].ToString(http://www.xielw.cn/shiyongqigongzuozongjie/ 試用期工作總結(jié) );
textBox6.Text = ds["price"].ToString();
textBox7.Text = ds["pages"].ToString();
textBox8.Text = ds["barcode"].ToString();
radioButton1.Checked = (bool)ds["cd"];
textBox10.Text = ds["storage"].ToString();
}
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);
conn.Open();
cmd = new SqlCommand(sql, conn);
cmd.Parameters.Add("@isbn", SqlDbType.NChar, 10).Value = textBox1.Text.ToString();
cmd.Parameters.Add("@name", SqlDbType.NVarChar, 256).Value = textBox2.Text.Trim();
cmd.Parameters.Add("@author", SqlDbType.NVarChar, 100).Value = textBox3.Text.Trim();
cmd.Parameters.Add("@press", SqlDbType.NVarChar, 50).Value = textBox4.Text.Trim();
cmd.Parameters.Add("@publishdate", SqlDbType.NVarChar,
50).Value = textBox5.Text.Trim();
cmd.Parameters.Add("@price", SqlDbType.NVarChar, 50).Value = textBox6.Text.Trim();
cmd.Parameters.Add("@pages", SqlDbType.NVarChar, 50).Value
= textBox7.Text.Trim();
cmd.Parameters.Add("@barcode", SqlDbTypehttp://www.xielw.cn/dangxiaoxuexixindetihui/ 黨校學(xué)習(xí)心得體會 .NVarChar,
50).Value = textBox8.Text.Trim();
cmd.Parameters.Add("@cd", SqlDbType.NVarChar, 50).Value = (bool)radioButton1.Checked;
cmd.Parameters.Add("@storage", SqlDbType.NVarChar,
50).Value = textBox10.Text.Trim();
cmd.ExecuteNonQuery();
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);
conn.Open();
cmd = new SqlCommand(sql, conn);
cmd.Parameters.Add("@isbn", SqlDbType.NChar, 10).Value = comboBox1.Text.ToString();
cmd.Parameters.Add("@name", SqlDbType.NVarChar, 256).Value = textBox2.Text.Trim();
cmd.Parameters.Add("@author", SqlDbType.NVarChar, 100).Value = textBox3.Text.Trim();
cmd.Parameters.Add("@press", SqlDbType.NVarChar, 50).Value = textBox4.Text.Trim();
cmd.Parameters.Add("@publishdate", SqlDbType.NVarChar,
50).Value = textBox5.Text.Trim();
cmd.Parameters.Add("@price", SqlDbType.NVarChar, 50).Value = textBox6.Text.Trim();
cmd.Parameters.Add("@pages", SqlDbType.NVarChar, 50).Value = textBox7.Text.Trim();
cmd.Parameters.Add("@barcode", SqlDbType.NVarChar,
50).Value = textBox8.Text.Trim();
cmd.Parameters.Add("@cd", SqlDbType.NVarChar, 50).Value = (bool)radioButton1.Checked;
cmd.Parameters.Add("@storage", SqlDbType.NVarChar,
50).Value = textBox10.Text.Trim();
cmd.ExecuteNonQuery();
SqlDataReader ds = cmd.ExecuteReader();
ds.Read();
load1();
}
private void quxiaosave_Click(object sender, EventArgs e) {
textBox1.Text = "";
textBox2.Text = "";
textBox3.Text = "";
textBox4.Text = "";
textBox5.Text = "&http://www.xielw.cn/shenbaocailiao/ 申報(bào)材料quot;;
textBox6.Text = "";
textBox7.Text = "";
textBox8.Text = "";
radioButton1.Checked = false;
textBox10.Text = "";
}
private void _Click(object sender, EventArgs e) {
string sql = " from book where isbn=@isbn"; conn = new SqlConnection(connstring);
cmd = new SqlCommand(sql, conn);
conn.Open();
cmd.Parameters.Add("@isbn", SqlDbType.NChar, 10).Value = comboBox1.Text.ToString();
cmd.ExecuteNonQuery();
load1();
load();
}
private void Form3_Load(object sender, EventArgs e) {
load();
load1();
}
protected void load()
{
conn = new SqlConnection(connstring);
conn.Open();
string sql_select = "SELECT DISTINCT [PRESS] FROM [BOOK] ORDER BY [PRESS]";
cmd = new SqlCommand(sql_select, conn);
SqlDataReader dr = cmd.ExecuteReader();
chubanshe.Items.Clear();
while (dr.Read())
chubanshe.Items.Add(dr[0]);
dr.Close();
cmd.CommandText = "SELECT DISTINCT [Barcode] FROM [Book] ORDER BY [Barcode]";
SqlDataReader ds = cmd.ExecuteReader();
tushutiaoma.Items.Clear();
while (ds.Read())
tushutiaoma.Items.Add(ds[0]);
ds.Close();
cmd.CommandText = "SELECT DISTINCT [ISBN] FROM [Book] ORDER BY [ISBN]";
SqlDataReader st = cmd.ExecuteReader();
comboBox1.Items.Clear();
while (st.Read())
comboBox1.Items.Add(st[0]);
st.Close();
}
protected void load1()
{
string sql = "select *from book";
conn = new SqlConnection(connstring);
conn.Open();
SqlDataAdapter da = http://www.xielw.cn/qingkuangbaogao/ 情況報(bào)告new SqlDataAdapter(sql, conn); DataSet ds = new DataSet();
da.Fill(ds, "book");
dataGridView1.DataSource = ds.Tables["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();
ad.Fill(ds, "Book");
return ds.Tables["Book"];
}
private void all_Click(object sender, EventArgs e)
{
string sql = "select *from book";
conn = new SqlConnection(connstring);
conn.Open();
SqlDataAdapter da = new SqlDataAdapter(sql, conn);
DataSet ds = new DataSet();
da.Fill(ds, "book");
dataGridView1.DataSource = ds.Tables["book"]; }
}
}
五.借書模塊
代碼如下:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication1
{
public partial class Form4 : Form
{
protected SqlConnection conn;
protected SqlCommand cmd;
string connstring = @"Data Source=panlunzhao;Initial Catalog=BOOKSTORE.MDhttp://www.xielw.cn/banjigongzuojihua/ 班級工作計(jì)劃 F;Integrated Security=True";
public Form4()
{
InitializeComponent();
}
private void Form4_Load(object sender, EventArgs e)
{
try
{
conn = new SqlConnection(@"Data
Source=panlunzhao;Initial Catalog=BOOKSTORE.MDF;Integrated
Security=True");
conn.Open();
this.InitData();
}
catch (Exception exp)
{
MessageBox.Show("無法建立數(shù)據(jù)連接:" + exp.Message); this.Close();
}
}
protected void InitData()
{
cmd = new SqlCommand("select distinct [ID] from Book order By [ID]", conn);
SqlDataReader reader1 = cmd.ExecuteReader();
comboBox1.Items.Clear();
while (reader1.Read())
comboBox1.Items.Add(reader1[0]);
reader1.Close();
cmd = new SqlCommand("select id from reader order by[ID]",conn);
SqlDataReader reader2 = cmd.ExecuteReader();
id.Items.Clear();
while (reader2.Read())
id.Items.Add(reader2[0]);
reader2.Close();
}
private void select_Click(object sender, EventArgs e) http://www.xielw.cn/chengxinyanjianggao/ 誠信演講稿 {
string sql = "select * from book where ID='" +
comboBox1.Text.ToString() + "'";
conn = new SqlConnection(connstring);
conn.Open();
SqlCommand cmd = new SqlCommand(sql, conn);
SqlDataReader ds = cmd.ExecuteReader();
ds.Read();
textBox1.Text = ds["ISBN"].ToString();
textBox2.Text = ds["name"].ToString();
textBox3.Text = ds["author"].ToString();
textBox4.Text = ds["press"].ToString();
textBox5.Text = ds["publishdate"].ToString();
textBox6.Text = ds["price"].ToString();
textBox7.Text = ds["pages"].ToString();
textBox8.Text = ds["barcode"].ToString();
radioButton1.Checked = (bool)ds["cd"];
textBox10.Text = ds["storage"].ToString();
}
private void jieshu_Click(object sender, EventArgs e) {
string sql = "select * from reader where ID='" + id.Text.ToString() + "'";
conn = new SqlConnection(connstring);
conn.Open();
SqlDataAdapter da = new SqlDataAdapter(sql, conn); DataSet ds = new DataSet();
da.Fill(ds, "book");
dataGridView1.DataSource = ds.Tables["book"];
string sql_up = "book set Storage=Storage-1 where ID='" + comboBox1.Text.ToString() + "'";
cmd = new SqlCommand(sql_up, conn);
cmd.ExecuteNonQuery();
DataSet hs = new DataSet();
da.Fill(hs, "book");
dataGridView1.DataSource = hs.Tables["book"];
if (comboBox1.Text == "")
return;
cmd.CommandText = "SELECT * FROM [reader] WHERE [ID]=" + id.Text;
SqlDataReader reader1 = null;
try
{
reader1 = cmd.ExecuteReader();
if (reader1.Read())
{
textBhttp://www.xielw.cn/gerengongzuojihua/ 個人工作計(jì)劃 ox17.Text = reader1["Name"].ToString();
}
else
{
MessageBox.Show("沒有符合條件的記錄", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
}
}
catch (Exception exp)
{
MessageBox.Show("數(shù)據(jù)訪問錯誤:" + exp.Message +
exp.StackTrace, "錯誤", MessageBoxButtons.OK, MessageBoxIcon.Error); }
finally
{
if (reader1 != null && !reader1.IsClosed)
reader1.Close();
}
}
}
}
總結(jié)
此次實(shí)訓(xùn)綜合考查了所學(xué)的c#知識,讓我知道一個項(xiàng)目從構(gòu)思、設(shè)計(jì)、實(shí)結(jié)題報(bào)告現(xiàn)、測試的過程。在實(shí)訓(xùn)中也綜合運(yùn)用了所學(xué)的知識,也涵蓋了數(shù)據(jù)庫的知識,用數(shù)據(jù)庫存放數(shù)據(jù),用腳本實(shí)現(xiàn)功能。
【上機(jī)實(shí)習(xí)報(bào)告總結(jié)結(jié)尾】相關(guān)文章:
計(jì)算機(jī)上機(jī)實(shí)習(xí)報(bào)告09-13
實(shí)習(xí)報(bào)告結(jié)尾01-24
優(yōu)秀實(shí)習(xí)報(bào)告結(jié)尾02-21
國際貿(mào)易實(shí)物機(jī)房上機(jī)模擬實(shí)習(xí)總結(jié)02-27
實(shí)習(xí)報(bào)告結(jié)尾怎么寫?07-10
國際貿(mào)易實(shí)物機(jī)房上機(jī)模擬實(shí)習(xí)總結(jié)3篇02-27
述職報(bào)告結(jié)尾06-01
工作報(bào)告結(jié)尾07-04
述職報(bào)告精彩結(jié)尾01-11
述職報(bào)告寫作結(jié)尾09-30