浏览代码

自定义标签打印语句拼接修改

Hcsy 8 年之前
父节点
当前提交
373cba8cb8
共有 2 个文件被更改,包括 8 次插入2 次删除
  1. 7 1
      UAS-MES/FunctionCode/Make/Make_CustomLabelPrint.cs
  2. 1 1
      UAS-MES/PublicMethod/BaseUtil.cs

+ 7 - 1
UAS-MES/FunctionCode/Make/Make_CustomLabelPrint.cs

@@ -8,6 +8,7 @@ using System.Drawing;
 using System.IO;
 using System.Linq;
 using System.Text;
+using System.Text.RegularExpressions;
 using System.Threading;
 using System.Windows.Forms;
 using UAS_MES.DataOperate;
@@ -160,7 +161,12 @@ namespace UAS_MES.Make
                             {
                                 //取sql拿值赋给变量
                                 string sql = paramsInfo.Rows[currentIndex - 1]["lp_sql"].ToString();
-                                sql = sql.Substring(0, sql.IndexOf("{")) + "'" + inputText.Text + "'";
+                                Regex ConnoteA = new Regex("{\\w+}");
+                                foreach (Match mch in ConnoteA.Matches(sql))
+                                {
+                                    string x = mch.Value.Trim();
+                                    sql = sql.Replace(x, "'" + inputText.Text + "'");
+                                }
                                 doc.Variables.FormVariables.Item(i + 1).Value = dh.GetLabelParam(sql).ToString();
                                 sb.AppendLine("打印参数【" + doc.Variables.FormVariables.Item(i + 1).Name + "】赋值," + "取值SQL:" + sql + ",取到值" + doc.Variables.FormVariables.Item(i + 1).Value);
                             }

+ 1 - 1
UAS-MES/PublicMethod/BaseUtil.cs

@@ -1135,7 +1135,7 @@ namespace UAS_MES.PublicMethod
 
         public static bool connectState(string path)
         {
-            return connectState(path, "", "");
+            return connectState(path, "a", "a");
         }
         /// <summary>
         /// 连接远程共享文件夹