فهرست منبع

打印插件修改

callm 3 ماه پیش
والد
کامیت
b1246d646e
2فایلهای تغییر یافته به همراه49 افزوده شده و 49 حذف شده
  1. 48 48
      UAS_PRINT/PrintHandler.cs
  2. 1 1
      UAS_PRINT/UAS_PRINT.csproj

+ 48 - 48
UAS_PRINT/PrintHandler.cs

@@ -73,7 +73,7 @@ namespace UAS_PRINT
         }
 
 
-        public static void vendorZplPrint( string str)
+        public static void vendorZplPrint(string str)
         {
             Report Report = new Report();
             string chooseprintername;
@@ -148,47 +148,47 @@ namespace UAS_PRINT
 
             foreach (var item in barcode)
             {
-                    foreach (var itemc in item)
+                foreach (var itemc in item)
+                {
+                    Dictionary<string, object> Sidc = parameter.Find(p => p["LP_NAME"].ToString().Replace(" ", "").Replace("\"", "").ToUpper() == itemc.Key.ToUpper());
+                    if (Sidc["LP_VALUETYPE"].ToString().Replace(" ", "").Replace("\"", "") == "text")
                     {
-                        Dictionary<string, object> Sidc = parameter.Find(p => p["LP_NAME"].ToString().Replace(" ", "").Replace("\"", "").ToUpper() == itemc.Key.ToUpper());
-                        if (Sidc["LP_VALUETYPE"].ToString().Replace(" ", "").Replace("\"", "") == "text")
+                        string itemstr = "";
+                        if (itemc.Value != null)
                         {
-                            string itemstr = "";
-                            if (itemc.Value != null)
+                            itemstr = itemc.Value.ToString();
+                            while (itemstr.StartsWith("\f") || itemstr.StartsWith("\v") || itemstr.StartsWith("\t") || itemstr.StartsWith("\r") || itemstr.StartsWith("\n"))
                             {
-                                itemstr = itemc.Value.ToString();
-                                while (itemstr.StartsWith("\f") || itemstr.StartsWith("\v") || itemstr.StartsWith("\t") || itemstr.StartsWith("\r") || itemstr.StartsWith("\n"))
-                                {
-                                    itemstr = itemstr.Remove(0, 2);
-                                }
-                                if (itemstr.StartsWith("\""))
-                                {
-                                    itemstr = itemstr.Remove(0, 1);
-                                }
-                                while (itemstr.EndsWith("\f") || itemstr.EndsWith("\v") || itemstr.EndsWith("\t") || itemstr.EndsWith("\r") || itemstr.EndsWith("\n"))
-                                {
-                                    itemstr = itemstr.Remove(itemstr.Length - 2);
-                                }
-                                if (itemstr.EndsWith("\""))
-                                {
-                                    itemstr = itemstr.Remove(itemstr.Length - 1);
-                                }
-                                if (itemstr.Contains("\\\""))
-                                {
-                                    itemstr = itemstr.Replace("\\\"", "\"");
-                                }
+                                itemstr = itemstr.Remove(0, 2);
+                            }
+                            if (itemstr.StartsWith("\""))
+                            {
+                                itemstr = itemstr.Remove(0, 1);
+                            }
+                            while (itemstr.EndsWith("\f") || itemstr.EndsWith("\v") || itemstr.EndsWith("\t") || itemstr.EndsWith("\r") || itemstr.EndsWith("\n"))
+                            {
+                                itemstr = itemstr.Remove(itemstr.Length - 2);
+                            }
+                            if (itemstr.EndsWith("\""))
+                            {
+                                itemstr = itemstr.Remove(itemstr.Length - 1);
+                            }
+                            if (itemstr.Contains("\\\""))
+                            {
+                                itemstr = itemstr.Replace("\\\"", "\"");
                             }
-                            DataColumn DC = new DataColumn(itemc.Key, Type.GetType("System.String"));
-                            if (!dt.Columns.Contains(itemc.Key))
-                                dt.Columns.Add(DC);
-                        }
-                        else if (Sidc["LP_VALUETYPE"].ToString().Replace(" ", "").Replace("\"", "") == "barcode")
-                        {
-                            DataColumn DC = new DataColumn(itemc.Key, Type.GetType("System.String"));
-                            if (!dt.Columns.Contains(itemc.Key))
-                                dt.Columns.Add(DC);
                         }
-                    }               
+                        DataColumn DC = new DataColumn(itemc.Key, Type.GetType("System.String"));
+                        if (!dt.Columns.Contains(itemc.Key))
+                            dt.Columns.Add(DC);
+                    }
+                    else if (Sidc["LP_VALUETYPE"].ToString().Replace(" ", "").Replace("\"", "") == "barcode")
+                    {
+                        DataColumn DC = new DataColumn(itemc.Key, Type.GetType("System.String"));
+                        if (!dt.Columns.Contains(itemc.Key))
+                            dt.Columns.Add(DC);
+                    }
+                }
             }
             code = 0;
             first = "";
