ソースを参照

供应商条码打印程序修改

Hcsy 7 年 前
コミット
779651dc86
3 ファイル変更54 行追加21 行削除
  1. 3 1
      UAS_Web/Browser.cs
  2. 2 5
      UAS_Web/tool/DownLoadFile.cs
  3. 49 15
      UAS_Web/tool/RequestHandler.cs

+ 3 - 1
UAS_Web/Browser.cs

@@ -18,7 +18,7 @@ namespace UAS_Web
         {
             InitializeComponent();
             Text = "供应商条码打印";
-            string path = "http://183.238.39.179:8099/ERP/jsps/vendbarcode/login.jsp";
+            string path = "http://192.168.253.80:8090/ERP/jsps/vendbarcode/login.jsp";
             webBrowser = new ChromiumWebBrowser(path)
             {
                 Dock = DockStyle.Fill
@@ -38,6 +38,8 @@ namespace UAS_Web
                 return;
             if (e.FailedUrl.Contains("common/excel"))
                 return;
+            if (e.FailedUrl.Contains("common/downloadbyId.action"))
+                return;
             MessageBox.Show("当前网络无法访问" + e.ErrorText);
         }
 

+ 2 - 5
UAS_Web/tool/DownLoadFile.cs

@@ -14,11 +14,8 @@ namespace UAS_Web.tool
             {
                 using (callback)
                 {
-                    callback.Continue(@"C:\Users\" +
-                            System.Security.Principal.WindowsIdentity.GetCurrent().Name +
-                            @"\Downloads\" +
-                            downloadItem.SuggestedFileName,
-                        showDialog: true);
+                    callback.Continue(System.AppDomain.CurrentDomain.BaseDirectory + "GD.frx",
+                        showDialog: false);
                 }
             }
         }

+ 49 - 15
UAS_Web/tool/RequestHandler.cs

@@ -9,6 +9,7 @@ using System.Windows.Forms;
 using System.Drawing.Printing;
 using FastReport;
 using System.Data;
+using System.Threading;
 
 namespace UAS_Web.tool
 {
@@ -19,7 +20,7 @@ namespace UAS_Web.tool
         //打印图片集合
         List<Bitmap> bitmaps = new List<Bitmap>();
 
-        DataTable dt = new DataTable("VENDORBARCODE_VIEW");
+     
 
         Report Report = new Report();
 
@@ -122,13 +123,40 @@ namespace UAS_Web.tool
                     PrintType = data["data"].ToString().Replace("\"", "");
                     break;
                 case "vendorZplPrint.action":
+                    DataTable dt = new DataTable();
                     RadioButton PRFR = (RadioButton)print.Controls["PRFR"];
                     RadioButton PRPIC = (RadioButton)print.Controls["PRPIC"];
+                
+                    string type;
+                    bitmaps.Clear();
+                    filter = FilterManager.GetFileter(request.Identifier.ToString()) as MessageFilter;
+                    str = System.Text.Encoding.UTF8.GetString(filter.dataAll.ToArray());
+                    data = ToDictionary(str);
+                    List<Dictionary<string, object>> parameter = new List<Dictionary<string, object>>();
+                    List<Dictionary<string, object>> barcode = new List<Dictionary<string, object>>();
+                    parameter = (List<Dictionary<string, object>>)data["parameter"];
+                    barcode = (List<Dictionary<string, object>>)data["barcode"];
+                    try 
+                    {
+                         type = ((String)data["type"]).Replace("\"", "");
+                    }
+                    catch {
+                         type = "no";
+                    }
+
                     if (PRFR.Checked)
                     {
+                        Thread.Sleep(800);
                         try
                         {
-                            Report.Load(System.AppDomain.CurrentDomain.BaseDirectory + "GD.frx");
+                            if (type == "box")
+                            {
+                                Report.Load(System.AppDomain.CurrentDomain.BaseDirectory + "GD_box.frx");
+                            }
+                            else
+                            {
+                                Report.Load(System.AppDomain.CurrentDomain.BaseDirectory + "GD.frx");
+                            }
                         }
                         catch
                         {
@@ -136,14 +164,6 @@ namespace UAS_Web.tool
                             return;
                         }
                     }
-                    bitmaps.Clear();
-                    filter = FilterManager.GetFileter(request.Identifier.ToString()) as MessageFilter;
-                    str = System.Text.Encoding.UTF8.GetString(filter.dataAll.ToArray());
-                    data = ToDictionary(str);
-                    List<Dictionary<string, object>> parameter = new List<Dictionary<string, object>>();
-                    List<Dictionary<string, object>> barcode = new List<Dictionary<string, object>>();
-                    parameter = (List<Dictionary<string, object>>)data["parameter"];
-                    barcode = (List<Dictionary<string, object>>)data["barcode"];
                     int la_width = int.Parse(parameter.First()["LA_WIDTH"].ToString());
                     int la_height = int.Parse(parameter.First()["LA_HEIGHT"].ToString());
 
@@ -282,11 +302,25 @@ namespace UAS_Web.tool
                     }
                     if(PRFR.Checked)
                     {
-                        Report.RegisterData(dt, "VENDORBARCODE_VIEW");
-                        Report.GetDataSource("VENDORBARCODE_VIEW").Enabled = true;
-                        Report.PrintSettings.ShowDialog = false;
-                        Report.PrintSettings.Printer = PrinterName;
-                        Report.Print();
+                        try
+                        {
+                            if (type == "box")
+                            {
+                                Report.RegisterData(dt, "VENDORBARCODE_BOX_VIEW");
+                                Report.GetDataSource("VENDORBARCODE_BOX_VIEW").Enabled = true;
+                            }
+                            else {
+                                Report.RegisterData(dt, "VENDORBARCODE_VIEW");
+                                Report.GetDataSource("VENDORBARCODE_VIEW").Enabled = true;
+                            }
+                          
+                            Report.PrintSettings.ShowDialog = false;
+                            Report.PrintSettings.Printer = PrinterName;
+                            Report.Print();
+                        }
+                        catch {
+                            MessageBox.Show("程序打印出现错误,请检查标签文件格式");
+                        }
                         dt.Clear();
                     }
                     break;