📄 shanchutushuxinxi.cs
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace tsh
{
public partial class shanchutushuxinxi : Form
{
public shanchutushuxinxi()
{
InitializeComponent();
}
DB.ClsSQL sql = new DB.ClsSQL(".", "mylw", "sa", "", 3);
DataSet ds, ds1;
private void butttch_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void textBbh_KeyPress(object sender, KeyPressEventArgs e)
{
if(e.KeyChar==13)
{
string s="select * from book where tushubianhao='"+textBbh.Text+"'";
ds=sql.DBToDS(s,"book");
int n=ds.Tables["book"].Rows.Count;
if(n==0)
{
buttqx_Click(null,null);
MessageBox.Show("无此图书编号!!","信息提示");
}
else
{
string s1="select * from borrow where tushubianhao='"+textBbh.Text+"'";
ds1=sql.DBToDS(s1,"borrow");
int i=ds1.Tables["borrow"].Rows.Count;
if(i!=0)
{
MessageBox.Show("已有读者借了这本书,不允许删除该记录!!","提示");
textBbh.Text="";
textBbh.Focus();
buttshch.Enabled=false;
buttqx.Enabled=false;
}
else
{
textBflh.Text=ds.Tables["book"].Rows[0]["fenleihao"].ToString();
textBjg.Text=ds.Tables["book"].Rows[0]["jiage"].ToString();
textBkb.Text=ds.Tables["book"].Rows[0]["kaiben"].ToString();
textBlb.Text=ds.Tables["book"].Rows[0]["leibie"].ToString();
textBzsh.Text=ds.Tables["book"].Rows[0]["zishu"].ToString();
textBzzh.Text=ds.Tables["book"].Rows[0]["zuozhe"].ToString();
textBshm.Text=ds.Tables["book"].Rows[0]["shuming"].ToString();
textBkcsh.Text=ds.Tables["book"].Rows[0]["kucunshu"].ToString();
textBchbsh.Text=ds.Tables["book"].Rows[0]["chubanshe"].ToString();
textBbc.Text=ds.Tables["book"].Rows[0]["banci"].ToString();
textBgrsh.Text=ds.Tables["book"].Rows[0]["zaikushu"].ToString();
buttshch.Enabled=true;
buttqx.Enabled=true;
buttshch.Focus();
}
}
}
}
private void buttqx_Click(object sender, EventArgs e)
{
textBbh.Text = "";
textBbh.Focus();
textBflh.Text="";
textBjg.Text="";
textBkb.Text="";
textBlb.Text="";
textBzsh.Text="";
textBzzh.Text="";
textBshm.Text="";
textBkcsh.Text="";
textBchbsh.Text="";
textBbc.Text="";
textBgrsh.Text = "";
buttshch.Enabled = false;
buttqx.Enabled = false;
}
private void buttshch_Click(object sender, EventArgs e)
{
string shm=ds.Tables["book"].Rows[0]["shuming"].ToString();
DialogResult result=MessageBox.Show("真的要删除“"+shm+"”这本书吗??","询问",MessageBoxButtons.YesNo,MessageBoxIcon.Question);
if (result == DialogResult.Yes)
{
string bh = ds.Tables["book"].Rows[0]["tushubianhao"].ToString();
string s2 = "delete from book where tushubianhao='" + bh + "'";
sql.SQLCommand(s2);
MessageBox.Show("已成功删除一条图书信息!!!", "提示");
buttqx_Click(null, null);
}
else
{
buttqx_Click(null, null);
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -