資源簡介
簡單的一個DEMO,因為不同的小票打印機指令不同,DEMO里只是使用了一個切紙的指令。

代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Data;
using?System.Drawing;
using?System.Drawing.Printing;
using?System.IO;
using?System.Text;
using?System.Windows.Forms;
namespace?Pos80Demo
{
????public?partial?class?frmMain?:?Form
????{
????????public?frmMain()
????????{
????????????InitializeComponent();
????????}
???????
???
????????LptControl?lc?=?new?LptControl(“lpt1“);
????????private?void?btnOpen_Click(object?sender?EventArgs?e)
????????{
????????????if(txtLpt.Text.Trim()?==?““)
????????????{
????????????????MessageBox.Show(“LPT端口不能為空!“);
????????????????return;
????????????}
????????????lc?=?new?LptControl(txtLpt.Text);
????????????if?(!lc.Open())
????????????{
????????????????ShowMessage(“打開LPT端口失敗!“);
????????????????return;
????????????}
????????????btnOpen.Enabled?=?false;
????????????btnClose.Enabled?=?true;
????????????btnSendCmd.Enabled?=?true;
????????}
????????private?void?btnClose_Click(object?sender?EventArgs?e)
????????{
????????????lc.Close();
????????????btnOpen.Enabled?=?true;
????????????btnSendCmd.Enabled?=?false;
????????????btnClose.Enabled?=?false;
????????}
????????private?void?btnSendCmd_Click(object?sender?EventArgs?e)
????????{
????????????if?(txtText.Text.Trim()?==?string.Empty)
????????????{
????????????????MessageBox.Show(“文本不能為空“);
????????????????return;
????????????}
????????????if?(!lc.Write(txtText.Text?+?“\n“))
????????????{
????????????????ShowMessage(“打印文本失敗!“);
????????????????return;
????????????}
????????????else
????????????{
????????????????ShowMessage(“打印文本成功!“);
????????????}
????????????if?(chkAutoCutPaper.Checked)
????????????{
????????????????string?send?=?““?+?(char)‘\n‘?+?(char)(29)?+?(char)(86)?+?(char)(66)?+?(char)(10)?+?(char)‘\n‘;
????????????????byte[]?buf?=?new?byte[send.Length];
????????????????for?(int?i?=?0;?i?????????????????{
????????????????????buf[i]?=?(byte)send[i];
????????????????}
????????????????if?(lc.Write(buf))
????????????????????ShowMessage(“執行切紙成功!“);
????????????????else
????????????????????ShowMessage(“執行切紙失敗!“);
????????????}
????????}
????????private?void?ShowMessage(string?msg)
????????{
????????????txtMessage.AppendText(msg);
????????????txtMessage.AppendText(“\r\n“);
????????}
????????private?string?GetPrintStr(string?hospitalNamestring?trueNamestring?queueNostring?departmentstring?roomNameint?count)
????????{
????????????StringBuilder?sb?=?new?StringBuilder();
????????????sb.Append(“?“?+?hospitalName?+?“?\r\n“);
????????????sb.Append(“------------------------------------------------\r\n“);
????????????sb.Append(“日期:“?+?DateTime.Now.ToShortDateString()?+?“\r\n“);
????????????sb.Append(“------------------------------------------------\r\n“);
????????????if(trueName?!=?string.Empty)
????????????????sb.Append(“姓名:\t“?+?trueName?+?“\r\n“);
????????????if?(queueNo?!=?stri
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件??????13312??2012-06-22?13:27??Pos80Demo\bin\Debug\Pos80Demo.exe
?????文件??????32256??2012-06-22?13:27??Pos80Demo\bin\Debug\Pos80Demo.pdb
?????文件??????14328??2012-06-22?13:28??Pos80Demo\bin\Debug\Pos80Demo.vshost.exe
?????文件???????4185??2012-06-22?13:32??Pos80Demo\frmMain.cs
?????文件???????7939??2012-06-22?13:22??Pos80Demo\frmMain.Designer.cs
?????文件???????5814??2012-06-22?13:22??Pos80Demo\frmMain.resx
?????文件???????2442??2012-06-22?11:25??Pos80Demo\LptControl.cs
?????文件????????548??2012-06-22?13:28??Pos80Demo\obj\Debug\Pos80Demo.csproj.FileListAbsolute.txt
?????文件????????849??2012-06-22?13:22??Pos80Demo\obj\Debug\Pos80Demo.csproj.GenerateResource.Cache
?????文件??????13312??2012-06-22?13:27??Pos80Demo\obj\Debug\Pos80Demo.exe
?????文件????????180??2012-06-22?13:22??Pos80Demo\obj\Debug\Pos80Demo.frmMain.resources
?????文件??????32256??2012-06-22?13:27??Pos80Demo\obj\Debug\Pos80Demo.pdb
?????文件????????180??2012-06-22?13:22??Pos80Demo\obj\Debug\Pos80Demo.Properties.Resources.resources
?????文件???????3401??2012-06-22?13:22??Pos80Demo\Pos80Demo.csproj
?????文件????????472??2012-06-21?21:08??Pos80Demo\Program.cs
?????文件???????1362??2012-06-20?23:27??Pos80Demo\Properties\AssemblyInfo.cs
?????文件???????2868??2012-06-20?23:27??Pos80Demo\Properties\Resources.Designer.cs
?????文件???????5612??2012-06-20?23:27??Pos80Demo\Properties\Resources.resx
?????文件???????1094??2012-06-20?23:27??Pos80Demo\Properties\Settings.Designer.cs
?????文件????????249??2012-06-20?23:27??Pos80Demo\Properties\Settings.settings
?????文件????????917??2012-06-20?23:28??Pos80Demo.sln
????..A..H.?????14848??2012-06-22?13:29??Pos80Demo.suo
?????目錄??????????0??2012-06-20?23:29??Pos80Demo\obj\Debug\Refactor
?????目錄??????????0??2012-06-20?23:27??Pos80Demo\obj\Debug\TempPE
?????目錄??????????0??2012-06-22?13:23??Pos80Demo\bin\Debug
?????目錄??????????0??2012-06-22?13:22??Pos80Demo\obj\Debug
?????目錄??????????0??2012-06-22?13:10??Pos80Demo\bin
?????目錄??????????0??2012-06-20?23:27??Pos80Demo\obj
?????目錄??????????0??2012-06-20?23:27??Pos80Demo\Properties
?????目錄??????????0??2012-06-22?13:32??Pos80Demo
............此處省略3個文件信息
- 上一篇:鮮花銷售管理系統.zip
- 下一篇:C#英文詞頻統計-統計單詞出現次數
評論
共有 條評論