📄 deletef.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.OleDb;
using System.Data.Common;
namespace bookstore
{
/// <summary>
/// DeleteF 的摘要说明。
/// </summary>
public class DeleteF : System.Windows.Forms.Form
{
private System.Windows.Forms.TabControl tabControl1;
private System.Windows.Forms.TabPage tabPage1;
private System.Windows.Forms.TabPage tabPage2;
private System.Windows.Forms.TabPage tabPage3;
private System.Windows.Forms.TabPage tabPage4;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.Button button3;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Button button4;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.TextBox textBox3;
private System.Windows.Forms.TextBox textBox4;
private System.Windows.Forms.Button button5;
private System.Windows.Forms.Button button6;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.TextBox textBox5;
private System.Windows.Forms.Button button7;
private System.Windows.Forms.Button button8;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
util1 util=new util1();
SqlBean sq=new SqlBean();
public DeleteF()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
textBox1.Clear();
textBox2.Clear();
textBox3.Clear();
textBox4.Clear();
textBox5.Clear();
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.tabControl1 = new System.Windows.Forms.TabControl();
this.tabPage1 = new System.Windows.Forms.TabPage();
this.button2 = new System.Windows.Forms.Button();
this.button1 = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.textBox1 = new System.Windows.Forms.TextBox();
this.tabPage2 = new System.Windows.Forms.TabPage();
this.button4 = new System.Windows.Forms.Button();
this.label2 = new System.Windows.Forms.Label();
this.button3 = new System.Windows.Forms.Button();
this.textBox2 = new System.Windows.Forms.TextBox();
this.tabPage3 = new System.Windows.Forms.TabPage();
this.button6 = new System.Windows.Forms.Button();
this.button5 = new System.Windows.Forms.Button();
this.textBox4 = new System.Windows.Forms.TextBox();
this.textBox3 = new System.Windows.Forms.TextBox();
this.label4 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.tabPage4 = new System.Windows.Forms.TabPage();
this.button8 = new System.Windows.Forms.Button();
this.button7 = new System.Windows.Forms.Button();
this.textBox5 = new System.Windows.Forms.TextBox();
this.label5 = new System.Windows.Forms.Label();
this.tabControl1.SuspendLayout();
this.tabPage1.SuspendLayout();
this.tabPage2.SuspendLayout();
this.tabPage3.SuspendLayout();
this.tabPage4.SuspendLayout();
this.SuspendLayout();
//
// tabControl1
//
this.tabControl1.Controls.Add(this.tabPage1);
this.tabControl1.Controls.Add(this.tabPage2);
this.tabControl1.Controls.Add(this.tabPage3);
this.tabControl1.Controls.Add(this.tabPage4);
this.tabControl1.Location = new System.Drawing.Point(8, 8);
this.tabControl1.Name = "tabControl1";
this.tabControl1.SelectedIndex = 0;
this.tabControl1.Size = new System.Drawing.Size(272, 248);
this.tabControl1.TabIndex = 0;
//
// tabPage1
//
this.tabPage1.Controls.Add(this.button2);
this.tabPage1.Controls.Add(this.button1);
this.tabPage1.Controls.Add(this.label1);
this.tabPage1.Controls.Add(this.textBox1);
this.tabPage1.Location = new System.Drawing.Point(4, 21);
this.tabPage1.Name = "tabPage1";
this.tabPage1.Size = new System.Drawing.Size(264, 223);
this.tabPage1.TabIndex = 0;
this.tabPage1.Text = "删除读者";
//
// button2
//
this.button2.Location = new System.Drawing.Point(152, 144);
this.button2.Name = "button2";
this.button2.TabIndex = 3;
this.button2.Text = "取消";
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// button1
//
this.button1.Location = new System.Drawing.Point(24, 144);
this.button1.Name = "button1";
this.button1.TabIndex = 2;
this.button1.Text = "删除";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// label1
//
this.label1.Location = new System.Drawing.Point(16, 48);
this.label1.Name = "label1";
this.label1.TabIndex = 1;
this.label1.Text = "读者编号:";
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(136, 48);
this.textBox1.Name = "textBox1";
this.textBox1.TabIndex = 0;
this.textBox1.Text = "textBox1";
this.textBox1.TextChanged += new System.EventHandler(this.textBox1_TextChanged);
//
// tabPage2
//
this.tabPage2.Controls.Add(this.button4);
this.tabPage2.Controls.Add(this.label2);
this.tabPage2.Controls.Add(this.button3);
this.tabPage2.Controls.Add(this.textBox2);
this.tabPage2.Location = new System.Drawing.Point(4, 21);
this.tabPage2.Name = "tabPage2";
this.tabPage2.Size = new System.Drawing.Size(264, 223);
this.tabPage2.TabIndex = 1;
this.tabPage2.Text = "删除图书";
//
// button4
//
this.button4.Location = new System.Drawing.Point(152, 144);
this.button4.Name = "button4";
this.button4.TabIndex = 3;
this.button4.Text = "取消";
this.button4.Click += new System.EventHandler(this.button4_Click);
//
// label2
//
this.label2.Location = new System.Drawing.Point(24, 56);
this.label2.Name = "label2";
this.label2.TabIndex = 2;
this.label2.Text = "图书编号:";
//
// button3
//
this.button3.Location = new System.Drawing.Point(32, 144);
this.button3.Name = "button3";
this.button3.TabIndex = 1;
this.button3.Text = "删除";
this.button3.Click += new System.EventHandler(this.button3_Click);
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(144, 56);
this.textBox2.Name = "textBox2";
this.textBox2.TabIndex = 0;
this.textBox2.Text = "textBox2";
//
// tabPage3
//
this.tabPage3.Controls.Add(this.button6);
this.tabPage3.Controls.Add(this.button5);
this.tabPage3.Controls.Add(this.textBox4);
this.tabPage3.Controls.Add(this.textBox3);
this.tabPage3.Controls.Add(this.label4);
this.tabPage3.Controls.Add(this.label3);
this.tabPage3.Location = new System.Drawing.Point(4, 21);
this.tabPage3.Name = "tabPage3";
this.tabPage3.Size = new System.Drawing.Size(264, 223);
this.tabPage3.TabIndex = 2;
this.tabPage3.Text = "还书";
//
// button6
//
this.button6.Location = new System.Drawing.Point(160, 168);
this.button6.Name = "button6";
this.button6.TabIndex = 5;
this.button6.Text = "取消";
//
// button5
//
this.button5.Location = new System.Drawing.Point(32, 168);
this.button5.Name = "button5";
this.button5.TabIndex = 4;
this.button5.Text = "还书";
this.button5.Click += new System.EventHandler(this.button5_Click);
//
// textBox4
//
this.textBox4.Location = new System.Drawing.Point(144, 96);
this.textBox4.Name = "textBox4";
this.textBox4.TabIndex = 3;
this.textBox4.Text = "textBox4";
//
// textBox3
//
this.textBox3.Location = new System.Drawing.Point(144, 40);
this.textBox3.Name = "textBox3";
this.textBox3.TabIndex = 2;
this.textBox3.Text = "textBox3";
//
// label4
//
this.label4.Location = new System.Drawing.Point(24, 96);
this.label4.Name = "label4";
this.label4.TabIndex = 1;
this.label4.Text = "图书编号:";
//
// label3
//
this.label3.Location = new System.Drawing.Point(24, 40);
this.label3.Name = "label3";
this.label3.TabIndex = 0;
this.label3.Text = "读者编号:";
//
// tabPage4
//
this.tabPage4.Controls.Add(this.button8);
this.tabPage4.Controls.Add(this.button7);
this.tabPage4.Controls.Add(this.textBox5);
this.tabPage4.Controls.Add(this.label5);
this.tabPage4.Location = new System.Drawing.Point(4, 21);
this.tabPage4.Name = "tabPage4";
this.tabPage4.Size = new System.Drawing.Size(264, 223);
this.tabPage4.TabIndex = 3;
this.tabPage4.Text = "删除读者类型";
//
// button8
//
this.button8.Location = new System.Drawing.Point(152, 144);
this.button8.Name = "button8";
this.button8.TabIndex = 3;
this.button8.Text = "取消";
this.button8.Click += new System.EventHandler(this.button8_Click);
//
// button7
//
this.button7.Location = new System.Drawing.Point(24, 144);
this.button7.Name = "button7";
this.button7.TabIndex = 2;
this.button7.Text = "删除";
this.button7.Click += new System.EventHandler(this.button7_Click);
//
// textBox5
//
this.textBox5.Location = new System.Drawing.Point(136, 56);
this.textBox5.Name = "textBox5";
this.textBox5.TabIndex = 1;
this.textBox5.Text = "textBox5";
//
// label5
//
this.label5.Location = new System.Drawing.Point(16, 56);
this.label5.Name = "label5";
this.label5.TabIndex = 0;
this.label5.Text = "类型编号:";
//
// DeleteF
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(292, 273);
this.Controls.Add(this.tabControl1);
this.Name = "DeleteF";
this.Text = "DeleteF";
this.tabControl1.ResumeLayout(false);
this.tabPage1.ResumeLayout(false);
this.tabPage2.ResumeLayout(false);
this.tabPage3.ResumeLayout(false);
this.tabPage4.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private void textBox1_TextChanged(object sender, System.EventArgs e)
{
}
private void button1_Click(object sender, System.EventArgs e)
{
string rid=textBox1.Text;
string sql="select * from Reader where Rid='"+rid+"'";
if(util.isExist(sql))
{
string sql11="select * from GetBInfo where Rid='"+rid+"'";
if(!util.isExist(sql11))
{
string sql1="delete from Reader where Rid='"+rid+"'";
int m=sq.Update(sql1);
if(m==0)
{
MessageBox.Show("发生错误,删除未成功!!");
}
else
{
MessageBox.Show("ok!!删除成功!!");
}
}
else{
MessageBox.Show("此用户正在借书当中,要想删除,请让他先还书!!");
}
}
else
{
MessageBox.Show("数据库里没有该读者,无需删除!!");
}
}
private void button2_Click(object sender, System.EventArgs e)
{
textBox1.Clear();
}
private void button3_Click(object sender, System.EventArgs e)
{
string bid=textBox2.Text;
string sql="select * from Book where Bid='"+bid+"'";
if(util.isExist(sql))
{
string sql11="select * from GetBInfo where Bid='"+bid+"'";
if(!util.isExist(sql11))
{
string sql1="delete from Book where Bid='"+bid+"'";
int m=sq.Update(sql1);
if(m==0)
{
MessageBox.Show("发生错误,删除未成功!!");
}
else
{
MessageBox.Show("ok!!删除成功!!");
}
}
else{
MessageBox.Show("这类书还有部分已借出,要想删除,请让所有用户先还!!");
}
}
else{
MessageBox.Show("数据库里没有该图书,无需删除!!");
}
}
private void button4_Click(object sender, System.EventArgs e)
{
textBox2.Clear();
}
private void button5_Click(object sender, System.EventArgs e)
{
string rid=textBox3.Text;
string bid=textBox4.Text;
//Book book=new Book();
util.setBook(rid,bid);
}
private void button8_Click(object sender, System.EventArgs e)
{
textBox5.Clear();
}
private void button7_Click(object sender, System.EventArgs e)
{
string tid=textBox5.Text;
string sql="select * from ReaderType where Typeid='"+tid+"'";
if(util.isExist(sql))
{
string sql11="select * from Reader where Rtypeno='"+tid+"'";
if(!util.isExist(sql11))
{
string sql1="delete from ReaderType where Typeid='"+tid+"'";
int m=sq.Update(sql1);
if(m==0)
{
MessageBox.Show("发生错误,删除未成功!!");
}
else
{
MessageBox.Show("ok!!删除成功!!");
}
}
else{
MessageBox.Show("目前还有读者是属于该类型,要想删除,先把属于该类型的读者更新!!");
}
}
else
{
MessageBox.Show("数据库里没有该读者类型,无需删除!!");
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -