📄 history.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.SqlClient;
namespace 图书馆管理系统客户端
{
/// <summary>
/// History 的摘要说明。
/// </summary>
public class History : System.Windows.Forms.Form
{
private CurrencyManager cmOrders;
private System.Windows.Forms.DataGrid dataGrid1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox txt9;
private System.Data.SqlClient.SqlDataAdapter da1;
private System.Data.SqlClient.SqlConnection sqlConnection1;
private 图书馆管理系统客户端.DataSet2 dataSet21;
private System.Windows.Forms.Button btnSearch;
private System.Data.SqlClient.SqlCommand sqlSelectCommand1;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
public History()
{
//
// 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(History));
this.dataGrid1 = new System.Windows.Forms.DataGrid();
this.dataSet21 = new 图书馆管理系统客户端.DataSet2();
this.txt9 = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.da1 = new System.Data.SqlClient.SqlDataAdapter();
this.sqlSelectCommand1 = new System.Data.SqlClient.SqlCommand();
this.sqlConnection1 = new System.Data.SqlClient.SqlConnection();
this.btnSearch = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.dataSet21)).BeginInit();
this.SuspendLayout();
//
// 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(0, 64);
this.dataGrid1.Name = "dataGrid1";
this.dataGrid1.ReadOnly = true;
this.dataGrid1.Size = new System.Drawing.Size(608, 312);
this.dataGrid1.TabIndex = 0;
//
// dataSet21
//
this.dataSet21.DataSetName = "DataSet2";
this.dataSet21.Locale = new System.Globalization.CultureInfo("zh-CN");
//
// txt9
//
this.txt9.Location = new System.Drawing.Point(200, 24);
this.txt9.Name = "txt9";
this.txt9.TabIndex = 1;
this.txt9.Text = "";
//
// label1
//
this.label1.Location = new System.Drawing.Point(16, 24);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(168, 23);
this.label1.TabIndex = 2;
this.label1.Text = "你的证号(去掉证号前面的0)";
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// 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("状态", "状态")})});
//
// sqlSelectCommand1
//
this.sqlSelectCommand1.CommandText = "SELECT 书号, 书名, 借阅时间, 应还时间, 状态 FROM 读者借阅 WHERE (证号 LIKE @Param2)";
this.sqlSelectCommand1.Connection = this.sqlConnection1;
this.sqlSelectCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Param2", System.Data.SqlDbType.VarChar, 10, "证号"));
//
// sqlConnection1
//
this.sqlConnection1.ConnectionString = "workstation id=YXK;packet size=4096;integrated security=SSPI;data source=YXK;pers" +
"ist security info=False;initial catalog=library";
//
// btnSearch
//
this.btnSearch.Image = ((System.Drawing.Image)(resources.GetObject("btnSearch.Image")));
this.btnSearch.ImageAlign = System.Drawing.ContentAlignment.BottomLeft;
this.btnSearch.Location = new System.Drawing.Point(336, 24);
this.btnSearch.Name = "btnSearch";
this.btnSearch.Size = new System.Drawing.Size(64, 23);
this.btnSearch.TabIndex = 3;
this.btnSearch.Text = "搜索";
this.btnSearch.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
this.btnSearch.Click += new System.EventHandler(this.btnSearch_Click);
//
// History
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(528, 382);
this.Controls.Add(this.btnSearch);
this.Controls.Add(this.label1);
this.Controls.Add(this.txt9);
this.Controls.Add(this.dataGrid1);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Name = "History";
this.Text = "【读者借阅情况】";
this.Load += new System.EventHandler(this.History_Load);
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.dataSet21)).EndInit();
this.ResumeLayout(false);
}
#endregion
private void History_Load(object sender, System.EventArgs e)
{
cmOrders=(CurrencyManager) BindingContext[dataSet21,"读者借阅"];
}
private void btnSearch_Click(object sender, System.EventArgs e)
{
if(txt9.Text!="")
da1.SelectCommand.Parameters[0].Value="%"+txt9.Text+"%";
else
{
DialogResult dlg=MessageBox.Show("请输入证号","提示",MessageBoxButtons.OKCancel,MessageBoxIcon.Warning);
if(dlg==DialogResult.OK)
{
return;
}
}
dataSet21.读者借阅.Clear();
da1.Fill(dataSet21);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -