|
@@ -13,6 +13,7 @@ using UAS_LabelMachine.PublicForm;
|
|
|
using System.Threading;
|
|
using System.Threading;
|
|
|
using System.IO;
|
|
using System.IO;
|
|
|
using System.Globalization;
|
|
using System.Globalization;
|
|
|
|
|
+using FastReport;
|
|
|
|
|
|
|
|
namespace UAS_LabelMachine
|
|
namespace UAS_LabelMachine
|
|
|
{
|
|
{
|
|
@@ -42,6 +43,10 @@ namespace UAS_LabelMachine
|
|
|
/// 外箱打印文件
|
|
/// 外箱打印文件
|
|
|
/// </summary>
|
|
/// </summary>
|
|
|
Document OutBoxDoc;
|
|
Document OutBoxDoc;
|
|
|
|
|
+
|
|
|
|
|
+ string OutLabelType = "";
|
|
|
|
|
+
|
|
|
|
|
+ Report OutReport = new Report();
|
|
|
/// <summary>
|
|
/// <summary>
|
|
|
/// 唛头文件
|
|
/// 唛头文件
|
|
|
/// </summary>
|
|
/// </summary>
|
|
@@ -625,37 +630,46 @@ namespace UAS_LabelMachine
|
|
|
}
|
|
}
|
|
|
if (OutBoxCombox.Text != "")
|
|
if (OutBoxCombox.Text != "")
|
|
|
{
|
|
{
|
|
|
- OutBoxDoc = lbl.Documents.Open(ftpOperater.DownLoadTo + OutBoxCombox.Text);
|
|
|
|
|
- string ParamCondition = "";
|
|
|
|
|
- for (int i = 0; i < OutBoxDoc.Variables.FreeVariables.Count; i++)
|
|
|
|
|
|
|
+ if (OutBoxCombox.Text.Substring(OutBoxCombox.Text.LastIndexOf(".") + 1).ToLower() == "frx")
|
|
|
|
|
+ {
|
|
|
|
|
+ OutLabelType = "FastReport";
|
|
|
|
|
+ OutReport.Load(ftpOperater.DownLoadTo + OutBoxCombox.Text);
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
{
|
|
{
|
|
|
- if (i != OutBoxDoc.Variables.FreeVariables.Count - 1)
|
|
|
|
|
|
|
+ OutLabelType = "CodeSoft";
|
|
|
|
|
+ OutBoxDoc = lbl.Documents.Open(ftpOperater.DownLoadTo + OutBoxCombox.Text);
|
|
|
|
|
+ string ParamCondition = "";
|
|
|
|
|
+ for (int i = 0; i < OutBoxDoc.Variables.FreeVariables.Count; i++)
|
|
|
{
|
|
{
|
|
|
- ParamCondition += "'" + OutBoxDoc.Variables.FreeVariables.Item(i + 1).Name + "',";
|
|
|
|
|
|
|
+ if (i != OutBoxDoc.Variables.FreeVariables.Count - 1)
|
|
|
|
|
+ {
|
|
|
|
|
+ ParamCondition += "'" + OutBoxDoc.Variables.FreeVariables.Item(i + 1).Name + "',";
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ ParamCondition += "'" + OutBoxDoc.Variables.FreeVariables.Item(i + 1).Name + "'";
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
- else
|
|
|
|
|
|
|
+ OutLabelParam = (DataTable)dh.ExecuteSql("select lp_name,lp_sql from label left join LABELPARAMETER on la_id= lp_laid where la_id=" + OutBoxCombox.SelectedValue.ToString().Split('#')[0] + " and lp_name in(" + ParamCondition + ") order by lp_detno", "select");
|
|
|
|
|
+ DataTable Attach = (DataTable)dh.ExecuteSql("select lap_param lp_name,lap_value lp_sql from LABELATTACHPARAMETER where lap_custcode='" + pi_cardcode.Text + "' and lap_param in(" + ParamCondition + ")", "select");
|
|
|
|
|
+ OutSQL = "select * from ";
|
|
|
|
|
+ for (int i = 0; i < OutLabelParam.Rows.Count; i++)
|
|
|
{
|
|
{
|
|
|
- ParamCondition += "'" + OutBoxDoc.Variables.FreeVariables.Item(i + 1).Name + "'";
|
|
|
|
|
|
|
+ if (i != OutLabelParam.Rows.Count - 1 || Attach.Rows.Count > 0)
|
|
|
|
|
+ OutSQL += "(" + OutLabelParam.Rows[i]["lp_sql"].ToString() + "),";
|
|
|
|
|
+ else
|
|
|
|
|
+ OutSQL += "(" + OutLabelParam.Rows[i]["lp_sql"].ToString() + ")";
|
|
|
}
|
|
}
|
|
|
|
|
+ for (int i = 0; i < Attach.Rows.Count; i++)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (i != Attach.Rows.Count - 1)
|
|
|
|
|
+ OutSQL += "(select '" + Attach.Rows[i]["lp_sql"].ToString() + "' from dual),";
|
|
|
|
|
+ else
|
|
|
|
|
+ OutSQL += "(select '" + Attach.Rows[i]["lp_sql"].ToString() + "' from dual)";
|
|
|
|
|
+ }
|
|
|
|
|
+ OutLabelParam.Merge(Attach);
|
|
|
}
|
|
}
|
|
|
- OutLabelParam = (DataTable)dh.ExecuteSql("select lp_name,lp_sql from label left join LABELPARAMETER on la_id= lp_laid where la_id=" + OutBoxCombox.SelectedValue.ToString().Split('#')[0] + " and lp_name in(" + ParamCondition + ") order by lp_detno", "select");
|
|
|
|
|
- DataTable Attach = (DataTable)dh.ExecuteSql("select lap_param lp_name,lap_value lp_sql from LABELATTACHPARAMETER where lap_custcode='" + pi_cardcode.Text + "' and lap_param in(" + ParamCondition + ")", "select");
|
|
|
|
|
- OutSQL = "select * from ";
|
|
|
|
|
- for (int i = 0; i < OutLabelParam.Rows.Count; i++)
|
|
|
|
|
- {
|
|
|
|
|
- if (i != OutLabelParam.Rows.Count - 1 || Attach.Rows.Count > 0)
|
|
|
|
|
- OutSQL += "(" + OutLabelParam.Rows[i]["lp_sql"].ToString() + "),";
|
|
|
|
|
- else
|
|
|
|
|
- OutSQL += "(" + OutLabelParam.Rows[i]["lp_sql"].ToString() + ")";
|
|
|
|
|
- }
|
|
|
|
|
- for (int i = 0; i < Attach.Rows.Count; i++)
|
|
|
|
|
- {
|
|
|
|
|
- if (i != Attach.Rows.Count - 1)
|
|
|
|
|
- OutSQL += "(select '" + Attach.Rows[i]["lp_sql"].ToString() + "' from dual),";
|
|
|
|
|
- else
|
|
|
|
|
- OutSQL += "(select '" + Attach.Rows[i]["lp_sql"].ToString() + "' from dual)";
|
|
|
|
|
- }
|
|
|
|
|
- OutLabelParam.Merge(Attach);
|
|
|
|
|
}
|
|
}
|
|
|
if (!File.Exists(ftpOperater.DownLoadTo + "唛头.lab"))
|
|
if (!File.Exists(ftpOperater.DownLoadTo + "唛头.lab"))
|
|
|
{
|
|
{
|
|
@@ -973,14 +987,11 @@ namespace UAS_LabelMachine
|
|
|
{
|
|
{
|
|
|
for (int i = 0; i < LabelInf.RowCount; i++)
|
|
for (int i = 0; i < LabelInf.RowCount; i++)
|
|
|
{
|
|
{
|
|
|
- if (LabelInf.Rows[i].Cells["Choose"].FormattedValue.ToString().ToLower() == "true")
|
|
|
|
|
- {
|
|
|
|
|
- string outboxcode2 = LabelInf.Rows[i].Cells["pib_outboxcode2"].Value.ToString();
|
|
|
|
|
- //富为使用包装单的逻辑
|
|
|
|
|
- //如果不包含该箱号则进行添加
|
|
|
|
|
- if (!Outboxcode.Contains(outboxcode2))
|
|
|
|
|
- Outboxcode.Add(outboxcode2);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ string outboxcode2 = LabelInf.Rows[i].Cells["pib_outboxcode2"].Value.ToString();
|
|
|
|
|
+ //富为使用包装单的逻辑
|
|
|
|
|
+ //如果不包含该箱号则进行添加
|
|
|
|
|
+ if (!Outboxcode.Contains(outboxcode2))
|
|
|
|
|
+ Outboxcode.Add(outboxcode2);
|
|
|
}
|
|
}
|
|
|
//按获取到的箱号列表进行打印
|
|
//按获取到的箱号列表进行打印
|
|
|
if (Outboxcode.ToArray().Length > 0)
|
|
if (Outboxcode.ToArray().Length > 0)
|
|
@@ -1094,24 +1105,50 @@ namespace UAS_LabelMachine
|
|
|
{
|
|
{
|
|
|
try
|
|
try
|
|
|
{
|
|
{
|
|
|
- //将维护的模板参数和模板本身的参数名称进行比对
|
|
|
|
|
string pib_id = LabelInf.Rows[rowindex].Cells["pib_id1"].Value.ToString();
|
|
string pib_id = LabelInf.Rows[rowindex].Cells["pib_id1"].Value.ToString();
|
|
|
string pib_outboxcode2 = LabelInf.Rows[rowindex].Cells["pib_outboxcode2"].Value.ToString();
|
|
string pib_outboxcode2 = LabelInf.Rows[rowindex].Cells["pib_outboxcode2"].Value.ToString();
|
|
|
- DataTable dt = (DataTable)dh.ExecuteSql(OutSQL.ToLower().Replace("{pib_id}", "'" + pib_id + "'").Replace("{pib_outboxcode2}", "'" + pib_outboxcode2 + "'"), "select");
|
|
|
|
|
- for (int k = 0; k < OutLabelParam.Rows.Count; k++)
|
|
|
|
|
|
|
+ if (OutLabelType == "CodeSoft")
|
|
|
|
|
+ {
|
|
|
|
|
+ //将维护的模板参数和模板本身的参数名称进行比对
|
|
|
|
|
+ DataTable dt = (DataTable)dh.ExecuteSql(OutSQL.ToLower().Replace("{pib_id}", "'" + pib_id + "'").Replace("{pib_outboxcode2}", "'" + pib_outboxcode2 + "'"), "select");
|
|
|
|
|
+ for (int k = 0; k < OutLabelParam.Rows.Count; k++)
|
|
|
|
|
+ {
|
|
|
|
|
+ //获取对应行的pib_id
|
|
|
|
|
+ string ParamName = OutLabelParam.Rows[k]["lp_name"].ToString();
|
|
|
|
|
+ OutBoxDoc.Variables.FreeVariables.Item(ParamName).Value = dt.Rows[0][k].ToString();
|
|
|
|
|
+ LogManager.DoLog("打印参数【" + OutBoxDoc.Variables.FreeVariables.Item(ParamName).Name + "】赋值" + ",取到值" + OutBoxDoc.Variables.FreeVariables.Item(ParamName).Value);
|
|
|
|
|
+ }
|
|
|
|
|
+ //保存参数打印
|
|
|
|
|
+ OutBoxDoc.Printer.SwitchTo(OutBoxPrinter.Text);
|
|
|
|
|
+ OutBoxDoc.PrintDocument();
|
|
|
|
|
+ Properties.Settings.Default.OPrinter = OutBoxPrinter.Text;
|
|
|
|
|
+ Properties.Settings.Default.Save();
|
|
|
|
|
+ LogManager.DoLog("执行打印外箱,pib_id:" + LabelInf.Rows[rowindex].Cells["pib_id1"].Value.ToString());
|
|
|
|
|
+ LogManager.DoCommandLog(pi_inoutno.Text, User.UserCode, "手动打印外箱箱标", "打印成功");
|
|
|
|
|
+ }
|
|
|
|
|
+ else if (OutLabelType == "FastReport")
|
|
|
{
|
|
{
|
|
|
- //获取对应行的pib_id
|
|
|
|
|
- string ParamName = OutLabelParam.Rows[k]["lp_name"].ToString();
|
|
|
|
|
- OutBoxDoc.Variables.FreeVariables.Item(ParamName).Value = dt.Rows[0][k].ToString();
|
|
|
|
|
- LogManager.DoLog("打印参数【" + OutBoxDoc.Variables.FreeVariables.Item(ParamName).Name + "】赋值" + ",取到值" + OutBoxDoc.Variables.FreeVariables.Item(ParamName).Value);
|
|
|
|
|
|
|
+ DataTable dt = (DataTable)dh.ExecuteSql("select * from prodioinfo_view where 出货单号='" + pi_inoutno.Text + "' and 外箱号='" + pib_outboxcode2 + "'", "select");
|
|
|
|
|
+ DataTable dt1 = dt.Clone();
|
|
|
|
|
+ for (int i = 0; i < dt.Rows.Count; i++)
|
|
|
|
|
+ {
|
|
|
|
|
+ DataRow dr = dt1.NewRow();
|
|
|
|
|
+ for (int j = 0; j < dt.Columns.Count; j++)
|
|
|
|
|
+ {
|
|
|
|
|
+ dr[j] = dt.Rows[i][j].ToString();
|
|
|
|
|
+ }
|
|
|
|
|
+ dt1.Rows.Add(dr);
|
|
|
|
|
+ if ((i + 1) % 5 == 0 || (i + 1) == dt.Rows.Count)
|
|
|
|
|
+ {
|
|
|
|
|
+ OutReport.RegisterData(dt1, "prodioinfo_view");
|
|
|
|
|
+ OutReport.GetDataSource("prodioinfo_view").Enabled = true;
|
|
|
|
|
+ OutReport.PrintSettings.ShowDialog = false;
|
|
|
|
|
+ OutReport.PrintSettings.Printer = OutBoxPrinter.Text;
|
|
|
|
|
+ OutReport.Print();
|
|
|
|
|
+ BaseUtil.CleanDataTableData(dt1);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
- //保存参数打印
|
|
|
|
|
- OutBoxDoc.Printer.SwitchTo(OutBoxPrinter.Text);
|
|
|
|
|
- OutBoxDoc.PrintDocument();
|
|
|
|
|
- Properties.Settings.Default.OPrinter = OutBoxPrinter.Text;
|
|
|
|
|
- Properties.Settings.Default.Save();
|
|
|
|
|
- LogManager.DoLog("执行打印外箱,pib_id:" + LabelInf.Rows[rowindex].Cells["pib_id1"].Value.ToString());
|
|
|
|
|
- LogManager.DoCommandLog(pi_inoutno.Text, User.UserCode, "手动打印外箱箱标", "打印成功");
|
|
|
|
|
}
|
|
}
|
|
|
catch (Exception ex) { MessageBox.Show(ex.Message, "提示"); }
|
|
catch (Exception ex) { MessageBox.Show(ex.Message, "提示"); }
|
|
|
}
|
|
}
|