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

📄 sysivn.cs

📁 此为本人和同学所开发的酒店管理系统.C#.net.也是软件工程课程的作业.
💻 CS
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data ;
using System.Data .SqlClient ;

namespace RoomManage
{
	/// <summary>
	/// sysivn 的摘要说明。
	/// </summary>
	public class sysivn : System.Windows.Forms.Form
	{
		private System.Windows.Forms.GroupBox groupBox1;
		private System.Windows.Forms.Button button1;
		private System.Windows.Forms.CheckBox checkBox1;
		private System.Windows.Forms.CheckBox checkBox2;
		private System.Windows.Forms.CheckBox checkBox3;
		private System.Windows.Forms.CheckBox checkBox4;
		private System.Windows.Forms.CheckBox checkBox5;
		private System.Windows.Forms.CheckBox checkBox7;
		private System.Windows.Forms.CheckBox checkBox8;
		private System.Windows.Forms.GroupBox groupBox2;
		private System.Windows.Forms.Button button2;
		private System.Windows.Forms.Button button3;
		private System.Windows.Forms.Button button4;
		private System.Windows.Forms.GroupBox groupBox3;
		/// <summary>
		/// 必需的设计器变量。
		/// </summary>
		private System.ComponentModel.Container components = null;

		DataConn dc=new DataConn ();

