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

📄 registerlossbooks.cs

📁 图书馆信息管理系统 Library Information Management System
💻 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>
	/// RegisterLossBooks 的摘要说明。
	/// </summary>
	public class RegisterLossBooks : System.Windows.Forms.Form
	{
		private System.Windows.Forms.Button button1;
		private System.Windows.Forms.Button button2;
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.TextBox textBox1;
		/// <summary>
		/// 必需的设计器变量。
		/// </summary>
		private System.ComponentModel.Container components = null;

		private SqlCommand cmd;
		private SqlDataReader dr;

		public RegisterLossBooks()
		{
			//
			// 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.label1 = new System.Windows.Forms.Label();
			this.textBox1 = new System.Windows.Forms.TextBox();
			this.SuspendLayout();
			// 
			// button1
			// 
			this.button1.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this.button1.Location = new System.Drawing.Point(136, 104);
			this.button1.Name = "button1";
			this.button1.TabIndex = 0;
			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(224, 104);
			this.button2.Name = "button2";
			this.button2.TabIndex = 1;
			this.button2.Text = "关闭";
			this.button2.Click += new System.EventHandler(this.button2_Click);
			// 
			// label1
			// 
			this.label1.AutoSize = true;
			this.label1.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this.label1.Location = new System.Drawing.Point(24, 24);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(54, 17);
			this.label1.TabIndex = 2;
			this.label1.Text = "图书条码";
			// 
			// textBox1
			// 
			this.textBox1.Location = new System.Drawing.Point(24, 56);
			this.textBox1.Name = "textBox1";
			this.textBox1.Size = new System.Drawing.Size(272, 21);
			this.textBox1.TabIndex = 3;
			this.textBox1.Text = "";
			// 
			// RegisterLossBooks
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(322, 152);
			this.ControlBox = false;
			this.Controls.Add(this.textBox1);
			this.Controls.Add(this.label1);
			this.Controls.Add(this.button2);
			this.Controls.Add(this.button1);
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
			this.Name = "RegisterLossBooks";
			this.ShowInTaskbar = false;
			this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "挂失图书";
			this.ResumeLayout(false);

		}
		#endregion
		/// <summary>
		/// 挂失
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void button1_Click(object sender, System.EventArgs e)
		{
			string str = "";
			str = "select * from 图书资料 where 条形码='" + textBox1.Text + "'";
			str = "select * from 读者借书 where 图书条码号='" + textBox1.Text + "'";
			str = "update 图书资料 set 挂失标志=1 where 条形码='" + textBox1.Text + "'";
			//创建事务
			SqlTransaction trans = Global.conn.BeginTransaction();
			cmd.Transaction = trans;
			try
			{
				cmd.CommandText = str;
				cmd.ExecuteNonQuery();
				cmd.CommandText = str;
				cmd.ExecuteNonQuery();
				trans.Commit();

			}
			catch
			{
				try
				{
					trans.Rollback();
				}
				catch (SqlException ex)
				{
					if (trans.Connection != null)
					{
						MessageBox.Show(ex.ToString());
					}
				}
				MessageBox.Show("发生错误!图书借阅未成功!");
				return;
			}
		}
		/// <summary>
		/// 关闭
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void button2_Click(object sender, System.EventArgs e)
		{
			this.Close();
		}
	}
}

⌨️ 快捷键说明

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