?? overduebook.cs
字號:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
namespace 圖書館管理系統
{
/// <summary>
/// OverdueBook 的摘要說明。
/// </summary>
public class OverdueBook : System.Windows.Forms.Form
{
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.Button btnSearch;
private System.Windows.Forms.TextBox txt1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox txt2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.TextBox txt3;
private System.Data.SqlClient.SqlDataAdapter da1;
private System.Data.SqlClient.SqlConnection sqlConnection1;
private 圖書館管理系統.DataSet2 dataSet21;
private System.Data.SqlClient.SqlCommand sqlSelectCommand1;
private System.Windows.Forms.DataGrid dataGrid1;
/// <summary>
/// 必需的設計器變量。
/// </summary>
private System.ComponentModel.Container components = null;
public OverdueBook()
{
//
// Windows 窗體設計器支持所必需的
//
InitializeComponent();
//
// 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()
{
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(OverdueBook));
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.btnSearch = new System.Windows.Forms.Button();
this.txt1 = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.txt2 = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.txt3 = new System.Windows.Forms.TextBox();
this.da1 = new System.Data.SqlClient.SqlDataAdapter();
this.sqlSelectCommand1 = new System.Data.SqlClient.SqlCommand();
this.sqlConnection1 = new System.Data.SqlClient.SqlConnection();
this.dataSet21 = new 圖書館管理系統.DataSet2();
this.dataGrid1 = new System.Windows.Forms.DataGrid();
this.groupBox1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.dataSet21)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();
this.SuspendLayout();
//
// groupBox1
//
this.groupBox1.Controls.Add(this.btnSearch);
this.groupBox1.Controls.Add(this.txt1);
this.groupBox1.Controls.Add(this.label2);
this.groupBox1.Controls.Add(this.label1);
this.groupBox1.Controls.Add(this.txt2);
this.groupBox1.Controls.Add(this.label3);
this.groupBox1.Controls.Add(this.txt3);
this.groupBox1.Location = new System.Drawing.Point(0, 0);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(642, 60);
this.groupBox1.TabIndex = 1;
this.groupBox1.TabStop = false;
//
// btnSearch
//
this.btnSearch.Image = ((System.Drawing.Image)(resources.GetObject("btnSearch.Image")));
this.btnSearch.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.btnSearch.Location = new System.Drawing.Point(16, 26);
this.btnSearch.Name = "btnSearch";
this.btnSearch.Size = new System.Drawing.Size(72, 23);
this.btnSearch.TabIndex = 3;
this.btnSearch.Text = " 搜索";
this.btnSearch.Click += new System.EventHandler(this.btnSearch_Click);
//
// txt1
//
this.txt1.Location = new System.Drawing.Point(155, 25);
this.txt1.Name = "txt1";
this.txt1.TabIndex = 8;
this.txt1.Text = "";
//
// label2
//
this.label2.Location = new System.Drawing.Point(104, 29);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(56, 16);
this.label2.TabIndex = 6;
this.label2.Text = "讀者編號";
//
// label1
//
this.label1.Location = new System.Drawing.Point(288, 29);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(56, 16);
this.label1.TabIndex = 4;
this.label1.Text = "圖書編號";
//
// txt2
//
this.txt2.Location = new System.Drawing.Point(347, 25);
this.txt2.Name = "txt2";
this.txt2.TabIndex = 9;
this.txt2.Text = "";
//
// label3
//
this.label3.Location = new System.Drawing.Point(472, 29);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(56, 16);
this.label3.TabIndex = 5;
this.label3.Text = "讀者姓名";
//
// txt3
//
this.txt3.Location = new System.Drawing.Point(528, 25);
this.txt3.Name = "txt3";
this.txt3.TabIndex = 7;
this.txt3.Text = "";
//
// da1
//
this.da1.SelectCommand = this.sqlSelectCommand1;
this.da1.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] {
new System.Data.Common.DataTableMapping("Table", "圖書借閱", 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("圖書編號", "圖書編號"),
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("操作員", "操作員"),
new System.Data.Common.DataColumnMapping("狀態", "狀態")})});
//
// sqlSelectCommand1
//
this.sqlSelectCommand1.CommandText = @"SELECT a.借閱編號, b.姓名, a.讀者編號, a.圖書編號, c.書名, a.借閱時間, a.應還時間, a.續借次數, a.操作員, a.狀態 FROM 圖書借閱 a INNER JOIN 讀者信息 b ON a.讀者編號 = b.編號 INNER JOIN 圖書信息 c ON a.圖書編號 = c.編號 WHERE (a.讀者編號 LIKE @Param14) AND (a.圖書編號 LIKE @Param15) AND (b.姓名 LIKE @Param16) AND (a.狀態 = '未還') AND (a.應還時間 < GETDATE())";
this.sqlSelectCommand1.Connection = this.sqlConnection1;
this.sqlSelectCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Param14", System.Data.SqlDbType.VarChar, 40, "讀者編號"));
this.sqlSelectCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Param15", System.Data.SqlDbType.VarChar, 50, "圖書編號"));
this.sqlSelectCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Param16", System.Data.SqlDbType.VarChar, 20, "姓名"));
//
// sqlConnection1
//
this.sqlConnection1.ConnectionString = "workstation id=localhost;Integrated Security=SSPI;Database=libbook;";
//
// dataSet21
//
this.dataSet21.DataSetName = "DataSet2";
this.dataSet21.Locale = new System.Globalization.CultureInfo("zh-CN");
//
// dataGrid1
//
this.dataGrid1.CaptionVisible = false;
this.dataGrid1.DataMember = "圖書借閱";
this.dataGrid1.DataSource = this.dataSet21;
this.dataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText;
this.dataGrid1.Location = new System.Drawing.Point(3, 64);
this.dataGrid1.Name = "dataGrid1";
this.dataGrid1.ReadOnly = true;
this.dataGrid1.Size = new System.Drawing.Size(637, 392);
this.dataGrid1.TabIndex = 2;
//
// OverdueBook
//
this.AcceptButton = this.btnSearch;
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(648, 462);
this.Controls.Add(this.dataGrid1);
this.Controls.Add(this.groupBox1);
this.Name = "OverdueBook";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "【逾期圖書清單】";
this.Load += new System.EventHandler(this.OverdueBook_Load);
this.groupBox1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.dataSet21)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
this.ResumeLayout(false);
}
#endregion
//------------初始化窗體時,填充數據-------------
private void OverdueBook_Load(object sender, System.EventArgs e)
{
da1.SelectCommand.Parameters[0].Value="%%";
da1.SelectCommand.Parameters[1].Value="%%";
da1.SelectCommand.Parameters[2].Value="%%";
da1.Fill(dataSet21);
}
//-----------搜索逾期圖書記錄-----------
private void btnSearch_Click(object sender, System.EventArgs e)
{
da1.SelectCommand.Parameters[0].Value="%%";
da1.SelectCommand.Parameters[1].Value="%%";
da1.SelectCommand.Parameters[2].Value="%%";
if(txt1.Text!="")
{
da1.SelectCommand.Parameters[0].Value="%"+txt1.Text+"%";
}
if(txt2.Text!="")
{
da1.SelectCommand.Parameters[1].Value="%"+txt2.Text+"%";
}
if(txt3.Text!="")
{
da1.SelectCommand.Parameters[2].Value="%"+txt3.Text+"%";
}
dataSet21.圖書借閱.Clear();
da1.Fill(dataSet21);
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -