Query_RadiumSN.cs 3.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. using System;
  2. using System.Data;
  3. using System.Drawing;
  4. using System.Drawing.Printing;
  5. using System.Text.RegularExpressions;
  6. using System.Windows.Forms;
  7. using UAS_MES.DataOperate;
  8. using UAS_MES.Entity;
  9. namespace UAS_MES.Query
  10. {
  11. public partial class Query_RadiumSN : Form
  12. {
  13. int serialnum = 0;
  14. //客户的流水号
  15. int custserialnum = 0;
  16. DataHelper dh = SystemInf.dh;
  17. //前缀条件
  18. //生成条码的流水号
  19. DataTable Dbfind;
  20. public Query_RadiumSN()
  21. {
  22. InitializeComponent();
  23. }
  24. private void PrintTest_Click(object sender, EventArgs e)
  25. {
  26. }
  27. private void Print_PrintPage(object sender, PrintPageEventArgs e)
  28. {
  29. Graphics g = e.Graphics;
  30. float leftMargin = 10f; //左边距
  31. SolidBrush myBrush = new SolidBrush(Color.Black);//刷子
  32. float yPosition = 5f;//行定位
  33. Font printFont = new Font("微软雅黑", 20f, FontStyle.Bold);//设置字体
  34. yPosition += printFont.GetHeight(g);//另起一行
  35. g.DrawString("成功连接此打印机", printFont, myBrush, leftMargin, yPosition, new StringFormat());
  36. }
  37. private void Setting_Click(object sender, EventArgs e)
  38. {
  39. }
  40. private void Export_Click(object sender, EventArgs e)
  41. {
  42. }
  43. private static string lpad(int length, string number)
  44. {
  45. while (number.Length < length)
  46. {
  47. number = "0" + number;
  48. }
  49. number = number.Substring(number.Length - length, length);
  50. return number;
  51. }
  52. private void SystemSetting_PrinterTest_Load(object sender, EventArgs e)
  53. {
  54. }
  55. private void Export_Click_1(object sender, EventArgs e)
  56. {
  57. string sql = "select mssncode SN,pr_detail 产品名称,pr_spec 产品规格,case when cm_fsoncode like '%072002%' then 'LCD-'||" +
  58. "cm_barcode when cm_fsoncode like '%070301%' then 'TP-'||cm_barcode when PR_SPEC like '%MID%' and " +
  59. "pr_detail='[半成品]-主板' then 'TM-'||cm_barcode when PR_SPEC like '%TC%' and pr_detail='[半成品]-主板' then " +
  60. "'CM-'||cm_barcode else cm_barcode end 物料条码,cm_indate 生产日期,ms_salecode 销售订单 from ( select " +
  61. "mssncode ,cm_barcode ,cm_firstsn Firstsn, cmsncode,cm_fsoncode ,ms_salecode ,to_char(cm_indate,'dd/mm/yyyy') " +
  62. "cm_indate,pr_detail ,pr_spec from CRAFTMATERIAL left join (select ms_sncode mssncode,cm_barcode cmbarcode," +
  63. "cm_sncode cmsncode,pr_detail,pr_spec from craftmaterial left join product on pr_code=cm_fsoncode left join " +
  64. "makeserial on ms_code=cm_sncode where pr_detail='[自制]-液晶屏组件' and cm_status=0) on cmbarcode=cm_sncode left join " +
  65. "makeserial on ms_code=cm_sncode where cm_status=0 and mssncode in (select v_barcode from mes_package_view where v_outboxcode " +
  66. "BETWEEN '"+box1.Text + "' and '"+box2.Text + "') union select ms_sncode,cm_barcode,cm_firstsn,cm_sncode cmsncode,cm_fsoncode,ms_salecode cmmakecode,to_char(cm_indate,'dd/mm/yyyy') " +
  67. " cmindate,pr_detail,pr_spec from craftmaterial left join product on pr_code=cm_fsoncode left join makeserial on ms_code=cm_sncode " +
  68. " where cm_status=0 and ms_sncode in (select v_barcode from mes_package_view where v_outboxcode BETWEEN '"+box1.Text + "' and '"+box2.Text + "'))";
  69. DataTable dt = (DataTable)dh.ExecuteSql(sql, "select");
  70. ExcelHandler ex = new ExcelHandler();
  71. ExportFileDialog.ShowDialog();
  72. ExportFileDialog.Description = "选择导出的路径";
  73. ex.ExportExcel(dt, ExportFileDialog.SelectedPath);
  74. }
  75. }
  76. }