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, string[] arg, string pib_id) { DataRow[] dr = UAS_出货标签打印.SingleBoxCacheData.Select("pib_id=" + pib_id); 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 = UAS_出货标签打印.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(); } } } SingleDoc.PrintDocument(); } public static void MidPrint(Document MidDoc, DataTable MidLabelParam, string[] arg, string pib_id, string 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 //获取打印执行的SQL string sql = MidLabelParam.Rows[k]["lp_sql"].ToString(); try { //获取打印执行的SQL if (sql.IndexOf("{") == 0) { MidDoc.Variables.FreeVariables.Item(j + 1).Value = SystemInf.dh.GetLabelParam(sql).ToString(); } else { DataRow[] dr = UAS_出货标签打印.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 = UAS_出货标签打印.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(); } } } } catch (Exception) { return; } } } } MidDoc.PrintDocument(); } public static void OutPrint(Document OutBoxDoc, DataTable OutLabelParam, string pib_id, string pib_outboxcode2) { 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 //获取打印执行的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 = SystemInf.dh.GetLabelParam(ExeSQL).ToString(); if (OutBoxDoc.Variables.FreeVariables.Item(j + 1).Value == "") { DataRow[] dr1 = UAS_出货标签打印.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) { return; } } } } OutBoxDoc.PrintDocument(); } } public class BarTender { public static void SinglePrint() { } public static void MidPrint() { } public static void OutPrint() { } } } }