|
|
@@ -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,8 +27,6 @@ namespace UAS_LabelMachine
|
|
|
|
|
|
DataHelper dh;
|
|
|
|
|
|
- Engine engine;
|
|
|
-
|
|
|
DataTable dt;
|
|
|
/// <summary>
|
|
|
/// 已经打印过的Vivo外箱号
|
|
|
@@ -96,7 +94,7 @@ namespace UAS_LabelMachine
|
|
|
|
|
|
Dictionary<string, string> CollectData;
|
|
|
//缓存单盘数据数据的DataTable
|
|
|
- public static DataTable SingleBoxCacheData;
|
|
|
+ DataTable SingleBoxCacheData;
|
|
|
/// <summary>
|
|
|
/// 存放单盘的ID
|
|
|
/// </summary>
|
|
|
@@ -108,7 +106,7 @@ namespace UAS_LabelMachine
|
|
|
/// <summary>
|
|
|
/// 中盒缓存数据
|
|
|
/// </summary>
|
|
|
- public static DataTable MidBoxCacheData;
|
|
|
+ DataTable MidBoxCacheData;
|
|
|
/// <summary>
|
|
|
/// 存放中盒的ID和盒号
|
|
|
/// </summary>
|
|
|
@@ -146,9 +144,7 @@ namespace UAS_LabelMachine
|
|
|
|
|
|
List<string> OutParam = new List<string>();
|
|
|
|
|
|
- public static DataTable Attach;
|
|
|
-
|
|
|
- string PrintMethod = "CodeSoft";
|
|
|
+ DataTable Attach;
|
|
|
|
|
|
public UAS_出货标签打印(string Master)
|
|
|
{
|
|
|
@@ -161,7 +157,7 @@ namespace UAS_LabelMachine
|
|
|
Text = Text + "-" + Master;
|
|
|
}
|
|
|
|
|
|
- protected override void WndProc(ref System.Windows.Forms.Message m)
|
|
|
+ protected override void WndProc(ref Message m)
|
|
|
{
|
|
|
//拦截双击标题栏、移动窗体的系统消息
|
|
|
if (m.Msg != 0xA3)
|
|
|
@@ -174,11 +170,6 @@ namespace UAS_LabelMachine
|
|
|
{
|
|
|
//杀死之前全部未关闭的进程
|
|
|
Process[] processes = System.Diagnostics.Process.GetProcessesByName("lppa");
|
|
|
- Process[] processes1 = System.Diagnostics.Process.GetProcessesByName("bartend");
|
|
|
- for (int i = 0; i < processes1.Length; i++)
|
|
|
- {
|
|
|
- processes1[i].Kill();
|
|
|
- }
|
|
|
for (int i = 0; i < processes.Length; i++)
|
|
|
{
|
|
|
processes[i].Kill();
|
|
|
@@ -252,23 +243,14 @@ namespace UAS_LabelMachine
|
|
|
}
|
|
|
asc.controllInitializeSize(this);
|
|
|
asc.controlAutoSize(this);
|
|
|
- //实例化打印进程,如果没有配置默认使用BarTener
|
|
|
- string Code = dh.GetConfig("PrintMethod", "CodeOrBar").ToString() ;
|
|
|
- if (Code == "")
|
|
|
+ //实例化打印进程
|
|
|
+ try
|
|
|
{
|
|
|
- try
|
|
|
- {
|
|
|
- lbl = new ApplicationClass();
|
|
|
- }
|
|
|
- catch (Exception)
|
|
|
- {
|
|
|
- MessageBox.Show("未安装CodeSoft软件或者版本不正确");
|
|
|
- }
|
|
|
+ lbl = new ApplicationClass();
|
|
|
}
|
|
|
- else
|
|
|
+ catch (Exception)
|
|
|
{
|
|
|
- engine = new Engine(true);
|
|
|
- PrintMethod = "BarTender";
|
|
|
+ MessageBox.Show("未安装CodeSoft软件或者版本不正确");
|
|
|
}
|
|
|
RefreshDBConnect.Interval = 60000;
|
|
|
RefreshDBConnect.Start();
|
|
|
@@ -580,7 +562,13 @@ namespace UAS_LabelMachine
|
|
|
CurrentRowIndex = i;
|
|
|
if (SingleLabelAutoPrint.Checked)
|
|
|
{
|
|
|
- AutoPrintSingleLabel();
|
|
|
+ if (la_id != "")
|
|
|
+ AutoPrintSingleLabel(la_id, LabelUrl);
|
|
|
+ else
|
|
|
+ {
|
|
|
+ MessageBox.Show("未维护单盘标签");
|
|
|
+ return;
|
|
|
+ }
|
|
|
}
|
|
|
if (MidLabelAutoPrint.Checked)
|
|
|
AutoPrintMidLabel();
|
|
|
@@ -615,7 +603,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();
|
|
|
+ AutoPrintSingleLabel(la_id, LabelUrl);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
@@ -688,15 +676,38 @@ namespace UAS_LabelMachine
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void AutoPrintSingleLabel()
|
|
|
+ private void AutoPrintSingleLabel(string la_id, string LabelUrl)
|
|
|
{
|
|
|
//用标签本身的变量作为最外层的循环条件去匹配;
|
|
|
string[] arg = SingleBoxArgument.ToArray();
|
|
|
- string pib_id = LabelInf.Rows[CurrentRowIndex].Cells["pib_id1"].Value.ToString();
|
|
|
- if (PrintMethod == "CodeSoft")
|
|
|
+ StringBuilder ParamLog = new StringBuilder();
|
|
|
+ for (int j = 0; j < SingleDoc.Variables.FreeVariables.Count; j++)
|
|
|
{
|
|
|
- Print.CodeSoft.SinglePrint(SingleDoc, arg, pib_id);
|
|
|
+ //将维护的模板参数和模板本身的参数名称进行比对
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
+ LogManager.DoLog(ParamLog.ToString());
|
|
|
+ SingleDoc.Printer.SwitchTo(SingleLabelPrinter.Text);
|
|
|
+ SingleDoc.PrintDocument();
|
|
|
LabelInf.Rows[CurrentRowIndex].Cells["pib_ifprint"].Value = true;
|
|
|
}
|
|
|
|
|
|
@@ -1044,11 +1055,11 @@ namespace UAS_LabelMachine
|
|
|
}
|
|
|
if (SingleLabelCombox.Text != "")
|
|
|
{
|
|
|
- if (PrintMethod == "CodeSoft")
|
|
|
+ SingleDoc = lbl.Documents.Open(ftpOperater.DownLoadTo + SingleLabelCombox.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++)
|
|
|
{
|
|
|
- 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");
|
|
|
+ SingleParam.Add(SingleDoc.Variables.FreeVariables.Item(i + 1).Name);
|
|
|
}
|
|
|
}
|
|
|
sql.Clear();
|
|
|
@@ -1073,12 +1084,8 @@ namespace UAS_LabelMachine
|
|
|
}
|
|
|
if (MidLabelCombox.Text != "")
|
|
|
{
|
|
|
- if (PrintMethod == "CodeSoft")
|
|
|
- {
|
|
|
- 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");
|
|
|
- }
|
|
|
+ MidDoc = lbl.Documents.Open(ftpOperater.DownLoadTo + MidLabelCombox.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");
|
|
|
}
|
|
|
//缓存中盒参数
|
|
|
sql.Clear();
|
|
|
@@ -1103,17 +1110,13 @@ namespace UAS_LabelMachine
|
|
|
}
|
|
|
if (OutBoxCombox.Text != "")
|
|
|
{
|
|
|
- if (PrintMethod == "CodeSoft")
|
|
|
- {
|
|
|
- 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");
|
|
|
- }
|
|
|
+ OutBoxDoc = lbl.Documents.Open(ftpOperater.DownLoadTo + OutBoxCombox.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");
|
|
|
}
|
|
|
//缓存外箱参数
|
|
|
ComBoxClickChangeLabelDoc = true;
|
|
|
- GetSingleBoxData(PrintMethod);
|
|
|
- GetMidBoxData(PrintMethod);
|
|
|
+ GetSingleBoxData();
|
|
|
+ GetMidBoxData();
|
|
|
}
|
|
|
bool InitGetLabel = true;
|
|
|
/// <summary>
|
|
|
@@ -1198,6 +1201,11 @@ namespace UAS_LabelMachine
|
|
|
MessageBox.Show("中盘标签未维护参数");
|
|
|
}
|
|
|
}
|
|
|
+ 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();
|
|
|
+ //查询该模板维护的所有参数
|
|
|
+ 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");
|
|
|
if (SingleLabelParam.Rows.Count > 0 && LabelInf.Rows.Count > 0)
|
|
|
{
|
|
|
//每次打印清除之前缓存的行号和ID,后面会判断需要打印的数据重新加载
|
|
|
@@ -1227,9 +1235,9 @@ namespace UAS_LabelMachine
|
|
|
}
|
|
|
//打印的时候如果不存在数据开始缓存
|
|
|
if (SingleBoxCacheData.Rows.Count == 0)
|
|
|
- GetSingleBoxData(PrintMethod);
|
|
|
+ GetSingleBoxData();
|
|
|
if (MidBoxCacheData.Rows.Count == 0)
|
|
|
- GetMidBoxData(PrintMethod);
|
|
|
+ GetMidBoxData();
|
|
|
for (int i = 0; i < LabelInf.RowCount; i++)
|
|
|
{
|
|
|
if (i + 1 < LabelInf.RowCount)
|
|
|
@@ -1262,8 +1270,25 @@ namespace UAS_LabelMachine
|
|
|
try
|
|
|
{
|
|
|
string pib_id = LabelInf.Rows[i].Cells["pib_id1"].Value.ToString();
|
|
|
- if (PrintMethod == "CodeSoft")
|
|
|
- Print.CodeSoft.SinglePrint(SingleDoc, arg, pib_id);
|
|
|
+ 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 (MidLabelAutoPrint.Checked)
|
|
|
{
|
|
|
//判断当前行的盒号和下一行不相等或者已经是最后一行了
|
|
|
@@ -1274,7 +1299,7 @@ namespace UAS_LabelMachine
|
|
|
if (MidLabelCombox.SelectedValue != null)
|
|
|
{
|
|
|
string la_id_mid = MidLabelCombox.SelectedValue.ToString().Split('#')[0];
|
|
|
- MidBoxCodePrint(CurrentRowIndex);
|
|
|
+ MidBoxCodePrint(la_id_mid, CurrentRowIndex);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -1304,167 +1329,161 @@ namespace UAS_LabelMachine
|
|
|
/// <summary>
|
|
|
/// 缓存单盘的数据
|
|
|
/// </summary>
|
|
|
- private void GetSingleBoxData(string PrintMethod)
|
|
|
+ private void GetSingleBoxData()
|
|
|
{
|
|
|
- if (PrintMethod == "CodeSoft")
|
|
|
+ if (SingleDoc == null)
|
|
|
+ return;
|
|
|
+ for (int i = 0; i < LabelInf.Rows.Count; i++)
|
|
|
{
|
|
|
- if (SingleDoc == null)
|
|
|
- return;
|
|
|
- for (int i = 0; i < LabelInf.Rows.Count; i++)
|
|
|
- {
|
|
|
- if (!SingleID.Contains(LabelInf.Rows[i].Cells["pib_id1"].Value.ToString()))
|
|
|
- SingleID.Add(LabelInf.Rows[i].Cells["pib_id1"].Value.ToString());
|
|
|
- //如果不存在中盒号则进行添加
|
|
|
- if (!MidIDAndOutboxcode.ContainsValue(LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString()))
|
|
|
- MidIDAndOutboxcode.Add(LabelInf.Rows[i].Cells["pib_id1"].Value.ToString(), LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString());
|
|
|
- }
|
|
|
- //id数组
|
|
|
- string[] pib_id_arr = SingleID.ToArray();
|
|
|
- //将所有的列存在在这里
|
|
|
- List<DataTable> AllSingleBoxCacheData = new List<DataTable>();
|
|
|
- //每五百条拼接一次条件
|
|
|
- //手动添加ID列
|
|
|
- DataColumn datacolumn = new DataColumn("pib_id");
|
|
|
- if (!SingleBoxCacheData.Columns.Contains("pib_id"))
|
|
|
- SingleBoxCacheData.Columns.Add(datacolumn);
|
|
|
- //获取打印的SQL
|
|
|
- try
|
|
|
+ if (!SingleID.Contains(LabelInf.Rows[i].Cells["pib_id1"].Value.ToString()))
|
|
|
+ SingleID.Add(LabelInf.Rows[i].Cells["pib_id1"].Value.ToString());
|
|
|
+ //如果不存在中盒号则进行添加
|
|
|
+ if (!MidIDAndOutboxcode.ContainsValue(LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString()))
|
|
|
+ MidIDAndOutboxcode.Add(LabelInf.Rows[i].Cells["pib_id1"].Value.ToString(), LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString());
|
|
|
+ }
|
|
|
+ //id数组
|
|
|
+ string[] pib_id_arr = SingleID.ToArray();
|
|
|
+ //将所有的列存在在这里
|
|
|
+ List<DataTable> AllSingleBoxCacheData = new List<DataTable>();
|
|
|
+ //每五百条拼接一次条件
|
|
|
+ //手动添加ID列
|
|
|
+ DataColumn datacolumn = new DataColumn("pib_id");
|
|
|
+ if (!SingleBoxCacheData.Columns.Contains("pib_id"))
|
|
|
+ SingleBoxCacheData.Columns.Add(datacolumn);
|
|
|
+ //获取打印的SQL
|
|
|
+ try
|
|
|
+ {
|
|
|
+ for (int j = 0; j < SingleDoc.Variables.FreeVariables.Count; j++)
|
|
|
{
|
|
|
- for (int j = 0; j < SingleDoc.Variables.FreeVariables.Count; j++)
|
|
|
+ //将维护的模板参数和模板本身的参数名称进行比对
|
|
|
+ for (int k = 0; k < SingleLabelParam.Rows.Count; k++)
|
|
|
{
|
|
|
- //将维护的模板参数和模板本身的参数名称进行比对
|
|
|
- for (int k = 0; k < SingleLabelParam.Rows.Count; k++)
|
|
|
+ if (SingleDoc.Variables.FreeVariables.Item(j + 1).Name == SingleLabelParam.Rows[k]["lp_name"].ToString())
|
|
|
{
|
|
|
- if (SingleDoc.Variables.FreeVariables.Item(j + 1).Name == SingleLabelParam.Rows[k]["lp_name"].ToString())
|
|
|
- {
|
|
|
- DataColumn dc = new DataColumn(SingleDoc.Variables.FreeVariables.Item(j + 1).Name);
|
|
|
- SingleBoxCacheData.Columns.Add(dc);
|
|
|
- SingleBoxArgument.Add(SingleDoc.Variables.FreeVariables.Item(j + 1).Name);
|
|
|
- string sql = SingleLabelParam.Rows[k]["lp_sql"].ToString();
|
|
|
- sql = sql.Substring(0, sql.IndexOf("{"));
|
|
|
- sql = sql.Substring(0, sql.LastIndexOf("="));
|
|
|
- DataTable temp = dh.getFieldsDatasByCondition(sql.Replace(" from ", " ,pib_id PIBID from ") + " in (select pib_id from PRODIOBARCODE where pib_inoutno='" + pi_inoutno.Text + "') ORDER by pib_id");
|
|
|
- temp.Columns[0].ColumnName = SingleDoc.Variables.FreeVariables.Item(j + 1).Name;
|
|
|
- AllSingleBoxCacheData.Add(temp);
|
|
|
- }
|
|
|
+ DataColumn dc = new DataColumn(SingleDoc.Variables.FreeVariables.Item(j + 1).Name);
|
|
|
+ SingleBoxCacheData.Columns.Add(dc);
|
|
|
+ SingleBoxArgument.Add(SingleDoc.Variables.FreeVariables.Item(j + 1).Name);
|
|
|
+ string sql = SingleLabelParam.Rows[k]["lp_sql"].ToString();
|
|
|
+ sql = sql.Substring(0, sql.IndexOf("{"));
|
|
|
+ sql = sql.Substring(0, sql.LastIndexOf("="));
|
|
|
+ DataTable temp = dh.getFieldsDatasByCondition(sql.Replace(" from ", " ,pib_id PIBID from ") + " in (select pib_id from PRODIOBARCODE where pib_inoutno='" + pi_inoutno.Text + "') ORDER by pib_id");
|
|
|
+ temp.Columns[0].ColumnName = SingleDoc.Variables.FreeVariables.Item(j + 1).Name;
|
|
|
+ AllSingleBoxCacheData.Add(temp);
|
|
|
}
|
|
|
}
|
|
|
- DataTable[] Temp = AllSingleBoxCacheData.ToArray();
|
|
|
- //将所有数据写入到CacheData中
|
|
|
- if (Temp.Length > 0)
|
|
|
- for (int i = 0; i < Temp[0].Rows.Count; i++)
|
|
|
+ }
|
|
|
+ DataTable[] Temp = AllSingleBoxCacheData.ToArray();
|
|
|
+ //将所有数据写入到CacheData中
|
|
|
+ if (Temp.Length > 0)
|
|
|
+ for (int i = 0; i < Temp[0].Rows.Count; i++)
|
|
|
+ {
|
|
|
+ DataRow dr = SingleBoxCacheData.NewRow();
|
|
|
+ dr["pib_id"] = pib_id_arr[i];
|
|
|
+ //由于之前加了一个ID列,导致j从1开始
|
|
|
+ for (int j = 1; j < SingleBoxCacheData.Columns.Count; j++)
|
|
|
{
|
|
|
- DataRow dr = SingleBoxCacheData.NewRow();
|
|
|
- dr["pib_id"] = pib_id_arr[i];
|
|
|
- //由于之前加了一个ID列,导致j从1开始
|
|
|
- for (int j = 1; j < SingleBoxCacheData.Columns.Count; j++)
|
|
|
- {
|
|
|
- dr[Temp[j - 1].Columns[0].ColumnName] = (Temp[j - 1].Select("PIBID=" + pib_id_arr[i]))[0][0];
|
|
|
- }
|
|
|
- SingleBoxCacheData.Rows.Add(dr);
|
|
|
+ dr[Temp[j - 1].Columns[0].ColumnName] = (Temp[j - 1].Select("PIBID=" + pib_id_arr[i]))[0][0];
|
|
|
}
|
|
|
- }
|
|
|
- catch (Exception)
|
|
|
- {
|
|
|
+ SingleBoxCacheData.Rows.Add(dr);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (Exception)
|
|
|
+ {
|
|
|
|
|
|
- SingleBoxArgument.Clear();
|
|
|
- SingleBoxCacheData.Clear();
|
|
|
- BaseUtil.CleanDataTable(SingleBoxCacheData);
|
|
|
- }
|
|
|
+ SingleBoxArgument.Clear();
|
|
|
+ SingleBoxCacheData.Clear();
|
|
|
+ BaseUtil.CleanDataTable(SingleBoxCacheData);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 缓存中盒的数据
|
|
|
/// </summary>
|
|
|
- private void GetMidBoxData(string PrintMethod)
|
|
|
+ private void GetMidBoxData()
|
|
|
{
|
|
|
- if (PrintMethod == "CodeSoft")
|
|
|
+ if (MidDoc == null)
|
|
|
+ return;
|
|
|
+ StringBuilder pib_condition_string = new StringBuilder();
|
|
|
+ StringBuilder pib_qtycondition_string = new StringBuilder();
|
|
|
+ for (int i = 0; i < LabelInf.Rows.Count; i++)
|
|
|
{
|
|
|
- if (MidDoc == null)
|
|
|
- return;
|
|
|
- StringBuilder pib_condition_string = new StringBuilder();
|
|
|
- StringBuilder pib_qtycondition_string = new StringBuilder();
|
|
|
- for (int i = 0; i < LabelInf.Rows.Count; i++)
|
|
|
+ //如果不存在中盒号则进行添加
|
|
|
+ if (!MidIDAndOutboxcode.ContainsValue(LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString()))
|
|
|
{
|
|
|
- //如果不存在中盒号则进行添加
|
|
|
- if (!MidIDAndOutboxcode.ContainsValue(LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString()))
|
|
|
- {
|
|
|
- MidIDAndOutboxcode.Add(LabelInf.Rows[i].Cells["pib_id1"].Value.ToString(), LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString());
|
|
|
- }
|
|
|
- }
|
|
|
- //id数组
|
|
|
- string[] pib_id_arr = MidIDAndOutboxcode.Keys.ToArray();
|
|
|
- string[] pib_outbox_arr = MidIDAndOutboxcode.Values.ToArray();
|
|
|
- if (pib_id_arr.Length == 0)
|
|
|
- {
|
|
|
- MessageBox.Show("未勾选打印明细");
|
|
|
- return;
|
|
|
- }
|
|
|
- //记录一个ID用来取中盒的数量
|
|
|
- string pib_id = pib_id_arr[0];
|
|
|
- //id个数
|
|
|
- //将所有的列存在在这里
|
|
|
- List<DataTable> AllMidBoxCacheData = new List<DataTable>();
|
|
|
- //每五百条拼接一次条件
|
|
|
- //手动添加ID列
|
|
|
- DataColumn IDColumn = new DataColumn("pib_id");
|
|
|
- DataColumn OutBoxColumn = new DataColumn("pib_outboxcode1");
|
|
|
- if (!MidBoxCacheData.Columns.Contains("pib_id"))
|
|
|
- MidBoxCacheData.Columns.Add(IDColumn);
|
|
|
- if (!MidBoxCacheData.Columns.Contains("pib_outboxcode1"))
|
|
|
- MidBoxCacheData.Columns.Add(OutBoxColumn);
|
|
|
- if (MidLabelCombox.SelectedValue == null)
|
|
|
- {
|
|
|
- return;
|
|
|
+ MidIDAndOutboxcode.Add(LabelInf.Rows[i].Cells["pib_id1"].Value.ToString(), LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString());
|
|
|
}
|
|
|
- string la_id = MidLabelCombox.SelectedValue.ToString().Split('#')[0];
|
|
|
- for (int j = 0; j < MidDoc.Variables.FreeVariables.Count; j++)
|
|
|
+ }
|
|
|
+ //id数组
|
|
|
+ string[] pib_id_arr = MidIDAndOutboxcode.Keys.ToArray();
|
|
|
+ string[] pib_outbox_arr = MidIDAndOutboxcode.Values.ToArray();
|
|
|
+ if (pib_id_arr.Length == 0)
|
|
|
+ {
|
|
|
+ MessageBox.Show("未勾选打印明细");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //记录一个ID用来取中盒的数量
|
|
|
+ string pib_id = pib_id_arr[0];
|
|
|
+ //id个数
|
|
|
+ //将所有的列存在在这里
|
|
|
+ List<DataTable> AllMidBoxCacheData = new List<DataTable>();
|
|
|
+ //每五百条拼接一次条件
|
|
|
+ //手动添加ID列
|
|
|
+ DataColumn IDColumn = new DataColumn("pib_id");
|
|
|
+ DataColumn OutBoxColumn = new DataColumn("pib_outboxcode1");
|
|
|
+ if (!MidBoxCacheData.Columns.Contains("pib_id"))
|
|
|
+ MidBoxCacheData.Columns.Add(IDColumn);
|
|
|
+ if (!MidBoxCacheData.Columns.Contains("pib_outboxcode1"))
|
|
|
+ MidBoxCacheData.Columns.Add(OutBoxColumn);
|
|
|
+ if (MidLabelCombox.SelectedValue == null)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ string la_id = MidLabelCombox.SelectedValue.ToString().Split('#')[0];
|
|
|
+ for (int j = 0; j < MidDoc.Variables.FreeVariables.Count; j++)
|
|
|
+ {
|
|
|
+ //将维护的模板参数和模板本身的参数名称进行比对
|
|
|
+ for (int k = 0; k < MidLabelParam.Rows.Count; k++)
|
|
|
{
|
|
|
- //将维护的模板参数和模板本身的参数名称进行比对
|
|
|
- for (int k = 0; k < MidLabelParam.Rows.Count; k++)
|
|
|
+ if (MidDoc.Variables.FreeVariables.Item(j + 1).Name == MidLabelParam.Rows[k]["lp_name"].ToString())
|
|
|
{
|
|
|
- if (MidDoc.Variables.FreeVariables.Item(j + 1).Name == MidLabelParam.Rows[k]["lp_name"].ToString())
|
|
|
+ DataColumn dc = new DataColumn(MidDoc.Variables.FreeVariables.Item(j + 1).Name);
|
|
|
+ MidBoxCacheData.Columns.Add(dc);
|
|
|
+ MidBoxArgument.Add(MidDoc.Variables.FreeVariables.Item(j + 1).Name);
|
|
|
+ string sql = MidLabelParam.Rows[k]["lp_sql"].ToString();
|
|
|
+ //如果打印的含有数量
|
|
|
+ if (sql.ToLower().Contains("pib_qty"))
|
|
|
{
|
|
|
- DataColumn dc = new DataColumn(MidDoc.Variables.FreeVariables.Item(j + 1).Name);
|
|
|
- MidBoxCacheData.Columns.Add(dc);
|
|
|
- MidBoxArgument.Add(MidDoc.Variables.FreeVariables.Item(j + 1).Name);
|
|
|
- string sql = MidLabelParam.Rows[k]["lp_sql"].ToString();
|
|
|
- //如果打印的含有数量
|
|
|
- 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("=")) + " in (select distinct pib_outboxcode1 from PRODIOBARCODE where pib_inoutno='" + pi_inoutno.Text + "')" + sql.Substring(sql.LastIndexOf("}") + 1);
|
|
|
- }
|
|
|
- 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 + "' order by to_number(pib_outboxcode1)";
|
|
|
- }
|
|
|
- DataTable temp = dh.getFieldsDatasByCondition(sql);
|
|
|
- temp.Columns[0].ColumnName = MidDoc.Variables.FreeVariables.Item(j + 1).Name;
|
|
|
- AllMidBoxCacheData.Add(temp);
|
|
|
+ sql = sql.Substring(0, sql.IndexOf("{")) + pib_id + sql.Substring(sql.IndexOf("}") + 1);
|
|
|
+ sql = sql.Substring(0, sql.LastIndexOf("=")) + " in (select distinct pib_outboxcode1 from PRODIOBARCODE where pib_inoutno='" + pi_inoutno.Text + "')" + sql.Substring(sql.LastIndexOf("}") + 1);
|
|
|
+ }
|
|
|
+ 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 + "' order by to_number(pib_outboxcode1)";
|
|
|
}
|
|
|
+ DataTable temp = dh.getFieldsDatasByCondition(sql);
|
|
|
+ temp.Columns[0].ColumnName = MidDoc.Variables.FreeVariables.Item(j + 1).Name;
|
|
|
+ AllMidBoxCacheData.Add(temp);
|
|
|
}
|
|
|
}
|
|
|
- DataTable[] Temp = AllMidBoxCacheData.ToArray();
|
|
|
- //将所有数据写入到CacheData中
|
|
|
- if (Temp.Length > 0)
|
|
|
+ }
|
|
|
+ DataTable[] Temp = AllMidBoxCacheData.ToArray();
|
|
|
+ //将所有数据写入到CacheData中
|
|
|
+ if (Temp.Length > 0)
|
|
|
+ {
|
|
|
+ for (int i = 0; i < pib_id_arr.Length; i++)
|
|
|
{
|
|
|
- for (int i = 0; i < pib_id_arr.Length; i++)
|
|
|
+ DataRow dr = MidBoxCacheData.NewRow();
|
|
|
+ dr["pib_id"] = pib_id_arr[i];
|
|
|
+ dr["pib_outboxcode1"] = pib_outbox_arr[i];
|
|
|
+ //由于之前加了一个ID列和箱号,导致j从2开始
|
|
|
+ for (int j = 2; j < MidBoxCacheData.Columns.Count; j++)
|
|
|
{
|
|
|
- DataRow dr = MidBoxCacheData.NewRow();
|
|
|
- dr["pib_id"] = pib_id_arr[i];
|
|
|
- dr["pib_outboxcode1"] = pib_outbox_arr[i];
|
|
|
- //由于之前加了一个ID列和箱号,导致j从2开始
|
|
|
- for (int j = 2; j < MidBoxCacheData.Columns.Count; j++)
|
|
|
- {
|
|
|
- //选出勾选的中盒号
|
|
|
- dr[Temp[j - 2].Columns[0].ColumnName] = Temp[j - 2].Select("PIB_OUTBOXCODE1='" + pib_outbox_arr[i] + "'")[0][0];
|
|
|
- }
|
|
|
- MidBoxCacheData.Rows.Add(dr);
|
|
|
+ //选出勾选的中盒号
|
|
|
+ dr[Temp[j - 2].Columns[0].ColumnName] = Temp[j - 2].Select("PIB_OUTBOXCODE1='" + pib_outbox_arr[i] + "'")[0][0];
|
|
|
}
|
|
|
+ MidBoxCacheData.Rows.Add(dr);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -1568,10 +1587,10 @@ namespace UAS_LabelMachine
|
|
|
MidOutBoxCodeIndex.Add(i);
|
|
|
}
|
|
|
}
|
|
|
- GetMidBoxData(PrintMethod);
|
|
|
+ GetMidBoxData();
|
|
|
for (int i = 0; i < MidOutBoxCodeIndex.Count; i++)
|
|
|
{
|
|
|
- MidBoxCodePrint(MidOutBoxCodeIndex[i]);
|
|
|
+ MidBoxCodePrint(la_id, MidOutBoxCodeIndex[i]);
|
|
|
}
|
|
|
MidBoxArgument.Clear();
|
|
|
MidBoxCacheData.Clear();
|
|
|
@@ -1601,7 +1620,7 @@ namespace UAS_LabelMachine
|
|
|
}
|
|
|
//找到了指定的盒号
|
|
|
if (FindMidLabel)
|
|
|
- MidBoxCodePrint(MidLabelRowIndex);
|
|
|
+ MidBoxCodePrint(la_id, MidLabelRowIndex, MidRowIndex.ToArray());
|
|
|
else
|
|
|
MessageBox.Show("该出入库单未找到该中盒号!");
|
|
|
}
|
|
|
@@ -1654,7 +1673,7 @@ namespace UAS_LabelMachine
|
|
|
{
|
|
|
if (LabelInf.Rows[h].Cells["pib_outboxcode2"].Value.ToString() == Outboxcode.ToArray()[i])
|
|
|
{
|
|
|
- OutBoxCodePrint(h);
|
|
|
+ OutBoxCodePrint(la_id, h);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
@@ -1686,7 +1705,7 @@ namespace UAS_LabelMachine
|
|
|
}
|
|
|
//找到了指定的盒号
|
|
|
if (FindMidLabel)
|
|
|
- OutBoxCodePrint(OutBoxLabelRowIndex);
|
|
|
+ OutBoxCodePrint(la_id, OutBoxLabelRowIndex);
|
|
|
else
|
|
|
MessageBox.Show("该出入库单未找到该外箱号!");
|
|
|
}
|
|
|
@@ -1695,34 +1714,179 @@ namespace UAS_LabelMachine
|
|
|
Outboxcode.Clear();
|
|
|
}
|
|
|
|
|
|
- private void MidBoxCodePrint(int rowindex)
|
|
|
+ private void MidBoxCodePrint(string la_id, 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(PrintMethod);
|
|
|
+ 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();
|
|
|
- //获取对应行的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);
|
|
|
+ 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();
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 执行打印外箱号
|
|
|
/// </summary>
|
|
|
- private void OutBoxCodePrint(int rowindex)
|
|
|
+ private void OutBoxCodePrint(string la_id, 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
|
|
|
- { //获取对应行的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);
|
|
|
- else
|
|
|
- Print.BarTender.OutPrint();
|
|
|
+ {
|
|
|
+ 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());
|
|
|
}
|
|
|
catch (Exception ex) { MessageBox.Show(ex.Message); }
|
|
|
}
|
|
|
@@ -1936,7 +2100,7 @@ namespace UAS_LabelMachine
|
|
|
{
|
|
|
if (!PrintedVivoOutboxCode.Contains(CusOutBoxCode[i].ToString()))
|
|
|
{
|
|
|
- OutBoxCodePrint(CusOutBoxCode[i]);
|
|
|
+ OutBoxCodePrint(la_id, CusOutBoxCode[i]);
|
|
|
PrintedVivoOutboxCode.Add(CusOutBoxCode[i].ToString());
|
|
|
}
|
|
|
}
|
|
|
@@ -2008,7 +2172,8 @@ namespace UAS_LabelMachine
|
|
|
{
|
|
|
if (MidLabelCombox.SelectedValue != null)
|
|
|
{
|
|
|
- MidBoxCodePrint(CurrentRowIndex);
|
|
|
+ string la_id = MidLabelCombox.SelectedValue.ToString().Split('#')[0];
|
|
|
+ MidBoxCodePrint(la_id, CurrentRowIndex);
|
|
|
}
|
|
|
else
|
|
|
MessageBox.Show("未维护中盒模板");
|
|
|
@@ -2507,26 +2672,5 @@ 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;
|
|
|
- }
|
|
|
- }
|
|
|
}
|
|
|
}
|