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

📄 insert_hsbook.cs

📁 因本人正在学习中
💻 CS
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.SqlClient;
using System.IO;
namespace 图书
{
	/// <summary>
	/// insert_hsbook 的摘要说明。
	/// </summary>
	public class insert_hsbook : System.Windows.Forms.Form
	{
		private System.Windows.Forms.Label label7;
		private System.Windows.Forms.Label label5;
		private System.Windows.Forms.Label label6;
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.Label label8;
		private System.Windows.Forms.Button btn_cancel;
		private System.Windows.Forms.Button btn_sure;
		private System.Windows.Forms.TextBox txt_hsrq;
		private System.Windows.Forms.TextBox txt_hsbh;
		private System.Windows.Forms.TextBox txt_hdzbh;
		private System.Windows.Forms.TextBox txt_hbz;
		/// <summary>
		/// 必需的设计器变量。
		/// </summary>
		private System.ComponentModel.Container components = null;

		public insert_hsbook()
		{
			//
			// 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()
		{
			this.txt_hsrq = new System.Windows.Forms.TextBox();
			this.txt_hsbh = new System.Windows.Forms.TextBox();
			this.txt_hdzbh = new System.Windows.Forms.TextBox();
			this.txt_hbz = new System.Windows.Forms.TextBox();
			this.label7 = new System.Windows.Forms.Label();
			this.label5 = new System.Windows.Forms.Label();
			this.label6 = new System.Windows.Forms.Label();
			this.label1 = new System.Windows.Forms.Label();
			this.label8 = new System.Windows.Forms.Label();
			this.btn_cancel = new System.Windows.Forms.Button();
			this.btn_sure = new System.Windows.Forms.Button();
			this.SuspendLayout();
			// 
			// txt_hsrq
			// 
			this.txt_hsrq.Location = new System.Drawing.Point(184, 96);
			this.txt_hsrq.Name = "txt_hsrq";
			this.txt_hsrq.Size = new System.Drawing.Size(120, 21);
			this.txt_hsrq.TabIndex = 108;
			this.txt_hsrq.Text = "";
			// 
			// txt_hsbh
			// 
			this.txt_hsbh.Location = new System.Drawing.Point(176, 48);
			this.txt_hsbh.Name = "txt_hsbh";
			this.txt_hsbh.Size = new System.Drawing.Size(112, 21);
			this.txt_hsbh.TabIndex = 104;
			this.txt_hsbh.Text = "";
			// 
			// txt_hdzbh
			// 
			this.txt_hdzbh.Location = new System.Drawing.Point(400, 48);
			this.txt_hdzbh.Name = "txt_hdzbh";
			this.txt_hdzbh.Size = new System.Drawing.Size(88, 21);
			this.txt_hdzbh.TabIndex = 111;
			this.txt_hdzbh.Text = "";
			// 
			// txt_hbz
			// 
			this.txt_hbz.Location = new System.Drawing.Point(176, 128);
			this.txt_hbz.Multiline = true;
			this.txt_hbz.Name = "txt_hbz";
			this.txt_hbz.Size = new System.Drawing.Size(288, 104);
			this.txt_hbz.TabIndex = 109;
			this.txt_hbz.Text = "";
			// 
			// label7
			// 
			this.label7.Location = new System.Drawing.Point(128, 120);
			this.label7.Name = "label7";
			this.label7.Size = new System.Drawing.Size(48, 32);
			this.label7.TabIndex = 106;
			this.label7.Text = "备注:";
			this.label7.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			// 
			// label5
			// 
			this.label5.Location = new System.Drawing.Point(104, 96);
			this.label5.Name = "label5";
			this.label5.Size = new System.Drawing.Size(72, 23);
			this.label5.TabIndex = 105;
			this.label5.Text = "还书日期:";
			this.label5.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			// 
			// label6
			// 
			this.label6.Location = new System.Drawing.Point(312, 48);
			this.label6.Name = "label6";
			this.label6.Size = new System.Drawing.Size(80, 24);
			this.label6.TabIndex = 103;
			this.label6.Text = "读者编号:";
			this.label6.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			// 
			// label1
			// 
			this.label1.Location = new System.Drawing.Point(64, 48);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(112, 24);
			this.label1.TabIndex = 102;
			this.label1.Text = "书籍编号:";
			this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			// 
			// label8
			// 
			this.label8.Dock = System.Windows.Forms.DockStyle.Top;
			this.label8.Font = new System.Drawing.Font("宋体", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.label8.ForeColor = System.Drawing.Color.Blue;
			this.label8.Location = new System.Drawing.Point(0, 0);
			this.label8.Name = "label8";
			this.label8.Size = new System.Drawing.Size(592, 24);
			this.label8.TabIndex = 101;
			this.label8.Text = "还书信息添加";
			this.label8.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
			// 
			// btn_cancel
			// 
			this.btn_cancel.BackColor = System.Drawing.Color.Silver;
			this.btn_cancel.Location = new System.Drawing.Point(352, 264);
			this.btn_cancel.Name = "btn_cancel";
			this.btn_cancel.Size = new System.Drawing.Size(72, 24);
			this.btn_cancel.TabIndex = 100;
			this.btn_cancel.Text = "取消(&C)";
			this.btn_cancel.TextAlign = System.Drawing.ContentAlignment.TopCenter;
			this.btn_cancel.Click += new System.EventHandler(this.btn_cancel_Click);
			// 
			// btn_sure
			// 
			this.btn_sure.BackColor = System.Drawing.Color.Silver;
			this.btn_sure.Location = new System.Drawing.Point(176, 264);
			this.btn_sure.Name = "btn_sure";
			this.btn_sure.Size = new System.Drawing.Size(72, 23);
			this.btn_sure.TabIndex = 99;
			this.btn_sure.Text = "确定(&S)";
			this.btn_sure.TextAlign = System.Drawing.ContentAlignment.TopCenter;
			this.btn_sure.Click += new System.EventHandler(this.btn_sure_Click);
			// 
			// insert_hsbook
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(255)), ((System.Byte)(192)), ((System.Byte)(255)));
			this.ClientSize = new System.Drawing.Size(592, 341);
			this.Controls.Add(this.txt_hsrq);
			this.Controls.Add(this.txt_hsbh);
			this.Controls.Add(this.txt_hdzbh);
			this.Controls.Add(this.txt_hbz);
			this.Controls.Add(this.label7);
			this.Controls.Add(this.label5);
			this.Controls.Add(this.label6);
			this.Controls.Add(this.label1);
			this.Controls.Add(this.label8);
			this.Controls.Add(this.btn_cancel);
			this.Controls.Add(this.btn_sure);
			this.ForeColor = System.Drawing.Color.Blue;
			this.Name = "insert_hsbook";
			this.Text = "还书信息界面";
			this.ResumeLayout(false);

		}
		#endregion

