Public Sub Insert_In_Table(ByVal EmployeId As Int32, ByVal EmployeCode As Int32, ByVal EmployeTypeAbsence As String)
Try
Dim Cmd As New OleDbCommand
If OleCn.State = 1 Then OleCn.Close()
If OleCn.State = ConnectionState.Closed Then OleCn.Open()
With Cmd
Cmd.Connection = OleCn
Cmd.CommandType = CommandType.Text
Cmd.CommandText = "update Table1 set " & EmployeTypeAbsence & "='yes' where EmployeCode=@EmployeCode"
Cmd.Parameters.Clear()
Cmd.Parameters.AddWithValue("@EmployeCode", OleDbType.Integer).Value = EmployeCode
End With
If Cmd.ExecuteNonQuery() <> 0 Then
With Cmd
Cmd.Connection = OleCn
Cmd.CommandType = CommandType.Text
Cmd.CommandText = "insert into Table2 (EmployeId , EmployeCode , EmployeTypeAbsence ) values ( @EmployeId , @EmployeCode , @EmployeTypeAbsence)"
Cmd.Parameters.Clear()
Cmd.Parameters.AddWithValue("@EmployeId", OleDbType.Integer).Value = EmployeId
Cmd.Parameters.AddWithValue("@EmployeCode", OleDbType.Integer).Value = EmployeCode
Cmd.Parameters.AddWithValue("@EmployeTypeAbsence", OleDbType.VarChar).Value = EmployeTypeAbsence
End With
If Cmd.ExecuteNonQuery() <> 0 Then
MsgBox("تم الحفظ بنجاح")
End If
Else
MsgBox("تاكد من كود الموظف")
End If
OleCn.Close()
Cmd = Nothing
Clr()
Catch ex As Exception
OleCn.Close()
MsgBox(Err.Description, MsgBoxStyle.Information)
Finally
If OleCn.State = ConnectionState.Open Then OleCn.Close()
End Try
End Sub