暫無描述
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 7.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. Option Explicit On
  2. Imports System.Net
  3. Imports System.IO
  4. Imports System.Data.SqlClient
  5. Public Class 簽名檔管理
  6. Public Property Credentials As ICredentials
  7. ReadOnly ds As New DataSet : ReadOnly ds1 As New DataSet
  8. Dim EDR As Integer = 0 : Dim ESTR As String
  9. Private Sub Set_DGV1載入前設定()
  10. DataGridView1.DataSource = Nothing : ds.Clear()
  11. DataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
  12. DataGridView1.ColumnHeadersHeight = 25
  13. DataGridView1.AllowUserToAddRows = False
  14. ConnOpen()
  15. End Sub
  16. Private Sub Set_DGV1載入後設定()
  17. CmdSet_For_DGV() : da.Fill(ds) : DataGridView1.DataSource = ds.Tables(0) : conn.Close() : Set_grid()
  18. End Sub
  19. Private Sub Set_清單()
  20. Set_DGV1載入前設定()
  21. SQL1 = "SELECT 圖片流水號 AS 圖檔編碼, 簽名檔人名 FROM GCM主管簽名檔管理 ORDER BY 圖片流水號"
  22. Set_DGV1載入後設定()
  23. End Sub
  24. Private Sub Set_grid()
  25. DataGridView1.Columns(0).FillWeight = 221 : DataGridView1.Columns(1).FillWeight = 220
  26. End Sub
  27. Private Sub ComboBox1下拉表單資料載入()
  28. conn.Close()
  29. ConnOpen()
  30. SQL1 = "SELECT 姓名 FROM 使用者權限管理表 ORDER BY 姓名"
  31. CmdSet_For_dr()
  32. ComboBox1.Items.Clear()
  33. While (dr.Read()) : ComboBox1.Items.Add(dr("姓名")) : End While
  34. conn.Close()
  35. End Sub
  36. Private Sub 簽名檔管理_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  37. Me.MdiParent = GCM_ERP_SYS : Me.WindowState = 2 : Me.AutoScroll = True
  38. Set_清單() : TextBox3.Visible = False
  39. ComboBox1下拉表單資料載入()
  40. If FolderBrowserDialog1.ShowDialog = DialogResult.OK Then
  41. WebBrowser2.Navigate(FolderBrowserDialog1.SelectedPath)
  42. End If
  43. Target1 = Target & AA(1) & "/"
  44. WebBrowser1.Url = New Uri(Target1)
  45. End Sub
  46. Private Sub DataGridView1_CellClick(ByVal sender As System.Object, ByVal e As DataGridViewCellEventArgs) Handles DataGridView1.CellClick
  47. If e.RowIndex = -1 Then : Else
  48. TextBox2.Text = DataGridView1(0, e.RowIndex).Value.ToString : ComboBox1.Text = DataGridView1(1, e.RowIndex).Value.ToString
  49. ConnOpen()
  50. SQL1 = "SELECT 簽名檔圖片 FROM GCM主管簽名檔管理 WHERE 圖片流水號 LIKE N'" & TextBox2.Text & "'"
  51. cmd.Connection = conn : cmd.CommandText = SQL1 : dr = cmd.ExecuteReader
  52. While dr.Read() = True
  53. Dim unused As Byte() = New Byte(-1) {}
  54. Dim bytes As Byte() = DirectCast(dr.Item("簽名檔圖片"), Byte())
  55. Dim oStream As New MemoryStream(bytes)
  56. PictureBox1.Image = Bitmap.FromStream(oStream)
  57. End While
  58. conn.Close()
  59. PictureBox1.SizeMode = 4
  60. End If
  61. End Sub
  62. Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
  63. If TextBox2.Text = "" Then
  64. MsgBox("請先將要入庫的編號準備好")
  65. Else
  66. If TextBox4.Text = "" Then
  67. MsgBox("請先確定圖片資料已準備完畢")
  68. Else
  69. PA49 = TextBox1.Text
  70. ConnOpen()
  71. SQL1 = "INSERT INTO GCM主管簽名檔管理 (圖片流水號, 簽名檔人名, 簽名檔圖片) SELECT '" & TextBox2.Text & "', '" & ComboBox1.Text & "', @binary_file"
  72. CmdSet_For_dr_pic() : conn.Close() : TextBox4.Text = ""
  73. ConnOpen()
  74. SQL1 = "SELECT 簽名檔圖片 FROM GCM主管簽名檔管理 WHERE 圖片流水號 LIKE N'" & TextBox2.Text & "'"
  75. cmd.Connection = conn : cmd.CommandText = SQL1 : dr = cmd.ExecuteReader
  76. While dr.Read() = True
  77. Dim unused As Byte() = New Byte(-1) {}
  78. Dim bytes As Byte() = DirectCast(dr.Item("簽名檔圖片"), Byte())
  79. Dim oStream As New MemoryStream(bytes)
  80. PictureBox1.Image = Bitmap.FromStream(oStream)
  81. End While
  82. conn.Close()
  83. PictureBox1.SizeMode = 4
  84. Set_清單() : TextBox2.Text = ""
  85. End If
  86. End If
  87. End Sub
  88. Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
  89. ConnOpen()
  90. SQL1 = "SELECT TOP (1) 圖片流水號 FROM GCM主管簽名檔管理 ORDER BY 圖片流水號 DESC"
  91. cmd.Connection = conn : cmd.CommandText = SQL1 : dr = cmd.ExecuteReader
  92. If dr.Read() Then : EDR = Double.Parse(Strings.Right(dr("圖片流水號").ToString, 8)) : Else : EDR = 0 : End If
  93. conn.Close()
  94. EDR += 1
  95. If EDR < 10 Then : ESTR = "PG" & "0000000" & EDR
  96. ElseIf EDR > 9 And EDR < 100 Then : ESTR = "PG" & "000000" & EDR
  97. ElseIf EDR > 99 And EDR < 1000 Then : ESTR = "PG" & "00000" & EDR
  98. ElseIf EDR > 999 And EDR < 10000 Then : ESTR = "PG" & "0000" & EDR
  99. ElseIf EDR > 9999 And EDR < 100000 Then : ESTR = "PG" & "000" & EDR
  100. ElseIf EDR > 99999 And EDR < 100000 Then : ESTR = "PG" & "00" & EDR
  101. ElseIf EDR > 999999 And EDR < 1000000 Then : ESTR = "PG" & "0" & EDR
  102. ElseIf EDR > 9999999 Then : ESTR = "PG" & EDR
  103. End If
  104. TextBox2.Text = ESTR
  105. End Sub
  106. Private Sub TextBox4_DragEnter(sender As Object, e As DragEventArgs) Handles TextBox4.DragEnter
  107. If e.Data.GetDataPresent(DataFormats.FileDrop) Then
  108. Dim files As String()
  109. Try
  110. files = CType(e.Data.GetData(DataFormats.FileDrop), String())
  111. TextBox4.Text = files(files.Length - 1)
  112. Catch ex As Exception
  113. MessageBox.Show(ex.Message)
  114. Return
  115. End Try
  116. End If
  117. Dim STR2 As Integer = 0
  118. TextBox1.Text = TextBox4.Text
  119. TextBox3.Text = TextBox4.Text
  120. If TextBox4.Text = "" Then
  121. Else
  122. For i As Integer = 0 To 9999
  123. Dim STR1 As Integer = Strings.Len(TextBox3.Text)
  124. If Strings.Right((TextBox3.Text), 1) <> "\" Then
  125. STR1 -= 1 : STR2 += 1
  126. If STR1 = 0 Then
  127. TextBox3.Text = ""
  128. TextBox4.Text = ""
  129. i = 9999
  130. Else
  131. TextBox3.Text = Strings.Left((TextBox3.Text), STR1)
  132. End If
  133. Else
  134. TextBox3.Text = Strings.Right((TextBox4.Text), STR2)
  135. TextBox4.Text = TextBox3.Text
  136. i = 9999
  137. End If
  138. Next
  139. End If
  140. End Sub
  141. Private Sub TextBox4_DragDrop(ByVal sender As Object, ByVal e As DragEventArgs) Handles TextBox4.DragDrop
  142. Dim files As Array = e.Data.GetData(DataFormats.FileDrop)
  143. For Each file As String In files
  144. TextBox4.AppendText(file + Environment.NewLine)
  145. Next
  146. End Sub
  147. Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
  148. SQL1 = "DELETE FROM GCM主管簽名檔管理 WHERE (圖片流水號 = N'" & TextBox2.Text & "')"
  149. cmd.CommandText = SQL1 : cmd.Connection = conn
  150. ConnOpen()
  151. Dim aa As MsgBoxResult
  152. aa = MsgBox("確定要刪除該筆資料?", MsgBoxStyle.OkCancel)
  153. If aa = MsgBoxResult.Ok Then
  154. cmd.ExecuteNonQuery()
  155. Set_清單() : TextBox2.Text = ""
  156. End If
  157. End Sub
  158. Private Sub Button14_Click(sender As Object, e As EventArgs) Handles Button14.Click
  159. If FolderBrowserDialog1.ShowDialog = DialogResult.OK Then
  160. WebBrowser2.Navigate(FolderBrowserDialog1.SelectedPath)
  161. End If
  162. End Sub
  163. End Class