@@ -235,9 +235,9 @@ namespace UAS_PRINT
                         {
                             dr[itemc.Key] = itemc.Value.ToString().Replace("\"", "");
                             if (code == 0)
-                             first = itemc.Value.ToString().Replace("\"", "");
-                            if(code == barcode.Count -1)
-                             last  = itemc.Value.ToString().Replace("\"", "");
+                                first = itemc.Value.ToString().Replace("\"", "");
+                            if (code == barcode.Count - 1)
+                                last = itemc.Value.ToString().Replace("\"", "");
                         }
                     }
                     dt.Rows.Add(dr);
@@ -250,10 +250,10 @@ namespace UAS_PRINT
                 ////string logout_confirm = MessageBox.Show("打印" + dt.Rows.Count + "张条码,"+first+"到"+last+",是否继续", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly).ToString();
                 if (logout_confirm == "Yes")
                 {
-               Report.PrintSettings.ShowDialog = false;
-               byte[] buffer = Encoding.GetEncoding("GB2312").GetBytes(chooseprintername);
-               chooseprintername = Encoding.UTF8.GetString(buffer);
-               Report.PrintSettings.Printer = chooseprintername.Replace("\\\\", "\\");
+                    Report.PrintSettings.ShowDialog = false;
+                    byte[] buffer = Encoding.GetEncoding("GB2312").GetBytes(chooseprintername);
+                    chooseprintername = Encoding.UTF8.GetString(buffer);
+                    Report.PrintSettings.Printer = chooseprintername.Replace("\\\\", "\\");
                     //foreach (DataRow dr in dt.Rows)
                     //{
                     //    DataTable dta = dt.Clone();
@@ -262,15 +262,15 @@ namespace UAS_PRINT
                     //    Report.GetDataSource(label_type).Enabled = true;
                     //    Report.Print();
                     //}
-                Report.RegisterData(dt, label_type);
-                Report.GetDataSource(label_type).Enabled = true;
-                Report.Print();
+                    Report.RegisterData(dt, label_type);
+                    Report.GetDataSource(label_type).Enabled = true;
+                    Report.Print();
                 }
 
             }
             catch (Exception ex)
             {
-                MessageBox.Show("打印出现错误,请检查标签文件选择是否正确"+ex.Message);
+                MessageBox.Show("打印出现错误,请检查标签文件选择是否正确" + ex.Message);
             }
             dt.Clear();
         }

+ 1 - 1
UAS_PRINT/UAS_PRINT.csproj

@@ -4,7 +4,7 @@
   <PropertyGroup>
     <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
     <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
-    <ProjectGuid>{B2428D57-87E0-4EFD-AF54-C52C4A964D1F}</ProjectGuid>
+    <ProjectGuid>{B8BBF7C9-BCCA-49B0-BC22-6519B594AB19}</ProjectGuid>
     <OutputType>WinExe</OutputType>
     <AppDesignerFolder>Properties</AppDesignerFolder>
     <RootNamespace>UAS_PRINT</RootNamespace>