|
|
@@ -15,8 +15,8 @@ using UAS_LabelMachine.PublicForm;
|
|
|
using System.Threading;
|
|
|
using System.IO;
|
|
|
using System.Globalization;
|
|
|
-using System.Threading.Tasks;
|
|
|
using System.Reflection;
|
|
|
+using Seagull.BarTender.Print;
|
|
|
|
|
|
namespace UAS_LabelMachine
|
|
|
{
|
|
|
@@ -27,6 +27,8 @@ namespace UAS_LabelMachine
|
|
|
|
|
|
DataHelper dh;
|
|
|
|
|
|
+ Engine engine;
|
|
|
+
|
|
|
DataTable dt;
|
|
|
/// <summary>
|
|
|
/// 已经打印过的Vivo外箱号
|
|
|
@@ -94,7 +96,7 @@ namespace UAS_LabelMachine
|
|
|
|
|
|
Dictionary<string, string> CollectData;
|
|
|
//缓存单盘数据数据的DataTable
|
|
|
- DataTable SingleBoxCacheData;
|
|
|
+ public static DataTable SingleBoxCacheData;
|
|
|
/// <summary>
|
|
|
/// 存放单盘的ID
|
|
|
/// </summary>
|
|
|
@@ -106,7 +108,7 @@ namespace UAS_LabelMachine
|
|
|
/// <summary>
|
|
|
/// 中盒缓存数据
|
|
|
/// </summary>
|
|
|
- DataTable MidBoxCacheData;
|
|
|
+ public static DataTable MidBoxCacheData;
|
|
|
/// <summary>
|
|
|
/// 存放中盒的ID和盒号
|
|
|
/// </summary>
|
|
|
@@ -144,7 +146,9 @@ namespace UAS_LabelMachine
|
|
|
|
|
|
List<string> OutParam = new List<string>();
|
|
|
|
|
|
- DataTable Attach;
|
|
|
+ public static DataTable Attach;
|
|
|
+
|
|
|
+ string PrintMethod = "CodeSoft";
|
|
|
|
|
|
public UAS_出货标签打印(string Master)
|
|
|
{
|
|
|
@@ -157,7 +161,7 @@ namespace UAS_LabelMachine
|
|
|
Text = Text + "-" + Master;
|
|
|
}
|
|
|
|
|
|
- protected override void WndProc(ref Message m)
|
|
|
+ protected override void WndProc(ref System.Windows.Forms.Message m)
|
|
|
{
|
|
|
//拦截双击标题栏、移动窗体的系统消息
|
|
|
if (m.Msg != 0xA3)
|
|
|
@@ -243,14 +247,23 @@ namespace UAS_LabelMachine
|
|
|
}
|
|
|
asc.controllInitializeSize(this);
|
|
|
asc.controlAutoSize(this);
|
|
|
- //实例化打印进程
|
|
|
- try
|
|
|
+ //实例化打印进程,如果没有配置默认使用BarTener
|
|
|
+ string Code = dh.GetConfig("", "").ToString();
|
|
|
+ if (Code == "")
|
|
|
{
|
|
|
- lbl = new ApplicationClass();
|
|
|
+ try
|
|
|
+ {
|
|
|
+ lbl = new ApplicationClass();
|
|
|
+ }
|
|
|
+ catch (Exception)
|
|
|
+ {
|
|
|
+ MessageBox.Show("未安装CodeSoft软件或者版本不正确");
|
|
|
+ }
|
|
|
}
|
|
|
- catch (Exception)
|
|
|
+ else
|
|
|
{
|
|
|
- MessageBox.Show("未安装CodeSoft软件或者版本不正确");
|
|
|
+ engine = new Engine(true);
|
|
|
+ PrintMethod = "BarTender";
|
|
|
}
|
|
|
RefreshDBConnect.Interval = 60000;
|
|
|
RefreshDBConnect.Start();
|
|
|
@@ -562,13 +575,7 @@ namespace UAS_LabelMachine
|
|
|
CurrentRowIndex = i;
|
|
|
if (SingleLabelAutoPrint.Checked)
|
|
|
{
|
|
|
- if (la_id != "")
|
|
|
- AutoPrintSingleLabel(la_id, LabelUrl);
|
|
|
- else
|
|
|
- {
|
|
|
- MessageBox.Show("未维护单盘标签");
|
|
|
- return;
|
|
|
- }
|
|
|
+ AutoPrintSingleLabel();
|
|
|
}
|
|
|
if (MidLabelAutoPrint.Checked)
|
|
|
AutoPrintMidLabel();
|
|
|
@@ -603,7 +610,7 @@ namespace UAS_LabelMachine
|
|
|
string la_id = SingleLabelCombox.SelectedValue.ToString().Split('#')[0];
|
|
|
string cl_labelname = SingleLabelCombox.Text;
|
|
|
string LabelUrl = dh.getFieldDataByCondition("label left join customerlabel on la_code=cl_labelcode", "cl_labelurl", "la_id='" + la_id + "' and cl_labelname='" + cl_labelname + "'").ToString();
|
|
|
- AutoPrintSingleLabel(la_id, LabelUrl);
|
|
|
+ AutoPrintSingleLabel();
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
@@ -676,38 +683,15 @@ namespace UAS_LabelMachine
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void AutoPrintSingleLabel(string la_id, string LabelUrl)
|
|
|
+ private void AutoPrintSingleLabel()
|
|
|
{
|
|
|
//用标签本身的变量作为最外层的循环条件去匹配;
|
|
|
string[] arg = SingleBoxArgument.ToArray();
|
|
|
- StringBuilder ParamLog = new StringBuilder();
|
|
|
- for (int j = 0; j < SingleDoc.Variables.FreeVariables.Count; j++)
|
|
|
+ string pib_id = LabelInf.Rows[CurrentRowIndex].Cells["pib_id1"].Value.ToString();
|
|
|
+ if (PrintMethod == "CodeSoft")
|
|
|
{
|
|
|
- //将维护的模板参数和模板本身的参数名称进行比对
|
|
|
- for (int k = 0; k < SingleLabelParam.Rows.Count; k++)
|
|
|
- {
|
|
|
- //名称相等的时候,取SQL进行值的查询
|
|
|
- if (SingleDoc.Variables.FreeVariables.Item(j + 1).Name == SingleLabelParam.Rows[k]["lp_name"].ToString().ToLower())
|
|
|
- {
|
|
|
- string pib_id = LabelInf.Rows[CurrentRowIndex].Cells["pib_id1"].Value.ToString();
|
|
|
- DataRow[] dr = SingleBoxCacheData.Select("pib_id=" + pib_id);
|
|
|
- if (arg.Contains(SingleDoc.Variables.FreeVariables.Item(j + 1).Name))
|
|
|
- SingleDoc.Variables.FreeVariables.Item(j + 1).Value = dr[0][SingleDoc.Variables.FreeVariables.Item(j + 1).Name].ToString();
|
|
|
- if (SingleDoc.Variables.FreeVariables.Item(j + 1).Value == "")
|
|
|
- {
|
|
|
- DataRow[] dr1 = Attach.Select("lp_name='" + SingleDoc.Variables.FreeVariables.Item(j + 1).Name + "'");
|
|
|
- if (dr1.Length > 0)
|
|
|
- {
|
|
|
- SingleDoc.Variables.FreeVariables.Item(j + 1).Value = dr1[0]["lp_sql"].ToString();
|
|
|
- }
|
|
|
- }
|
|
|
- ParamLog.AppendLine("pib_id:" + LabelInf.Rows[CurrentRowIndex].Cells["pib_id1"].Value.ToString() + ",SingleDoc打印参数【" + SingleDoc.Variables.FreeVariables.Item(j + 1).Name + "】赋值," + "取到值" + SingleDoc.Variables.FreeVariables.Item(j + 1).Value);
|
|
|
- }
|
|
|
- }
|
|
|
+ Print.CodeSoft.SinglePrint(SingleDoc, arg, pib_id);
|
|
|
}
|
|
|
- LogManager.DoLog(ParamLog.ToString());
|
|
|
- SingleDoc.Printer.SwitchTo(SingleLabelPrinter.Text);
|
|
|
- SingleDoc.PrintDocument();
|
|
|
LabelInf.Rows[CurrentRowIndex].Cells["pib_ifprint"].Value = true;
|
|
|
}
|
|
|
|
|
|
@@ -1056,6 +1040,7 @@ namespace UAS_LabelMachine
|
|
|
if (SingleLabelCombox.Text != "")
|
|
|
{
|
|
|
SingleDoc = lbl.Documents.Open(ftpOperater.DownLoadTo + SingleLabelCombox.Text);
|
|
|
+ SingleDoc.Printer.SwitchTo(SingleLabelPrinter.Text);
|
|
|
SingleLabelParam = (DataTable)dh.ExecuteSql("select lp_name,lp_sql from label left join LABELPARAMETER on la_id= lp_laid where la_id=" + SingleLabelCombox.SelectedValue.ToString().Split('#')[0], "select");
|
|
|
for (int i = 0; i < SingleDoc.Variables.FreeVariables.Count; i++)
|
|
|
{
|
|
|
@@ -1085,6 +1070,7 @@ namespace UAS_LabelMachine
|
|
|
if (MidLabelCombox.Text != "")
|
|
|
{
|
|
|
MidDoc = lbl.Documents.Open(ftpOperater.DownLoadTo + MidLabelCombox.Text);
|
|
|
+ MidDoc.Printer.SwitchTo(MidLabelPrinter.Text);
|
|
|
MidLabelParam = (DataTable)dh.ExecuteSql("select lp_name,lp_sql from label left join LABELPARAMETER on la_id= lp_laid where la_id=" + MidLabelCombox.SelectedValue.ToString().Split('#')[0], "select");
|
|
|
}
|
|
|
//缓存中盒参数
|
|
|
@@ -1111,6 +1097,7 @@ namespace UAS_LabelMachine
|
|
|
if (OutBoxCombox.Text != "")
|
|
|
{
|
|
|
OutBoxDoc = lbl.Documents.Open(ftpOperater.DownLoadTo + OutBoxCombox.Text);
|
|
|
+ OutBoxDoc.Printer.SwitchTo(OutBoxPrinter.Text);
|
|
|
OutLabelParam = (DataTable)dh.ExecuteSql("select lp_name,lp_sql,lp_valuetype from label left join LABELPARAMETER on la_id= lp_laid where la_id=" + OutBoxCombox.SelectedValue.ToString().Split('#')[0], "select");
|
|
|
}
|
|
|
//缓存外箱参数
|
|
|
@@ -1270,25 +1257,8 @@ namespace UAS_LabelMachine
|
|
|
try
|
|
|
{
|
|
|
string pib_id = LabelInf.Rows[i].Cells["pib_id1"].Value.ToString();
|
|
|
- DataRow[] dr = SingleBoxCacheData.Select("pib_id=" + pib_id);
|
|
|
- StringBuilder ParamLog = new StringBuilder();
|
|
|
- for (int j = 0; j < SingleDoc.Variables.FreeVariables.Count; j++)
|
|
|
- {
|
|
|
- if (arg.Contains(SingleDoc.Variables.FreeVariables.Item(j + 1).Name))
|
|
|
- SingleDoc.Variables.FreeVariables.Item(j + 1).Value = dr[0][SingleDoc.Variables.FreeVariables.Item(j + 1).Name].ToString();
|
|
|
- if (SingleDoc.Variables.FreeVariables.Item(j + 1).Value == "")
|
|
|
- {
|
|
|
- DataRow[] dr1 = Attach.Select("lp_name='" + SingleDoc.Variables.FreeVariables.Item(j + 1).Name + "'");
|
|
|
- if (dr1.Length > 0)
|
|
|
- {
|
|
|
- SingleDoc.Variables.FreeVariables.Item(j + 1).Value = dr1[0]["lp_sql"].ToString();
|
|
|
- }
|
|
|
- }
|
|
|
- ParamLog.AppendLine("pib_id:" + LabelInf.Rows[i].Cells["pib_id1"].Value.ToString() + ",SingleDoc打印参数【" + SingleDoc.Variables.FreeVariables.Item(j + 1).Name + "】赋值," + "取到值" + SingleDoc.Variables.FreeVariables.Item(j + 1).Value);
|
|
|
- }
|
|
|
- LogManager.DoLog(ParamLog.ToString());
|
|
|
- SingleDoc.Printer.SwitchTo(SingleLabelPrinter.Text);
|
|
|
- SingleDoc.PrintDocument();
|
|
|
+ if (PrintMethod == "CodeSoft")
|
|
|
+ Print.CodeSoft.SinglePrint(SingleDoc, arg, pib_id);
|
|
|
if (MidLabelAutoPrint.Checked)
|
|
|
{
|
|
|
//判断当前行的盒号和下一行不相等或者已经是最后一行了
|
|
|
@@ -1299,7 +1269,7 @@ namespace UAS_LabelMachine
|
|
|
if (MidLabelCombox.SelectedValue != null)
|
|
|
{
|
|
|
string la_id_mid = MidLabelCombox.SelectedValue.ToString().Split('#')[0];
|
|
|
- MidBoxCodePrint(la_id_mid, CurrentRowIndex);
|
|
|
+ MidBoxCodePrint(CurrentRowIndex);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -1590,7 +1560,7 @@ namespace UAS_LabelMachine
|
|
|
GetMidBoxData();
|
|
|
for (int i = 0; i < MidOutBoxCodeIndex.Count; i++)
|
|
|
{
|
|
|
- MidBoxCodePrint(la_id, MidOutBoxCodeIndex[i]);
|
|
|
+ MidBoxCodePrint(MidOutBoxCodeIndex[i]);
|
|
|
}
|
|
|
MidBoxArgument.Clear();
|
|
|
MidBoxCacheData.Clear();
|
|
|
@@ -1620,7 +1590,7 @@ namespace UAS_LabelMachine
|
|
|
}
|
|
|
//找到了指定的盒号
|
|
|
if (FindMidLabel)
|
|
|
- MidBoxCodePrint(la_id, MidLabelRowIndex, MidRowIndex.ToArray());
|
|
|
+ MidBoxCodePrint(MidLabelRowIndex);
|
|
|
else
|
|
|
MessageBox.Show("该出入库单未找到该中盒号!");
|
|
|
}
|
|
|
@@ -1673,7 +1643,7 @@ namespace UAS_LabelMachine
|
|
|
{
|
|
|
if (LabelInf.Rows[h].Cells["pib_outboxcode2"].Value.ToString() == Outboxcode.ToArray()[i])
|
|
|
{
|
|
|
- OutBoxCodePrint(la_id, h);
|
|
|
+ OutBoxCodePrint(h);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
@@ -1705,7 +1675,7 @@ namespace UAS_LabelMachine
|
|
|
}
|
|
|
//找到了指定的盒号
|
|
|
if (FindMidLabel)
|
|
|
- OutBoxCodePrint(la_id, OutBoxLabelRowIndex);
|
|
|
+ OutBoxCodePrint(OutBoxLabelRowIndex);
|
|
|
else
|
|
|
MessageBox.Show("该出入库单未找到该外箱号!");
|
|
|
}
|
|
|
@@ -1714,179 +1684,32 @@ namespace UAS_LabelMachine
|
|
|
Outboxcode.Clear();
|
|
|
}
|
|
|
|
|
|
- private void MidBoxCodePrint(string la_id, int rowindex)
|
|
|
+ private void MidBoxCodePrint(int rowindex)
|
|
|
{
|
|
|
if (MidBoxCacheData.Rows.Count == 0)
|
|
|
{
|
|
|
MidIDAndOutboxcode.Add(LabelInf.Rows[rowindex].Cells["pib_id1"].Value.ToString(), LabelInf.Rows[rowindex].Cells["pib_outboxcode1"].Value.ToString());
|
|
|
GetMidBoxData();
|
|
|
}
|
|
|
- DataTable dt = (DataTable)dh.ExecuteSql("select lp_name,lp_sql from label left join LABELPARAMETER on la_id= lp_laid where la_id=" + la_id, "select");
|
|
|
string[] arg = MidBoxArgument.ToArray();
|
|
|
- for (int j = 0; j < MidDoc.Variables.FreeVariables.Count; j++)
|
|
|
- {
|
|
|
- //将维护的模板参数和模板本身的参数名称进行比对
|
|
|
- for (int k = 0; k < MidLabelParam.Rows.Count; k++)
|
|
|
- {
|
|
|
- //名称相等的时候,取SQL进行值的查询
|
|
|
- if (MidDoc.Variables.FreeVariables.Item(j + 1).Name == MidLabelParam.Rows[k]["lp_name"].ToString())
|
|
|
- {
|
|
|
- //获取对应行的pib_id
|
|
|
- string pib_id = LabelInf.Rows[rowindex].Cells["pib_id1"].Value.ToString();
|
|
|
- string pib_outboxcode1 = LabelInf.Rows[rowindex].Cells["pib_outboxcode1"].Value.ToString();
|
|
|
- //获取打印执行的SQL
|
|
|
- string sql = MidLabelParam.Rows[k]["lp_sql"].ToString();
|
|
|
- try
|
|
|
- {
|
|
|
- //获取打印执行的SQL
|
|
|
- if (sql.IndexOf("{") == 0)
|
|
|
- {
|
|
|
- MidDoc.Variables.FreeVariables.Item(j + 1).Value = dh.GetLabelParam(sql).ToString();
|
|
|
- LogManager.DoLog("打印参数【" + MidDoc.Variables.FreeVariables.Item(j + 1).Name + "】赋值," + "取值SQL:" + dt.Rows[k]["lp_sql"].ToString() + ",取到值" + MidDoc.Variables.FreeVariables.Item(j + 1).Value);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- DataRow[] dr = MidBoxCacheData.Select("pib_outboxcode1='" + pib_outboxcode1 + "'");
|
|
|
- if (arg.Contains(MidDoc.Variables.FreeVariables.Item(j + 1).Name))
|
|
|
- {
|
|
|
- if (dr.Length > 0)
|
|
|
- {
|
|
|
- MidDoc.Variables.FreeVariables.Item(j + 1).Value = dr[0][MidDoc.Variables.FreeVariables.Item(j + 1).Name].ToString();
|
|
|
- }
|
|
|
- }
|
|
|
- if (MidDoc.Variables.FreeVariables.Item(j + 1).Value == "")
|
|
|
- {
|
|
|
- DataRow[] dr1 = Attach.Select("lp_name='" + MidDoc.Variables.FreeVariables.Item(j + 1).Name + "'");
|
|
|
- if (dr1.Length > 0)
|
|
|
- {
|
|
|
- MidDoc.Variables.FreeVariables.Item(j + 1).Value = dr1[0]["lp_sql"].ToString();
|
|
|
- }
|
|
|
- }
|
|
|
- LogManager.DoLog("打印参数【" + MidDoc.Variables.FreeVariables.Item(j + 1).Name + "】赋值," + "取值SQL:" + sql + ",取到值" + MidDoc.Variables.FreeVariables.Item(j + 1).Value);
|
|
|
- }
|
|
|
- }
|
|
|
- catch (Exception)
|
|
|
- {
|
|
|
- LogManager.DoLog("SQL维护不正确,请检查SQL语句\n" + sql);
|
|
|
- return;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- MidDoc.Printer.SwitchTo(MidLabelPrinter.Text);
|
|
|
- MidDoc.PrintDocument();
|
|
|
- }
|
|
|
-
|
|
|
- private void MidBoxCodePrint(string la_id, int rowindex, int[] midindex)
|
|
|
- {
|
|
|
- for (int j = 0; j < MidDoc.Variables.FreeVariables.Count; j++)
|
|
|
- {
|
|
|
- //将维护的模板参数和模板本身的参数名称进行比对
|
|
|
- for (int k = 0; k < MidLabelParam.Rows.Count; k++)
|
|
|
- {
|
|
|
- //名称相等的时候,取SQL进行值的查询
|
|
|
- if (MidDoc.Variables.FreeVariables.Item(j + 1).Name == MidLabelParam.Rows[k]["lp_name"].ToString())
|
|
|
- {
|
|
|
- //获取对应行的pib_id
|
|
|
- string pib_id = LabelInf.Rows[rowindex].Cells["pib_id1"].Value.ToString();
|
|
|
- string pib_outboxcode1 = LabelInf.Rows[rowindex].Cells["pib_outboxcode1"].Value.ToString();
|
|
|
- //获取打印执行的SQL
|
|
|
- string sql = MidLabelParam.Rows[k]["lp_sql"].ToString();
|
|
|
- try
|
|
|
- {
|
|
|
- //获取打印执行的SQL
|
|
|
- if (sql.IndexOf("{") == 0)
|
|
|
- {
|
|
|
- MidDoc.Variables.FreeVariables.Item(j + 1).Value = dh.GetLabelParam(sql).ToString();
|
|
|
- LogManager.DoLog("打印参数【" + MidDoc.Variables.FreeVariables.Item(j + 1).Name + "】赋值," + "取值SQL:" + dt.Rows[k]["lp_sql"].ToString() + ",取到值" + MidDoc.Variables.FreeVariables.Item(j + 1).Value);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- if (sql.ToLower().Contains("pib_qty"))
|
|
|
- {
|
|
|
- sql = sql.Substring(0, sql.IndexOf("{")) + pib_id + sql.Substring(sql.IndexOf("}") + 1);
|
|
|
- sql = sql.Substring(0, sql.LastIndexOf("=")) + "='" + pib_outboxcode1 + "' group by pib_outboxcode1";
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- sql = sql.Substring(0, sql.IndexOf("{"));
|
|
|
- sql = sql.Substring(0, sql.LastIndexOf("="));
|
|
|
- sql = sql + " in (select distinct pib_outboxcode1 from PRODIOBARCODE where pib_inoutno='" + pi_inoutno.Text + "')" + " and pib_inoutno='" + pi_inoutno.Text + "' and pib_outboxcode1='" + pib_outboxcode1 + "'";
|
|
|
- }
|
|
|
- MidDoc.Variables.FreeVariables.Item(j + 1).Value = dh.GetLabelParam(sql).ToString();
|
|
|
- if (MidDoc.Variables.FreeVariables.Item(j + 1).Value == "")
|
|
|
- {
|
|
|
- DataRow[] dr1 = Attach.Select("lp_name='" + MidDoc.Variables.FreeVariables.Item(j + 1).Name + "'");
|
|
|
- if (dr1.Length > 0)
|
|
|
- {
|
|
|
- MidDoc.Variables.FreeVariables.Item(j + 1).Value = dr1[0]["lp_sql"].ToString();
|
|
|
- }
|
|
|
- }
|
|
|
- LogManager.DoLog("打印参数【" + MidDoc.Variables.FreeVariables.Item(j + 1).Name + "】赋值," + "取值SQL:" + sql + ",取到值" + MidDoc.Variables.FreeVariables.Item(j + 1).Value);
|
|
|
- }
|
|
|
- }
|
|
|
- catch (Exception)
|
|
|
- {
|
|
|
- LogManager.DoLog("SQL维护不正确,请检查SQL语句\n" + sql);
|
|
|
- return;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- MidDoc.Printer.SwitchTo(MidLabelPrinter.Text);
|
|
|
- MidDoc.PrintDocument();
|
|
|
+ //获取对应行的pib_id
|
|
|
+ string pib_id = LabelInf.Rows[rowindex].Cells["pib_id1"].Value.ToString();
|
|
|
+ string pib_outboxcode1 = LabelInf.Rows[rowindex].Cells["pib_outboxcode1"].Value.ToString();
|
|
|
+ if (PrintMethod == "CodeSoft")
|
|
|
+ Print.CodeSoft.MidPrint(MidDoc, MidLabelParam, arg, pib_id, pib_outboxcode1);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 执行打印外箱号
|
|
|
/// </summary>
|
|
|
- private void OutBoxCodePrint(string la_id, int rowindex)
|
|
|
+ private void OutBoxCodePrint(int rowindex)
|
|
|
{
|
|
|
- DataTable dt = (DataTable)dh.ExecuteSql("select lp_name,lp_sql,lp_valuetype from label left join LABELPARAMETER on la_id= lp_laid where la_id=" + la_id, "select");
|
|
|
try
|
|
|
- {
|
|
|
- for (int j = 0; j < OutBoxDoc.Variables.FreeVariables.Count; j++)
|
|
|
- {
|
|
|
- //将维护的模板参数和模板本身的参数名称进行比对
|
|
|
- for (int k = 0; k < OutLabelParam.Rows.Count; k++)
|
|
|
- {
|
|
|
- //名称相等的时候,取SQL进行值的查询
|
|
|
- if (OutBoxDoc.Variables.FreeVariables.Item(j + 1).Name == OutLabelParam.Rows[k]["lp_name"].ToString())
|
|
|
- {
|
|
|
- //获取对应行的pib_id
|
|
|
- string pib_id = LabelInf.Rows[rowindex].Cells["pib_id1"].Value.ToString();
|
|
|
- string pib_outboxcode2 = LabelInf.Rows[rowindex].Cells["pib_outboxcode2"].Value.ToString();
|
|
|
- //获取打印执行的SQL
|
|
|
- string sql = OutLabelParam.Rows[k]["lp_sql"].ToString();
|
|
|
- //select * from productiobarcode where pib_id={pib_id} and pib_outboxcode1={pib_outboxcode1}
|
|
|
- try
|
|
|
- {
|
|
|
- string ExeSQL = "";
|
|
|
- ExeSQL = sql.ToLower().Replace("{pib_id}", "'" + pib_id + "'");
|
|
|
- ExeSQL = ExeSQL.Replace("{pib_outboxcode2}", "'" + pib_outboxcode2 + "'");
|
|
|
- OutBoxDoc.Variables.FreeVariables.Item(j + 1).Value = dh.GetLabelParam(ExeSQL).ToString();
|
|
|
- if (OutBoxDoc.Variables.FreeVariables.Item(j + 1).Value == "")
|
|
|
- {
|
|
|
- DataRow[] dr1 = Attach.Select("lp_name='" + OutBoxDoc.Variables.FreeVariables.Item(j + 1).Name + "'");
|
|
|
- if (dr1.Length > 0)
|
|
|
- {
|
|
|
- OutBoxDoc.Variables.FreeVariables.Item(j + 1).Value = dr1[0]["lp_sql"].ToString();
|
|
|
- }
|
|
|
- }
|
|
|
- LogManager.DoLog("打印参数【" + OutBoxDoc.Variables.FreeVariables.Item(j + 1).Name + "】赋值," + "取值SQL:" + ExeSQL + ",取到值" + OutBoxDoc.Variables.FreeVariables.Item(j + 1).Value);
|
|
|
- }
|
|
|
- catch (Exception)
|
|
|
- {
|
|
|
- LogManager.DoLog("SQL维护不正确,请检查SQL语句" + sql);
|
|
|
- MessageBox.Show("SQL维护不正确,请检查SQL语句\n" + sql);
|
|
|
- return;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- OutBoxDoc.Printer.SwitchTo(OutBoxPrinter.Text);
|
|
|
- OutBoxDoc.PrintDocument();
|
|
|
- LogManager.DoLog("执行打印外箱,pib_id:" + LabelInf.Rows[rowindex].Cells["pib_id1"].Value.ToString());
|
|
|
+ { //获取对应行的pib_id
|
|
|
+ string pib_id = LabelInf.Rows[rowindex].Cells["pib_id1"].Value.ToString();
|
|
|
+ string pib_outboxcode2 = LabelInf.Rows[rowindex].Cells["pib_outboxcode2"].Value.ToString();
|
|
|
+ if (PrintMethod == "CodeSoft")
|
|
|
+ Print.CodeSoft.OutPrint(OutBoxDoc, OutLabelParam, pib_id, pib_outboxcode2);
|
|
|
}
|
|
|
catch (Exception ex) { MessageBox.Show(ex.Message); }
|
|
|
}
|
|
|
@@ -2035,7 +1858,7 @@ namespace UAS_LabelMachine
|
|
|
bool mouseOver = e.CellBounds.Contains(this.PointToClient(Cursor.Position));
|
|
|
if (e.ColumnIndex > 0)
|
|
|
{
|
|
|
- if (LabelInf.Columns[e.ColumnIndex].Name == "pib_custbarcode"|| LabelInf.Columns[e.ColumnIndex].Name == "pib_barcode"||LabelInf.Columns[e.ColumnIndex].Name == "pib_madein" || LabelInf.Columns[e.ColumnIndex].Name == "pib_lotno" || LabelInf.Columns[e.ColumnIndex].Name == "pib_datecode" || LabelInf.Columns[e.ColumnIndex].Name == "pib_outboxcode1" || LabelInf.Columns[e.ColumnIndex].Name == "pib_outboxcode2" || LabelInf.Columns[e.ColumnIndex].Name == "pib_brand")
|
|
|
+ if (LabelInf.Columns[e.ColumnIndex].Name == "pib_custbarcode" || LabelInf.Columns[e.ColumnIndex].Name == "pib_barcode" || LabelInf.Columns[e.ColumnIndex].Name == "pib_madein" || LabelInf.Columns[e.ColumnIndex].Name == "pib_lotno" || LabelInf.Columns[e.ColumnIndex].Name == "pib_datecode" || LabelInf.Columns[e.ColumnIndex].Name == "pib_outboxcode1" || LabelInf.Columns[e.ColumnIndex].Name == "pib_outboxcode2" || LabelInf.Columns[e.ColumnIndex].Name == "pib_brand")
|
|
|
{
|
|
|
SolidBrush solidBrush = new SolidBrush(Color.FromArgb(51, 153, 255));
|
|
|
e.Graphics.FillRectangle(mouseOver ? solidBrush : Brushes.LightSeaGreen, e.CellBounds);
|
|
|
@@ -2100,7 +1923,7 @@ namespace UAS_LabelMachine
|
|
|
{
|
|
|
if (!PrintedVivoOutboxCode.Contains(CusOutBoxCode[i].ToString()))
|
|
|
{
|
|
|
- OutBoxCodePrint(la_id, CusOutBoxCode[i]);
|
|
|
+ OutBoxCodePrint(CusOutBoxCode[i]);
|
|
|
PrintedVivoOutboxCode.Add(CusOutBoxCode[i].ToString());
|
|
|
}
|
|
|
}
|
|
|
@@ -2172,8 +1995,7 @@ namespace UAS_LabelMachine
|
|
|
{
|
|
|
if (MidLabelCombox.SelectedValue != null)
|
|
|
{
|
|
|
- string la_id = MidLabelCombox.SelectedValue.ToString().Split('#')[0];
|
|
|
- MidBoxCodePrint(la_id, CurrentRowIndex);
|
|
|
+ MidBoxCodePrint(CurrentRowIndex);
|
|
|
}
|
|
|
else
|
|
|
MessageBox.Show("未维护中盒模板");
|
|
|
@@ -2672,5 +2494,26 @@ namespace UAS_LabelMachine
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ private void LabelPrinter_UserOnSelectIndexChange(object sender, EventArgs e)
|
|
|
+ {
|
|
|
+ switch ((sender as Control).Parent.Name)
|
|
|
+ {
|
|
|
+ case "SingleLabelPrinter":
|
|
|
+ if (SingleDoc != null)
|
|
|
+ SingleDoc.Printer.SwitchTo(SingleLabelPrinter.Text);
|
|
|
+ break;
|
|
|
+ case "MidLabelPrinter":
|
|
|
+ if (MidDoc != null)
|
|
|
+ MidDoc.Printer.SwitchTo(MidLabelPrinter.Text);
|
|
|
+ break;
|
|
|
+ case "OutBoxPrinter":
|
|
|
+ if (OutBoxDoc != null)
|
|
|
+ OutBoxDoc.Printer.SwitchTo(OutBoxLabelPrint.Text);
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|