|
|
@@ -15,6 +15,7 @@ using UAS_LabelMachine.PublicForm;
|
|
|
using System.Threading;
|
|
|
using System.IO;
|
|
|
using System.Globalization;
|
|
|
+using System.Threading.Tasks;
|
|
|
|
|
|
namespace UAS_LabelMachine
|
|
|
{
|
|
|
@@ -86,6 +87,10 @@ namespace UAS_LabelMachine
|
|
|
//每个不同序号存在的
|
|
|
object[] ItemData;
|
|
|
|
|
|
+ DataTable SingleLabelParam;
|
|
|
+ DataTable MidLabelParam;
|
|
|
+ DataTable OutLabelParam;
|
|
|
+
|
|
|
Dictionary<string, string> CollectData;
|
|
|
//缓存单盘数据数据的DataTable
|
|
|
DataTable SingleBoxCacheData;
|
|
|
@@ -134,6 +139,12 @@ namespace UAS_LabelMachine
|
|
|
/// </summary>
|
|
|
bool ComBoxClickChangeLabelDoc = false;
|
|
|
|
|
|
+ List<string> SingleParam = new List<string>();
|
|
|
+
|
|
|
+ List<string> MidParam = new List<string>();
|
|
|
+
|
|
|
+ List<string> OutParam = new List<string>();
|
|
|
+
|
|
|
public UAS_出货标签打印(string Master)
|
|
|
{
|
|
|
InitializeComponent();
|
|
|
@@ -159,7 +170,7 @@ namespace UAS_LabelMachine
|
|
|
}
|
|
|
//用计时器重置数据库链接
|
|
|
LogManager.DoLog("程序启动,登陆人员【" + User.UserName + "】");
|
|
|
- dh = new DataHelper();
|
|
|
+ dh = SystemInf.dh;
|
|
|
CheckForIllegalCrossThreadCalls = false;
|
|
|
CloumnCount = LabelInf.Columns.Count;
|
|
|
pi_inoutno.Focus();
|
|
|
@@ -231,9 +242,15 @@ namespace UAS_LabelMachine
|
|
|
BaseUtil.SetFormValue(this.Controls, dt);
|
|
|
}
|
|
|
|
|
|
+ //只执行一次窗体自适应
|
|
|
+ bool AutoSized = false;
|
|
|
private void 贴标机条码打印_SizeChanged(object sender, EventArgs e)
|
|
|
{
|
|
|
- asc.controlAutoSize(this);
|
|
|
+ if (!AutoSized)
|
|
|
+ {
|
|
|
+ asc.controlAutoSize(this);
|
|
|
+ AutoSized = true;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private void GenerateBarCode_Click(object sender, EventArgs e)
|
|
|
@@ -294,17 +311,6 @@ namespace UAS_LabelMachine
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void SaveGridData()
|
|
|
- {
|
|
|
- DataTable savedt = (LabelInf.DataSource as DataTable);
|
|
|
- if (LabelInf.DataSource != null && savedt.GetChanges() != null)
|
|
|
- {
|
|
|
- dh.UpDateTableByCondition(savedt, "ProdioBarCode", "pib_id");
|
|
|
- LoadGridData(new object(), new EventArgs());
|
|
|
- MessageBox.Show("保存成功!");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
//放大镜选择后出发的事件
|
|
|
private void sg_code_UserControlTextChanged(object sender, EventArgs e)
|
|
|
{
|
|
|
@@ -655,45 +661,58 @@ namespace UAS_LabelMachine
|
|
|
|
|
|
private void AutoPrintSingleLabel(string la_id, string LabelUrl)
|
|
|
{
|
|
|
- //获取维护的变量名称和SQL
|
|
|
- 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");
|
|
|
- DataTable Attach = (DataTable)dh.ExecuteSql("select lap_param lp_name,lap_value lp_sql from LabelAttachPARAMETER where lap_custcode='" + pi_cardcode.Text + "'", "select");
|
|
|
//用标签本身的变量作为最外层的循环条件去匹配;
|
|
|
- dt.Merge(Attach);
|
|
|
+ string[] arg = SingleBoxArgument.ToArray();
|
|
|
+ StringBuilder ParamLog = new StringBuilder();
|
|
|
for (int j = 0; j < SingleDoc.Variables.FreeVariables.Count; j++)
|
|
|
{
|
|
|
//将维护的模板参数和模板本身的参数名称进行比对
|
|
|
- for (int k = 0; k < dt.Rows.Count; k++)
|
|
|
+ for (int k = 0; k < SingleLabelParam.Rows.Count; k++)
|
|
|
{
|
|
|
//名称相等的时候,取SQL进行值的查询
|
|
|
- if (SingleDoc.Variables.FreeVariables.Item(j + 1).Name.ToLower() == dt.Rows[k]["lp_name"].ToString().ToLower())
|
|
|
+ if (SingleDoc.Variables.FreeVariables.Item(j + 1).Name == SingleLabelParam.Rows[k]["lp_name"].ToString().ToLower())
|
|
|
{
|
|
|
- //获取打印执行的SQL
|
|
|
- string sql = dt.Rows[k]["lp_sql"].ToString();
|
|
|
- if (sql.IndexOf("{") == 0)
|
|
|
+ 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).Name.Contains("datecode1"))
|
|
|
{
|
|
|
- SingleDoc.Variables.FreeVariables.Item(j + 1).Value = dh.GetLabelParam(sql).ToString();
|
|
|
- LogManager.DoLog("打印参数【" + SingleDoc.Variables.FreeVariables.Item(j + 1).Name + "】赋值," + "取值SQL:" + sql + ",取到值" + SingleDoc.Variables.FreeVariables.Item(j + 1).Value);
|
|
|
+ if (LabelInf.Rows[CurrentRowIndex].Cells["pib_datecode1"].Value != null)
|
|
|
+ SingleDoc.Variables.FreeVariables.Item(j + 1).Value = LabelInf.Rows[CurrentRowIndex].Cells["pib_datecode1"].Value.ToString();
|
|
|
}
|
|
|
- else
|
|
|
+ else if (SingleDoc.Variables.FreeVariables.Item(j + 1).Name.Contains("lotno"))
|
|
|
{
|
|
|
- sql = sql.Substring(0, sql.IndexOf("{"));
|
|
|
- //获取对应行的pib_id
|
|
|
- string pib_id = LabelInf.Rows[CurrentRowIndex].Cells["pib_id1"].Value.ToString();
|
|
|
- if (sql.ToLower().Contains("pib_lotno"))
|
|
|
+ if (LabelInf.Rows[CurrentRowIndex].Cells["pib_lotno"].Value != null)
|
|
|
SingleDoc.Variables.FreeVariables.Item(j + 1).Value = LabelInf.Rows[CurrentRowIndex].Cells["pib_lotno"].Value.ToString();
|
|
|
- else if (sql.ToLower().Contains("pib_datecode"))
|
|
|
+ }
|
|
|
+ else if (SingleDoc.Variables.FreeVariables.Item(j + 1).Name.Contains("datecode"))
|
|
|
+ {
|
|
|
+ if (LabelInf.Rows[CurrentRowIndex].Cells["pib_datecode"].Value != null)
|
|
|
SingleDoc.Variables.FreeVariables.Item(j + 1).Value = LabelInf.Rows[CurrentRowIndex].Cells["pib_datecode"].Value.ToString();
|
|
|
- else if (sql.ToLower().Contains("pib_madein"))
|
|
|
+ }
|
|
|
+ else if (SingleDoc.Variables.FreeVariables.Item(j + 1).Name.Contains("产地"))
|
|
|
+ {
|
|
|
+ if (LabelInf.Rows[CurrentRowIndex].Cells["pib_madein"].Value != null)
|
|
|
SingleDoc.Variables.FreeVariables.Item(j + 1).Value = LabelInf.Rows[CurrentRowIndex].Cells["pib_madein"].Value.ToString();
|
|
|
- else if (sql.ToLower().Contains("pib_cusbarcode"))
|
|
|
+ }
|
|
|
+ else if (SingleDoc.Variables.FreeVariables.Item(j + 1).Name.Contains("pib_cusbarcode"))
|
|
|
+ {
|
|
|
+ if (LabelInf.Rows[CurrentRowIndex].Cells["pib_cusbarcode"].Value != null)
|
|
|
SingleDoc.Variables.FreeVariables.Item(j + 1).Value = LabelInf.Rows[CurrentRowIndex].Cells["pib_cusbarcode"].Value.ToString();
|
|
|
- else if (sql.ToLower().Contains("pib_cusoutboxcode"))
|
|
|
- SingleDoc.Variables.FreeVariables.Item(j + 1).Value = LabelInf.Rows[CurrentRowIndex].Cells["pib_cusoutboxcode"].Value.ToString();
|
|
|
- else
|
|
|
- SingleDoc.Variables.FreeVariables.Item(j + 1).Value = dh.GetLabelParam(sql + pib_id).ToString();
|
|
|
- LogManager.DoLog("打印参数【" + SingleDoc.Variables.FreeVariables.Item(j + 1).Name + "】赋值," + "取值SQL:" + sql + pib_id + ",取到值" + SingleDoc.Variables.FreeVariables.Item(j + 1).Value);
|
|
|
}
|
|
|
+ if (SingleDoc.Variables.FreeVariables.Item(j + 1).Value == "")
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ SingleDoc.Variables.FreeVariables.Item(j + 1).Value = SingleLabelParam.Select("lp_name='" + SingleDoc.Variables.FreeVariables.Item(j + 1).Name + "'")[0]["lp_sql"].ToString();
|
|
|
+ }
|
|
|
+ catch (Exception)
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ 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);
|
|
|
}
|
|
|
else if (SingleDoc.Variables.FreeVariables.Item(j + 1).Name == "DateCode1")
|
|
|
{
|
|
|
@@ -702,10 +721,13 @@ namespace UAS_LabelMachine
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ LogManager.DoLog(ParamLog.ToString());
|
|
|
//保存参数打印
|
|
|
- SingleDoc.Printer.SwitchTo(SingleLabelPrinter.Text);
|
|
|
- SingleDoc.PrintDocument();
|
|
|
- LogManager.DoLog("执行打印单盘,pib_id:" + LabelInf.Rows[CurrentRowIndex].Cells["pib_id1"].Value.ToString() + ",标签地址" + LabelUrl);
|
|
|
+ if (EnablePrint)
|
|
|
+ {
|
|
|
+ SingleDoc.Printer.SwitchTo(SingleLabelPrinter.Text);
|
|
|
+ SingleDoc.PrintDocument();
|
|
|
+ }
|
|
|
LabelInf.Rows[CurrentRowIndex].Cells["pib_ifprint"].Value = true;
|
|
|
}
|
|
|
|
|
|
@@ -962,7 +984,7 @@ namespace UAS_LabelMachine
|
|
|
else
|
|
|
str = str.Substring(int.Parse(SiItem[item]["si_index"]));
|
|
|
}
|
|
|
- catch (Exception e) { LogManager.DoLog(e.Message); }
|
|
|
+ catch (Exception e) { LogManager.DoLog(e.StackTrace); }
|
|
|
}
|
|
|
break;
|
|
|
case "索引字符":
|
|
|
@@ -978,7 +1000,7 @@ namespace UAS_LabelMachine
|
|
|
str = str.Substring(str.IndexOf(SiItem[item]["si_indexstring"]) + 1);
|
|
|
}
|
|
|
}
|
|
|
- catch (Exception e) { LogManager.DoLog(e.Message); }
|
|
|
+ catch (Exception e) { LogManager.DoLog(e.StackTrace); }
|
|
|
break;
|
|
|
case "二次解析":
|
|
|
if (SiItem[item]["si_indexstring"] != "")
|
|
|
@@ -1038,6 +1060,7 @@ namespace UAS_LabelMachine
|
|
|
private void GetInOutInfAndLabelFile()
|
|
|
{
|
|
|
ComBoxClickChangeLabelDoc = false;
|
|
|
+ DataTable Attach = (DataTable)dh.ExecuteSql("select lap_param lp_name,lap_value lp_sql from LabelAttachPARAMETER where lap_custcode='" + pi_cardcode.Text + "'", "select");
|
|
|
sql.Clear();
|
|
|
sql.Append("select to_char(nvl(cl_date,sysdate),'YYYY-MM-DD HH24:Mi:SS') cl_date,cl_labelname,cl_isdefault,la_id||'#'||cl_labelurl||'#'||to_char(cl_date,'YYYY-MM-DD HH24:Mi:SS') la_id,cl_custcode from customerlabel left join prodinout on pi_cardcode=cl_custcode ");
|
|
|
sql.Append("left join customer on cu_code=cl_custcode left join label on la_code=CL_LABELCODE where ((pi_cardcode='" + pi_cardcode.Text + "' ");
|
|
|
@@ -1059,7 +1082,15 @@ namespace UAS_LabelMachine
|
|
|
BaseUtil.GetLabelUrl(LabelUrl, LabelName, time);
|
|
|
}
|
|
|
if (SingleLabelCombox.Text != "")
|
|
|
+ {
|
|
|
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");
|
|
|
+ SingleLabelParam.Merge(Attach);
|
|
|
+ for (int i = 0; i < SingleDoc.Variables.FreeVariables.Count; i++)
|
|
|
+ {
|
|
|
+ SingleParam.Add(SingleDoc.Variables.FreeVariables.Item(i + 1).Name);
|
|
|
+ }
|
|
|
+ }
|
|
|
sql.Clear();
|
|
|
sql.Append("select to_char(nvl(cl_date,sysdate),'YYYY-MM-DD HH24:Mi:SS') cl_date,cl_labelname,cl_isdefault,la_id||'#'||cl_labelurl||'#'||to_char(cl_date,'YYYY-MM-DD HH24:Mi:SS') la_id,cl_custcode from customerlabel left join prodinout on pi_cardcode=cl_custcode ");
|
|
|
sql.Append("left join customer on cu_code=cl_custcode left join label on la_code=CL_LABELCODE where ((pi_cardcode='" + pi_cardcode.Text + "' ");
|
|
|
@@ -1081,7 +1112,12 @@ namespace UAS_LabelMachine
|
|
|
BaseUtil.GetLabelUrl(LabelUrl, LabelName, time);
|
|
|
}
|
|
|
if (MidLabelCombox.Text != "")
|
|
|
+ {
|
|
|
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");
|
|
|
+ MidLabelParam.Merge(Attach);
|
|
|
+ }
|
|
|
+ //缓存中盒参数
|
|
|
sql.Clear();
|
|
|
sql.Append("select to_char(nvl(cl_date,sysdate),'YYYY-MM-DD HH24:Mi:SS') cl_date,cl_labelname,cl_isdefault,la_id||'#'||cl_labelurl||'#'||to_char(cl_date,'YYYY-MM-DD HH24:Mi:SS') la_id,cl_custcode from customerlabel left join prodinout on pi_cardcode=cl_custcode ");
|
|
|
sql.Append("left join customer on cu_code=cl_custcode left join label on la_code=CL_LABELCODE where ((pi_cardcode='" + pi_cardcode.Text + "' ");
|
|
|
@@ -1105,8 +1141,12 @@ namespace UAS_LabelMachine
|
|
|
if (OutBoxCombox.Text != "")
|
|
|
{
|
|
|
OutBoxDoc = lbl.Documents.Open(ftpOperater.DownLoadTo + OutBoxCombox.Text);
|
|
|
+ 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], "select");
|
|
|
+ OutLabelParam.Merge(Attach);
|
|
|
}
|
|
|
+ //缓存外箱参数
|
|
|
ComBoxClickChangeLabelDoc = true;
|
|
|
+ Parallel.Invoke(GetSingleBoxData, GetMidBoxData);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
@@ -1139,6 +1179,8 @@ namespace UAS_LabelMachine
|
|
|
SingleBoxArgument.Clear();
|
|
|
SingleBoxCacheData.Clear();
|
|
|
BaseUtil.CleanDataTable(SingleBoxCacheData);
|
|
|
+ MidIDAndOutboxcode.Clear();
|
|
|
+ SingleID.Clear();
|
|
|
//刷新采集进度
|
|
|
RefreshProcessData();
|
|
|
//设置当前的最大箱号
|
|
|
@@ -1153,6 +1195,7 @@ namespace UAS_LabelMachine
|
|
|
//if (int.Parse(outboxcode == "" ? "1" : outboxcode) > MaxOutBoxCode)
|
|
|
// MaxOutBoxCode = int.Parse(outboxcode);
|
|
|
}
|
|
|
+ LoadPrcodeData();
|
|
|
thread = new Thread(GetInOutInfAndLabelFile);
|
|
|
stw = new SetLoadingWindow(thread, "正在获取打印标签");
|
|
|
BaseUtil.SetFormCenter(stw);
|
|
|
@@ -1192,7 +1235,7 @@ namespace UAS_LabelMachine
|
|
|
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 (dt.Rows.Count > 0 && LabelInf.Rows.Count > 0)
|
|
|
+ if (SingleLabelParam.Rows.Count > 0 && LabelInf.Rows.Count > 0)
|
|
|
{
|
|
|
//每次打印清除之前缓存的行号和ID,后面会判断需要打印的数据重新加载
|
|
|
MidIDAndOutboxcode.Clear();
|
|
|
@@ -1203,7 +1246,8 @@ namespace UAS_LabelMachine
|
|
|
outboxcode1.Add(LabelInf.Rows[0].Cells["pib_outboxcode1"].Value.ToString(), true);
|
|
|
for (int i = 0; i < LabelInf.Rows.Count; i++)
|
|
|
{
|
|
|
- SingleID.Add(LabelInf.Rows[i].Cells["pib_id1"].Value.ToString());
|
|
|
+ if (!SingleID.Contains(LabelInf.Rows[i].Cells["pib_id1"].Value.ToString()))
|
|
|
+ SingleID.Add(LabelInf.Rows[i].Cells["pib_id1"].Value.ToString());
|
|
|
if (LabelInf.Rows[i].Cells["Choose"].FormattedValue.ToString() == "True" && LabelInf.Rows[i].Cells["pib_ifpick"].FormattedValue.ToString() == "True" && LabelInf.Rows[i].Cells["pib_ifprint"].FormattedValue.ToString() != "True")
|
|
|
{
|
|
|
//如果不存在中盒号则进行添加
|
|
|
@@ -1222,9 +1266,7 @@ namespace UAS_LabelMachine
|
|
|
if (SingleBoxCacheData.Rows.Count == 0)
|
|
|
GetSingleBoxData();
|
|
|
if (MidBoxCacheData.Rows.Count == 0)
|
|
|
- {
|
|
|
GetMidBoxData();
|
|
|
- }
|
|
|
for (int i = 0; i < LabelInf.RowCount; i++)
|
|
|
{
|
|
|
if (i + 1 < LabelInf.RowCount)
|
|
|
@@ -1246,10 +1288,6 @@ namespace UAS_LabelMachine
|
|
|
//用于判断用户是否勾选了行
|
|
|
int CheckedRowCount = 0;
|
|
|
string[] arg = SingleBoxArgument.ToArray();
|
|
|
- //打印所有的选中行
|
|
|
- DataTable Attach = (DataTable)dh.ExecuteSql("select lap_param lp_name,lap_value lp_sql from LabelAttachPARAMETER where lap_custcode='" + pi_cardcode.Text + "'", "select");
|
|
|
- //用标签本身的变量作为最外层的循环条件去匹配;
|
|
|
- dt.Merge(Attach);
|
|
|
for (int i = 0; i < LabelInf.RowCount; i++)
|
|
|
{
|
|
|
//勾选了并且未打印
|
|
|
@@ -1294,14 +1332,23 @@ namespace UAS_LabelMachine
|
|
|
}
|
|
|
if (SingleDoc.Variables.FreeVariables.Item(j + 1).Value == "")
|
|
|
{
|
|
|
- SingleDoc.Variables.FreeVariables.Item(j + 1).Value = dt.Select("lp_name='" + SingleDoc.Variables.FreeVariables.Item(j + 1).Name + "'")[0]["lp_sql"].ToString();
|
|
|
+ try
|
|
|
+ {
|
|
|
+ SingleDoc.Variables.FreeVariables.Item(j + 1).Value = SingleLabelParam.Select("lp_name='" + SingleDoc.Variables.FreeVariables.Item(j + 1).Name + "'")[0]["lp_sql"].ToString();
|
|
|
+ }
|
|
|
+ catch (Exception)
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
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 (EnablePrint) {
|
|
|
+ SingleDoc.Printer.SwitchTo(SingleLabelPrinter.Text);
|
|
|
+ SingleDoc.PrintDocument();
|
|
|
+ }
|
|
|
if (MidLabelAutoPrint.Checked)
|
|
|
{
|
|
|
//判断当前行的盒号和下一行不相等或者已经是最后一行了
|
|
|
@@ -1344,6 +1391,16 @@ namespace UAS_LabelMachine
|
|
|
/// </summary>
|
|
|
private void GetSingleBoxData()
|
|
|
{
|
|
|
+ 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();
|
|
|
//将所有的列存在在这里
|
|
|
@@ -1357,14 +1414,14 @@ namespace UAS_LabelMachine
|
|
|
for (int j = 0; j < SingleDoc.Variables.FreeVariables.Count; j++)
|
|
|
{
|
|
|
//将维护的模板参数和模板本身的参数名称进行比对
|
|
|
- for (int k = 0; k < dt.Rows.Count; k++)
|
|
|
+ for (int k = 0; k < SingleLabelParam.Rows.Count; k++)
|
|
|
{
|
|
|
- if (SingleDoc.Variables.FreeVariables.Item(j + 1).Name == dt.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 = dt.Rows[k]["lp_sql"].ToString();
|
|
|
+ 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");
|
|
|
@@ -1394,8 +1451,18 @@ namespace UAS_LabelMachine
|
|
|
/// </summary>
|
|
|
private void GetMidBoxData()
|
|
|
{
|
|
|
+ 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()))
|
|
|
+ {
|
|
|
+ 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();
|
|
|
@@ -1422,18 +1489,17 @@ namespace UAS_LabelMachine
|
|
|
return;
|
|
|
}
|
|
|
string la_id = MidLabelCombox.SelectedValue.ToString().Split('#')[0];
|
|
|
- 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");
|
|
|
for (int j = 0; j < MidDoc.Variables.FreeVariables.Count; j++)
|
|
|
{
|
|
|
//将维护的模板参数和模板本身的参数名称进行比对
|
|
|
- for (int k = 0; k < dt.Rows.Count; k++)
|
|
|
+ for (int k = 0; k < MidLabelParam.Rows.Count; k++)
|
|
|
{
|
|
|
- if (MidDoc.Variables.FreeVariables.Item(j + 1).Name == dt.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 = dt.Rows[k]["lp_sql"].ToString();
|
|
|
+ string sql = MidLabelParam.Rows[k]["lp_sql"].ToString();
|
|
|
//如果打印的含有数量
|
|
|
if (sql.ToLower().Contains("pib_qty"))
|
|
|
{
|
|
|
@@ -1712,16 +1778,16 @@ namespace UAS_LabelMachine
|
|
|
for (int j = 0; j < MidDoc.Variables.FreeVariables.Count; j++)
|
|
|
{
|
|
|
//将维护的模板参数和模板本身的参数名称进行比对
|
|
|
- for (int k = 0; k < dt.Rows.Count; k++)
|
|
|
+ for (int k = 0; k < MidLabelParam.Rows.Count; k++)
|
|
|
{
|
|
|
//名称相等的时候,取SQL进行值的查询
|
|
|
- if (MidDoc.Variables.FreeVariables.Item(j + 1).Name == dt.Rows[k]["lp_name"].ToString())
|
|
|
+ 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 = dt.Rows[k]["lp_sql"].ToString();
|
|
|
+ string sql = MidLabelParam.Rows[k]["lp_sql"].ToString();
|
|
|
try
|
|
|
{
|
|
|
//获取打印执行的SQL
|
|
|
@@ -1755,6 +1821,17 @@ namespace UAS_LabelMachine
|
|
|
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 == "")
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ MidDoc.Variables.FreeVariables.Item(j + 1).Value = MidLabelParam.Select("lp_name='" + MidDoc.Variables.FreeVariables.Item(j + 1).Name + "'")[0]["lp_sql"].ToString();
|
|
|
+ }
|
|
|
+ catch (Exception)
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
LogManager.DoLog("打印参数【" + MidDoc.Variables.FreeVariables.Item(j + 1).Name + "】赋值," + "取值SQL:" + sql + ",取到值" + MidDoc.Variables.FreeVariables.Item(j + 1).Value);
|
|
|
}
|
|
|
}
|
|
|
@@ -1767,29 +1844,27 @@ namespace UAS_LabelMachine
|
|
|
}
|
|
|
}
|
|
|
//保存参数打印
|
|
|
- MidDoc.Printer.SwitchTo(MidLabelPrinter.Text);
|
|
|
- MidDoc.PrintDocument();
|
|
|
+ if (EnablePrint) {
|
|
|
+ MidDoc.Printer.SwitchTo(MidLabelPrinter.Text);
|
|
|
+ MidDoc.PrintDocument();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private void MidBoxCodePrint(string la_id, int rowindex, int[] midindex)
|
|
|
{
|
|
|
- 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");
|
|
|
- DataTable Attach = (DataTable)dh.ExecuteSql("select lap_param lp_name,lap_value lp_sql from LabelAttachPARAMETER where lap_custcode='" + pi_cardcode.Text + "'", "select");
|
|
|
- //用标签本身的变量作为最外层的循环条件去匹配;
|
|
|
- dt.Merge(Attach);
|
|
|
for (int j = 0; j < MidDoc.Variables.FreeVariables.Count; j++)
|
|
|
{
|
|
|
//将维护的模板参数和模板本身的参数名称进行比对
|
|
|
- for (int k = 0; k < dt.Rows.Count; k++)
|
|
|
+ for (int k = 0; k < MidLabelParam.Rows.Count; k++)
|
|
|
{
|
|
|
//名称相等的时候,取SQL进行值的查询
|
|
|
- if (MidDoc.Variables.FreeVariables.Item(j + 1).Name == dt.Rows[k]["lp_name"].ToString())
|
|
|
+ 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 = dt.Rows[k]["lp_sql"].ToString();
|
|
|
+ string sql = MidLabelParam.Rows[k]["lp_sql"].ToString();
|
|
|
try
|
|
|
{
|
|
|
//获取打印执行的SQL
|
|
|
@@ -1830,6 +1905,17 @@ namespace UAS_LabelMachine
|
|
|
}
|
|
|
MidDoc.Variables.FreeVariables.Item(j + 1).Value = dh.GetLabelParam(sql).ToString();
|
|
|
}
|
|
|
+ if (MidDoc.Variables.FreeVariables.Item(j + 1).Value == "")
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ MidDoc.Variables.FreeVariables.Item(j + 1).Value = MidLabelParam.Select("lp_name='" + MidDoc.Variables.FreeVariables.Item(j + 1).Name + "'")[0]["lp_sql"].ToString();
|
|
|
+ }
|
|
|
+ catch (Exception)
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
LogManager.DoLog("打印参数【" + MidDoc.Variables.FreeVariables.Item(j + 1).Name + "】赋值," + "取值SQL:" + sql + ",取到值" + MidDoc.Variables.FreeVariables.Item(j + 1).Value);
|
|
|
}
|
|
|
}
|
|
|
@@ -1842,8 +1928,10 @@ namespace UAS_LabelMachine
|
|
|
}
|
|
|
}
|
|
|
//保存参数打印
|
|
|
- MidDoc.Printer.SwitchTo(MidLabelPrinter.Text);
|
|
|
- MidDoc.PrintDocument();
|
|
|
+ if (EnablePrint) {
|
|
|
+ MidDoc.Printer.SwitchTo(MidLabelPrinter.Text);
|
|
|
+ MidDoc.PrintDocument();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
@@ -1860,18 +1948,18 @@ namespace UAS_LabelMachine
|
|
|
for (int j = 0; j < OutBoxDoc.Variables.FreeVariables.Count; j++)
|
|
|
{
|
|
|
//将维护的模板参数和模板本身的参数名称进行比对
|
|
|
- for (int k = 0; k < dt.Rows.Count; k++)
|
|
|
+ for (int k = 0; k < OutLabelParam.Rows.Count; k++)
|
|
|
{
|
|
|
//名称相等的时候,取SQL进行值的查询
|
|
|
- if (OutBoxDoc.Variables.FreeVariables.Item(j + 1).Name == dt.Rows[k]["lp_name"].ToString())
|
|
|
+ if (OutBoxDoc.Variables.FreeVariables.Item(j + 1).Name == OutLabelParam.Rows[k]["lp_name"].ToString())
|
|
|
{
|
|
|
//如果毛重填写的是毛重或者净重
|
|
|
- if (dt.Rows[k]["lp_valuetype"].ToString() == "字符串" && dt.Rows[k]["lp_sql"].ToString() == "GW")
|
|
|
+ if (OutLabelParam.Rows[k]["lp_valuetype"].ToString() == "字符串" && OutLabelParam.Rows[k]["lp_sql"].ToString() == "GW")
|
|
|
{
|
|
|
OutBoxDoc.Variables.FreeVariables.Item(j + 1).Value = WeightGross.Text;
|
|
|
LogManager.DoLog("打印参数【毛重】赋值," + WeightGross.Text);
|
|
|
}
|
|
|
- else if (dt.Rows[k]["lp_valuetype"].ToString() == "字符串" && dt.Rows[k]["lp_sql"].ToString() == "NW")
|
|
|
+ else if (OutLabelParam.Rows[k]["lp_valuetype"].ToString() == "字符串" && OutLabelParam.Rows[k]["lp_sql"].ToString() == "NW")
|
|
|
{
|
|
|
OutBoxDoc.Variables.FreeVariables.Item(j + 1).Value = WeightNet.Text;
|
|
|
LogManager.DoLog("打印参数【净重】赋值," + WeightNet.Text);
|
|
|
@@ -1882,7 +1970,7 @@ namespace UAS_LabelMachine
|
|
|
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 = dt.Rows[k]["lp_sql"].ToString();
|
|
|
+ string sql = OutLabelParam.Rows[k]["lp_sql"].ToString();
|
|
|
//select * from productiobarcode where pib_id={pib_id} and pib_outboxcode1={pib_outboxcode1}
|
|
|
try
|
|
|
{
|
|
|
@@ -1903,6 +1991,17 @@ namespace UAS_LabelMachine
|
|
|
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 == "")
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ OutBoxDoc.Variables.FreeVariables.Item(j + 1).Value = OutLabelParam.Select("lp_name='" + OutBoxDoc.Variables.FreeVariables.Item(j + 1).Name + "'")[0]["lp_sql"].ToString();
|
|
|
+ }
|
|
|
+ catch (Exception)
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
LogManager.DoLog("打印参数【" + OutBoxDoc.Variables.FreeVariables.Item(j + 1).Name + "】赋值," + "取值SQL:" + ExeSQL + ",取到值" + OutBoxDoc.Variables.FreeVariables.Item(j + 1).Value);
|
|
|
}
|
|
|
catch (Exception)
|
|
|
@@ -1923,8 +2022,10 @@ namespace UAS_LabelMachine
|
|
|
}
|
|
|
}
|
|
|
//保存参数打印
|
|
|
- OutBoxDoc.Printer.SwitchTo(OutBoxPrinter.Text);
|
|
|
- OutBoxDoc.PrintDocument();
|
|
|
+ if (EnablePrint) {
|
|
|
+ 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); }
|
|
|
@@ -2613,5 +2714,44 @@ namespace UAS_LabelMachine
|
|
|
{
|
|
|
dh.ExecuteSql("select count(1) from employee", "select");
|
|
|
}
|
|
|
+
|
|
|
+ private void LoadPrcodeData()
|
|
|
+ {
|
|
|
+ GridPrcode.DataSource = (DataTable)dh.ExecuteSql("select distinct pib_prodcode from prodiobarcode where pib_inoutno='" + pi_inoutno.Text + "' order by pib_prodcode", "select");
|
|
|
+ }
|
|
|
+
|
|
|
+ private void GridPrcode_CellClick(object sender, DataGridViewCellEventArgs e)
|
|
|
+ {
|
|
|
+ //用户在重新勾选后重置采集项目的索引
|
|
|
+ if (e.ColumnIndex >= 0 && e.RowIndex >= 0)
|
|
|
+ {
|
|
|
+ CurrentItemIndex = 0;
|
|
|
+ for (int i = 0; i < LabelInf.RowCount; i++)
|
|
|
+ {
|
|
|
+ if (GridPrcode.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString() == LabelInf.Rows[i].Cells["pib_prodcode"].Value.ToString() && LabelInf.Rows[i].Cells["pib_ifpick"].FormattedValue.ToString() != "True")
|
|
|
+ {
|
|
|
+ CurrentRowIndex = i;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private bool EnablePrint = true;
|
|
|
+
|
|
|
+ private void SetPrintStatus_Click(object sender, EventArgs e)
|
|
|
+ {
|
|
|
+ EnablePrint = !EnablePrint;
|
|
|
+ if (EnablePrint)
|
|
|
+ {
|
|
|
+ SetPrintStatus_label.ForeColor = Color.Green;
|
|
|
+ SetPrintStatus_label.Text = "可打印";
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ SetPrintStatus_label.ForeColor = Color.Red;
|
|
|
+ SetPrintStatus_label.Text = "暂停打印";
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|