⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 registerloss.cs

📁 图书馆信息管理系统 Library Information Management System
💻 CS
字号:
using System;
using System.Drawing;
using System.Data;
using System.Data.SqlClient;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;

namespace Library
{
	/// <summary>
	/// RegisterLoss 的摘要说明。
	/// </summary>
	public class RegisterLoss : System.Windows.Forms.Form
	{
		private System.Windows.Forms.Button btnClose;
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.TextBox textBox1;
		private System.Windows.Forms.Button btnRegLoss;
		private System.Windows.Forms.Label label2;
		/// <summary>
		/// 必需的设计器变量。
		/// </summary>
		private System.ComponentModel.Container components = null;

		private SqlCommand cmd;
		private SqlDataReader dr;

		public RegisterLoss()
		{
			//
			// 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.btnClose = new System.Windows.Forms.Button();
			this.label1 = new System.Windows.Forms.Label();
			this.textBox1 = new System.Windows.Forms.TextBox();
			this.btnRegLoss = new System.Windows.Forms.Button();
			this.label2 = new System.Windows.Forms.Label();
			this.SuspendLayout();
			// 
			// btnClose
			// 
			this.btnClose.DialogResult = System.Windows.Forms.DialogResult.Cancel;
			this.btnClose.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this.btnClose.Location = new System.Drawing.Point(208, 120);
			this.btnClose.Name = "btnClose";
			this.btnClose.TabIndex = 2;
			this.btnClose.Text = "关闭";
			this.btnClose.Click += new System.EventHandler(this.button1_Click);
			// 
			// label1
			// 
			this.label1.AutoSize = true;
			this.label1.Location = new System.Drawing.Point(32, 24);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(72, 17);
			this.label1.TabIndex = 1;
			this.label1.Text = "读者证号码:";
			// 
			// textBox1
			// 
			this.textBox1.Location = new System.Drawing.Point(32, 64);
			this.textBox1.Name = "textBox1";
			this.textBox1.Size = new System.Drawing.Size(216, 21);
			this.textBox1.TabIndex = 0;
			this.textBox1.Text = "";
			// 
			// btnRegLoss
			// 
			this.btnRegLoss.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this.btnRegLoss.Location = new System.Drawing.Point(112, 120);
			this.btnRegLoss.Name = "btnRegLoss";
			this.btnRegLoss.TabIndex = 1;
			this.btnRegLoss.Text = "挂失";
			this.btnRegLoss.Click += new System.EventHandler(this.btnRegLoss_Click);
			// 
			// label2
			// 
			this.label2.AutoSize = true;
			this.label2.ForeColor = System.Drawing.Color.Red;
			this.label2.Location = new System.Drawing.Point(248, 64);
			this.label2.Name = "label2";
			this.label2.Size = new System.Drawing.Size(48, 17);
			this.label2.TabIndex = 4;
			this.label2.Text = "<Enter>";
			// 
			// RegisterLoss
			// 
			this.AcceptButton = this.btnRegLoss;
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.CancelButton = this.btnClose;
			this.ClientSize = new System.Drawing.Size(306, 168);
			this.ControlBox = false;
			this.Controls.Add(this.label2);
			this.Controls.Add(this.btnRegLoss);
			this.Controls.Add(this.textBox1);
			this.Controls.Add(this.label1);
			this.Controls.Add(this.btnClose);
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
			this.Name = "RegisterLoss";
			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.RegisterLoss_Load);
			this.ResumeLayout(false);

		}
		#endregion
		/// <summary>
		/// 关闭
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void button1_Click(object sender, System.EventArgs e)
		{
			Global.sbpGlobal.Text = "就绪";
			this.Close();
		}

		private void btnRegLoss_Click(object sender, System.EventArgs e)
		{
			string str = "select * from 借书证 where 借书证号='" + textBox1.Text + "'";
			cmd.CommandText = str;
			try
			{
				dr = cmd.ExecuteReader();
				dr.Read();
				if(dr.HasRows!=true)
				{
					if(dr!=null)dr.Close();
					MessageBox.Show("此借书证不存在!请检查输入","提示",MessageBoxButtons.OK,MessageBoxIcon.Warning);
					textBox1.SelectAll();
					textBox1.Focus();
					return;
				}
				if(dr!=null)dr.Close();
			}
			catch(Exception ex)
			{
				if(dr!=null)dr.Close();
				MessageBox.Show(ex.ToString(),"错误",MessageBoxButtons.OK,MessageBoxIcon.Error);
				return;
			}
			str = "update 借书证 set 借书证状态=1 where 借书证号='" + textBox1.Text + "'";
			cmd.CommandText = str;
			try
			{
				cmd.ExecuteNonQuery();
				MessageBox.Show("成功挂失此借书证!","信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
				textBox1.Text = "";
				textBox1.Focus();
			}
			catch(Exception ex)
			{
				MessageBox.Show(ex.ToString(),"错误",MessageBoxButtons.OK,MessageBoxIcon.Error);
				return;
			}
		}
		/// <summary>
		/// 窗体加载代码
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void RegisterLoss_Load(object sender, System.EventArgs e)
		{
			cmd = Global.conn.CreateCommand();
			textBox1.Text = "";
			textBox1.Focus();
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -