• 大小: 44KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-12-02
  • 语言: C#
  • 标签:

资源简介

简单的一个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 < send.Length; 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个文件信息

评论

共有 条评论

相关资源