?? booksinfo.cs
字號:
using System;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
namespace Library
{
/// <summary>
/// BooksInfo 的摘要說明。
/// </summary>
public class BooksInfo : System.Windows.Forms.Form
{
#region Private Forms
private System.Windows.Forms.Label label1;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.Button btnClose;
private System.Windows.Forms.GroupBox groupBox3;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Button btnSearch;
private System.Windows.Forms.Button btnRefresh;
private System.Windows.Forms.Button btnBuyBooks;
private System.Windows.Forms.Button btnExcel;
private System.Windows.Forms.Button btnEdit;
private System.Windows.Forms.Button btnDelete;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.ComboBox comboBox1;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.RadioButton radioButton1;
private System.Windows.Forms.RadioButton radioButton2;
private System.Windows.Forms.ListView listView1;
/// <summary>
/// 必需的設計器變量。
/// </summary>
private System.ComponentModel.Container components = null;
#endregion
private SqlCommand cmd = null;
//private SqlDataReader dr = null;
private DataTable tableTemp = null;
public BooksInfo()
{
//
// Windows 窗體設計器支持所必需的
//
InitializeComponent();
//
//Table
//
tableTemp = GetData();
textBox1.Text = "";
radioButton1.Checked = true;
ListViewItem item = null;
int colIndex=0;
//tableTemp = GetData();
//將所得到的表的列名,賦值給單元格
foreach(DataColumn col in tableTemp.Columns)
{
colIndex++;
listView1.Columns.Add(col.ColumnName,-2,HorizontalAlignment.Left);
comboBox1.Items.Add(col.ColumnName);
}
//同樣方法處理數據
foreach(DataRow row in tableTemp.Rows)
{
colIndex=0;
item = new ListViewItem(row[0].ToString());
for(colIndex= 1;colIndex<tableTemp.Columns.Count;colIndex++)
{
item.SubItems.Add(row[colIndex].ToString());
}
listView1.Items.Add(item);
}
}
/// <summary>
/// 清理所有正在使用的資源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(tableTemp!=null)
{
tableTemp.Dispose();
}
if(cmd!=null)
{
cmd.Dispose();
}
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows 窗體設計器生成的代碼
/// <summary>
/// 設計器支持所需的方法 - 不要使用代碼編輯器修改
/// 此方法的內容。
/// </summary>
private void InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.listView1 = new System.Windows.Forms.ListView();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.btnDelete = new System.Windows.Forms.Button();
this.btnEdit = new System.Windows.Forms.Button();
this.btnBuyBooks = new System.Windows.Forms.Button();
this.btnRefresh = new System.Windows.Forms.Button();
this.btnClose = new System.Windows.Forms.Button();
this.btnExcel = new System.Windows.Forms.Button();
this.groupBox3 = new System.Windows.Forms.GroupBox();
this.comboBox1 = new System.Windows.Forms.ComboBox();
this.radioButton2 = new System.Windows.Forms.RadioButton();
this.radioButton1 = new System.Windows.Forms.RadioButton();
this.label3 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.btnSearch = new System.Windows.Forms.Button();
this.textBox1 = new System.Windows.Forms.TextBox();
this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
this.groupBox3.SuspendLayout();
this.SuspendLayout();
//
// label1
//
this.label1.BackColor = System.Drawing.Color.WhiteSmoke;
this.label1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.label1.Font = new System.Drawing.Font("宋體", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.label1.ForeColor = System.Drawing.Color.Black;
this.label1.Location = new System.Drawing.Point(289, 16);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(216, 23);
this.label1.TabIndex = 0;
this.label1.Text = "圖 書 資 料";
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// groupBox1
//
this.groupBox1.Controls.Add(this.listView1);
this.groupBox1.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.groupBox1.Location = new System.Drawing.Point(8, 48);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(776, 312);
this.groupBox1.TabIndex = 1;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "已入庫圖書";
//
// listView1
//
this.listView1.Dock = System.Windows.Forms.DockStyle.Fill;
this.listView1.FullRowSelect = true;
this.listView1.GridLines = true;
this.listView1.Location = new System.Drawing.Point(3, 17);
this.listView1.MultiSelect = false;
this.listView1.Name = "listView1";
this.listView1.Size = new System.Drawing.Size(770, 292);
this.listView1.Sorting = System.Windows.Forms.SortOrder.Descending;
this.listView1.TabIndex = 0;
this.listView1.View = System.Windows.Forms.View.Details;
this.listView1.DoubleClick += new System.EventHandler(this.listView1_DoubleClick);
this.listView1.ColumnClick += new System.Windows.Forms.ColumnClickEventHandler(this.listView1_ColumnClick);
//
// groupBox2
//
this.groupBox2.Controls.Add(this.btnDelete);
this.groupBox2.Controls.Add(this.btnEdit);
this.groupBox2.Controls.Add(this.btnBuyBooks);
this.groupBox2.Controls.Add(this.btnRefresh);
this.groupBox2.Controls.Add(this.btnClose);
this.groupBox2.Controls.Add(this.btnExcel);
this.groupBox2.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.groupBox2.Location = new System.Drawing.Point(448, 376);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(312, 112);
this.groupBox2.TabIndex = 2;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "導航";
//
// btnDelete
//
this.btnDelete.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.btnDelete.Location = new System.Drawing.Point(207, 32);
this.btnDelete.Name = "btnDelete";
this.btnDelete.Size = new System.Drawing.Size(82, 23);
this.btnDelete.TabIndex = 8;
this.btnDelete.Text = "刪除";
this.btnDelete.Click += new System.EventHandler(this.btnDelete_Click);
//
// btnEdit
//
this.btnEdit.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.btnEdit.Location = new System.Drawing.Point(115, 32);
this.btnEdit.Name = "btnEdit";
this.btnEdit.Size = new System.Drawing.Size(82, 23);
this.btnEdit.TabIndex = 7;
this.btnEdit.Text = "修改";
this.btnEdit.Click += new System.EventHandler(this.btnEdit_Click);
//
// btnBuyBooks
//
this.btnBuyBooks.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.btnBuyBooks.Location = new System.Drawing.Point(23, 32);
this.btnBuyBooks.Name = "btnBuyBooks";
this.btnBuyBooks.Size = new System.Drawing.Size(82, 23);
this.btnBuyBooks.TabIndex = 6;
this.btnBuyBooks.Text = "新添";
this.btnBuyBooks.Click += new System.EventHandler(this.btnBuyBooks_Click);
//
// btnRefresh
//
this.btnRefresh.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.btnRefresh.Location = new System.Drawing.Point(115, 72);
this.btnRefresh.Name = "btnRefresh";
this.btnRefresh.Size = new System.Drawing.Size(82, 23);
this.btnRefresh.TabIndex = 5;
this.btnRefresh.Text = "重置";
this.btnRefresh.Click += new System.EventHandler(this.btnRefresh_Click);
//
// btnClose
//
this.btnClose.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.btnClose.Location = new System.Drawing.Point(207, 72);
this.btnClose.Name = "btnClose";
this.btnClose.Size = new System.Drawing.Size(82, 23);
this.btnClose.TabIndex = 4;
this.btnClose.Text = "關閉";
this.btnClose.Click += new System.EventHandler(this.btnClose_Click);
//
// btnExcel
//
this.btnExcel.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.btnExcel.Location = new System.Drawing.Point(23, 72);
this.btnExcel.Name = "btnExcel";
this.btnExcel.Size = new System.Drawing.Size(82, 23);
this.btnExcel.TabIndex = 0;
this.btnExcel.Text = "導出至Excel";
this.btnExcel.Click += new System.EventHandler(this.btnExcel_Click);
//
// groupBox3
//
this.groupBox3.Controls.Add(this.comboBox1);
this.groupBox3.Controls.Add(this.radioButton2);
this.groupBox3.Controls.Add(this.radioButton1);
this.groupBox3.Controls.Add(this.label3);
this.groupBox3.Controls.Add(this.label2);
this.groupBox3.Controls.Add(this.btnSearch);
this.groupBox3.Controls.Add(this.textBox1);
this.groupBox3.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.groupBox3.Location = new System.Drawing.Point(24, 376);
this.groupBox3.Name = "groupBox3";
this.groupBox3.Size = new System.Drawing.Size(416, 112);
this.groupBox3.TabIndex = 3;
this.groupBox3.TabStop = false;
this.groupBox3.Text = "查詢記錄";
//
// comboBox1
//
this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBox1.Location = new System.Drawing.Point(104, 32);
this.comboBox1.Name = "comboBox1";
this.comboBox1.Size = new System.Drawing.Size(121, 20);
this.comboBox1.TabIndex = 6;
//
// radioButton2
//
this.radioButton2.Location = new System.Drawing.Point(320, 32);
this.radioButton2.Name = "radioButton2";
this.radioButton2.Size = new System.Drawing.Size(72, 24);
this.radioButton2.TabIndex = 9;
this.radioButton2.Text = "模糊查詢";
//
// radioButton1
//
this.radioButton1.Checked = true;
this.radioButton1.Location = new System.Drawing.Point(240, 32);
this.radioButton1.Name = "radioButton1";
this.radioButton1.Size = new System.Drawing.Size(72, 24);
this.radioButton1.TabIndex = 8;
this.radioButton1.TabStop = true;
this.radioButton1.Text = "精確查詢";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(24, 72);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(66, 17);
this.label3.TabIndex = 7;
this.label3.Text = "查詢條件:";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(24, 32);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(66, 17);
this.label2.TabIndex = 5;
this.label2.Text = "查詢依據:";
//
// btnSearch
//
this.btnSearch.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.btnSearch.Location = new System.Drawing.Point(336, 72);
this.btnSearch.Name = "btnSearch";
this.btnSearch.Size = new System.Drawing.Size(56, 23);
this.btnSearch.TabIndex = 4;
this.btnSearch.Text = "查詢";
this.btnSearch.Click += new System.EventHandler(this.btnSearch_Click);
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(104, 72);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(208, 21);
this.textBox1.TabIndex = 3;
this.textBox1.Text = "";
this.textBox1.KeyDown += new System.Windows.Forms.KeyEventHandler(this.textBox1_KeyDown);
//
// BooksInfo
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(790, 503);
this.ControlBox = false;
this.Controls.Add(this.groupBox3);
this.Controls.Add(this.groupBox2);
this.Controls.Add(this.groupBox1);
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -