基本信息
源码名称:实现调用bartender打印条码
源码大小:9.09M
文件格式:.zip
开发语言:C#
更新时间:2020-04-07
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):78630559
本次赞助数额为: 2 元×
微信扫码支付:2 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
调用bartender软件进行打印操作,支持bartender9.4 10.0版本
调用bartender软件进行打印操作,支持bartender9.4 10.0版本
中节能代工唛头打印
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Oracle.ManagedDataAccess;
using Oracle.ManagedDataAccess.Client;
namespace WindowsFormsApp1
{
public partial class bartender : Form
{
// private BarTender.Application btapp;
BarTender.Application btApp=new BarTender.Application();
BarTender.Format btFormat;
// OpenFileDialog fileDlg = new OpenFileDialog();
public bartender()
{
InitializeComponent();
}
private void Form1_Load(object sender, KeyPressEventArgs e)
{
// btApp = new BarTender.Application();
}
private void button2_Click(object sender, EventArgs e)
{
OpenFileDialog fileDlg = new OpenFileDialog();
// 设置打开控件后,默认程序所在盘
fileDlg.InitialDirectory = Application.StartupPath;
// 设置控件打开的文件类型
//fileDlg.Filter = "hex files(*.hex)| *.hex";
// 设置控件打开文件类型的显示顺序
fileDlg.FilterIndex = 1;
// 设置对话框是否记忆之前打开的目录
fileDlg.RestoreDirectory = true;
if (fileDlg.ShowDialog() == DialogResult.OK)
{
file.Text = fileDlg.FileName;
}
}
private void button1_Click(object sender, EventArgs e)
{
if (textBox1.Text.Length == 0)
{
MessageBox.Show("未输入箱号");
}
else
{
string cartionid = textBox1.Text;
OracleConnection conn = null;
try
{
//获取与数据库的连接对象
conn = new OracleConnection();
//绑定连接字符串
conn.ConnectionString = "Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=10.0.24.13)(PORT=1521)) (CONNECT_DATA=(SERVICE_NAME=module)));Persist Security Info=True;User ID=mycim;Password=mycim;";
//开启连接
conn.Open();
OracleCommand cmd = conn.CreateCommand();
cmd.CommandText = "select max(nvl(case when ROWNUM = 1 then lp.lot_id end, 0)) tm1,"
" max(nvl(case when ROWNUM = 2 then lp.lot_id end, 0)) tm2,"
" max(nvl(case when ROWNUM = 3 then lp.lot_id end, 0)) tm3 ,"
" max(nvl(case when rownum = 4 then lp.lot_id end, 0)) tm4,"
" max(nvl(case when rownum = 5 then lp.lot_id end, 0)) tm5,"
" max(nvl(case when rownum = 6 then lp.lot_id end, 0)) tm6,"
" max(nvl(case when rownum = 7 then lp.lot_id end, 0)) tm7,"
" max(nvl(case when rownum = 8 then lp.lot_id end, 0)) tm8,"
" max(nvl(case when rownum = 9 then lp.lot_id end, 0)) tm9,"
" max(nvl(case when rownum = 10 then lp.lot_id end, 0)) tm10,"
" max(nvl(case when rownum = 11 then lp.lot_id end, 0)) tm11,"
" max(nvl(case when rownum = 12 then lp.lot_id end, 0)) tm12,"
" max(nvl(case when rownum = 13 then lp.lot_id end, 0)) tm13,"
" max(nvl(case when rownum = 14 then lp.lot_id end, 0)) tm14,"
" max(nvl(case when rownum = 15 then lp.lot_id end, 0)) tm15,"
" max(nvl(case when rownum = 16 then lp.lot_id end, 0)) tm16,"
" max(nvl(case when rownum = 17 then lp.lot_id end, 0)) tm17,"
" max(nvl(case when rownum = 18 then lp.lot_id end, 0)) tm18,"
" max(nvl(case when rownum = 19 then lp.lot_id end, 0)) tm19,"
" max(nvl(case when rownum = 20 then lp.lot_id end, 0)) tm20,"
" max(nvl(case when rownum = 21 then lp.lot_id end, 0)) tm21,"
" max(nvl(case when rownum = 22 then lp.lot_id end, 0)) tm22,"
" max(nvl(case when rownum = 23 then lp.lot_id end, 0)) tm23,"
" max(nvl(case when rownum = 24 then lp.lot_id end, 0)) tm24,"
" max(nvl(case when rownum = 25 then lp.lot_id end, 0)) tm25,"
" max(nvl(case when rownum = 26 then lp.lot_id end, 0)) tm26,"
" t.palletsmall,t.palletbig"
" from lot_package lp, pallet p,test009 t where lp.pallet_rrn = p.pallet_rrn and p.carton_id=t.cartonid and p.carton_id = " "'" cartionid "'"
"group by t.palletsmall,t.palletbig";
cmd.CommandType = CommandType.Text;
//执行并设置返回值
IDataReader reader = null;
reader = cmd.ExecuteReader();
while (reader.Read())
{
string tm1 = reader["tm1"].ToString();
string tm2 = reader["tm2"].ToString();
string tm3 = reader["tm3"].ToString();
string tm4 = reader["tm4"].ToString();
string tm5 = reader["tm5"].ToString();
string tm6 = reader["tm6"].ToString();
string tm7 = reader["tm7"].ToString();
string tm8 = reader["tm8"].ToString();
string tm9 = reader["tm9"].ToString();
string tm10 = reader["tm10"].ToString();
string tm11 = reader["tm11"].ToString();
string tm12 = reader["tm12"].ToString();
string tm13 = reader["tm13"].ToString();
string tm14 = reader["tm14"].ToString();
string tm15 = reader["tm15"].ToString();
string tm16 = reader["tm16"].ToString();
string tm17 = reader["tm17"].ToString();
string tm18 = reader["tm18"].ToString();
string tm19 = reader["tm19"].ToString();
string tm20 = reader["tm20"].ToString();
string tm21 = reader["tm21"].ToString();
string tm22 = reader["tm22"].ToString();
string tm23 = reader["tm23"].ToString();
string tm24 = reader["tm24"].ToString();
string tm25 = reader["tm25"].ToString();
string tm26 = reader["tm26"].ToString();
string palletsmall = reader["palletsmall"].ToString();
string palletbig = reader["palletbig"].ToString();
string moudle = Moudle.Text;
string qty = Qty.Text;
string weight = Weight.Text;
string grade = Grade.Text;
string File = file.Text;
// moudle = string(370);
switch (moudle.Trim())
{
case "350": number.Text = "50014778"; break;
case "355": number.Text = "50014783"; break;
case "360": number.Text = "50007313"; break;
case "365": number.Text = "50014792"; break;
case "370": number.Text = "50014797"; break;
case "375": number.Text = "50014802"; break;
}
btFormat = btApp.Formats.Open(File, false, "");
btFormat.PrintSetup.IdenticalCopiesOfLabel = 1; //设置同序列打印的份数
btFormat.PrintSetup.NumberSerializedLabels = 1; //设置需要打印的序列数
btFormat.SetNamedSubStringValue("tm1", tm1); //向bartender模板传递变量
btFormat.SetNamedSubStringValue("tm2", tm2); // 向bartender模板传递变量
btFormat.SetNamedSubStringValue("tm3", tm3); //向bartender模板传递变量
btFormat.SetNamedSubStringValue("tm4", tm4); //向bartender模板传递变量
btFormat.SetNamedSubStringValue("tm5", tm5); //向bartender模板传递变量
btFormat.SetNamedSubStringValue("tm6", tm6); //向bartender模板传递变量
btFormat.SetNamedSubStringValue("tm7", tm7); //向bartender模板传递变量
btFormat.SetNamedSubStringValue("tm8", tm8); //向bartender模板传递变量
btFormat.SetNamedSubStringValue("tm9", tm9); //向bartender模板传递变量
btFormat.SetNamedSubStringValue("tm10", tm10); //向bartender模板传递变量
btFormat.SetNamedSubStringValue("tm11", tm11); //向bartender模板传递变量
btFormat.SetNamedSubStringValue("tm12", tm12); //向bartender模板传递变量
btFormat.SetNamedSubStringValue("tm13", tm13); //向bartender模板传递变量
btFormat.SetNamedSubStringValue("tm14", tm14); //向bartender模板传递变量
btFormat.SetNamedSubStringValue("tm15", tm15); //向bartender模板传递变量
btFormat.SetNamedSubStringValue("tm16", tm16); //向bartender模板传递变量
btFormat.SetNamedSubStringValue("tm17", tm17); //向bartender模板传递变量
btFormat.SetNamedSubStringValue("tm18", tm18); //向bartender模板传递变量
btFormat.SetNamedSubStringValue("tm19", tm19); //向bartender模板传递变量
btFormat.SetNamedSubStringValue("tm20", tm20); //向bartender模板传递变量
btFormat.SetNamedSubStringValue("tm21", tm21); //向bartender模板传递变量
btFormat.SetNamedSubStringValue("tm22", tm22); //向bartender模板传递变量
btFormat.SetNamedSubStringValue("tm23", tm23); //向bartender模板传递变量
btFormat.SetNamedSubStringValue("tm24", tm24); //向bartender模板传递变量
btFormat.SetNamedSubStringValue("tm25", tm25); //向bartender模板传递变量
btFormat.SetNamedSubStringValue("tm26", tm26); //向bartender模板传递变量
btFormat.SetNamedSubStringValue("palletsmall", palletsmall); //向bartender模板传递变量
btFormat.SetNamedSubStringValue("palletbig", palletbig); //向bartender模板传递变量
btFormat.SetNamedSubStringValue("moudle", moudle); //向bartender模板传递变量
btFormat.SetNamedSubStringValue("qty", qty); //向bartender模板传递变量
btFormat.SetNamedSubStringValue("weight", weight); //向bartender模板传递变量
btFormat.SetNamedSubStringValue("grade", grade); //向bartender模板传递变量
btFormat.SetNamedSubStringValue("number", number.Text);
btFormat.PrintOut(false, false); //第二个false设置打印时是否跳出打印属性
btFormat.Close(BarTender.BtSaveOptions.btSaveChanges); //退出时是否保存标签
textBox1.Text = "";
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
finally
{
conn.Close();
}
}
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
private void bartender_Load(object sender, EventArgs e)
{
}
private void label3_Click(object sender, EventArgs e)
{
}
private void textBox3_TextChanged(object sender, EventArgs e)
{
}
private void label4_Click(object sender, EventArgs e)
{
}
private void reset_Click(object sender, EventArgs e)
{
textBox1.Text = "";
Moudle.Text = "";
Qty.Text = "";
Grade.Text = "";
Weight.Text = "";
}
}
}