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

📄 form1.cs

📁 在。NET中利用VB6.0的控件来现实对串口的操作来完成短信发送的功能
💻 CS
📖 第 1 页 / 共 2 页
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Text;

namespace Sms
{
	/// <summary>
	/// Form1 的摘要说明。
	/// </summary>
	public class Form1 : System.Windows.Forms.Form
	{
		private AxMSCommLib.AxMSComm axMSComm1;
		private System.Windows.Forms.Button Open_Button;
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.Label label2;
		private System.Windows.Forms.Label label3;
		private System.Windows.Forms.Label label4;
		private System.Windows.Forms.Label label5;
		private System.Windows.Forms.Label label6;
		private System.Windows.Forms.Button Save_Button;
		private System.Windows.Forms.ComboBox BitRatio_ComboBox;
		private System.Windows.Forms.TextBox Interval_TextBox;
		private System.Windows.Forms.ComboBox Parity_ComboBox;
		private System.Windows.Forms.ComboBox DataBit_ComboBox;
		private System.Windows.Forms.ComboBox Digit_ComboBox;
		private System.Windows.Forms.ComboBox CommPort_omboBox;
		private System.Windows.Forms.Button Default_Button;
		private System.Windows.Forms.Timer timer1;
		private System.ComponentModel.IContainer components;

		private DataAccess dataAccess = new DataAccess();
		DataTable smsInform = null;

		public Form1()
		{
			//
			// Windows 窗体设计器支持所必需的
			//
			InitializeComponent();

			//
			// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
			//
		}

