설명 없음
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 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. Option Strict Off
  2. Imports System.Data.SqlClient
  3. Imports System.IO
  4. Imports System.Net
  5. Public Class 薪資確認系統
  6. Dim conn As New SqlConnection
  7. Dim cmd As New SqlCommand
  8. Dim dr As SqlDataReader
  9. Dim 月 As String
  10. Private Sub ComboBox1下拉表單資料載入()
  11. conn.Close()
  12. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  13. SQL1 = "SELECT 年份 FROM 年份清單 ORDER BY 年份 DESC"
  14. cmd.CommandText = SQL1 : cmd.Connection = conn : dr = cmd.ExecuteReader
  15. ComboBox1.Items.Clear()
  16. While (dr.Read()) : ComboBox1.Items.Add(dr("年份")) : End While
  17. conn.Close()
  18. End Sub
  19. Private Sub 薪資確認系統_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  20. FormBorderStyle = FormBorderStyle.SizableToolWindow : ControlBox = False
  21. ComboBox1下拉表單資料載入() : ComboBox1.Text = Year(Today)
  22. TextBox2.Enabled = False : TextBox3.Enabled = False : TextBox4.Enabled = False : TextBox5.Enabled = False : TextBox6.Enabled = False : TextBox7.Enabled = False
  23. End Sub
  24. Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
  25. PictureBox1.Image = Nothing
  26. TextBox2.Text = "" : TextBox3.Text = "" : TextBox4.Text = "" : TextBox5.Text = "" : TextBox6.Text = "" : TextBox7.Text = ""
  27. Label36.Text = "0.00" : Label37.Text = "0.00" : Label38.Text = "0.00" : Label39.Text = "0.00" : Label40.Text = "0.00" : Label41.Text = "0.00" : Label42.Text = "0.00"
  28. Label43.Text = "0.00" : Label44.Text = "0.00" : Label45.Text = "0.00" : Label46.Text = "0.00" : Label47.Text = "0.00" : Label48.Text = "0.00" : Label49.Text = "0.00"
  29. Label50.Text = "0.00" : Label51.Text = "0.00" : Label52.Text = "0.00" : Label53.Text = "0.00" : Label54.Text = "0.00" : Label55.Text = "0.00" : Label56.Text = "0.00"
  30. Label57.Text = "0.00" : Label58.Text = "0.00" : Label59.Text = "0.00" : Label60.Text = "0.00" : Label61.Text = "0.00"
  31. Label62.Text = "未簽"
  32. Timer1.Enabled = False
  33. End Sub
  34. Private Sub UsernameTextBox_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged
  35. If IsNumeric(TextBox1.Text) = True Then
  36. If TextBox1.Text.Length = 10 Then
  37. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  38. SQL1 = "SELECT 姓名, 部門, 課別, 組別, 職稱, 員工編號 FROM 使用者權限管理表 WHERE (ID卡號 = '" & TextBox1.Text & "')"
  39. cmd.Connection = conn : cmd.CommandText = SQL1 : dr = cmd.ExecuteReader
  40. If dr.Read() Then
  41. TextBox2.Text = dr("姓名").ToString : TextBox3.Text = dr("部門").ToString : TextBox4.Text = dr("課別").ToString : TextBox5.Text = dr("組別").ToString : TextBox6.Text = dr("職稱").ToString
  42. TextBox7.Text = dr("員工編號").ToString
  43. conn.Close() : TextBox1.Text = ""
  44. End If
  45. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  46. SQL1 = "SELECT 簽名檔 FROM 人事職員簽名檔 WHERE 員工編號 LIKE '" & TextBox7.Text & "'"
  47. cmd.Connection = conn : cmd.CommandText = SQL1 : dr = cmd.ExecuteReader
  48. While dr.Read() = True
  49. Dim bytes As Byte() = New Byte(-1) {}
  50. bytes = DirectCast(dr.Item("簽名檔"), Byte())
  51. Dim oStream As New MemoryStream(bytes)
  52. PictureBox1.Image = Bitmap.FromStream(oStream)
  53. End While
  54. conn.Close()
  55. PictureBox1.SizeMode = 4
  56. TextBox1.Focus()
  57. Timer1.Enabled = True
  58. End If
  59. End If
  60. End Sub
  61. Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
  62. Me.Close()
  63. End Sub
  64. Private Sub 讀取薪資條()
  65. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  66. SQL1 = "SELECT 底薪, 職務等類, 職務等類工資, 上班天數, 正班工資, 全勤獎, 平時加班工時, 平時加班工資, 週末加班工時,
  67. 週末加班工資, 假日加班工時, 假日加班工資, 職務級數, 單位級數工資, 職務工資, 往年年資, 去年年資, 年資工資,
  68. [夜班/其他], 應發工資, 社保費, 代扣稅, 借款, 其他, 扣款合計, 實發合計
  69. FROM 人員薪資表
  70. WHERE (姓名 LIKE N'" & TextBox2.Text & "') AND (年份 LIKE '" & ComboBox1.Text & "') AND (月份 LIKE '" & 月 & "')"
  71. cmd.Connection = conn : cmd.CommandText = SQL1 : dr = cmd.ExecuteReader
  72. If dr.Read() Then
  73. Label36.Text = Format(Val(dr("底薪").ToString), "#,##0.00") : Label37.Text = Format(Val(dr("職務等類").ToString), "#,##0.00")
  74. Label38.Text = Format(Val(dr("職務等類工資").ToString), "#,##0.00") : Label39.Text = Format(Val(dr("上班天數").ToString), "#,##0.00")
  75. Label40.Text = Format(Val(dr("正班工資").ToString), "#,##0.00") : Label41.Text = Format(Val(dr("全勤獎").ToString), "#,##0.00")
  76. Label42.Text = Format(Val(dr("平時加班工時").ToString), "#,##0.00") : Label43.Text = Format(Val(dr("平時加班工資").ToString), "#,##0.00")
  77. Label44.Text = Format(Val(dr("週末加班工時").ToString), "#,##0.00") : Label45.Text = Format(Val(dr("週末加班工資").ToString), "#,##0.00")
  78. Label46.Text = Format(Val(dr("假日加班工時").ToString), "#,##0.00") : Label47.Text = Format(Val(dr("假日加班工資").ToString), "#,##0.00")
  79. Label48.Text = Format(Val(dr("職務級數").ToString), "#,##0.00") : Label49.Text = Format(Val(dr("單位級數工資").ToString), "#,##0.00")
  80. Label50.Text = Format(Val(dr("職務工資").ToString), "#,##0.00") : Label51.Text = Format(Val(dr("往年年資").ToString), "#,##0.00")
  81. Label52.Text = Format(Val(dr("去年年資").ToString), "#,##0.00") : Label53.Text = Format(Val(dr("年資工資").ToString), "#,##0.00")
  82. Label54.Text = Format(Val(dr("夜班/其他").ToString), "#,##0.00") : Label55.Text = Format(Val(dr("應發工資").ToString), "#,##0.00")
  83. Label56.Text = Format(Val(dr("社保費").ToString), "#,##0.00") : Label57.Text = Format(Val(dr("代扣稅").ToString), "#,##0.00")
  84. Label58.Text = Format(Val(dr("借款").ToString), "#,##0.00") : Label59.Text = Format(Val(dr("其他").ToString), "#,##0.00")
  85. Label60.Text = Format(Val(dr("扣款合計").ToString), "#,##0.00") : Label61.Text = Format(Val(dr("實發合計").ToString), "#,##0.00")
  86. Else
  87. Label36.Text = "0.00" : Label37.Text = "0.00" : Label38.Text = "0.00" : Label39.Text = "0.00" : Label40.Text = "0.00" : Label41.Text = "0.00" : Label42.Text = "0.00"
  88. Label43.Text = "0.00" : Label44.Text = "0.00" : Label45.Text = "0.00" : Label46.Text = "0.00" : Label47.Text = "0.00" : Label48.Text = "0.00" : Label49.Text = "0.00"
  89. Label50.Text = "0.00" : Label51.Text = "0.00" : Label52.Text = "0.00" : Label53.Text = "0.00" : Label54.Text = "0.00" : Label55.Text = "0.00" : Label56.Text = "0.00"
  90. Label57.Text = "0.00" : Label58.Text = "0.00" : Label59.Text = "0.00" : Label60.Text = "0.00" : Label61.Text = "0.00"
  91. End If
  92. conn.Close()
  93. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  94. SQL1 = "SELECT 核實 FROM 人員薪資表簽名核實 WHERE (姓名 LIKE N'" & TextBox2.Text & "') AND (工號 LIKE N'" & TextBox7.Text & "') AND (年份 LIKE '" & ComboBox1.Text & "') AND (月份 LIKE '" & 月 & "')"
  95. cmd.Connection = conn : cmd.CommandText = SQL1 : dr = cmd.ExecuteReader
  96. If dr.Read() Then
  97. Label62.Text = "已簽"
  98. Else
  99. Label62.Text = "未簽"
  100. End If
  101. conn.Close()
  102. End Sub
  103. Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
  104. 月 = "01" : 讀取薪資條() : TextBox1.Focus() : Timer1.Interval = 60000
  105. End Sub
  106. Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
  107. 月 = "02" : 讀取薪資條() : TextBox1.Focus() : Timer1.Interval = 60000
  108. End Sub
  109. Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
  110. 月 = "03" : 讀取薪資條() : TextBox1.Focus() : Timer1.Interval = 60000
  111. End Sub
  112. Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
  113. 月 = "04" : 讀取薪資條() : TextBox1.Focus() : Timer1.Interval = 60000
  114. End Sub
  115. Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
  116. 月 = "05" : 讀取薪資條() : TextBox1.Focus() : Timer1.Interval = 60000
  117. End Sub
  118. Private Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.Click
  119. 月 = "06" : 讀取薪資條() : TextBox1.Focus() : Timer1.Interval = 60000
  120. End Sub
  121. Private Sub Button8_Click(sender As Object, e As EventArgs) Handles Button8.Click
  122. 月 = "07" : 讀取薪資條() : TextBox1.Focus() : Timer1.Interval = 60000
  123. End Sub
  124. Private Sub Button9_Click(sender As Object, e As EventArgs) Handles Button9.Click
  125. 月 = "08" : 讀取薪資條() : TextBox1.Focus() : Timer1.Interval = 60000
  126. End Sub
  127. Private Sub Button10_Click(sender As Object, e As EventArgs) Handles Button10.Click
  128. 月 = "09" : 讀取薪資條() : TextBox1.Focus() : Timer1.Interval = 60000
  129. End Sub
  130. Private Sub Button11_Click(sender As Object, e As EventArgs) Handles Button11.Click
  131. 月 = "10" : 讀取薪資條() : TextBox1.Focus() : Timer1.Interval = 60000
  132. End Sub
  133. Private Sub Button12_Click(sender As Object, e As EventArgs) Handles Button12.Click
  134. 月 = "11" : 讀取薪資條() : TextBox1.Focus() : Timer1.Interval = 60000
  135. End Sub
  136. Private Sub Button13_Click(sender As Object, e As EventArgs) Handles Button13.Click
  137. 月 = "12" : 讀取薪資條() : TextBox1.Focus() : Timer1.Interval = 60000
  138. End Sub
  139. Private Sub Button14_Click(sender As Object, e As EventArgs) Handles Button14.Click
  140. If 月 = "" Then
  141. MsgBox("簽核前請先確定資料正確")
  142. Else
  143. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  144. SQL1 = "SELECT 實發合計 FROM 人員薪資表 WHERE (姓名 LIKE N'" & TextBox2.Text & "') AND (年份 LIKE '" & ComboBox1.Text & "') AND (月份 LIKE '" & 月 & "')"
  145. cmd.Connection = conn : cmd.CommandText = SQL1 : dr = cmd.ExecuteReader
  146. If dr.Read() Then
  147. conn.Close()
  148. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  149. SQL1 = "SELECT 核實 FROM 人員薪資表簽名核實
  150. WHERE (姓名 LIKE N'" & TextBox2.Text & "') AND (工號 LIKE N'" & TextBox7.Text & "') AND (年份 LIKE '" & ComboBox1.Text & "') AND (月份 LIKE '" & 月 & "')"
  151. cmd.Connection = conn : cmd.CommandText = SQL1 : dr = cmd.ExecuteReader
  152. If dr.Read() Then
  153. MsgBox("已簽核過") : conn.Close()
  154. Else
  155. conn.Close()
  156. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  157. SQL1 = "INSERT INTO 人員薪資表簽名核實 ( 姓名, 工號, 年份, 月份, 核實)
  158. VALUES (N'" & TextBox2.Text & "',N'" & TextBox7.Text & "',N'" & ComboBox1.Text & "',N'" & 月 & "',N'1')"
  159. cmd.Connection = conn : cmd.CommandText = SQL1 : cmd.ExecuteNonQuery() : conn.Close()
  160. Label62.Text = "已簽"
  161. End If
  162. Else
  163. MsgBox("簽核前請先確定資料正確") : conn.Close()
  164. End If
  165. End If
  166. 月 = "" : TextBox1.Focus()
  167. End Sub
  168. End Class