|
@@ -9,6 +9,9 @@ using UAS_LabelMachine.CustomControl.GroupBoxWithBorder;
|
|
|
using static System.Windows.Forms.Control;
|
|
|
using System.Text.RegularExpressions;
|
|
|
using Seagull.BarTender.Print;
|
|
|
+using Microsoft.CSharp;
|
|
|
+using System.CodeDom.Compiler;
|
|
|
+using System.Reflection;
|
|
|
|
|
|
namespace UAS_LabelMachine
|
|
|
{
|
|
@@ -879,13 +882,77 @@ namespace UAS_LabelMachine
|
|
|
{
|
|
|
GroupByCondition += "pd_ordercode,";
|
|
|
}
|
|
|
- if (iCustProdCode || iCustPo || iDC || iLotNo|| iOrderCode)
|
|
|
+ if (iCustProdCode || iCustPo || iDC || iLotNo || iOrderCode)
|
|
|
{
|
|
|
GroupByCondition = " group by " + (GroupByCondition.Substring(0, GroupByCondition.Length - 1));
|
|
|
}
|
|
|
sql.Append("max(pib_id),");
|
|
|
- Console.WriteLine("select " + sql.ToString().Substring(0, sql.Length - 1) + " from prodiobarcode where pib_inoutno = '" + pi_inoutno + "' and pib_outboxcode2 = " + (pib_outboxcode2 == "" ? "0" : pib_outboxcode2) + GroupByCondition);
|
|
|
return "select " + sql.ToString().Substring(0, sql.Length - 1) + " from prodiobarcode where pib_inoutno = '" + pi_inoutno + "' and pib_outboxcode2 = " + (pib_outboxcode2 == "" ? "0" : pib_outboxcode2) + GroupByCondition;
|
|
|
}
|
|
|
+
|
|
|
+ public static void CustomerInit()
|
|
|
+ {
|
|
|
+
|
|
|
+ CSharpCodeProvider objCSharpCodePrivoder = new CSharpCodeProvider();
|
|
|
+
|
|
|
+ CompilerParameters objCompilerParameters = new CompilerParameters();
|
|
|
+ objCompilerParameters.ReferencedAssemblies.Add("System.dll");
|
|
|
+ objCompilerParameters.ReferencedAssemblies.Add("System.Windows.Forms.dll");
|
|
|
+ objCompilerParameters.GenerateExecutable = false;
|
|
|
+ objCompilerParameters.GenerateInMemory = true;
|
|
|
+
|
|
|
+
|
|
|
+ CompilerResults cr = objCSharpCodePrivoder.CompileAssemblyFromSource(objCompilerParameters, GenerateCode());
|
|
|
+
|
|
|
+ if (cr.Errors.HasErrors)
|
|
|
+ {
|
|
|
+ Console.WriteLine("编译错误:");
|
|
|
+ foreach (CompilerError err in cr.Errors)
|
|
|
+ {
|
|
|
+ Console.WriteLine(err.ErrorText);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+
|
|
|
+ Assembly objAssembly = cr.CompiledAssembly;
|
|
|
+ object objHelloWorld = objAssembly.CreateInstance("Test.TestClass");
|
|
|
+ MethodInfo objMI = objHelloWorld.GetType().GetMethod("Test");
|
|
|
+ Console.WriteLine(objMI.Invoke(objHelloWorld, null));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ static string GenerateCode()
|
|
|
+ {
|
|
|
+ StringBuilder sb = new StringBuilder();
|
|
|
+ sb.Append(Environment.NewLine);
|
|
|
+ sb.Append("using System; ");
|
|
|
+ sb.Append(Environment.NewLine);
|
|
|
+ sb.Append("using System.Windows.Forms; ");
|
|
|
+ sb.Append(Environment.NewLine);
|
|
|
+ sb.Append("namespace Test ");
|
|
|
+ sb.Append(Environment.NewLine);
|
|
|
+ sb.Append("{ ");
|
|
|
+ sb.Append(" public class TestClass");
|
|
|
+ sb.Append(Environment.NewLine);
|
|
|
+ sb.Append(" {");
|
|
|
+ sb.Append(Environment.NewLine);
|
|
|
+ sb.Append(" public void Test() ");
|
|
|
+ sb.Append(Environment.NewLine);
|
|
|
+ sb.Append(" {");
|
|
|
+ sb.Append(Environment.NewLine);
|
|
|
+ sb.Append(" Form f=Form.ActiveForm; if(f.Controls[\"cu_code\"].Text==\"C000027\"){");
|
|
|
+ sb.Append(Environment.NewLine);
|
|
|
+ sb.Append(" (f.Controls[\"OutBoxLabel\"].Controls[\"DiffCustOutBoxCode\"] as CheckBox).Checked = false;}else {(f.Controls[\"OutBoxLabel\"].Controls[\"DiffCustOutBoxCode\"] as CheckBox).Checked = true;}");
|
|
|
+ sb.Append(Environment.NewLine);
|
|
|
+ sb.Append(" }");
|
|
|
+ sb.Append(Environment.NewLine);
|
|
|
+ sb.Append(" }");
|
|
|
+ sb.Append(Environment.NewLine);
|
|
|
+ sb.Append("}");
|
|
|
+ string code = sb.ToString();
|
|
|
+ Console.WriteLine(code);
|
|
|
+ return sb.ToString();
|
|
|
+ }
|
|
|
}
|
|
|
}
|