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

📄 frm_roomtype.cs

📁 酒店管理,主要从事酒店管理都可以.这可是北大青鸟的程序
💻 CS
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using HotelApp;

namespace HotelApp
{
	/// <summary>
	/// frm_roomType 的摘要说明。
	/// </summary>
	public class frm_roomType : System.Windows.Forms.Form
	{
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.TextBox typeNmae;
		private System.Windows.Forms.Label label2;
		private System.Windows.Forms.TextBox description;
		private System.Windows.Forms.Button bt_canel;
		private System.Windows.Forms.Button bt_Excute;
		/// <summary>
		/// 必需的设计器变量。
		/// </summary>
		private System.ComponentModel.Container components = null;

		public frm_roomType()
		{
			//
			// 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.label1 = new System.Windows.Forms.Label();
			this.typeNmae = new System.Windows.Forms.TextBox();
			this.label2 = new System.Windows.Forms.Label();
			this.bt_Excute = new System.Windows.Forms.Button();
			this.bt_canel = new System.Windows.Forms.Button();
			this.description = new System.Windows.Forms.TextBox();
			this.SuspendLayout();
			// 
			// label1
			// 
			this.label1.Location = new System.Drawing.Point(16, 24);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(72, 23);
			this.label1.TabIndex = 0;
			this.label1.Text = "类型名称:";
			// 
			// typeNmae
			// 
			this.typeNmae.Location = new System.Drawing.Point(88, 16);
			this.typeNmae.Name = "typeNmae";
			this.typeNmae.TabIndex = 1;
			this.typeNmae.Text = "";
			// 
			// label2
			// 
			this.label2.Location = new System.Drawing.Point(16, 48);
			this.label2.Name = "label2";
			this.label2.TabIndex = 2;
			this.label2.Text = "类型描述:";
			// 
			// bt_Excute
			// 
			this.bt_Excute.Location = new System.Drawing.Point(200, 16);
			this.bt_Excute.Name = "bt_Excute";
			this.bt_Excute.Size = new System.Drawing.Size(56, 23);
			this.bt_Excute.TabIndex = 4;
			this.bt_Excute.Text = "确定(&Y)";
			this.bt_Excute.Click += new System.EventHandler(this.button1_Click);
			// 
			// bt_canel
			// 
			this.bt_canel.Location = new System.Drawing.Point(264, 16);
			this.bt_canel.Name = "bt_canel";
			this.bt_canel.Size = new System.Drawing.Size(56, 23);
			this.bt_canel.TabIndex = 5;
			this.bt_canel.Text = "取消(&N)";
			this.bt_canel.Click += new System.EventHandler(this.button2_Click);
			// 
			// description
			// 
			this.description.Location = new System.Drawing.Point(88, 48);
			this.description.Name = "description";
			this.description.Size = new System.Drawing.Size(232, 21);
			this.description.TabIndex = 6;
			this.description.Text = "";
			// 
			// frm_roomType
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(352, 93);
			this.Controls.Add(this.description);
			this.Controls.Add(this.bt_canel);
			this.Controls.Add(this.bt_Excute);
			this.Controls.Add(this.label2);
			this.Controls.Add(this.typeNmae);
			this.Controls.Add(this.label1);
			this.Name = "frm_roomType";
			this.Text = "新增房间类型";
			this.Load += new System.EventHandler(this.frm_roomType_Load);
			this.ResumeLayout(false);

		}
		#endregion

		private void button1_Click(object sender, System.EventArgs e)
		{
			DBService_2 mycon=new DBService_2();
			try
			{
				if(this.typeNmae.Text=="" || this.description.Text=="")
				{
					throw new Exception("请把资料填写完整!");
				}
				mycon.ExecuteNonQuery("INSERT INTO roomtype(typename,description) VALUES('"+this.typeNmae.Text + "','" + this.description.Text +"')");
				
				MessageBox.Show("成功保存!");
				this.Close();
				
			}
			catch(System.Data.Odbc.OdbcException ee)
			{
				MessageBox.Show("该房间名称已存在!");
				//MessageBox.Show(ee.Message);
				string a = ee.Message;
				this.typeNmae.Focus();
				this.typeNmae.SelectAll();

			}
			catch(Exception ex)
			{
				MessageBox.Show(ex.Message);
				this.typeNmae.Focus();
			}
		}

		private void frm_roomType_Load(object sender, System.EventArgs e)
		{
		
		}

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

	
	}
}

⌨️ 快捷键说明

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