		private void btn_sure_Click(object sender, System.EventArgs e)
		{
			int i=0;
			StreamReader sr=new StreamReader("ts.ini",System.Text.Encoding.Default);
			string sn=sr.ReadLine();	
			SqlConnection conn=new SqlConnection(sn);	
			SqlCommand comm=new SqlCommand("Insert_hsxxb",conn);
			comm.CommandType=CommandType.StoredProcedure;
			comm.Parameters.Add("@hsbh",(this.txt_hsbh.Text));
			comm.Parameters.Add("@dzbh",(this.txt_hdzbh.Text));
			comm.Parameters.Add("@hsrq",(this.txt_hsrq.Text));
			comm.Parameters.Add("@bz",(this.txt_hbz.Text));
			try
			{
				conn.Open();
				i=comm.ExecuteNonQuery();
				if(i==1)
				{
				
					MessageBox.Show("添加成功!");
					this.Hide();
				}
				else
				{
				
					MessageBox.Show("已插入,不能再添加!");
				}	   
			}
			catch
			{
				MessageBox.Show("添加失败!");
			}
			finally
			{
				conn.Close();
			}
		
		}

		private void btn_cancel_Click(object sender, System.EventArgs e)
		{
			this.Close();
		}
	}
}

⌨️ 快捷键说明

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