Query_SpecialReport.cs 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. using Seagull.BarTender.Print;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Data;
  6. using System.Drawing;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Windows.Forms;
  10. using UAS_MES_NEW.DataOperate;
  11. using UAS_MES_NEW.Entity;
  12. using UAS_MES_NEW.PublicMethod;
  13. namespace UAS_MES_NEW.Query
  14. {
  15. public partial class Query_SpecialReport : Form
  16. {
  17. DataHelper dh = SystemInf.dh;
  18. Seagull.BarTender.Print.Engine engine = new Seagull.BarTender.Print.Engine();
  19. LabelFormatDocument format;
  20. public Query_SpecialReport()
  21. {
  22. InitializeComponent();
  23. }
  24. private void Export_Click(object sender, EventArgs e)
  25. {
  26. ExcelExport("");
  27. }
  28. //选择导出Excel时是选择导出数据的还是模板
  29. private void ExcelExport(string DataOrTemplet)
  30. {
  31. for (int i = int.Parse(Rn.Text); i < int.Parse(Num.Text); i = i + 4)
  32. {
  33. int temp = i;
  34. for (int j = 0; j < format.SubStrings.Count; j++)
  35. {
  36. switch (format.SubStrings[j].Name)
  37. {
  38. case "RN1":
  39. format.SubStrings[j].Value = (Prefix.Text + Date.Value.ToString("yymmdd") + lpad(4, (temp).ToString()));
  40. break;
  41. case "RN2":
  42. format.SubStrings[j].Value = (Prefix.Text + Date.Value.ToString("yymmdd") + lpad(4, (temp + 1).ToString()));
  43. break;
  44. case "RN3":
  45. format.SubStrings[j].Value = (Prefix.Text + Date.Value.ToString("yymmdd") + lpad(4, (temp + 2).ToString()));
  46. break;
  47. case "RN4":
  48. format.SubStrings[j].Value = (Prefix.Text + Date.Value.ToString("yymmdd") + lpad(4, (temp + 3).ToString()));
  49. break;
  50. default:
  51. break;
  52. }
  53. }
  54. }
  55. format.PrintSetup.PrinterName = Printer.Text;
  56. format.PrintSetup.IdenticalCopiesOfLabel = 1;
  57. format.Print();
  58. }
  59. private void Query_SpecialReport_Load(object sender, EventArgs e)
  60. {
  61. format = engine.Documents.Open("Label.btw");
  62. }
  63. private static string lpad(int length, string number)
  64. {
  65. while (number.Length < length)
  66. {
  67. number = "0" + number;
  68. }
  69. number = number.Substring(number.Length - length, length);
  70. return number;
  71. }
  72. private void inoutno_TextChanged(object sender, EventArgs e)
  73. {
  74. }
  75. }
  76. }