Browse Source

日期格式转换

章政 7 years ago
parent
commit
b945fb8ad2
1 changed files with 17 additions and 1 deletions
  1. 17 1
      UAS-出货标签管理(吉利通)/UAS_出货标签管理.cs

+ 17 - 1
UAS-出货标签管理(吉利通)/UAS_出货标签管理.cs

@@ -2473,6 +2473,7 @@ namespace UAS_LabelMachine
 
         private void SinglePrint(string pib_id)
         {
+            StringBuilder sql = new StringBuilder();
             sql.Clear();
             for (int j = 0; j < SingleDoc.Variables.FormVariables.Count; j++)
             {
@@ -2487,7 +2488,22 @@ namespace UAS_LabelMachine
             for (int j = 0; j < SingleDoc.Variables.FormVariables.Count; j++)
             {
                 DataRow[] dr1 = SingleLabelParam.Select("lp_name='" + SingleDoc.Variables.FormVariables.Item(j + 1).Name.ToLower() + "'");
-                if (dr1.Length > 0)
+                if (dr1.Length > 0 && dr1[0]["lp_valuetype"].ToString() == "SQL值")
+                {
+                    DataTable dt1 = (DataTable)adh.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();
+                        if (dr1[0]["lp_sql"].ToString().Contains("pib_year"))
+                        {
+                            string date = dt1.Rows[0][0].ToString();
+                            System.DateTime dtime = System.DateTime.ParseExact(date, "yyyymmdd", System.Globalization.CultureInfo.CurrentCulture);
+                            date = dtime.ToString(cu_print_dateformat.Text);
+                            SingleDoc.Variables.FormVariables.Item(j + 1).Value = date;
+                        }
+                    }
+                }
+                else
                 {
                     SingleDoc.Variables.FormVariables.Item(j + 1).Value = dt.Rows[0][dr1[0]["lp_sql"].ToString()].ToString();
                 }