• 大小: 0.20M
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2024-06-16
  • 语言: C#
  • 标签:

资源简介

核心代码:
                btFormat = btAPP.Formats.Open(System.Windows.Forms.Application.StartupPath @"\1.btw", false, "");
                btFormat.PrintSetup.IdenticalCopiesOfLabel = 1;//打印份数
                btFormat.PrintSetup.NumberSerializedLabels = 1;//序列标签数
                btFormat.SetNamedSubStringValue("打印文本", txtMemo.Text.Trim());
                btFormat.SetNamedSubStringValue("打印条码", txtBarcode.Text.Trim());
                btFormat.PrintOut(true, true);//第二个false设置打印时是否跳出打印属性
                btFormat.Close(BarTender.BtSaveOptions.btDoNotSaveChanges); //退出时是否保存标签

二、基本原理:
    1、先设计好Btw模板
    2、代码调用模板去打印 



using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace BarTenderDemo
{
    public partial class Form1 : Form
    {
        private BarTender.Application btAPP;
        private BarTender.Format btFormat;

        //SELECT MaterielId,ProductBigPackId,NetWeight,GrossWeight,num 
        //FROM Make_ProductBigPack mpb
        //LEFT JOIN Make_TaskInfo mti ON mpb.TaskId=mti.TaskId
        //WHERE ProductBigPackId=''

        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            btAPP = new BarTender.Application();
        }

        private void btPrint_Click(object sender, EventArgs e)
        {
            try
            {
                btFormat = btAPP.Formats.Open(System.Windows.Forms.Application.StartupPath @"\1.btw", false, "");
                btFormat.PrintSetup.IdenticalCopiesOfLabel = 1;//打印份数
                btFormat.PrintSetup.NumberSerializedLabels = 1;//序列标签数
                btFormat.SetNamedSubStringValue("打印文本", txtMemo.Text.Trim());
                btFormat.SetNamedSubStringValue("打印条码", txtBarcode.Text.Trim());
                btFormat.PrintOut(true, true);//第二个false设置打印时是否跳出打印属性
                btFormat.Close(BarTender.BtSaveOptions.btSaveChanges); //退出时是否保存标签
            }
            catch(Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

        private void Form1_FormClosed(object sender, FormClosedEventArgs e)
        {
            btAPP.Quit(BarTender.BtSaveOptions.btSaveChanges);//界面退出时同步退出bartender进程
        }
    }
}

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace BarTenderDemo
{
    public partial class Form1 : Form
    {
        private BarTender.Application btAPP;
        private BarTender.Format btFormat;

        //SELECT MaterielIdProductBigPackIdNetWeightGrossWeightnum 
        //FROM Make_ProductBigPack mpb
        //LEFT JOIN Make_TaskInfo mti ON mpb.TaskId=mti.TaskId
        //WHERE ProductBigPackId=‘‘

        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender EventArgs e)
        {
            btAPP = new BarTender.Application();
        }

        private void btPrint_Click(object sender EventArgs e)
        {
            try
            {
                btFormat = btAPP.Formats.Open(System.Windows.Forms.Application.StartupPath+@“\1.btw“ false ““);
                btFormat.PrintSetup.IdenticalCopiesOfLabel = 1;//打印份数
                btFormat.PrintSetup.NumberSerializedLabels = 1;//序列标签数
                btFormat.SetNamedSubStringValue(“打印文本“ txtMemo.Text.Trim());
                btFormat.SetNamedSubStringValue(“打印条码“ txtBarcode.Text.Trim());
                btFormat.PrintOut(true true);//第二个false设置打印时是否跳出打印属性
                btFormat.Close(BarTender.BtSaveOptions.btSaveChanges); //退出时是否保存标签
            }
            catch(Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

        private void Form1_FormClosed(object sender FormClosedEventArgs e)
        {
            btAPP.Quit(BarTender.BtSaveOptions.btSaveChanges);//界面退出时同步退出bartender进程
        }
    }
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件      10212  2017-03-30 11:10  BarTender二次开发示例\1.btw

     文件      10212  2018-03-07 17:55  BarTender二次开发示例\BarTenderDemo\1.btw

     文件       3793  2018-03-07 17:56  BarTender二次开发示例\BarTenderDemo\BarTenderDemo.csproj

     文件      10212  2018-03-07 17:55  BarTender二次开发示例\BarTenderDemo\bin\Debug\1.btw

     文件       9728  2018-03-07 17:58  BarTender二次开发示例\BarTenderDemo\bin\Debug\BarTenderDemo.exe

     文件      22016  2018-03-07 17:58  BarTender二次开发示例\BarTenderDemo\bin\Debug\BarTenderDemo.pdb

     文件      11592  2018-03-07 17:58  BarTender二次开发示例\BarTenderDemo\bin\Debug\BarTenderDemo.vshost.exe

     文件        490  2013-06-18 20:24  BarTender二次开发示例\BarTenderDemo\bin\Debug\BarTenderDemo.vshost.exe.manifest

     文件     143360  2018-03-07 17:58  BarTender二次开发示例\BarTenderDemo\bin\Debug\Interop.BarTender.dll

     文件       1897  2018-03-07 17:58  BarTender二次开发示例\BarTenderDemo\Form1.cs

     文件       4295  2017-03-01 14:23  BarTender二次开发示例\BarTenderDemo\Form1.Designer.cs

     文件       5814  2017-03-01 14:23  BarTender二次开发示例\BarTenderDemo\Form1.resx

     文件       2326  2018-03-07 17:58  BarTender二次开发示例\BarTenderDemo\obj\Debug\BarTenderDemo.csproj.FileListAbsolute.txt

     文件        847  2018-03-07 17:58  BarTender二次开发示例\BarTenderDemo\obj\Debug\BarTenderDemo.csproj.GenerateResource.Cache

     文件        575  2018-03-07 17:58  BarTender二次开发示例\BarTenderDemo\obj\Debug\BarTenderDemo.csproj.ResolveComReference.cache

     文件       9728  2018-03-07 17:58  BarTender二次开发示例\BarTenderDemo\obj\Debug\BarTenderDemo.exe

     文件        180  2018-03-07 17:58  BarTender二次开发示例\BarTenderDemo\obj\Debug\BarTenderDemo.Form1.resources

     文件      22016  2018-03-07 17:58  BarTender二次开发示例\BarTenderDemo\obj\Debug\BarTenderDemo.pdb

     文件        180  2018-03-07 17:58  BarTender二次开发示例\BarTenderDemo\obj\Debug\BarTenderDemo.Properties.Resources.resources

     文件     143360  2018-03-07 17:58  BarTender二次开发示例\BarTenderDemo\obj\Debug\Interop.BarTender.dll

     文件        474  2017-02-28 11:27  BarTender二次开发示例\BarTenderDemo\Program.cs

     文件       1358  2017-02-28 11:27  BarTender二次开发示例\BarTenderDemo\Properties\AssemblyInfo.cs

     文件       2876  2017-02-28 11:27  BarTender二次开发示例\BarTenderDemo\Properties\Resources.Designer.cs

     文件       5612  2017-02-28 11:27  BarTender二次开发示例\BarTenderDemo\Properties\Resources.resx

     文件       1098  2017-02-28 11:27  BarTender二次开发示例\BarTenderDemo\Properties\Settings.Designer.cs

     文件        249  2017-02-28 11:27  BarTender二次开发示例\BarTenderDemo\Properties\Settings.settings

     文件        929  2017-02-28 11:27  BarTender二次开发示例\BarTenderDemo.sln

     文件     275536  2014-11-08 12:11  BarTender二次开发示例\Seagull.BarTender.Print.dll

     文件        709  2018-07-15 11:39  BarTender二次开发示例\说明.txt

    ..AD...         0  2018-03-07 17:58  BarTender二次开发示例\BarTenderDemo\obj\Debug\Refactor

............此处省略11个文件信息

评论

共有 条评论

相关资源