private void button1_Click(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection("Data Source=LAPTOP-C0MIMKL4\\SQLEXPRESSS;Initial Catalog=借阅系统;Integrated Security=True");
conn.Open();
string sql = "update book set benshu=benshu+'" + textBox3.Text + "' where bnum = '" + textBox1.Text.Trim() + "'";
string jtime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
string sql1 = "insert into borrow values('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "','" + "归还" + "','" + jtime + "')";
string sqllr = sql + sql1;
SqlCommand cmd = new SqlCommand(sqllr, conn);
int count = cmd.ExecuteNonQuery();
conn.Close();
if (count > 0)
{
DateTime t1 = DateTime.Parse(jtime);
string str1 = "select time from borrow where bnum ='" + textBox1.Text.Trim()+"'";
DateTime t2 = Convert.ToDateTime(str1);
TimeSpan t3 = t1 - t2;
double getDay = t3.TotalDays;
double a = getDay - 30;
if (a > 0)
{
MessageBox.Show("归还成功!您已超期");
MessageBox.Show("您已超期" + a + "天\n罚金为" + a + "* 1元");
}
else
MessageBox.Show("归还成功");
}
textBox4.Text = jtime;
}