Browse Source

修改SQL错误时的提示

章政 8 years ago
parent
commit
13e94dd57e
1 changed files with 11 additions and 3 deletions
  1. 11 3
      UAS-MES/PublicMethod/Print.cs

+ 11 - 3
UAS-MES/PublicMethod/Print.cs

@@ -4,6 +4,7 @@ using System.Data;
 using System.Text;
 using System.IO;
 using UAS_MES.Entity;
+using System.Windows;
 
 namespace UAS_MES.PublicMethod
 {
@@ -38,9 +39,16 @@ namespace UAS_MES.PublicMethod
                     if (doc.Variables.FormVariables.Item(i + 1).Name == dt.Rows[j]["lp_name"].ToString())
                     {
                         string sql = dt.Rows[j]["lp_sql"].ToString();
-                        sql = sql.Substring(0, sql.IndexOf("{")) + "'" + SnCode + "'";
-                        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);
+                        try
+                        {
+                            sql = sql.Substring(0, sql.IndexOf("{")) + "'" + SnCode + "'";
+                            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);
+                        }
+                        catch (System.Exception)
+                        {
+                            BaseUtil.ShowError("SQL" + sql + "维护不正确");
+                        }
                     }
                 }
             }