📄 form1.cs
字号:
// label5
//
this.label5.Location = new System.Drawing.Point(120, 120);
this.label5.Name = "label5";
this.label5.TabIndex = 10;
this.label5.Text = "定价:";
//
// label4
//
this.label4.Location = new System.Drawing.Point(120, 96);
this.label4.Name = "label4";
this.label4.TabIndex = 9;
this.label4.Text = "出版日期:";
//
// label3
//
this.label3.Location = new System.Drawing.Point(120, 72);
this.label3.Name = "label3";
this.label3.TabIndex = 8;
this.label3.Text = "出版社:";
//
// label2
//
this.label2.Location = new System.Drawing.Point(120, 48);
this.label2.Name = "label2";
this.label2.TabIndex = 7;
this.label2.Text = "作者:";
//
// label1
//
this.label1.Location = new System.Drawing.Point(120, 24);
this.label1.Name = "label1";
this.label1.TabIndex = 6;
this.label1.Text = "书名:";
//
// checkBox6
//
this.checkBox6.Location = new System.Drawing.Point(16, 144);
this.checkBox6.Name = "checkBox6";
this.checkBox6.TabIndex = 5;
this.checkBox6.Text = "逻辑与";
//
// checkBox5
//
this.checkBox5.Location = new System.Drawing.Point(16, 120);
this.checkBox5.Name = "checkBox5";
this.checkBox5.TabIndex = 4;
this.checkBox5.Text = "逻辑与";
//
// checkBox4
//
this.checkBox4.Location = new System.Drawing.Point(16, 96);
this.checkBox4.Name = "checkBox4";
this.checkBox4.TabIndex = 3;
this.checkBox4.Text = "逻辑与";
//
// checkBox3
//
this.checkBox3.Location = new System.Drawing.Point(16, 72);
this.checkBox3.Name = "checkBox3";
this.checkBox3.TabIndex = 2;
this.checkBox3.Text = "逻辑与";
//
// checkBox2
//
this.checkBox2.Location = new System.Drawing.Point(16, 48);
this.checkBox2.Name = "checkBox2";
this.checkBox2.TabIndex = 1;
this.checkBox2.Text = "逻辑与";
//
// checkBox1
//
this.checkBox1.Location = new System.Drawing.Point(16, 24);
this.checkBox1.Name = "checkBox1";
this.checkBox1.TabIndex = 0;
this.checkBox1.Text = "逻辑与";
//
// button3
//
this.button3.Location = new System.Drawing.Point(16, 232);
this.button3.Name = "button3";
this.button3.TabIndex = 4;
this.button3.Text = "清理数据";
this.button3.Click += new System.EventHandler(this.button3_Click);
//
// button4
//
this.button4.Location = new System.Drawing.Point(16, 272);
this.button4.Name = "button4";
this.button4.TabIndex = 5;
this.button4.Text = "超级用户";
this.button4.Click += new System.EventHandler(this.button4_Click);
//
// sqlDataAdapter1
//
this.sqlDataAdapter1.DeleteCommand = this.sqlDeleteCommand1;
this.sqlDataAdapter1.InsertCommand = this.sqlInsertCommand1;
this.sqlDataAdapter1.SelectCommand = this.sqlSelectCommand1;
this.sqlDataAdapter1.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] {
new System.Data.Common.DataTableMapping("Table", "TABLE1", new System.Data.Common.DataColumnMapping[] {
new System.Data.Common.DataColumnMapping("ISBN", "ISBN"),
new System.Data.Common.DataColumnMapping("书名", "书名"),
new System.Data.Common.DataColumnMapping("作者", "作者"),
new System.Data.Common.DataColumnMapping("出版社", "出版社"),
new System.Data.Common.DataColumnMapping("出版日期", "出版日期"),
new System.Data.Common.DataColumnMapping("定价", "定价")})});
this.sqlDataAdapter1.UpdateCommand = this.sqlUpdateCommand1;
//
// sqlSelectCommand1
//
this.sqlSelectCommand1.CommandText = "SELECT ISBN, 书名, 作者, 出版社, 出版日期, 定价 FROM TABLE1";
this.sqlSelectCommand1.Connection = this.sqlConnection1;
//
// sqlInsertCommand1
//
this.sqlInsertCommand1.CommandText = "INSERT INTO TABLE1(ISBN, 书名, 作者, 出版社, 出版日期, 定价) VALUES (@ISBN, @书名, @作者, @出版社, @出" +
"版日期, @定价); SELECT ISBN, 书名, 作者, 出版社, 出版日期, 定价 FROM TABLE1 WHERE (ISBN = @ISBN)";
this.sqlInsertCommand1.Connection = this.sqlConnection1;
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@ISBN", System.Data.SqlDbType.VarChar, 50, "ISBN"));
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@书名", System.Data.SqlDbType.VarChar, 50, "书名"));
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@作者", System.Data.SqlDbType.VarChar, 50, "作者"));
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@出版社", System.Data.SqlDbType.VarChar, 50, "出版社"));
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@出版日期", System.Data.SqlDbType.VarChar, 50, "出版日期"));
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@定价", System.Data.SqlDbType.VarChar, 50, "定价"));
//
// sqlUpdateCommand1
//
this.sqlUpdateCommand1.CommandText = @"UPDATE TABLE1 SET ISBN = @ISBN, 书名 = @书名, 作者 = @作者, 出版社 = @出版社, 出版日期 = @出版日期, 定价 = @定价 WHERE (ISBN = @Original_ISBN) AND (书名 = @Original_书名 OR @Original_书名 IS NULL AND 书名 IS NULL) AND (作者 = @Original_作者 OR @Original_作者 IS NULL AND 作者 IS NULL) AND (出版日期 = @Original_出版日期 OR @Original_出版日期 IS NULL AND 出版日期 IS NULL) AND (出版社 = @Original_出版社 OR @Original_出版社 IS NULL AND 出版社 IS NULL) AND (定价 = @Original_定价 OR @Original_定价 IS NULL AND 定价 IS NULL); SELECT ISBN, 书名, 作者, 出版社, 出版日期, 定价 FROM TABLE1 WHERE (ISBN = @ISBN)";
this.sqlUpdateCommand1.Connection = this.sqlConnection1;
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@ISBN", System.Data.SqlDbType.VarChar, 50, "ISBN"));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@书名", System.Data.SqlDbType.VarChar, 50, "书名"));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@作者", System.Data.SqlDbType.VarChar, 50, "作者"));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@出版社", System.Data.SqlDbType.VarChar, 50, "出版社"));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@出版日期", System.Data.SqlDbType.VarChar, 50, "出版日期"));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@定价", System.Data.SqlDbType.VarChar, 50, "定价"));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_ISBN", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "ISBN", System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_书名", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "书名", System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_作者", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "作者", System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_出版日期", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "出版日期", System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_出版社", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "出版社", System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_定价", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "定价", System.Data.DataRowVersion.Original, null));
//
// sqlDeleteCommand1
//
this.sqlDeleteCommand1.CommandText = @"DELETE FROM TABLE1 WHERE (ISBN = @Original_ISBN) AND (书名 = @Original_书名 OR @Original_书名 IS NULL AND 书名 IS NULL) AND (作者 = @Original_作者 OR @Original_作者 IS NULL AND 作者 IS NULL) AND (出版日期 = @Original_出版日期 OR @Original_出版日期 IS NULL AND 出版日期 IS NULL) AND (出版社 = @Original_出版社 OR @Original_出版社 IS NULL AND 出版社 IS NULL) AND (定价 = @Original_定价 OR @Original_定价 IS NULL AND 定价 IS NULL)";
this.sqlDeleteCommand1.Connection = this.sqlConnection1;
this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_ISBN", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "ISBN", System.Data.DataRowVersion.Original, null));
this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_书名", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "书名", System.Data.DataRowVersion.Original, null));
this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_作者", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "作者", System.Data.DataRowVersion.Original, null));
this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_出版日期", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "出版日期", System.Data.DataRowVersion.Original, null));
this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_出版社", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "出版社", System.Data.DataRowVersion.Original, null));
this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_定价", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "定价", System.Data.DataRowVersion.Original, null));
//
// sqlConnection1
//
this.sqlConnection1.ConnectionString = "workstation id=\"LDQ-EB332257960\";packet size=4096;user id=sa;data source=\"LDQ-EB3" +
"32257960\";persist security info=False;initial catalog=图书数据库";
//
// books1
//
this.books1.DataSetName = "books";
this.books1.Locale = new System.Globalization.CultureInfo("zh-CN");
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(528, 326);
this.Controls.Add(this.button4);
this.Controls.Add(this.button3);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.Controls.Add(this.dataGrid1);
this.Name = "Form1";
this.Text = "图书销售系统";
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
this.groupBox1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.books1)).EndInit();
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
//"全部浏览"按钮的Click事件代码
private void button1_Click(object sender, System.EventArgs e)
{
sqlDataAdapter1.SelectCommand.CommandText="SELECT * FROM TABLE1";
sqlDataAdapter1.Fill(books1.TABLE1);
}
//"查询数据"按钮的Click事件代码
private void button2_Click(object sender, System.EventArgs e)
{
string add=null;
string query1="SELECT * FROM TABLE1 WHERE ";
if(checkBox1.Checked)
{
add="书名 like"+"'"+textBox1.Text+"%"+"'";
}
if(checkBox2.Checked)
{
add="作者 like"+"'"+textBox2.Text+"%"+"'";
}
if(checkBox3.Checked)
{
add="出版社 like"+"'"+textBox3.Text+"%"+"'";
}
if(checkBox4.Checked)
{
add="出版日期>="+"'"+textBox4.Text+"'";
}
if(checkBox5.Checked)
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -