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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. Option Strict Off
  2. Imports System.Data.SqlClient
  3. Public Class 人員入職資料表
  4. Dim conn1 As New SqlConnection
  5. Dim cmd1 As New SqlCommand
  6. Dim dr1 As SqlDataReader
  7. Dim da As New SqlDataAdapter
  8. Dim ds As New DataSet
  9. Private Sub DGV1讀取前設定()
  10. DataGridView1.DataSource = Nothing : ds.Clear()
  11. DataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
  12. DataGridView1.ColumnHeadersHeight = 50
  13. DataGridView1.AllowUserToAddRows = False
  14. If conn1.State = ConnectionState.Closed Then : conn1.ConnectionString = ConString : conn1.Open() : End If
  15. End Sub
  16. Private Sub DGV1讀取後設定()
  17. cmd1.Connection = conn1 : cmd1.CommandText = SQL1 : da.SelectCommand = cmd1 : da.Fill(ds) : DataGridView1.DataSource = ds.Tables(0) : conn1.Close() : Set_grid1()
  18. End Sub
  19. Private Sub 讀取人員資料表()
  20. DGV1讀取前設定()
  21. If PA = "" Then
  22. SQL1 = "SELECT 人員編號, 姓名, 性別, 籍貫, 出生年份, 手機 AS 大陸手機, 台灣手機, 階段, 級別, 性質, 在職, 是否給薪, 薪資結構, 薪資, 給薪幣別, 備註, 月薪, 日薪, 時薪, 證件, 証號
  23. FROM 人員資料
  24. ORDER BY 人員編號"
  25. Else
  26. SQL1 = "SELECT 人員編號, 姓名, 性別, 籍貫, 出生年份, 手機 AS 大陸手機, 台灣手機, 階段, 級別, 性質, 在職, 是否給薪, 薪資結構, 薪資, 給薪幣別, 備註, 月薪, 日薪, 時薪, 證件, 証號
  27. FROM 人員資料 WHERE 人員編號 LIKE '%" & PA & "%' OR 姓名 LIKE '%" & PA & "%' OR 性別 LIKE '%" & PA & "%' OR 籍貫 LIKE '%" & PA & "%' OR 出生年份 LIKE '%" & PA & "%' OR
  28. 證件 LIKE '%" & PA & "%' OR 証號 LIKE '%" & PA & "%' OR 手機 LIKE '%" & PA & "%' OR 薪資結構 LIKE '%" & PA & "%' OR 薪資 LIKE '%" & PA & "%' OR 在職 LIKE '%" & PA & "%' OR
  29. 備註 LIKE '%" & PA & "%' OR
  30. ORDER BY 人員編號"
  31. End If
  32. 列印用SQL = SQL1 : DGV1讀取後設定()
  33. End Sub
  34. Private Sub Set_grid1()
  35. DataGridView1.Columns(0).Width = 90 : DataGridView1.Columns(1).Width = 80 : DataGridView1.Columns(2).Width = 30 : DataGridView1.Columns(3).Width = 70
  36. DataGridView1.Columns(4).Width = 40 : DataGridView1.Columns(5).Width = 120 : DataGridView1.Columns(6).Width = 120 : DataGridView1.Columns(7).Width = 75
  37. DataGridView1.Columns(8).Width = 75 : DataGridView1.Columns(9).Width = 75 : DataGridView1.Columns(10).Width = 75 : DataGridView1.Columns(11).Width = 75
  38. DataGridView1.Columns(12).Width = 75 : DataGridView1.Columns(13).Width = 100 : DataGridView1.Columns(14).Width = 60 : DataGridView1.Columns(15).Width = 503
  39. DataGridView1.Columns(16).Visible = False : DataGridView1.Columns(17).Visible = False : DataGridView1.Columns(18).Visible = False
  40. DataGridView1.Columns(19).Visible = False : DataGridView1.Columns(20).Visible = False
  41. DataGridView1.Columns(13).DefaultCellStyle.Format = "#,##0.00"
  42. DataGridView1.Columns(13).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight : DataGridView1.Columns(13).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight
  43. End Sub
  44. Private Sub 格式設定()
  45. TextBox1.Enabled = False : TextBox7.Enabled = False
  46. End Sub
  47. Private Sub 人員資料_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  48. Me.MdiParent = GCM_ERP_SYS : Me.WindowState = 2
  49. 讀取人員資料表() : Set_grid1() : 格式設定()
  50. End Sub
  51. Private Sub 登入閒置控制_MouseMove(sender As Object, e As EventArgs) Handles MyBase.MouseMove
  52. timeNow = 0
  53. GCM_ERP_SYS.Timer1.Enabled = False
  54. GCM_ERP_SYS.Timer1.Enabled = True
  55. End Sub
  56. Private Sub 登入閒置控制_KeyPress(sender As Object, e As EventArgs) Handles MyBase.KeyPress
  57. timeNow = 0
  58. GCM_ERP_SYS.Timer1.Enabled = False
  59. GCM_ERP_SYS.Timer1.Enabled = True
  60. End Sub
  61. Private Sub DataGridView1_CellClick(ByVal sender As Object, ByVal e As DataGridViewCellEventArgs) Handles DataGridView1.CellClick
  62. If e.RowIndex = -1 Then : Else
  63. TextBox1.Text = DataGridView1.Rows(e.RowIndex).Cells("人員編號").Value : TextBox2.Text = DataGridView1.Rows(e.RowIndex).Cells("姓名").Value
  64. ComboBox1.Text = DataGridView1.Rows(e.RowIndex).Cells("性別").Value : ComboBox2.Text = DataGridView1.Rows(e.RowIndex).Cells("籍貫").Value
  65. ComboBox3.Text = DataGridView1.Rows(e.RowIndex).Cells("出生年份").Value : ComboBox4.Text = DataGridView1.Rows(e.RowIndex).Cells("證件").Value
  66. TextBox3.Text = DataGridView1.Rows(e.RowIndex).Cells("証號").Value : TextBox4.Text = DataGridView1.Rows(e.RowIndex).Cells("大陸手機").Value
  67. TextBox8.Text = DataGridView1.Rows(e.RowIndex).Cells("台灣手機").Value : ComboBox6.Text = DataGridView1.Rows(e.RowIndex).Cells("階段").Value
  68. ComboBox7.Text = DataGridView1.Rows(e.RowIndex).Cells("級別").Value : ComboBox8.Text = DataGridView1.Rows(e.RowIndex).Cells("性質").Value
  69. CheckBox1.Checked = DataGridView1.Rows(e.RowIndex).Cells("在職").Value : CheckBox2.Checked = DataGridView1.Rows(e.RowIndex).Cells("是否給薪").Value
  70. ComboBox5.Text = DataGridView1.Rows(e.RowIndex).Cells("薪資結構").Value : TextBox5.Text = Format(Val(DataGridView1.Rows(e.RowIndex).Cells("薪資").Value.ToString), "#,##0.00")
  71. TextBox6.Text = DataGridView1.Rows(e.RowIndex).Cells("備註").Value : ComboBox9.Text = DataGridView1.Rows(e.RowIndex).Cells("給薪幣別").Value
  72. TextBox7.Text = Year(Today) - (Double.Parse(ComboBox3.Text)) + 1
  73. End If
  74. End Sub
  75. Private Sub ComboBox3_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox3.TextChanged
  76. TextBox7.Text = Year(Today) - (Double.Parse(ComboBox3.Text)) + 1
  77. End Sub
  78. Private Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.Click
  79. PA = InputBox("請輸入要查詢的資料")
  80. 讀取人員資料表()
  81. PA = ""
  82. End Sub
  83. Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
  84. If ComboBox1.Text = "" Or ComboBox2.Text = "" Or ComboBox3.Text = "" Or ComboBox4.Text = "" Or
  85. ComboBox5.Text = "" Or TextBox2.Text = "" Or TextBox3.Text = "" Or TextBox5.Text = "" Then
  86. MsgBox("有重要資料空白不可空白")
  87. Else
  88. If conn1.State = ConnectionState.Closed Then : conn1.ConnectionString = ConString : conn1.Open() : End If
  89. SQL1 = "SELECT TOP (1) 人員編號 FROM 人員資料 ORDER BY 人員編號 DESC"
  90. cmd1.Connection = conn1 : cmd1.CommandText = SQL1 : dr1 = cmd1.ExecuteReader
  91. If dr1.Read() Then : TextBox1.Text = dr1("人員編號").ToString : Else : TextBox1.Text = "" : End If
  92. conn1.Close()
  93. Dim NUM1 As Integer
  94. NUM1 = Strings.Right(TextBox1.Text, 5) + 1
  95. If NUM1 < 10 Then : TextBox1.Text = "PER" & "0000" & NUM1
  96. ElseIf NUM1 > 9 And NUM1 < 100 Then : TextBox1.Text = "PER" & "000" & NUM1
  97. ElseIf NUM1 > 99 And NUM1 < 1000 Then : TextBox1.Text = "PER" & "00" & NUM1
  98. ElseIf NUM1 > 999 And NUM1 < 10000 Then : TextBox1.Text = "PER" & "0" & NUM1
  99. ElseIf NUM1 > 9999 Then : TextBox1.Text = "PER" & NUM1
  100. End If
  101. If conn1.State = ConnectionState.Closed Then : conn1.ConnectionString = ConString : conn1.Open() : End If
  102. If ComboBox5.Text = "NA" Or ComboBox5.Text = "佣金" Then
  103. SQL1 = "INSERT INTO 人員資料 (人員編號, 姓名, 性別, 籍貫, 出生年份, 證件, 証號, 手機, 薪資結構, 薪資, 備註, 在職, 月薪, 日薪, 時薪, 台灣手機, 階段, 級別, 性質, 是否給薪, 給薪幣別)
  104. VALUES (N'" & TextBox1.Text &
  105. "', N'" & TextBox2.Text & "', N'" & ComboBox1.Text & "', N'" & ComboBox2.Text & "', N'" & ComboBox3.Text & "', N'" & ComboBox4.Text &
  106. "', N'" & TextBox3.Text & "', N'" & TextBox4.Text & "', N'" & ComboBox5.Text & "', N'0', N'" & TextBox6.Text &
  107. "', N'" & CheckBox1.Checked & "', N'0', N'0', N'0', N'" & TextBox8.Text & "', N'" & ComboBox6.Text & "', N'" & ComboBox7.Text &
  108. "', N'" & ComboBox8.Text & "', N'" & CheckBox2.Checked & "', N'" & ComboBox9.Text & "')"
  109. ElseIf ComboBox5.Text = "月薪" Then
  110. SQL1 = "INSERT INTO 人員資料 (人員編號, 姓名, 性別, 籍貫, 出生年份, 證件, 証號, 手機, 薪資結構, 薪資, 備註, 在職, 月薪, 日薪, 時薪, 台灣手機, 階段, 級別, 性質, 是否給薪, 給薪幣別)
  111. VALUES (N'" & TextBox1.Text &
  112. "', N'" & TextBox2.Text & "', N'" & ComboBox1.Text & "', N'" & ComboBox2.Text & "', N'" & ComboBox3.Text & "', N'" & ComboBox4.Text &
  113. "', N'" & TextBox3.Text & "', N'" & TextBox4.Text & "', N'" & ComboBox5.Text & "', N'" & TextBox5.Text & "', N'" & TextBox6.Text &
  114. "', N'" & CheckBox1.Checked & "', N'" & TextBox5.Text & "', N'0', N'0', N'" & TextBox8.Text & "', N'" & ComboBox6.Text & "', N'" & ComboBox7.Text &
  115. "', N'" & ComboBox8.Text & "', N'" & CheckBox2.Checked & "', N'" & ComboBox9.Text & "')"
  116. ElseIf ComboBox5.Text = "日薪" Then
  117. SQL1 = "INSERT INTO 人員資料 (人員編號, 姓名, 性別, 籍貫, 出生年份, 證件, 証號, 手機, 薪資結構, 薪資, 備註, 在職, 月薪, 日薪, 時薪, 台灣手機, 階段, 級別, 性質, 是否給薪, 給薪幣別)
  118. VALUES ('" & TextBox1.Text &
  119. "', '" & TextBox2.Text & "', '" & ComboBox1.Text & "', '" & ComboBox2.Text & "', '" & ComboBox3.Text & "', '" & ComboBox4.Text &
  120. "', '" & TextBox3.Text & "', '" & TextBox4.Text & "', '" & ComboBox5.Text & "', '" & TextBox5.Text & "', '" & TextBox6.Text &
  121. "', '" & CheckBox1.Checked & "', '0', '" & TextBox5.Text & "', '0'', N'" & TextBox8.Text & "', N'" & ComboBox6.Text & "', N'" & ComboBox7.Text &
  122. "', N'" & ComboBox8.Text & "', N'" & CheckBox2.Checked & "', N'" & ComboBox9.Text & "')"
  123. ElseIf ComboBox5.Text = "時薪" Then
  124. SQL1 = "INSERT INTO 人員資料 (人員編號, 姓名, 性別, 籍貫, 出生年份, 證件, 証號, 手機, 薪資結構, 薪資, 備註, 在職, 月薪, 日薪, 時薪, 台灣手機, 階段, 級別, 性質, 是否給薪, 給薪幣別)
  125. VALUES ('" & TextBox1.Text &
  126. "', '" & TextBox2.Text & "', '" & ComboBox1.Text & "', '" & ComboBox2.Text & "', '" & ComboBox3.Text & "', '" & ComboBox4.Text &
  127. "', '" & TextBox3.Text & "', '" & TextBox4.Text & "', '" & ComboBox5.Text & "', '" & TextBox5.Text & "', '" & TextBox6.Text &
  128. "', '" & CheckBox1.Checked & "', '0', '0', '" & TextBox5.Text & "'', N'" & TextBox8.Text & "', N'" & ComboBox6.Text & "', N'" & ComboBox7.Text &
  129. "', N'" & ComboBox8.Text & "', N'" & CheckBox2.Checked & "', N'" & ComboBox9.Text & "')"
  130. End If
  131. cmd1.Connection = conn1 : cmd1.CommandText = SQL1 : cmd1.ExecuteNonQuery()
  132. MsgBox("新增完成")
  133. conn1.Close()
  134. End If
  135. 讀取人員資料表() : Set_grid1()
  136. End Sub
  137. Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
  138. If conn1.State = ConnectionState.Closed Then : conn1.Open() : End If
  139. SQL1 = "UPDATE 人員資料 SET 姓名 = N'" & TextBox2.Text & "', 性別 = N'" & ComboBox1.Text & "', 籍貫 = N'" & ComboBox2.Text & "', 出生年份 = N'" & ComboBox3.Text &
  140. "', 證件 = N'" & ComboBox4.Text & "', 証號 = N'" & TextBox3.Text & "', 手機 = N'" & TextBox4.Text & "', 薪資結構 = N'" & ComboBox5.Text &
  141. "', 薪資 = N'" & TextBox5.Text & "', 備註 = N'" & TextBox6.Text & "', 在職 = N'" & CheckBox1.Checked & "', 台灣手機 = N'" & TextBox8.Text &
  142. "', 階段 = N'" & ComboBox6.Text & "', 級別 = N'" & ComboBox7.Text & "', 性質 = N'" & ComboBox8.Text & "', 是否給薪 = N'" & CheckBox2.Checked &
  143. "', 給薪幣別 = N'" & ComboBox9.Text & "'
  144. WHERE (人員編號 = '" & TextBox1.Text & "')"
  145. cmd1.CommandText = SQL1 : cmd1.ExecuteNonQuery()
  146. MsgBox("修改完成")
  147. conn1.Close()
  148. 讀取人員資料表() : Set_grid1()
  149. End Sub
  150. Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
  151. SQL = "DELETE FROM 人員資料 WHERE (人員編號 = '" & TextBox1.Text & "')"
  152. cmd1.CommandText = SQL : cmd1.Connection = conn1
  153. If conn1.State = ConnectionState.Closed Then : conn1.Open() : End If
  154. Dim aa As MsgBoxResult
  155. aa = MsgBox("確定要刪除該筆資料?", MsgBoxStyle.OkCancel)
  156. If aa = MsgBoxResult.Ok Then : cmd1.ExecuteNonQuery() : MsgBox("刪除完成") : End If
  157. conn1.Close()
  158. 讀取人員資料表() : Set_grid1()
  159. End Sub
  160. End Class