?? liftregisterloss.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>
/// 借書證解掛 的摘要說明。
/// </summary>
public class LiftRegisterLoss : System.Windows.Forms.Form
{
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label1;
/// <summary>
/// 必需的設計器變量。
/// </summary>
private System.ComponentModel.Container components = null;
private SqlCommand cmd;
//private SqlDataReader dr;
public LiftRegisterLoss()
{
//
// Windows 窗體設計器支持所必需的
//
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.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.label2 = new System.Windows.Forms.Label();
this.textBox1 = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.groupBox1.SuspendLayout();
this.SuspendLayout();
//
// button1
//
this.button1.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.button1.Location = new System.Drawing.Point(232, 96);
this.button1.Name = "button1";
this.button1.TabIndex = 1;
this.button1.Text = "關閉";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// button2
//
this.button2.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.button2.Location = new System.Drawing.Point(136, 96);
this.button2.Name = "button2";
this.button2.TabIndex = 2;
this.button2.Text = "解掛";
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// groupBox1
//
this.groupBox1.Controls.Add(this.label2);
this.groupBox1.Controls.Add(this.textBox1);
this.groupBox1.Controls.Add(this.label1);
this.groupBox1.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.groupBox1.Location = new System.Drawing.Point(16, 8);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(288, 72);
this.groupBox1.TabIndex = 3;
this.groupBox1.TabStop = false;
//
// label2
//
this.label2.AutoSize = true;
this.label2.Font = new System.Drawing.Font("宋體", 7.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.label2.ForeColor = System.Drawing.Color.Red;
this.label2.Location = new System.Drawing.Point(232, 32);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(40, 15);
this.label2.TabIndex = 4;
this.label2.Text = "<Enter>";
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(64, 30);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(168, 21);
this.textBox1.TabIndex = 3;
this.textBox1.Text = "";
this.textBox1.KeyDown += new System.Windows.Forms.KeyEventHandler(this.textBox1_KeyDown);
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(16, 32);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(42, 17);
this.label1.TabIndex = 0;
this.label1.Text = "借書證";
//
// LiftRegisterLoss
//
this.AcceptButton = this.button2;
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(320, 135);
this.ControlBox = false;
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.Name = "LiftRegisterLoss";
this.ShowInTaskbar = false;
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "借書證解掛";
this.Load += new System.EventHandler(this.LiftRegisterLoss_Load);
this.groupBox1.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// 初始化
/// </summary>
private void initializeScreen()
{
textBox1.Text = "";
textBox1.Focus();
}
/// <summary>
/// 關閉
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button1_Click(object sender, System.EventArgs e)
{
Global.sbpGlobal.Text = "就緒";
this.Close();
}
/// <summary>
/// 窗體加載代碼
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void LiftRegisterLoss_Load(object sender, System.EventArgs e)
{
cmd = Global.conn.CreateCommand();
initializeScreen();
}
/// <summary>
/// 借書證號輸入完成后,按回車鍵顯示該讀者證信息
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void textBox1_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
{
if(e.KeyCode == Keys.Enter)
{
ShowInfomation();
}
}
/// <summary>
/// 顯示讀者證信息
/// </summary>
private void ShowInfomation()
{
//string str = @"select * from 讀者信息 where 借書證號='" + this.textBox1.Text.Trim() + "'";
}
/// <summary>
/// 解掛
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button2_Click(object sender, System.EventArgs e)
{
string sql = "select * from 借書證 where 借書證號='" + this.textBox1.Text.Trim() + "' and 借書證狀態=1";
cmd.CommandText = sql;
SqlDataReader dr = cmd.ExecuteReader();
dr.Read();
if(!dr.HasRows)
{
MessageBox.Show("當前掛失的證件記錄中不存此借書證記錄!因此您不能解掛此借書證,它可能未被進行掛失處理或已經解掛!");
return;
}
string sqlstr = "update 借書證 set 借書證狀態=0 where 借書證號='" + this.textBox1.Text.Trim() + "'";
cmd.CommandText = sqlstr;
try
{
cmd.ExecuteNonQuery();
MessageBox.Show("已經成功解掛此借書證!");
this.Close();
}
catch(Exception ex)
{
MessageBox.Show("解掛借書證時發生未知錯誤!錯誤信息:" + ex.Message);
return;
}
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -