資源簡(jiǎn)介
c#編寫(xiě)的簡(jiǎn)單抄電表軟件,有很詳細(xì)的注釋?zhuān)瑢?duì)初學(xué)者很有幫助

代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Data;
using?System.Data.SqlClient;
using?System.Drawing;
using?System.Linq;
using?System.Text;
using?System.Text.Regularexpressions;
using?System.Windows.Forms;
using?System.IO;
using?System.IO.Ports;
namespace?抄表軟件
{
????public?partial?class?Form1?:?Form
????{
????????static?SerialPort?com;
????????public?byte[]?dizhi?=?new?byte[6];?//?用來(lái)保存表內(nèi)通信地址?
????????public?Form1()
????????{
????????????InitializeComponent();
????????}
????????
????????private?void?Form1_Load(object?sender?EventArgs?e)
????????{
????????????com?=?new?SerialPort();
????????????//?初始化串口組合框
????????????combox.Items.Clear();
????????????foreach?(string?s?in?SerialPort.GetPortNames())
????????????{
????????????????combox.Items.Add(s.Trim());
????????????}
????????????if?(0?==?combox.Items.Count)
????????????{?MessageBox.Show(“當(dāng)前沒(méi)有可用的串口!“);
??????????????
????????????}
????????????//?初始化波特率組合框
????????????baudratebox.Items.Clear();
????????????baudratebox.Items.AddRange(new?object[]?{?600?1200?2400?4800?9600?19200?});
????????????
???????????
????????}
????private?void?dutongxun_Click(object?sender?EventArgs?e)
????????{
????????????byte[]?inputAddr?=?new?byte[6];?//?用來(lái)保存原先通信地址
????????????#region?設(shè)置并打開(kāi)串口
????????????//?根據(jù)協(xié)議對(duì)串口進(jìn)行設(shè)置
????????????com.PortName?=?SetPortName(com.PortName);???????//?串口名由用戶(hù)自己選擇
????????????com.BaudRate?=?SetPortBaudRate(com.BaudRate);???//?波特率由用戶(hù)自己選擇
????????????com.Parity?=?Parity.Even;???????????????????????????????//?偶校驗(yàn)
????????????com.DataBits?=?8;???????????????????????????????????????//?8位數(shù)據(jù)位
????????????com.StopBits?=?StopBits.One;????????????????????????????//?1位停止位
????????????com.Handshake?=?Handshake.None;
????????????//?設(shè)置讀/寫(xiě)延時(shí)
????????????com.ReadTimeout?=?500;
????????????com.WriteTimeout?=?500;
????????????try
????????????{
????????????????com.Open();
????????????}
????????????#region?catch塊
????????????catch?(InvalidOperationException)
????????????{
????????????????MessageBox.Show(“通訊失??!“?“提示“?MessageBoxButtons.OK?MessageBoxIcon.Error);
????????????????return;
????????????}
????????????catch?(ArgumentOutOfRangeException)
????????????{
????????????????MessageBox.Show(“通訊失??!“?“提示“?MessageBoxButtons.OK?MessageBoxIcon.Error);
????????????????return;
????????????}
????????????catch?(ArgumentException)
????????????{
????????????????MessageBox.Show(“通訊失??!“?“提示“?MessageBoxButtons.OK?MessageBoxIcon.Error);
????????????????return;
????????????}
????????????catch?(IOException)
????????????{
????????????????MessageBox.Show(“通訊失敗!“?“提示“?MessageBoxButtons.OK?MessageBoxIcon.Error);
????????????????return;
????????????}
????????????catch?(UnauthorizedAccessException)
????????????{
????????????????MessageBox.Show(“通訊失??!“?“提示“?MessageBoxButtons.OK?MessageBoxIcon.Error);
????????????????return;
????????????}
????????????#endregion
?????????
?屬性????????????大小?????日期????時(shí)間???名稱(chēng)
-----------?---------??----------?-----??----
?????文件???????5612??2011-12-09?14:04??抄表軟件\抄表軟件\Properties\Resources.resx
?????文件????????249??2011-12-09?14:04??抄表軟件\抄表軟件\Properties\Settings.settings
?????文件???????1380??2011-12-09?14:04??抄表軟件\抄表軟件\Properties\AssemblyInfo.cs
?????文件???????2874??2011-12-09?14:04??抄表軟件\抄表軟件\Properties\Resources.Designer.cs
?????文件???????1097??2011-12-09?14:04??抄表軟件\抄表軟件\Properties\Settings.Designer.cs
?????文件???????5814??2011-12-13?13:49??抄表軟件\抄表軟件\Form1.resx
?????文件??????52947??2011-12-13?14:25??抄表軟件\抄表軟件\Form1.cs
?????文件???????3770??2011-12-09?14:08??抄表軟件\抄表軟件\抄表軟件.csproj
?????文件????????490??2007-07-21?01:33??抄表軟件\抄表軟件\bin\Debug\抄表軟件.vshost.exe.manifest
?????文件??????14328??2011-12-13?14:33??抄表軟件\抄表軟件\bin\Debug\抄表軟件.vshost.exe
?????文件??????24064??2011-12-13?14:25??抄表軟件\抄表軟件\bin\Debug\抄表軟件.exe
?????文件??????46592??2011-12-13?14:25??抄表軟件\抄表軟件\bin\Debug\抄表軟件.pdb
?????文件????????180??2011-12-13?13:49??抄表軟件\抄表軟件\obj\Debug\抄表軟件.Form1.resources
?????文件????????180??2011-12-09?14:08??抄表軟件\抄表軟件\obj\Debug\抄表軟件.Properties.Resources.resources
?????文件??????24064??2011-12-13?14:25??抄表軟件\抄表軟件\obj\Debug\抄表軟件.exe
?????文件????????887??2011-12-13?14:33??抄表軟件\抄表軟件\obj\Debug\抄表軟件.csproj.FileListAbsolute.txt
?????文件??????46592??2011-12-13?14:25??抄表軟件\抄表軟件\obj\Debug\抄表軟件.pdb
?????文件????????847??2011-12-13?13:49??抄表軟件\抄表軟件\obj\Debug\抄表軟件.csproj.GenerateResource.Cache
?????文件??????13687??2011-12-13?13:49??抄表軟件\抄表軟件\Form1.Designer.cs
?????文件????????493??2011-12-09?14:04??抄表軟件\抄表軟件\Program.cs
?????文件????????926??2011-12-09?14:04??抄表軟件\抄表軟件.sln
????..A..H.?????14848??2011-12-13?14:42??抄表軟件\抄表軟件.suo
?????目錄??????????0??2011-12-09?14:04??抄表軟件\抄表軟件\obj\Debug\TempPE
?????目錄??????????0??2011-12-09?15:13??抄表軟件\抄表軟件\obj\Debug\Refactor
?????目錄??????????0??2011-12-09?14:04??抄表軟件\抄表軟件\bin\Debug
?????目錄??????????0??2011-12-09?14:04??抄表軟件\抄表軟件\obj\Debug
?????目錄??????????0??2011-12-09?14:04??抄表軟件\抄表軟件\Properties
?????目錄??????????0??2011-12-09?14:04??抄表軟件\抄表軟件\bin
?????目錄??????????0??2011-12-09?14:04??抄表軟件\抄表軟件\obj
?????目錄??????????0??2011-12-09?14:04??抄表軟件\抄表軟件
............此處省略4個(gè)文件信息
評(píng)論
共有 條評(píng)論