		/// <summary>
		/// 清理所有正在使用的资源。
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if (components != null) 
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{
			this.components = new System.ComponentModel.Container();
			System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));
			this.axMSComm1 = new AxMSCommLib.AxMSComm();
			this.Open_Button = new System.Windows.Forms.Button();
			this.label1 = new System.Windows.Forms.Label();
			this.label2 = new System.Windows.Forms.Label();
			this.label3 = new System.Windows.Forms.Label();
			this.label4 = new System.Windows.Forms.Label();
			this.label5 = new System.Windows.Forms.Label();
			this.Interval_TextBox = new System.Windows.Forms.TextBox();
			this.label6 = new System.Windows.Forms.Label();
			this.BitRatio_ComboBox = new System.Windows.Forms.ComboBox();
			this.Parity_ComboBox = new System.Windows.Forms.ComboBox();
			this.DataBit_ComboBox = new System.Windows.Forms.ComboBox();
			this.Digit_ComboBox = new System.Windows.Forms.ComboBox();
			this.CommPort_omboBox = new System.Windows.Forms.ComboBox();
			this.Save_Button = new System.Windows.Forms.Button();
			this.Default_Button = new System.Windows.Forms.Button();
			this.timer1 = new System.Windows.Forms.Timer(this.components);
			((System.ComponentModel.ISupportInitialize)(this.axMSComm1)).BeginInit();
			this.SuspendLayout();
			// 
			// axMSComm1
			// 
			this.axMSComm1.Enabled = true;
			this.axMSComm1.Location = new System.Drawing.Point(16, 232);
			this.axMSComm1.Name = "axMSComm1";
			this.axMSComm1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axMSComm1.OcxState")));
			this.axMSComm1.Size = new System.Drawing.Size(38, 38);
			this.axMSComm1.TabIndex = 0;
			this.axMSComm1.OnComm += new System.EventHandler(this.axMSComm1_OnComm);
			// 
			// Open_Button
			// 
			this.Open_Button.Location = new System.Drawing.Point(24, 24);
			this.Open_Button.Name = "Open_Button";
			this.Open_Button.Size = new System.Drawing.Size(64, 23);
			this.Open_Button.TabIndex = 5;
			this.Open_Button.Text = "打开端口";
			this.Open_Button.Click += new System.EventHandler(this.Open_Button_Click);
			// 
			// label1
			// 
			this.label1.Location = new System.Drawing.Point(24, 66);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(100, 16);
			this.label1.TabIndex = 12;
			this.label1.Text = "波特率:";
			// 
			// label2
			// 
			this.label2.Location = new System.Drawing.Point(24, 93);
			this.label2.Name = "label2";
			this.label2.Size = new System.Drawing.Size(100, 22);
			this.label2.TabIndex = 13;
			this.label2.Text = "奇偶校验位:";
			// 
			// label3
			// 
			this.label3.Location = new System.Drawing.Point(24, 126);
			this.label3.Name = "label3";
			this.label3.Size = new System.Drawing.Size(100, 20);
			this.label3.TabIndex = 14;
			this.label3.Text = "数据位:";
			// 
			// label4
			// 
			this.label4.Location = new System.Drawing.Point(24, 157);
			this.label4.Name = "label4";
			this.label4.Size = new System.Drawing.Size(100, 18);
			this.label4.TabIndex = 15;
			this.label4.Text = "停止位:";
			// 
			// label5
			// 
			this.label5.Location = new System.Drawing.Point(24, 186);
			this.label5.Name = "label5";
			this.label5.Size = new System.Drawing.Size(100, 16);
			this.label5.TabIndex = 16;
			this.label5.Text = "端口号:";
			// 
			// Interval_TextBox
			// 
			this.Interval_TextBox.Location = new System.Drawing.Point(136, 214);
			this.Interval_TextBox.Name = "Interval_TextBox";
			this.Interval_TextBox.Size = new System.Drawing.Size(120, 21);
			this.Interval_TextBox.TabIndex = 8;
			this.Interval_TextBox.Text = "";
			// 
			// label6
			// 
			this.label6.Location = new System.Drawing.Point(24, 216);
			this.label6.Name = "label6";
			this.label6.Size = new System.Drawing.Size(104, 16);
			this.label6.TabIndex = 16;
			this.label6.Text = "访问间隔(毫秒):";
			// 
			// BitRatio_ComboBox
			// 
			this.BitRatio_ComboBox.Items.AddRange(new object[] {
																   "9600",
																   "1200",
																   "2400",
																   "4800",
																   "19200",
																   "38400",
																   "57600",
																   "115200",
																   "230400",
																   "460800",
																   "921600"});
			this.BitRatio_ComboBox.Location = new System.Drawing.Point(136, 64);
			this.BitRatio_ComboBox.Name = "BitRatio_ComboBox";
			this.BitRatio_ComboBox.Size = new System.Drawing.Size(120, 20);
			this.BitRatio_ComboBox.TabIndex = 18;
			// 
			// Parity_ComboBox
			// 
			this.Parity_ComboBox.Items.AddRange(new object[] {
																 "无",
																 "偶校验",
																 "奇校验",
																 "标记",
																 "空格"});
			this.Parity_ComboBox.Location = new System.Drawing.Point(136, 94);
			this.Parity_ComboBox.Name = "Parity_ComboBox";
			this.Parity_ComboBox.Size = new System.Drawing.Size(120, 20);
			this.Parity_ComboBox.TabIndex = 18;
			// 
			// DataBit_ComboBox
			// 
			this.DataBit_ComboBox.Items.AddRange(new object[] {
																  "8",
																  "5",
																  "6",
																  "7"});
			this.DataBit_ComboBox.Location = new System.Drawing.Point(136, 124);
			this.DataBit_ComboBox.Name = "DataBit_ComboBox";
			this.DataBit_ComboBox.Size = new System.Drawing.Size(120, 20);
			this.DataBit_ComboBox.TabIndex = 18;
			// 
			// Digit_ComboBox
			// 
			this.Digit_ComboBox.Items.AddRange(new object[] {
																"1",
																"1.5",
																"2"});
			this.Digit_ComboBox.Location = new System.Drawing.Point(136, 154);
			this.Digit_ComboBox.Name = "Digit_ComboBox";
			this.Digit_ComboBox.Size = new System.Drawing.Size(120, 20);
			this.Digit_ComboBox.TabIndex = 18;
			// 
			// CommPort_omboBox
			// 
			this.CommPort_omboBox.Items.AddRange(new object[] {
																  "COM1",
																  "COM2",
																  "COM3",
																  "COM4"});
			this.CommPort_omboBox.Location = new System.Drawing.Point(136, 184);
			this.CommPort_omboBox.Name = "CommPort_omboBox";
			this.CommPort_omboBox.Size = new System.Drawing.Size(120, 20);
			this.CommPort_omboBox.TabIndex = 18;
			// 
			// Save_Button
			// 
			this.Save_Button.Location = new System.Drawing.Point(108, 24);
			this.Save_Button.Name = "Save_Button";
			this.Save_Button.Size = new System.Drawing.Size(64, 23);
			this.Save_Button.TabIndex = 19;
			this.Save_Button.Text = "保存设置";
			this.Save_Button.Click += new System.EventHandler(this.Save_Button_Click);
			// 
			// Default_Button
			// 
			this.Default_Button.Location = new System.Drawing.Point(192, 24);
			this.Default_Button.Name = "Default_Button";
			this.Default_Button.Size = new System.Drawing.Size(64, 23);
			this.Default_Button.TabIndex = 20;
			this.Default_Button.Text = "设置默认";
			this.Default_Button.Click += new System.EventHandler(this.Default_Button_Click);
			// 
			// timer1
			// 
			this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
			// 
			// Form1
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(292, 273);
			this.Controls.AddRange(new System.Windows.Forms.Control[] {
																		  this.Default_Button,
																		  this.Save_Button,
																		  this.BitRatio_ComboBox,
																		  this.label5,
																		  this.label4,
																		  this.label3,
																		  this.label2,
																		  this.label1,
																		  this.Open_Button,
																		  this.axMSComm1,
																		  this.Interval_TextBox,

⌨️ 快捷键说明

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