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

📄 读卡器配置.cs

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

	namespace 射频卡
	{
		/// <summary>
		/// Config 的摘要说明。
		/// </summary>
		public class 读卡器配置 : System.Windows.Forms.Form
		{
			private System.Windows.Forms.Label label1;
			private System.Windows.Forms.Label label2;
			private System.Windows.Forms.Button btnConfirm;
			private System.Windows.Forms.Button btnCancel;
			private System.Windows.Forms.ComboBox cmbPort;
			private System.Windows.Forms.ComboBox cmbSpeed;
			private System.Windows.Forms.Label label3;
			private System.Windows.Forms.Label label6;
			private System.Windows.Forms.ComboBox cmbSecNo;
			private System.Windows.Forms.ComboBox cmdMode;
			/// <summary>
			/// 必需的设计器变量。
			/// </summary>
			private System.ComponentModel.Container components = null;

			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.label1 = new System.Windows.Forms.Label();
				this.label2 = new System.Windows.Forms.Label();
				this.btnConfirm = new System.Windows.Forms.Button();
				this.btnCancel = new System.Windows.Forms.Button();
				this.cmbSpeed = new System.Windows.Forms.ComboBox();
				this.cmbPort = new System.Windows.Forms.ComboBox();
				this.label3 = new System.Windows.Forms.Label();
				this.label6 = new System.Windows.Forms.Label();
				this.cmbSecNo = new System.Windows.Forms.ComboBox();
				this.cmdMode = new System.Windows.Forms.ComboBox();
				this.SuspendLayout();
				// 
				// label1
				// 
				this.label1.Location = new System.Drawing.Point(8, 32);
				this.label1.Name = "label1";
				this.label1.TabIndex = 0;
				this.label1.Text = "端口";
				this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
				// 
				// label2
				// 
				this.label2.Location = new System.Drawing.Point(8, 80);
				this.label2.Name = "label2";
				this.label2.TabIndex = 1;
				this.label2.Text = "传输率";
				this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
				// 
				// btnConfirm
				// 
				this.btnConfirm.Location = new System.Drawing.Point(48, 208);
				this.btnConfirm.Name = "btnConfirm";
				this.btnConfirm.TabIndex = 2;
				this.btnConfirm.Text = "确定";
				this.btnConfirm.Click += new System.EventHandler(this.btnConfirm_Click);
				// 
				// btnCancel
				// 
				this.btnCancel.Location = new System.Drawing.Point(152, 208);
				this.btnCancel.Name = "btnCancel";
				this.btnCancel.TabIndex = 3;
				this.btnCancel.Text = "取消";
				this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
				// 
				// cmbSpeed
				// 
				this.cmbSpeed.Items.AddRange(new object[] {
															  "9600",
															  "14400",
															  "19200",
															  "38400",
															  "57600",
															  "115200"});
				this.cmbSpeed.Location = new System.Drawing.Point(128, 80);
				this.cmbSpeed.Name = "cmbSpeed";
				this.cmbSpeed.Size = new System.Drawing.Size(104, 20);
				this.cmbSpeed.TabIndex = 5;
				this.cmbSpeed.Text = "9600";
				// 
				// cmbPort
				// 
				this.cmbPort.Items.AddRange(new object[] {
															 "COM1",
															 "COM2",
															 "COM3",
															 "COM4",
															 "COM5",
															 "COM6",
															 "COM7",
															 "COM8"});
				this.cmbPort.Location = new System.Drawing.Point(128, 32);
				this.cmbPort.Name = "cmbPort";
				this.cmbPort.Size = new System.Drawing.Size(104, 20);
				this.cmbPort.TabIndex = 6;
				this.cmbPort.Text = "COM1";
				// 
				// label3
				// 
				this.label3.Location = new System.Drawing.Point(8, 160);
				this.label3.Name = "label3";
				this.label3.TabIndex = 7;
				this.label3.Text = "读写模式";
				this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
				// 
				// label6
				// 
				this.label6.Location = new System.Drawing.Point(8, 120);
				this.label6.Name = "label6";
				this.label6.TabIndex = 10;
				this.label6.Text = "读写扇区";
				this.label6.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
				// 
				// cmbSecNo
				// 
				this.cmbSecNo.Items.AddRange(new object[] {
															  "0",
															  "1",
															  "2",
															  "3",
															  "4",
															  "5",
															  "6",
															  "7",
															  "8",
															  "9",
															  "10",
															  "11",
															  "12",
															  "13",
															  "14",
															  "15"});
				this.cmbSecNo.Location = new System.Drawing.Point(128, 120);
				this.cmbSecNo.Name = "cmbSecNo";
				this.cmbSecNo.Size = new System.Drawing.Size(104, 20);
				this.cmbSecNo.TabIndex = 11;
				this.cmbSecNo.Text = "2";
				// 
				// cmdMode
				// 
				this.cmdMode.Items.AddRange(new object[] {
															 "0",
															 "1"});
				this.cmdMode.Location = new System.Drawing.Point(128, 160);
				this.cmdMode.Name = "cmdMode";
				this.cmdMode.Size = new System.Drawing.Size(104, 20);
				this.cmdMode.TabIndex = 12;
				this.cmdMode.Text = "1";
				// 
				// Config
				// 
				this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
				this.ClientSize = new System.Drawing.Size(292, 246);
				this.Controls.Add(this.cmdMode);
				this.Controls.Add(this.cmbSecNo);
				this.Controls.Add(this.label6);
				this.Controls.Add(this.label3);
				this.Controls.Add(this.cmbPort);
				this.Controls.Add(this.cmbSpeed);
				this.Controls.Add(this.btnCancel);
				this.Controls.Add(this.btnConfirm);
				this.Controls.Add(this.label2);
				this.Controls.Add(this.label1);
				this.Name = "Config";
				this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
				this.Text = "配置程序";
				this.Load += new System.EventHandler(this.Config_Load);
				this.ResumeLayout(false);

			}
			#endregion

			private void btnConfirm_Click(object sender, System.EventArgs e)
			{
				System.Data.DataSet o=new System.Data.DataSet();
				System.Data.DataTable tb=new System.Data.DataTable();
				tb.Columns.Add("PORT",System.Type.GetType("System.String"));
				tb.Columns.Add("SPEED",System.Type.GetType("System.String"));
				tb.Columns.Add("SECNO",System.Type.GetType("System.String"));
				tb.Columns.Add("MODE",System.Type.GetType("System.String"));
				o.Tables.Add(tb);
				System.Data.DataRow dr=o.Tables[0].NewRow();
				dr[0]=cmbPort.Text;
				dr[1]=cmbSpeed.Text;
				dr[2]=this.cmbSecNo.Text;
				dr[3]=this.cmdMode.Text;
				o.Tables[0].Rows.Add(dr);
				o.WriteXml("Machine.Config",System.Data.XmlWriteMode.WriteSchema);
				this.Close();
			}

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

			private void Config_Load(object sender, System.EventArgs e)
			{
				System.Data.DataSet o=new System.Data.DataSet();
				try
				{
					o.ReadXml("Machine.Config");
					cmbPort.Text=o.Tables[0].Rows[0][0].ToString();
					cmbSpeed.Text=o.Tables[0].Rows[0][1].ToString();
					this.cmbSecNo.Text=o.Tables[0].Rows[0][2].ToString();
					this.cmdMode.Text=o.Tables[0].Rows[0][3].ToString();
				}
				catch
				{
					MessageBox.Show("配置文件丢失,请配置程序!");
				}
			}
		}
	}
}

⌨️ 快捷键说明

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