Geen omschrijving
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

簽名檔管理.vb 6.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. Option Explicit On
  2. Imports System.Net
  3. Imports System.IO
  4. Imports System.Windows.Forms.VisualStyles.VisualStyleElement
  5. Public Class 簽名檔管理
  6. Public Property Credentials As ICredentials
  7. Private ReadOnly ds, ds1 As New DataSet
  8. Dim EDR As Integer = 0 : Dim ESTR As String
  9. Private Sub Set_清單()
  10. 簽名檔_dgv.DataSource = Nothing : ds.Clear()
  11. 簽名檔_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
  12. 簽名檔_dgv.ColumnHeadersHeight = 25
  13. 簽名檔_dgv.AllowUserToAddRows = False
  14. SQL_簽名檔管理清單()
  15. da.Fill(ds) : 簽名檔_dgv.DataSource = ds.Tables(0) : conn.Close()
  16. 簽名檔_dgv.Columns(0).Width = 221 : 簽名檔_dgv.Columns(1).Width = 220
  17. End Sub
  18. Private Sub ComboBox1下拉表單資料載入()
  19. SQL_下拉使用者權限管理表()
  20. 簽名檔持有人_cb.Items.Clear()
  21. While (dr.Read()) : 簽名檔持有人_cb.Items.Add(dr("姓名")) : End While
  22. conn.Close()
  23. End Sub
  24. Private Sub 簽名檔管理_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  25. WINPROFIT_ERP_SYS.WindowState = 2 : Me.MdiParent = WINPROFIT_ERP_SYS : Me.WindowState = 2 : Me.AutoScroll = True
  26. Set_清單() : TextBox3.Visible = False
  27. ComboBox1下拉表單資料載入()
  28. If FolderBrowserDialog1.ShowDialog = DialogResult.OK Then
  29. WebBrowser2.Navigate(FolderBrowserDialog1.SelectedPath)
  30. End If
  31. End Sub
  32. Private Sub DataGridView1_CellClick(ByVal sender As System.Object, ByVal e As DataGridViewCellEventArgs) Handles 簽名檔_dgv.CellClick
  33. If e.RowIndex = -1 Then : Else
  34. 圖檔編號_tb.Text = 簽名檔_dgv(0, e.RowIndex).Value.ToString : 簽名檔持有人_cb.Text = 簽名檔_dgv(1, e.RowIndex).Value.ToString
  35. SQL_讀取簽名檔圖片()
  36. While dr.Read() = True
  37. Dim unused As Byte() = New Byte(-1) {}
  38. Dim bytes As Byte() = DirectCast(dr.Item("簽名檔圖片"), Byte())
  39. Dim oStream As New MemoryStream(bytes)
  40. PictureBox1.Image = Bitmap.FromStream(oStream)
  41. End While
  42. conn.Close()
  43. PictureBox1.SizeMode = 4
  44. End If
  45. End Sub
  46. Private Sub Button2_Click(sender As Object, e As EventArgs) Handles 簽名檔入系統_bt.Click
  47. If 圖檔編號_tb.Text = "" Then : MsgBox("請先將要入庫的編號準備好") : Else
  48. If 檔案名稱_tb.Text = "" Then : MsgBox("請先確定圖片資料已準備完畢") : Else
  49. Dim 驗證 As String = "" : Dim 取變數 As String : 取變數 = Strings.StrReverse(檔案名稱_tb.Text)
  50. For i As Integer = 1 To 10
  51. If i = 1 Then : 驗證 = Strings.Left(取變數, i) : Else
  52. If Strings.Mid(取變數, i, 1) = "." Then : 驗證 = Strings.StrReverse(驗證) : Exit For : Else : 驗證 &= Strings.Mid(取變數, i, 1) : End If
  53. End If
  54. Next
  55. If 驗證 = "PNG" Or 驗證 = "png" Or 驗證 = "GIF" Or 驗證 = "gif" Or 驗證 = "BMP" Or 驗證 = "bmp" Or 驗證 = "JPG" Or 驗證 = "jpg" Or 驗證 = "JPEG" Or 驗證 = "jpeg" Then
  56. PA49 = TextBox3.Text : SQL_新增簽名檔管理() : conn.Close()
  57. SQL_讀取簽名檔圖片()
  58. While dr.Read() = True
  59. Dim unused As Byte() = New Byte(-1) {}
  60. Dim bytes As Byte() = DirectCast(dr.Item("簽名檔圖片"), Byte())
  61. Dim oStream As New MemoryStream(bytes)
  62. PictureBox1.Image = Bitmap.FromStream(oStream)
  63. End While : conn.Close() : PictureBox1.SizeMode = 4
  64. MsgBox("修改完成") : Set_清單() : 圖檔編號_tb.Text = "" : 檔案名稱_tb.Text = ""
  65. Else : 檔案名稱_tb.Text = "" : MsgBox("上傳文件並非常用圖片格式,文件已自動刪除,請專換成常用圖片檔案再行操作。") : End If
  66. End If
  67. End If
  68. End Sub
  69. Private Sub Button1_Click(sender As Object, e As EventArgs) Handles 生成圖檔編號_bt.Click
  70. SQL_最後一筆圖片流水號()
  71. If dr.Read() Then : EDR = Double.Parse(Strings.Right(dr("圖片流水號").ToString, 8)) : Else : EDR = 0 : End If
  72. conn.Close()
  73. EDR += 1
  74. If EDR < 10 Then : ESTR = "PG" & "0000000" & EDR
  75. ElseIf EDR > 9 And EDR < 100 Then : ESTR = "PG" & "000000" & EDR
  76. ElseIf EDR > 99 And EDR < 1000 Then : ESTR = "PG" & "00000" & EDR
  77. ElseIf EDR > 999 And EDR < 10000 Then : ESTR = "PG" & "0000" & EDR
  78. ElseIf EDR > 9999 And EDR < 100000 Then : ESTR = "PG" & "000" & EDR
  79. ElseIf EDR > 99999 And EDR < 100000 Then : ESTR = "PG" & "00" & EDR
  80. ElseIf EDR > 999999 And EDR < 1000000 Then : ESTR = "PG" & "0" & EDR
  81. ElseIf EDR > 9999999 Then : ESTR = "PG" & EDR
  82. End If
  83. 圖檔編號_tb.Text = ESTR
  84. End Sub
  85. Private Sub TextBox4_DragEnter(sender As Object, e As DragEventArgs) Handles 檔案名稱_tb.DragEnter
  86. If e.Data.GetDataPresent(DataFormats.FileDrop) Then : Dim files As String()
  87. Try : files = CType(e.Data.GetData(DataFormats.FileDrop), String()) : 檔案名稱_tb.Text = files(files.Length - 1)
  88. Catch ex As Exception : MessageBox.Show(ex.Message) : Return : End Try
  89. End If
  90. Dim STR2 As Integer = 0 : TextBox3.Text = 檔案名稱_tb.Text
  91. If 檔案名稱_tb.Text = "" Then : Else
  92. For i As Integer = 0 To 9999 : Dim STR1 As Integer = Strings.Len(TextBox3.Text)
  93. If Strings.Right((TextBox3.Text), 1) <> "\" Then : STR1 -= 1 : STR2 += 1
  94. If STR1 = 0 Then : TextBox3.Text = "" : 檔案名稱_tb.Text = "" : i = 9999
  95. Else : TextBox3.Text = Strings.Left((TextBox3.Text), STR1) : End If
  96. Else
  97. TextBox3.Text = Strings.Right((檔案名稱_tb.Text), STR2)
  98. 檔案名稱_tb.Text = TextBox3.Text : i = 9999
  99. End If
  100. Next
  101. Dim files As String() : files = CType(e.Data.GetData(DataFormats.FileDrop), String())
  102. TextBox3.Text = files(files.Length - 1)
  103. End If
  104. End Sub
  105. Private Sub TextBox4_DragDrop(ByVal sender As Object, ByVal e As DragEventArgs) Handles 檔案名稱_tb.DragDrop
  106. Dim files As Array = e.Data.GetData(DataFormats.FileDrop)
  107. For Each file As String In files
  108. 檔案名稱_tb.AppendText(file + Environment.NewLine)
  109. Next
  110. End Sub
  111. Private Sub Button3_Click(sender As Object, e As EventArgs) Handles 刪除簽名檔_bt.Click
  112. Dim aa As MsgBoxResult
  113. aa = MsgBox("確定要刪除該筆資料?", MsgBoxStyle.OkCancel)
  114. If aa = MsgBoxResult.Ok Then : SQL_刪除簽名檔管理() : Set_清單() : 圖檔編號_tb.Text = "" : End If
  115. End Sub
  116. End Class