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

📄 主程序.cs

📁 射频卡读写程序,C#版
💻 CS
字号:
namespace 毕业设计
{
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data; 
using System.IO; 


namespace 射频卡
{
	/// <summary>
	/// Form1 的摘要说明。
	/// </summary>
	public class 管理系统 : System.Windows.Forms.Form
	{
		/// <summary>
		/// 必需的设计器变量。
		/// </summary>
		private System.ComponentModel.Container components = null;
		private System.Windows.Forms.MainMenu SysMenu;
		private System.Windows.Forms.MenuItem Exit;
		private System.Windows.Forms.MenuItem SystemMenu;
		private System.Windows.Forms.MenuItem ConfigMenu;
		private System.Windows.Forms.MenuItem ConfigMachine;
		private System.Windows.Forms.Button btnLogin;
		private System.Windows.Forms.Button btnCard;
		private System.Windows.Forms.Button btnScore;
		private System.Windows.Forms.Button btnFomartCard;
		private System.Windows.Forms.MenuItem ConfigDataBase;
		private System.Windows.Forms.MenuItem OpMachine;

		public OprationCard.OprationCrad Machine;

		public 管理系统()
		{
			//
			// 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.SysMenu = new System.Windows.Forms.MainMenu();
			this.SystemMenu = new System.Windows.Forms.MenuItem();
			this.Exit = new System.Windows.Forms.MenuItem();
			this.ConfigMenu = new System.Windows.Forms.MenuItem();
			this.ConfigMachine = new System.Windows.Forms.MenuItem();
			this.ConfigDataBase = new System.Windows.Forms.MenuItem();
			this.btnLogin = new System.Windows.Forms.Button();
			this.btnCard = new System.Windows.Forms.Button();
			this.btnScore = new System.Windows.Forms.Button();
			this.btnFomartCard = new System.Windows.Forms.Button();
			this.OpMachine = new System.Windows.Forms.MenuItem();
			this.SuspendLayout();
			// 
			// SysMenu
			// 
			this.SysMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																					this.SystemMenu,
																					this.ConfigMenu,
																					this.OpMachine});
			// 
			// SystemMenu
			// 
			this.SystemMenu.Index = 0;
			this.SystemMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																					   this.Exit});
			this.SystemMenu.Text = "系统";
			// 
			// Exit
			// 
			this.Exit.Index = 0;
			this.Exit.Text = "退出";
			// 
			// ConfigMenu
			// 
			this.ConfigMenu.Index = 1;
			this.ConfigMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																					   this.ConfigMachine,
																					   this.ConfigDataBase});
			this.ConfigMenu.Text = "配置";
			// 
			// ConfigMachine
			// 
			this.ConfigMachine.Index = 0;
			this.ConfigMachine.Text = "配置机器";
			this.ConfigMachine.Click += new System.EventHandler(this.ConfigMachine_Click);
			// 
			// ConfigDataBase
			// 
			this.ConfigDataBase.Index = 1;
			this.ConfigDataBase.Text = "配置数据库";
			this.ConfigDataBase.Click += new System.EventHandler(this.ConfigDataBase_Click);
			// 
			// btnLogin
			// 
			this.btnLogin.Location = new System.Drawing.Point(168, 16);
			this.btnLogin.Name = "btnLogin";
			this.btnLogin.TabIndex = 0;
			this.btnLogin.Text = "登录系统";
			this.btnLogin.Click += new System.EventHandler(this.btnLogin_Click);
			// 
			// btnCard
			// 
			this.btnCard.Location = new System.Drawing.Point(48, 16);
			this.btnCard.Name = "btnCard";
			this.btnCard.TabIndex = 1;
			this.btnCard.Text = "发卡系统";
			this.btnCard.Click += new System.EventHandler(this.CardSystem_Click);
			// 
			// btnScore
			// 
			this.btnScore.Location = new System.Drawing.Point(48, 64);
			this.btnScore.Name = "btnScore";
			this.btnScore.TabIndex = 2;
			this.btnScore.Text = "记分系统";
			this.btnScore.Click += new System.EventHandler(this.btnScore_Click);
			// 
			// btnFomartCard
			// 
			this.btnFomartCard.Location = new System.Drawing.Point(168, 64);
			this.btnFomartCard.Name = "btnFomartCard";
			this.btnFomartCard.TabIndex = 3;
			this.btnFomartCard.Text = "格式化卡";
			this.btnFomartCard.Click += new System.EventHandler(this.btnFomartCard_Click);
			// 
			// OpMachine
			// 
			this.OpMachine.Index = 2;
			this.OpMachine.Text = "读卡器";
			this.OpMachine.Click += new System.EventHandler(this.OpMachine_Click);
			// 
			// 管理系统
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(292, 105);
			this.Controls.Add(this.btnFomartCard);
			this.Controls.Add(this.btnScore);
			this.Controls.Add(this.btnCard);
			this.Controls.Add(this.btnLogin);
			this.Menu = this.SysMenu;
			this.Name = "管理系统";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "体育锻炼管理系统";
			this.Load += new System.EventHandler(this.Form1_Load);
			this.ResumeLayout(false);

		}
		#endregion

		/// <summary>
		/// 应用程序的主入口点。
		/// </summary>
		[STAThread]
		static void Main() 
		{
			Application.Run(new 管理系统());
		}

		

		private void Form1_Load(object sender, System.EventArgs e)
		{	
			while(!(new 毕业设计.数据处理.数据处理().TestConnect()))
			{
				MessageBox.Show("数据库连接失败!请检查服务器及配置!");
				if(MessageBox.Show("是否配置服务器?","不配置将退出程序",MessageBoxButtons.YesNo,MessageBoxIcon.Question,MessageBoxDefaultButton.Button1)==DialogResult.Yes)
				{
					this.Hide();
					毕业设计.软件系统.数据库配置 oo=new 毕业设计.软件系统.数据库配置();
					oo.ShowDialog(this);
					this.Show();
				}
				else
				{
				
					  Application.Exit();
						break;
				}
			}


			毕业设计.数据处理.数据处理 create=new 毕业设计.数据处理.数据处理();
			if(!create.ExitsDataBase("sportmanage"))
			{
				if(File.Exists("CreateTable.sql"))
				{
					System.IO.StreamReader rw=new StreamReader("CreateTable.sql");
					string TableSql=rw.ReadToEnd();
					rw.Close();
					if(create.Execute("create database sportmanage","master"))
					{
						if(create.Execute(TableSql,"sportmanage"))
						{
							MessageBox.Show("数据库建立成功!");
						}
						else
						{
							MessageBox.Show("数据库建立失败!");
						}
					}
					else
					{
						create.Execute("drop database sportmanage","master");
						MessageBox.Show("数据库建立失败!");
					}
				}
				else
				{
					MessageBox.Show("找不到数据库文件 或 CreateTable.sql!");
				}
			}
		}

		private void CardSystem_Click(object sender, System.EventArgs e)
		{
			this.Hide();
			毕业设计.射频卡.发卡系统 o=new 发卡系统();
			o.ShowDialog(this);
			this.Show();
		}

		private void ConfigMachine_Click(object sender, System.EventArgs e)
		{
			this.Hide();
			毕业设计.射频卡.读卡器配置 o=new 毕业设计.射频卡.读卡器配置();
			o.ShowDialog(this);
			this.Show();
		}

		private void btnLogin_Click(object sender, System.EventArgs e)
		{
			this.Hide();
			毕业设计.软件系统.登录 login=new 毕业设计.软件系统.登录();
			login.ShowDialog(this);
			this.Show();
		}

		private void btnScore_Click(object sender, System.EventArgs e)
		{
			this.Hide();
			毕业设计.软件系统.项目选择 o=new 毕业设计.软件系统.项目选择();
			o.Opration=1;
			o.ShowDialog();
			this.Show();
		}

		private void btnFomartCard_Click(object sender, System.EventArgs e)
		{
			this.Hide();
			毕业设计.射频卡.格式化系统 格式化=new 格式化系统();
			格式化.ShowDialog(this);
			this.Show();
		}

		private void ConfigDataBase_Click(object sender, System.EventArgs e)
		{
			this.Hide();
			毕业设计.软件系统.数据库配置 数据库配置=new 毕业设计.软件系统.数据库配置();
			数据库配置.ShowDialog(this);
			this.Show();
		}

		private void OpMachine_Click(object sender, System.EventArgs e)
		{
			this.Hide();
			毕业设计.射频卡.读卡器操作 读卡器=new 读卡器操作();
			读卡器.ShowDialog(this);
			this.Show();
		}
	}
}
}

⌨️ 快捷键说明

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