123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162 |
- Option Strict Off
- Imports System.Data.SqlClient
- Public Class 人員入職資料表
- Dim conn1 As New SqlConnection
- Dim cmd1 As New SqlCommand
- Dim dr1 As SqlDataReader
- Dim da As New SqlDataAdapter
- Dim ds As New DataSet
- Private Sub DGV1讀取前設定()
- DataGridView1.DataSource = Nothing : ds.Clear()
- DataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
- DataGridView1.ColumnHeadersHeight = 50
- DataGridView1.AllowUserToAddRows = False
- If conn1.State = ConnectionState.Closed Then : conn1.ConnectionString = ConString : conn1.Open() : End If
- End Sub
- Private Sub DGV1讀取後設定()
- cmd1.Connection = conn1 : cmd1.CommandText = SQL1 : da.SelectCommand = cmd1 : da.Fill(ds) : DataGridView1.DataSource = ds.Tables(0) : conn1.Close() : Set_grid1()
- End Sub
- Private Sub 讀取人員資料表()
- DGV1讀取前設定()
- If PA = "" Then
- SQL1 = "SELECT 人員編號, 姓名, 性別, 籍貫, 出生年份, 手機 AS 大陸手機, 台灣手機, 階段, 級別, 性質, 在職, 是否給薪, 薪資結構, 薪資, 給薪幣別, 備註, 月薪, 日薪, 時薪, 證件, 証號
- FROM 人員資料
- ORDER BY 人員編號"
- Else
- SQL1 = "SELECT 人員編號, 姓名, 性別, 籍貫, 出生年份, 手機 AS 大陸手機, 台灣手機, 階段, 級別, 性質, 在職, 是否給薪, 薪資結構, 薪資, 給薪幣別, 備註, 月薪, 日薪, 時薪, 證件, 証號
- FROM 人員資料 WHERE 人員編號 LIKE '%" & PA & "%' OR 姓名 LIKE '%" & PA & "%' OR 性別 LIKE '%" & PA & "%' OR 籍貫 LIKE '%" & PA & "%' OR 出生年份 LIKE '%" & PA & "%' OR
- 證件 LIKE '%" & PA & "%' OR 証號 LIKE '%" & PA & "%' OR 手機 LIKE '%" & PA & "%' OR 薪資結構 LIKE '%" & PA & "%' OR 薪資 LIKE '%" & PA & "%' OR 在職 LIKE '%" & PA & "%' OR
- 備註 LIKE '%" & PA & "%' OR
- ORDER BY 人員編號"
- End If
- 列印用SQL = SQL1 : DGV1讀取後設定()
- End Sub
- Private Sub Set_grid1()
- DataGridView1.Columns(0).Width = 90 : DataGridView1.Columns(1).Width = 80 : DataGridView1.Columns(2).Width = 30 : DataGridView1.Columns(3).Width = 70
- DataGridView1.Columns(4).Width = 40 : DataGridView1.Columns(5).Width = 120 : DataGridView1.Columns(6).Width = 120 : DataGridView1.Columns(7).Width = 75
- DataGridView1.Columns(8).Width = 75 : DataGridView1.Columns(9).Width = 75 : DataGridView1.Columns(10).Width = 75 : DataGridView1.Columns(11).Width = 75
- DataGridView1.Columns(12).Width = 75 : DataGridView1.Columns(13).Width = 100 : DataGridView1.Columns(14).Width = 60 : DataGridView1.Columns(15).Width = 503
- DataGridView1.Columns(16).Visible = False : DataGridView1.Columns(17).Visible = False : DataGridView1.Columns(18).Visible = False
- DataGridView1.Columns(19).Visible = False : DataGridView1.Columns(20).Visible = False
- DataGridView1.Columns(13).DefaultCellStyle.Format = "#,##0.00"
- DataGridView1.Columns(13).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight : DataGridView1.Columns(13).HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight
- End Sub
- Private Sub 格式設定()
- TextBox1.Enabled = False : TextBox7.Enabled = False
- End Sub
- Private Sub 人員資料_Load(sender As Object, e As EventArgs) Handles MyBase.Load
- Me.MdiParent = GCM_ERP_SYS : Me.WindowState = 2
- 讀取人員資料表() : Set_grid1() : 格式設定()
- End Sub
- Private Sub 登入閒置控制_MouseMove(sender As Object, e As EventArgs) Handles MyBase.MouseMove
- timeNow = 0
- GCM_ERP_SYS.Timer1.Enabled = False
- GCM_ERP_SYS.Timer1.Enabled = True
- End Sub
- Private Sub 登入閒置控制_KeyPress(sender As Object, e As EventArgs) Handles MyBase.KeyPress
- timeNow = 0
- GCM_ERP_SYS.Timer1.Enabled = False
- GCM_ERP_SYS.Timer1.Enabled = True
- End Sub
- Private Sub DataGridView1_CellClick(ByVal sender As Object, ByVal e As DataGridViewCellEventArgs) Handles DataGridView1.CellClick
- If e.RowIndex = -1 Then : Else
- TextBox1.Text = DataGridView1.Rows(e.RowIndex).Cells("人員編號").Value : TextBox2.Text = DataGridView1.Rows(e.RowIndex).Cells("姓名").Value
- ComboBox1.Text = DataGridView1.Rows(e.RowIndex).Cells("性別").Value : ComboBox2.Text = DataGridView1.Rows(e.RowIndex).Cells("籍貫").Value
- ComboBox3.Text = DataGridView1.Rows(e.RowIndex).Cells("出生年份").Value : ComboBox4.Text = DataGridView1.Rows(e.RowIndex).Cells("證件").Value
- TextBox3.Text = DataGridView1.Rows(e.RowIndex).Cells("証號").Value : TextBox4.Text = DataGridView1.Rows(e.RowIndex).Cells("大陸手機").Value
- TextBox8.Text = DataGridView1.Rows(e.RowIndex).Cells("台灣手機").Value : ComboBox6.Text = DataGridView1.Rows(e.RowIndex).Cells("階段").Value
- ComboBox7.Text = DataGridView1.Rows(e.RowIndex).Cells("級別").Value : ComboBox8.Text = DataGridView1.Rows(e.RowIndex).Cells("性質").Value
- CheckBox1.Checked = DataGridView1.Rows(e.RowIndex).Cells("在職").Value : CheckBox2.Checked = DataGridView1.Rows(e.RowIndex).Cells("是否給薪").Value
- ComboBox5.Text = DataGridView1.Rows(e.RowIndex).Cells("薪資結構").Value : TextBox5.Text = Format(Val(DataGridView1.Rows(e.RowIndex).Cells("薪資").Value.ToString), "#,##0.00")
- TextBox6.Text = DataGridView1.Rows(e.RowIndex).Cells("備註").Value : ComboBox9.Text = DataGridView1.Rows(e.RowIndex).Cells("給薪幣別").Value
- TextBox7.Text = Year(Today) - (Double.Parse(ComboBox3.Text)) + 1
- End If
- End Sub
- Private Sub ComboBox3_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox3.TextChanged
- TextBox7.Text = Year(Today) - (Double.Parse(ComboBox3.Text)) + 1
- End Sub
- Private Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.Click
- PA = InputBox("請輸入要查詢的資料")
- 讀取人員資料表()
- PA = ""
- End Sub
- Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
- If ComboBox1.Text = "" Or ComboBox2.Text = "" Or ComboBox3.Text = "" Or ComboBox4.Text = "" Or
- ComboBox5.Text = "" Or TextBox2.Text = "" Or TextBox3.Text = "" Or TextBox5.Text = "" Then
- MsgBox("有重要資料空白不可空白")
- Else
- If conn1.State = ConnectionState.Closed Then : conn1.ConnectionString = ConString : conn1.Open() : End If
- SQL1 = "SELECT TOP (1) 人員編號 FROM 人員資料 ORDER BY 人員編號 DESC"
- cmd1.Connection = conn1 : cmd1.CommandText = SQL1 : dr1 = cmd1.ExecuteReader
- If dr1.Read() Then : TextBox1.Text = dr1("人員編號").ToString : Else : TextBox1.Text = "" : End If
- conn1.Close()
-
- Dim NUM1 As Integer
- NUM1 = Strings.Right(TextBox1.Text, 5) + 1
- If NUM1 < 10 Then : TextBox1.Text = "PER" & "0000" & NUM1
- ElseIf NUM1 > 9 And NUM1 < 100 Then : TextBox1.Text = "PER" & "000" & NUM1
- ElseIf NUM1 > 99 And NUM1 < 1000 Then : TextBox1.Text = "PER" & "00" & NUM1
- ElseIf NUM1 > 999 And NUM1 < 10000 Then : TextBox1.Text = "PER" & "0" & NUM1
- ElseIf NUM1 > 9999 Then : TextBox1.Text = "PER" & NUM1
- End If
-
- If conn1.State = ConnectionState.Closed Then : conn1.ConnectionString = ConString : conn1.Open() : End If
- If ComboBox5.Text = "NA" Or ComboBox5.Text = "佣金" Then
- SQL1 = "INSERT INTO 人員資料 (人員編號, 姓名, 性別, 籍貫, 出生年份, 證件, 証號, 手機, 薪資結構, 薪資, 備註, 在職, 月薪, 日薪, 時薪, 台灣手機, 階段, 級別, 性質, 是否給薪, 給薪幣別)
- VALUES (N'" & TextBox1.Text &
- "', N'" & TextBox2.Text & "', N'" & ComboBox1.Text & "', N'" & ComboBox2.Text & "', N'" & ComboBox3.Text & "', N'" & ComboBox4.Text &
- "', N'" & TextBox3.Text & "', N'" & TextBox4.Text & "', N'" & ComboBox5.Text & "', N'0', N'" & TextBox6.Text &
- "', N'" & CheckBox1.Checked & "', N'0', N'0', N'0', N'" & TextBox8.Text & "', N'" & ComboBox6.Text & "', N'" & ComboBox7.Text &
- "', N'" & ComboBox8.Text & "', N'" & CheckBox2.Checked & "', N'" & ComboBox9.Text & "')"
- ElseIf ComboBox5.Text = "月薪" Then
- SQL1 = "INSERT INTO 人員資料 (人員編號, 姓名, 性別, 籍貫, 出生年份, 證件, 証號, 手機, 薪資結構, 薪資, 備註, 在職, 月薪, 日薪, 時薪, 台灣手機, 階段, 級別, 性質, 是否給薪, 給薪幣別)
- VALUES (N'" & TextBox1.Text &
- "', N'" & TextBox2.Text & "', N'" & ComboBox1.Text & "', N'" & ComboBox2.Text & "', N'" & ComboBox3.Text & "', N'" & ComboBox4.Text &
- "', N'" & TextBox3.Text & "', N'" & TextBox4.Text & "', N'" & ComboBox5.Text & "', N'" & TextBox5.Text & "', N'" & TextBox6.Text &
- "', N'" & CheckBox1.Checked & "', N'" & TextBox5.Text & "', N'0', N'0', N'" & TextBox8.Text & "', N'" & ComboBox6.Text & "', N'" & ComboBox7.Text &
- "', N'" & ComboBox8.Text & "', N'" & CheckBox2.Checked & "', N'" & ComboBox9.Text & "')"
- ElseIf ComboBox5.Text = "日薪" Then
- SQL1 = "INSERT INTO 人員資料 (人員編號, 姓名, 性別, 籍貫, 出生年份, 證件, 証號, 手機, 薪資結構, 薪資, 備註, 在職, 月薪, 日薪, 時薪, 台灣手機, 階段, 級別, 性質, 是否給薪, 給薪幣別)
- VALUES ('" & TextBox1.Text &
- "', '" & TextBox2.Text & "', '" & ComboBox1.Text & "', '" & ComboBox2.Text & "', '" & ComboBox3.Text & "', '" & ComboBox4.Text &
- "', '" & TextBox3.Text & "', '" & TextBox4.Text & "', '" & ComboBox5.Text & "', '" & TextBox5.Text & "', '" & TextBox6.Text &
- "', '" & CheckBox1.Checked & "', '0', '" & TextBox5.Text & "', '0'', N'" & TextBox8.Text & "', N'" & ComboBox6.Text & "', N'" & ComboBox7.Text &
- "', N'" & ComboBox8.Text & "', N'" & CheckBox2.Checked & "', N'" & ComboBox9.Text & "')"
- ElseIf ComboBox5.Text = "時薪" Then
- SQL1 = "INSERT INTO 人員資料 (人員編號, 姓名, 性別, 籍貫, 出生年份, 證件, 証號, 手機, 薪資結構, 薪資, 備註, 在職, 月薪, 日薪, 時薪, 台灣手機, 階段, 級別, 性質, 是否給薪, 給薪幣別)
- VALUES ('" & TextBox1.Text &
- "', '" & TextBox2.Text & "', '" & ComboBox1.Text & "', '" & ComboBox2.Text & "', '" & ComboBox3.Text & "', '" & ComboBox4.Text &
- "', '" & TextBox3.Text & "', '" & TextBox4.Text & "', '" & ComboBox5.Text & "', '" & TextBox5.Text & "', '" & TextBox6.Text &
- "', '" & CheckBox1.Checked & "', '0', '0', '" & TextBox5.Text & "'', N'" & TextBox8.Text & "', N'" & ComboBox6.Text & "', N'" & ComboBox7.Text &
- "', N'" & ComboBox8.Text & "', N'" & CheckBox2.Checked & "', N'" & ComboBox9.Text & "')"
- End If
- cmd1.Connection = conn1 : cmd1.CommandText = SQL1 : cmd1.ExecuteNonQuery()
- MsgBox("新增完成")
- conn1.Close()
- End If
- 讀取人員資料表() : Set_grid1()
- End Sub
- Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
- If conn1.State = ConnectionState.Closed Then : conn1.Open() : End If
- SQL1 = "UPDATE 人員資料 SET 姓名 = N'" & TextBox2.Text & "', 性別 = N'" & ComboBox1.Text & "', 籍貫 = N'" & ComboBox2.Text & "', 出生年份 = N'" & ComboBox3.Text &
- "', 證件 = N'" & ComboBox4.Text & "', 証號 = N'" & TextBox3.Text & "', 手機 = N'" & TextBox4.Text & "', 薪資結構 = N'" & ComboBox5.Text &
- "', 薪資 = N'" & TextBox5.Text & "', 備註 = N'" & TextBox6.Text & "', 在職 = N'" & CheckBox1.Checked & "', 台灣手機 = N'" & TextBox8.Text &
- "', 階段 = N'" & ComboBox6.Text & "', 級別 = N'" & ComboBox7.Text & "', 性質 = N'" & ComboBox8.Text & "', 是否給薪 = N'" & CheckBox2.Checked &
- "', 給薪幣別 = N'" & ComboBox9.Text & "'
- WHERE (人員編號 = '" & TextBox1.Text & "')"
- cmd1.CommandText = SQL1 : cmd1.ExecuteNonQuery()
- MsgBox("修改完成")
- conn1.Close()
- 讀取人員資料表() : Set_grid1()
- End Sub
- Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
- SQL = "DELETE FROM 人員資料 WHERE (人員編號 = '" & TextBox1.Text & "')"
- cmd1.CommandText = SQL : cmd1.Connection = conn1
- If conn1.State = ConnectionState.Closed Then : conn1.Open() : End If
- Dim aa As MsgBoxResult
- aa = MsgBox("確定要刪除該筆資料?", MsgBoxStyle.OkCancel)
- If aa = MsgBoxResult.Ok Then : cmd1.ExecuteNonQuery() : MsgBox("刪除完成") : End If
- conn1.Close()
- 讀取人員資料表() : Set_grid1()
- End Sub
- End Class
|