Sin descripción
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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. Option Strict Off
  2. Public Class 人事請假申請
  3. ReadOnly ds As New DataSet : ReadOnly ds1 As New DataSet
  4. Dim 編號 As String
  5. Private Sub Set_考勤明細()
  6. 明細_DGV.DataSource = Nothing : ds.Clear()
  7. 明細_DGV.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
  8. 明細_DGV.ColumnHeadersHeight = 25
  9. 明細_DGV.AllowUserToAddRows = False
  10. ConnOpen()
  11. SQL1 = "SELECT 萬年曆.日期, 萬年曆.星期, AA.請假類別, AA.事由, AA.是否生效, AA.核准人, AA.核准日期, QQ.上午上班, QQ.上午上班 AS 上午下班, QQ.上午上班 AS 上午工時, QQ.下午下班 AS 下午上班,
  12. QQ.下午下班, QQ.下午下班 AS 下午工時, QQ.下午下班 AS 整日工時, BB.上午補登, BB.下午補登, BB.公出事由, QQ.員工編號
  13. FROM 萬年曆 LEFT OUTER JOIN
  14. (SELECT 員工編號, 日期, 請假類別, 事由, 是否生效, 核准人, 核准日期
  15. FROM 人事請假單
  16. WHERE (員工編號 LIKE N'" & 編號 & "') AND (日期 LIKE N'" & ComboBox1.Text & "/" & ComboBox2.Text & "%')) AS AA ON 萬年曆.日期 = AA.日期
  17. LEFT OUTER JOIN
  18. (SELECT 員工編號, 日期, 請假類別, 上午上班, 下午下班
  19. FROM 人事考勤明細表
  20. WHERE (員工編號 LIKE N'" & 編號 & "') AND (日期 LIKE N'" & ComboBox1.Text & "/" & ComboBox2.Text & "%')) AS QQ ON 萬年曆.日期 = QQ.日期
  21. LEFT OUTER JOIN
  22. (SELECT 員工編號, 日期, 上午補登, 下午補登, 公出事由
  23. FROM 人事漏打卡補登紀錄
  24. WHERE (員工編號 LIKE N'" & 編號 & "') AND (日期 LIKE N'" & ComboBox1.Text & "/" & ComboBox2.Text & "%')) AS BB ON 萬年曆.日期 = BB.日期
  25. WHERE (萬年曆.日期 LIKE N'" & ComboBox1.Text & "/" & ComboBox2.Text & "%') ORDER BY 萬年曆.日期"
  26. CmdSet_For_DGV() : da.Fill(ds) : 明細_DGV.DataSource = ds.Tables(0) : conn.Close() : Set_grid()
  27. End Sub
  28. Private Sub Set_grid()
  29. 明細_DGV.Columns(0).FillWeight = 85 : 明細_DGV.Columns(1).FillWeight = 60 : 明細_DGV.Columns(2).FillWeight = 90 : 明細_DGV.Columns(3).FillWeight = 262
  30. 明細_DGV.Columns(4).FillWeight = 80 : 明細_DGV.Columns(5).FillWeight = 65 : 明細_DGV.Columns(6).FillWeight = 90 : 明細_DGV.Columns(7).FillWeight = 75
  31. 明細_DGV.Columns(8).FillWeight = 75 : 明細_DGV.Columns(9).FillWeight = 80 : 明細_DGV.Columns(10).FillWeight = 75 : 明細_DGV.Columns(11).FillWeight = 75
  32. 明細_DGV.Columns(12).FillWeight = 80 : 明細_DGV.Columns(13).FillWeight = 90 : 明細_DGV.Columns(14).FillWeight = 70 : 明細_DGV.Columns(15).FillWeight = 70
  33. 明細_DGV.Columns(16).FillWeight = 262 : 明細_DGV.Columns(17).Visible = False
  34. Dim T, S, F, M, T1, S1 As Integer : Dim T2, S2, F2, M2 As String : Dim 上午 As Integer = 0 : Dim 下午 As Integer = 0
  35. For i As Integer = 0 To 明細_DGV.Rows.Count - 1
  36. 資料數 = 明細_DGV.Rows.Count : MyModule1.進度條()
  37. Dim QASW As Integer = 0
  38. If 明細_DGV.Rows(i).Cells("上午上班").Value.ToString <> "" Then
  39. 明細_DGV.Rows(i).Cells("上午下班").Value = "12:00:00"
  40. Dim TSFM As Integer = DateDiff("s", 明細_DGV.Rows(i).Cells("上午上班").Value.ToString, 明細_DGV.Rows(i).Cells("上午下班").Value)
  41. T = TSFM \ 86400 : T1 = TSFM Mod 86400 : S = T1 \ 3600 : S1 = T1 Mod 3600 : F = S1 \ 60 : M = S1 Mod 60
  42. If T = 0 Then : T2 = "" : Else : T2 = T & "天" : End If : If S = 0 Then : S2 = "" : Else : S2 = S & "時" : End If : If F = 0 Then : F2 = "" : Else : F2 = F & "分" : End If : M2 = M & "秒"
  43. 明細_DGV.Rows(i).Cells("上午工時").Value = T2 & S2 & F2 & M2
  44. QASW += TSFM : 上午 += TSFM
  45. End If
  46. If 明細_DGV.Rows(i).Cells("下午下班").Value.ToString <> "" Then
  47. 明細_DGV.Rows(i).Cells("下午上班").Value = "13:00:00"
  48. Dim TSFM As Integer = DateDiff("s", 明細_DGV.Rows(i).Cells("下午上班").Value.ToString, 明細_DGV.Rows(i).Cells("下午下班").Value)
  49. If TSFM > 23400 Then
  50. TSFM -= 5400
  51. End If
  52. T = TSFM \ 86400 : T1 = TSFM Mod 86400 : S = T1 \ 3600 : S1 = T1 Mod 3600 : F = S1 \ 60 : M = S1 Mod 60
  53. If T = 0 Then : T2 = "" : Else : T2 = T & "天" : End If : If S = 0 Then : S2 = "" : Else : S2 = S & "時" : End If : If F = 0 Then : F2 = "" : Else : F2 = F & "分" : End If : M2 = M & "秒"
  54. 明細_DGV.Rows(i).Cells("下午工時").Value = T2 & S2 & F2 & M2
  55. QASW += TSFM : 下午 += TSFM
  56. End If
  57. If QASW = 0 Then : Else
  58. T = QASW \ 86400 : T1 = QASW Mod 86400 : S = T1 \ 3600 : S1 = T1 Mod 3600 : F = S1 \ 60 : M = S1 Mod 60
  59. If T = 0 Then : T2 = "" : Else : T2 = T & "天" : End If : If S = 0 Then : S2 = "" : Else : S2 = S & "時" : End If : If F = 0 Then : F2 = "" : Else : F2 = F & "分" : End If : M2 = M & "秒"
  60. 明細_DGV.Rows(i).Cells("整日工時").Value = T2 & S2 & F2 & M2
  61. End If
  62. If 明細_DGV.Rows(i).Cells("星期").Value.ToString = "星期六" Then : 明細_DGV.Rows(i).DefaultCellStyle.BackColor = Color.LightPink
  63. ElseIf 明細_DGV.Rows(i).Cells("星期").Value.ToString = "星期日" Then : 明細_DGV.Rows(i).DefaultCellStyle.BackColor = Color.LightPink
  64. ElseIf 明細_DGV.Rows(i).Cells("請假類別").Value.ToString = "國定假日" Then : 明細_DGV.Rows(i).DefaultCellStyle.BackColor = Color.LightPink
  65. ElseIf 明細_DGV.Rows(i).Cells("請假類別").Value.ToString <> "" Then : 明細_DGV.Rows(i).DefaultCellStyle.BackColor = Color.LightYellow
  66. End If
  67. Next : GCM_ERP_SYS.ToolStripProgressBar1.Value = 0 : 最終數 = 0
  68. End Sub
  69. Private Sub Set_人員清單()
  70. DataGridView2.DataSource = Nothing : ds1.Clear()
  71. DataGridView2.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
  72. DataGridView2.ColumnHeadersHeight = 25
  73. DataGridView2.AllowUserToAddRows = False
  74. ConnOpen()
  75. SQL1 = "SELECT 人事資料表.員工編號, 使用者權限管理表.姓名 AS 系統登入姓名, 人事資料表.姓名, 人事資料表.入職日期, 人事資料表.離職日期
  76. FROM 使用者權限管理表 LEFT OUTER JOIN
  77. 人事資料表 ON 使用者權限管理表.員工編號 = 人事資料表.員工編號 AND
  78. 使用者權限管理表.姓名 = 人事資料表.系統登入姓名
  79. WHERE (使用者權限管理表.CC27 = 0) AND (人事資料表.員工編號 IS NOT NULL) AND (人事資料表.離職日期 LIKE N'在職')
  80. ORDER BY 使用者權限管理表.姓名"
  81. CmdSet_For_DGV() : da.Fill(ds1) : DataGridView2.DataSource = ds1.Tables(0) : conn.Close() : Set_grid1()
  82. End Sub
  83. Private Sub Set_grid1()
  84. DataGridView2.Columns(0).FillWeight = 150 : DataGridView2.Columns(1).FillWeight = 150 : DataGridView2.Columns(2).Visible = False : DataGridView2.Columns(3).Visible = False
  85. DataGridView2.Columns(4).Visible = False
  86. End Sub
  87. Private Sub ComboBox1下拉表單資料載入()
  88. conn.Close()
  89. ConnOpen()
  90. SQL1 = "SELECT 年份 FROM 年份清單 ORDER BY 年份 DESC"
  91. CmdSet_For_dr()
  92. ComboBox1.Items.Clear()
  93. While (dr.Read()) : ComboBox1.Items.Add(dr("年份")) : End While
  94. conn.Close()
  95. End Sub
  96. Private Sub ComboBox3下拉表單資料載入()
  97. conn.Close()
  98. ConnOpen()
  99. SQL1 = "SELECT 請假類別 FROM GCM請假類別 WHERE 請假類別 NOT LIKE N'%國%' ORDER BY 請假類別 DESC"
  100. CmdSet_For_dr()
  101. 請假類別_cb.Items.Clear()
  102. While (dr.Read()) : 請假類別_cb.Items.Add(dr("請假類別")) : End While
  103. conn.Close()
  104. End Sub
  105. Private Sub 人事請假申請_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  106. Me.MdiParent = GCM_ERP_SYS : Me.WindowState = 2 : Me.AutoScroll = True
  107. Set_人員清單() : ComboBox1下拉表單資料載入() : ComboBox3下拉表單資料載入()
  108. ComboBox1.Text = Year(Today) : ComboBox2.SelectedIndex = Month(Today) - 1
  109. If CC(27) = True Or gUserName = "李協叡" Then
  110. DataGridView2.Enabled = True
  111. ElseIf CC(27) = False Then
  112. DataGridView2.Enabled = False
  113. 編號 = 員工編號 : Set_考勤明細()
  114. TextBox2.Text = 員工編號 : TextBox1.Text = gUserName : TextBox3.Text = 登入人部門
  115. End If
  116. End Sub
  117. Private Sub 登入閒置控制_MouseMove(sender As Object, e As EventArgs) Handles MyBase.MouseMove
  118. timeNow = 0
  119. GCM_ERP_SYS.Timer1.Enabled = False
  120. GCM_ERP_SYS.Timer1.Enabled = True
  121. End Sub
  122. Private Sub 登入閒置控制_KeyPress(sender As Object, e As EventArgs) Handles MyBase.KeyPress
  123. timeNow = 0
  124. GCM_ERP_SYS.Timer1.Enabled = False
  125. GCM_ERP_SYS.Timer1.Enabled = True
  126. End Sub
  127. Private Sub DataGridView1_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles 明細_DGV.CellClick
  128. If e.RowIndex = -1 Then : Else
  129. TextBox4.Text = 明細_DGV(0, e.RowIndex).Value.ToString
  130. End If
  131. End Sub
  132. Private Sub DataGridView2_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles DataGridView2.CellClick
  133. If e.RowIndex = -1 Then : Else
  134. 編號 = DataGridView2(0, e.RowIndex).Value.ToString : TextBox2.Text = DataGridView2(0, e.RowIndex).Value.ToString
  135. DateTimePicker1.Value = DataGridView2(3, e.RowIndex).Value.ToString : TextBox1.Text = DataGridView2(1, e.RowIndex).Value.ToString
  136. Set_考勤明細()
  137. Dim TSFM As Integer = DateDiff("d", DateTimePicker1.Value, Today()) : TextBox18.Text = TSFM
  138. ConnOpen()
  139. SQL1 = "SELECT 部門 FROM 使用者權限管理表 WHERE (員工編號 = '" & 編號 & "')"
  140. cmd.Connection = conn : cmd.CommandText = SQL1 : dr = cmd.ExecuteReader
  141. If dr.Read() Then
  142. TextBox3.Text = dr("部門").ToString
  143. End If
  144. conn.Close()
  145. End If
  146. End Sub
  147. Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
  148. If TextBox1.Text = "" Or TextBox4.Text = "" Or TextBox5.Text = "" Or 請假類別_cb.Text = "" Then
  149. MsgBox("請檢查資料是否有填選完畢")
  150. Else
  151. ConnOpen()
  152. SQL1 = "SELECT 員工編號 FROM 人事請假單 WHERE (員工編號 LIKE N'" & TextBox2.Text & "') AND (日期 LIKE N'" & TextBox4.Text & "')"
  153. cmd.Connection = conn : cmd.CommandText = SQL1 : dr = cmd.ExecuteReader
  154. If dr.Read() Then
  155. conn.Close()
  156. MsgBox("該日期已有寫過請假單")
  157. Else
  158. conn.Close()
  159. ConnOpen()
  160. SQL1 = "INSERT INTO 人事請假單 (員工編號, 日期, 請假類別, 事由, 是否生效) SELECT N'" & TextBox2.Text & "',N'" & TextBox4.Text & "',N'" & 請假類別_cb.Text &
  161. "','" & TextBox5.Text & "','申請中'"
  162. CmdSet_For_dr() : conn.Close()
  163. Set_考勤明細()
  164. End If
  165. End If
  166. End Sub
  167. End Class