| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186 |
- using LabelManager2;
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Linq;
- using System.Text;
- using UAS_LabelMachine.Entity;
- namespace UAS_LabelMachine.PublicMethod
- {
- class Print
- {
- public class CodeSoft
- {
- public static void SinglePrint(Document SingleDoc, DataTable SingleLabelParam, string pib_id)
- {
- StringBuilder sql = new StringBuilder();
- sql.Clear();
- for (int j = 0; j < SingleDoc.Variables.FormVariables.Count; j++)
- {
- DataRow[] dr1 = SingleLabelParam.Select("lp_name='" + SingleDoc.Variables.FormVariables.Item(j + 1).Name + "'");
- if (dr1.Length > 0)
- {
- if (dr1[0]["lp_valuetype"].ToString() == "字符串")
- sql.Append(dr1[0]["lp_sql"].ToString() + ",");
- }
- }
- sql.Append("1,");
- DataTable dt = (DataTable)SystemInf.sdh.ExecuteSql("select " + sql.ToString().Substring(0, sql.Length - 1) + " from prodiobarcode where pib_id=" + pib_id, "select");
- for (int j = 0; j < SingleDoc.Variables.FormVariables.Count; j++)
- {
- DataRow[] dr1 = SingleLabelParam.Select("lp_name='" + SingleDoc.Variables.FormVariables.Item(j + 1).Name + "'");
- if (dr1.Length > 0 && dr1[0]["lp_valuetype"].ToString() == "SQL值")
- {
- DataTable dt1 = (DataTable)SystemInf.sdh.ExecuteSql(dr1[0]["lp_sql"].ToString().Replace("{1}", pib_id), "select");
- if (dt1.Rows.Count > 0)
- {
- SingleDoc.Variables.FormVariables.Item(j + 1).Value = dt1.Rows[0][0].ToString();
- }
- }
- else if (dr1.Length > 0)
- {
- SingleDoc.Variables.FormVariables.Item(j + 1).Value = dt.Rows[0][dr1[0]["lp_sql"].ToString()].ToString();
- }
- if (SingleDoc.Variables.FormVariables.Item(j + 1).Value == "")
- {
- dr1 = UAS_出货标签打印.Attach.Select("lp_name='" + SingleDoc.Variables.FormVariables.Item(j + 1).Name + "'");
- if (dr1.Length > 0)
- SingleDoc.Variables.FormVariables.Item(j + 1).Value = dr1[0]["lp_sql"].ToString();
- }
- }
- SingleDoc.PrintDocument();
- }
- public static void MidPrint(Document MidDoc, DataTable MidLabelParam, string pi_inoutno, string pib_id, string pib_outboxcode1)
- {
- StringBuilder sql = new StringBuilder();
- //查询参数名称相同的获取到取值字段
- for (int j = 0; j < MidDoc.Variables.FormVariables.Count; j++)
- {
- DataRow[] dr1 = MidLabelParam.Select("lp_name='" + MidDoc.Variables.FormVariables.Item(j + 1).Name + "'");
- if (dr1.Length > 0 && dr1[0]["lp_valuetype"].ToString() == "字符串")
- {
- sql.Append(dr1[0]["lp_sql"].ToString() + ",");
- }
- }
- sql.Append("1,");
- DataTable dt = (DataTable)SystemInf.sdh.ExecuteSql("select " + sql.ToString().Substring(0, sql.Length - 1) + " from prodiobarcode where pib_inoutno='" + pi_inoutno + "' and pib_outboxcode1=" + (pib_outboxcode1 == "" ? "0" : pib_outboxcode1), "select");
- for (int j = 0; j < MidDoc.Variables.FormVariables.Count; j++)
- {
- DataRow[] dr1 = MidLabelParam.Select("lp_name='" + MidDoc.Variables.FormVariables.Item(j + 1).Name + "'");
- if (dr1.Length == 0)
- dr1 = MidLabelParam.Select("lp_name='" + MidDoc.Variables.FormVariables.Item(j + 1).Name.Replace("_1", "") + "'");
- if (dr1.Length > 0 && dr1[0]["lp_valuetype"].ToString() == "字符串")
- {
- MidDoc.Variables.FormVariables.Item(j + 1).Value = dt.Rows[0][dr1[0]["lp_sql"].ToString()].ToString();
- }
- //SQL判断多个值的时候
- if (dr1.Length > 0 && dr1[0]["lp_valuetype"].ToString() == "SQL值")
- {
- DataTable dt1 = (DataTable)SystemInf.sdh.ExecuteSql(dr1[0]["lp_sql"].ToString().Replace("{1}", "'" + pi_inoutno + "'").Replace("{2}", pib_outboxcode1), "select");
- for (int i = 0; i < dt1.Rows.Count; i++)
- {
- for (int k = 0; k < MidDoc.Variables.FormVariables.Count; k++)
- {
- if (i == 0 & MidDoc.Variables.FormVariables.Item(k + 1).Name == dr1[0]["lp_name"].ToString())
- {
- MidDoc.Variables.FormVariables.Item(k + 1).Value = dt1.Rows[0][0].ToString();
- }
- //使用SN开头的参数赋值SN1,SN2,SN3等参数
- if (MidDoc.Variables.FormVariables.Item(k + 1).Name == (dr1[0]["lp_name"].ToString() + "_" + (i + 1)))
- {
- MidDoc.Variables.FormVariables.Item(k + 1).Value = dt1.Rows[i][0].ToString();
- }
- }
- }
- }
- if (MidDoc.Variables.FormVariables.Item(j + 1).Value == "")
- {
- dr1 = UAS_出货标签打印.Attach.Select("lp_name='" + MidDoc.Variables.FormVariables.Item(j + 1).Name + "'");
- if (dr1.Length > 0)
- MidDoc.Variables.FormVariables.Item(j + 1).Value = dr1[0]["lp_sql"].ToString();
- }
- }
- MidDoc.PrintDocument();
- }
- public static void OutPrint(Document OutBoxDoc, DataTable OutLabelParam, string pi_inoutno, string pib_id, string pib_outboxcode2)
- {
- StringBuilder sql = new StringBuilder();
- sql.Clear();
- for (int j = 0; j < OutBoxDoc.Variables.FormVariables.Count; j++)
- {
- DataRow[] dr1 = OutLabelParam.Select("lp_name='" + OutBoxDoc.Variables.FormVariables.Item(j + 1).Name + "'");
- if (dr1.Length > 0 && dr1[0]["lp_valuetype"].ToString() == "字符串")
- {
- sql.Append(dr1[0]["lp_sql"].ToString() + ",");
- }
- }
- sql.Append("1,");
- DataTable dt = (DataTable)SystemInf.sdh.ExecuteSql("select " + sql.ToString().Substring(0, sql.Length - 1) + " from prodiobarcode where pib_inoutno='" + pi_inoutno + "' and pib_outboxcode2=" + (pib_outboxcode2 == "" ? "0" : pib_outboxcode2), "select");
- if (dt.Rows.Count > 0)
- {
- for (int j = 0; j < OutBoxDoc.Variables.FormVariables.Count; j++)
- {
- DataRow[] dr1 = OutLabelParam.Select("lp_name='" + OutBoxDoc.Variables.FormVariables.Item(j + 1).Name + "'");
- //多参数命名
- if (dr1.Length == 0)
- dr1 = OutLabelParam.Select("lp_name='" + OutBoxDoc.Variables.FormVariables.Item(j + 1).Name.Replace("_1", "") + "'");
- if (dr1.Length > 0 && dr1[0]["lp_valuetype"].ToString() == "字符串")
- {
- OutBoxDoc.Variables.FormVariables.Item(j + 1).Value = dt.Rows[0][dr1[0]["lp_sql"].ToString()].ToString();
- }
- //SQL判断多个值的时候
- if (dr1.Length > 0 && dr1[0]["lp_valuetype"].ToString() == "SQL值")
- {
- DataTable dt1 = (DataTable)SystemInf.sdh.ExecuteSql(dr1[0]["lp_sql"].ToString().Replace("{1}", "'" + pi_inoutno + "'").Replace("{2}", pib_outboxcode2), "select");
- for (int i = 0; i < dt1.Rows.Count; i++)
- {
- for (int k = 0; k < OutBoxDoc.Variables.FormVariables.Count; k++)
- {
- if (i == 0 & OutBoxDoc.Variables.FormVariables.Item(k + 1).Name == dr1[0]["lp_name"].ToString())
- {
- OutBoxDoc.Variables.FormVariables.Item(k + 1).Value = dt1.Rows[0][0].ToString();
- }
- //使用SN开头的参数赋值SN1,SN2,SN3等参数
- if (OutBoxDoc.Variables.FormVariables.Item(k + 1).Name == (dr1[0]["lp_name"].ToString() + "_" + (i + 1)))
- {
- OutBoxDoc.Variables.FormVariables.Item(k + 1).Value = dt1.Rows[i][0].ToString();
- }
- if (dr1[0]["lp_sql"].ToString().Contains("pib_year"))
- {
- string date = dt1.Rows[0][0].ToString();
- }
- }
- }
- }
- if (OutBoxDoc.Variables.FormVariables.Item(j + 1).Value == "")
- {
- dr1 = UAS_出货标签打印.Attach.Select("lp_name='" + OutBoxDoc.Variables.FormVariables.Item(j + 1).Name + "'");
- if (dr1.Length > 0)
- OutBoxDoc.Variables.FormVariables.Item(j + 1).Value = dr1[0]["lp_sql"].ToString();
- }
- }
- OutBoxDoc.PrintDocument();
- }
- }
- }
- public class BarTender
- {
- public static void SinglePrint()
- {
- }
- public static void MidPrint()
- {
- }
- public static void OutPrint()
- {
- }
- }
- }
- }
|