You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
LibraryManagementSystem/tianjiatushu.cs

95 lines
2.9 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

//熊宇杰 20200933
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace tushuguanli
{
public partial class tianjiatushu : Form
{
public tianjiatushu()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
//创建数据库连接
private void button1_Click(object sender, EventArgs e)
{ //连接数据库
string str = @"Data Source=LAPTOP-HKE14BIG;Initial catalog=BookDB;integrated Security=True";
SqlConnection conn = new SqlConnection(str);
conn.Open();
//分别插入书号、书名、书作者、出版社、数量
string selectsql = "insert into t_book values('" + textBox_Bid.Text + "','" + textBox_Bname.Text + "','" + textBox_Bauthor.Text + "','" + textBox_Bpress.Text +"','" + textBox_Bnu.Text + "')";
SqlCommand cmd = new SqlCommand(selectsql, conn);
cmd.CommandType = CommandType.Text;
SqlDataReader sdr;
sdr = cmd.ExecuteReader();
conn.Close();
MessageBox.Show("添加成功!", "添加图书", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
//////////////////////////////////
///
//添加书号
private void label_Bid_Click(object sender, EventArgs e)
{
//书号标签label_Bid
}
private void textBox_Bid_TextChanged(object sender, EventArgs e)
{
//文本按钮命名textBox_Bid
}
//添加书名
private void label_Bname_Click(object sender, EventArgs e)
{
//书名标签label_Bname
}
private void textBox_Bname_TextChanged(object sender, EventArgs e)
{
//文本按钮命名textBox_Bname
}
//添加作者
private void label_Bauthor_Click(object sender, EventArgs e)
{
//书号标签label_Bauthor
}
private void textBox_Bauthor_TextChanged(object sender, EventArgs e)
{
//文本按钮命名textBox_Bautho
}
//添加出版社
private void label_Bpress_Click(object sender, EventArgs e)
{
//书号标签label_Bpress
}
private void textBox_Bpress_TextChanged(object sender, EventArgs e)
{
//文本按钮命名textBox_Bpress
}
//添加数量
private void label_Bnu_Click(object sender, EventArgs e)
{
//数量标签label_Bnu
}
private void textBox_Bnu_TextChanged(object sender, EventArgs e)
{
//文本按钮命名textBox_Bnu
}
}
}