		public sysivn()
		{
			//
			// 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.groupBox1 = new System.Windows.Forms.GroupBox();
			this.checkBox1 = new System.Windows.Forms.CheckBox();
			this.checkBox2 = new System.Windows.Forms.CheckBox();
			this.checkBox3 = new System.Windows.Forms.CheckBox();
			this.checkBox4 = new System.Windows.Forms.CheckBox();
			this.checkBox5 = new System.Windows.Forms.CheckBox();
			this.checkBox7 = new System.Windows.Forms.CheckBox();
			this.checkBox8 = new System.Windows.Forms.CheckBox();
			this.button1 = new System.Windows.Forms.Button();
			this.groupBox2 = new System.Windows.Forms.GroupBox();
			this.button2 = new System.Windows.Forms.Button();
			this.button3 = new System.Windows.Forms.Button();
			this.button4 = new System.Windows.Forms.Button();
			this.groupBox3 = new System.Windows.Forms.GroupBox();
			this.groupBox1.SuspendLayout();
			this.groupBox2.SuspendLayout();
			this.SuspendLayout();
			// 
			// groupBox1
			// 
			this.groupBox1.Controls.Add(this.checkBox1);
			this.groupBox1.Controls.Add(this.checkBox2);
			this.groupBox1.Controls.Add(this.checkBox3);
			this.groupBox1.Controls.Add(this.checkBox4);
			this.groupBox1.Controls.Add(this.checkBox5);
			this.groupBox1.Controls.Add(this.checkBox7);
			this.groupBox1.Controls.Add(this.checkBox8);
			this.groupBox1.Location = new System.Drawing.Point(2, 2);
			this.groupBox1.Name = "groupBox1";
			this.groupBox1.Size = new System.Drawing.Size(232, 120);
			this.groupBox1.TabIndex = 0;
			this.groupBox1.TabStop = false;
			this.groupBox1.Text = "选择要清空的表";
			// 
			// checkBox1
			// 
			this.checkBox1.Location = new System.Drawing.Point(16, 16);
			this.checkBox1.Name = "checkBox1";
			this.checkBox1.TabIndex = 0;
			this.checkBox1.Text = "本单位信息表";
			// 
			// checkBox2
			// 
			this.checkBox2.Location = new System.Drawing.Point(16, 40);
			this.checkBox2.Name = "checkBox2";
			this.checkBox2.Size = new System.Drawing.Size(88, 24);
			this.checkBox2.TabIndex = 0;
			this.checkBox2.Text = "部门信息表";
			// 
			// checkBox3
			// 
			this.checkBox3.Location = new System.Drawing.Point(16, 64);
			this.checkBox3.Name = "checkBox3";
			this.checkBox3.Size = new System.Drawing.Size(64, 24);
			this.checkBox3.TabIndex = 0;
			this.checkBox3.Text = "登记表";
			// 
			// checkBox4
			// 
			this.checkBox4.Location = new System.Drawing.Point(16, 88);
			this.checkBox4.Name = "checkBox4";
			this.checkBox4.Size = new System.Drawing.Size(88, 24);
			this.checkBox4.TabIndex = 0;
			this.checkBox4.Text = "客房信息表";
			// 
			// checkBox5
			// 
			this.checkBox5.Location = new System.Drawing.Point(136, 16);
			this.checkBox5.Name = "checkBox5";
			this.checkBox5.Size = new System.Drawing.Size(88, 24);
			this.checkBox5.TabIndex = 0;
			this.checkBox5.Text = "客房预定表";
			// 
			// checkBox7
			// 
			this.checkBox7.Location = new System.Drawing.Point(136, 40);
			this.checkBox7.Name = "checkBox7";
			this.checkBox7.Size = new System.Drawing.Size(64, 24);
			this.checkBox7.TabIndex = 0;
			this.checkBox7.Text = "退房表";
			// 
			// checkBox8
			// 
			this.checkBox8.Location = new System.Drawing.Point(136, 64);
			this.checkBox8.Name = "checkBox8";
			this.checkBox8.Size = new System.Drawing.Size(88, 24);
			this.checkBox8.TabIndex = 0;
			this.checkBox8.Text = "员工信息表";
			// 
			// button1
			// 
			this.button1.Location = new System.Drawing.Point(172, 14);
			this.button1.Name = "button1";
			this.button1.Size = new System.Drawing.Size(48, 23);
			this.button1.TabIndex = 1;
			this.button1.Text = "退出";
			this.button1.Click += new System.EventHandler(this.button1_Click);
			// 
			// groupBox2
			// 
			this.groupBox2.Controls.Add(this.button1);
			this.groupBox2.Controls.Add(this.button2);
			this.groupBox2.Controls.Add(this.button3);
			this.groupBox2.Controls.Add(this.button4);
			this.groupBox2.Controls.Add(this.groupBox3);
			this.groupBox2.Location = new System.Drawing.Point(2, 122);
			this.groupBox2.Name = "groupBox2";
			this.groupBox2.Size = new System.Drawing.Size(232, 46);
			this.groupBox2.TabIndex = 2;
			this.groupBox2.TabStop = false;
			// 
			// button2
			// 
			this.button2.Location = new System.Drawing.Point(8, 14);
			this.button2.Name = "button2";
			this.button2.Size = new System.Drawing.Size(48, 23);
			this.button2.TabIndex = 1;
			this.button2.Text = "清空";
			this.button2.Click += new System.EventHandler(this.button2_Click);
			// 
			// button3
			// 
			this.button3.Location = new System.Drawing.Point(56, 14);
			this.button3.Name = "button3";
			this.button3.Size = new System.Drawing.Size(48, 23);
			this.button3.TabIndex = 1;
			this.button3.Text = "全选";
			this.button3.Click += new System.EventHandler(this.button3_Click);
			// 
			// button4
			// 
			this.button4.Location = new System.Drawing.Point(104, 14);
			this.button4.Name = "button4";
			this.button4.Size = new System.Drawing.Size(48, 23);
			this.button4.TabIndex = 1;
			this.button4.Text = "重选";
			this.button4.Click += new System.EventHandler(this.button4_Click);
			// 
			// groupBox3
			// 
			this.groupBox3.Location = new System.Drawing.Point(160, 1);
			this.groupBox3.Name = "groupBox3";
			this.groupBox3.Size = new System.Drawing.Size(2, 48);
			this.groupBox3.TabIndex = 1;
			this.groupBox3.TabStop = false;
			// 
			// sysivn
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(240, 173);
			this.ControlBox = false;
			this.Controls.Add(this.groupBox2);
			this.Controls.Add(this.groupBox1);
			this.MaximizeBox = false;
			this.MaximumSize = new System.Drawing.Size(248, 200);
			this.MinimizeBox = false;
			this.MinimumSize = new System.Drawing.Size(248, 200);
			this.Name = "sysivn";
			this.ShowInTaskbar = false;
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
			this.Text = "系统初始化";
			this.TopMost = true;
			this.groupBox1.ResumeLayout(false);
			this.groupBox2.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion

		private void button1_Click(object sender, System.EventArgs e)
		{
			if(MessageBox.Show("真的要退出吗?","注意",MessageBoxButtons.OKCancel,MessageBoxIcon.Question)==DialogResult.OK)
				this.Close ();
		}

		private void button3_Click(object sender, System.EventArgs e)
		{
			checkBox1.Checked =true;
			checkBox2.Checked =true;
			checkBox3.Checked =true;
			checkBox4.Checked =true;
			checkBox5.Checked =true;
			checkBox7.Checked =true;
			checkBox8.Checked =true;
		}

		private void button4_Click(object sender, System.EventArgs e)
		{
			checkBox1.Checked =false;
			checkBox2.Checked =false;
			checkBox3.Checked =false;
			checkBox4.Checked =false;
			checkBox5.Checked =false;
			checkBox7.Checked =false;
			checkBox8.Checked =false;
		}

		private void button2_Click(object sender, System.EventArgs e)
		{
			if(MessageBox.Show("真的要清空所选择的表吗?","注意",MessageBoxButtons.OKCancel,MessageBoxIcon.Question)==DialogResult.OK)
			{
				string str=dc.connstr ;
				SqlConnection conn=new SqlConnection (str);
				string sql;
				string temp="";
				int num=0;//选择表的数目
				if(checkBox1.Checked ==true)
				{
					sql="TRUNCATE TABLE tabbdwdy";
					SqlCommand cmd=new SqlCommand (sql,conn);
					conn.Open ();
					cmd.ExecuteNonQuery ();
				
					conn.Close ();
					cmd.Dispose ();
				
					temp=temp+"本单位信息表 ";
					num++;
				}
				if(checkBox2.Checked ==true)
				{
					sql="TRUNCATE TABLE tabbmdy";
					SqlCommand cmd=new SqlCommand (sql,conn);
					conn.Open ();
					cmd.ExecuteNonQuery ();
				
					conn.Close ();
					cmd.Dispose ();
				
					temp=temp+"部门信息表 ";
					num++;
				}
				if(checkBox3.Checked ==true)
				{
					sql="TRUNCATE TABLE tabdjb";
					SqlCommand cmd=new SqlCommand (sql,conn);
					conn.Open ();
					cmd.ExecuteNonQuery ();
				
					conn.Close ();
					cmd.Dispose ();
				
					temp=temp+"登记表 ";
					num++;
				}
				if(checkBox4.Checked ==true)
				{
					sql="TRUNCATE TABLE tabkfinfo";
					SqlCommand cmd=new SqlCommand (sql,conn);
					conn.Open ();
					cmd.ExecuteNonQuery ();
				
					conn.Close ();
					cmd.Dispose ();
				
					temp=temp+"客房信息表 ";
					num++;
				}
				if(checkBox5.Checked ==true)
				{
					sql="TRUNCATE TABLE tabkfyd";
					SqlCommand cmd=new SqlCommand (sql,conn);
					conn.Open ();
					cmd.ExecuteNonQuery ();
				
					conn.Close ();
					cmd.Dispose ();
				
					temp=temp+"客房预定表 ";
					num++;
				}
				if(checkBox7.Checked ==true)
				{
					sql="TRUNCATE TABLE tabtfd";
					SqlCommand cmd=new SqlCommand (sql,conn);
					conn.Open ();
					cmd.ExecuteNonQuery ();
				
					conn.Close ();
					cmd.Dispose ();
				
					temp=temp+"退房表 ";
					num++;
				}
				if(checkBox8.Checked ==true)
				{
					sql="TRUNCATE TABLE tabyginfo";
					SqlCommand cmd=new SqlCommand (sql,conn);
					conn.Open ();
					cmd.ExecuteNonQuery ();
				
					conn.Close ();
					cmd.Dispose ();
				
					temp=temp+"员工信息表 ";
					num++;
				}
				if(num==0)
				{
					MessageBox.Show ("您没有选择任何表!");
				}
				if(num==7)
				{
					MessageBox.Show ("您已经成功清空了所有表!");
				}
				if(num>0&num<7)
				{
					MessageBox.Show ("您已经成功清除了"+temp);
				}
			}
		}
	}
}

⌨️ 快捷键说明

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