60 lines
2.1 KiB
VB.net
60 lines
2.1 KiB
VB.net
Imports System.Data.SqlClient
|
|
Public Class Standorthinzu
|
|
|
|
Private con As New SqlConnection
|
|
Private cmd As New SqlCommand
|
|
Private reader As SqlDataReader
|
|
Public NeuerStandortName As String
|
|
Public NeuerStandortNameIntern As String
|
|
|
|
Private Function dbload()
|
|
con.ConnectionString = Class1.DBConString
|
|
cmd.Connection = con
|
|
End Function
|
|
|
|
Private Sub CmdAdd_Click(sender As Object, e As EventArgs) Handles CmdAdd.Click
|
|
StandortAdd()
|
|
NetzwerkAdmin.LstStandortLoad()
|
|
NetzwerkAdmin.LstNetzwerkLoad()
|
|
End Sub
|
|
|
|
Private Sub TxtNetzwerkIntern_Enter(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TxtNetzwerkintern.KeyDown
|
|
If e.KeyCode = Keys.Enter Then
|
|
StandortAdd()
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Private Function StandortAdd()
|
|
Dim ds As New DataSet()
|
|
Dim dt As New DataTable()
|
|
dbload()
|
|
NeuerStandortName = TxtStandort.Text
|
|
NeuerStandortNameIntern = TxtStandort.Text & "_Intern"
|
|
Try
|
|
con.Open()
|
|
cmd.CommandText = "SELECT * FROM Tbl_Netzwerke WHERE Netzwerkname='" & NeuerStandortNameIntern & "'"
|
|
reader = cmd.ExecuteReader()
|
|
If reader.Read() Then
|
|
MsgBox("Standort ist bereits vorhanden!")
|
|
reader.Close()
|
|
Else
|
|
MsgBox("Neuer Standort mit Standardnetzwerk 'Intern' wird erstellt: " & NeuerStandortNameIntern)
|
|
reader.Close()
|
|
cmd.CommandText = "INSERT INTO Tbl_Netzwerke (Netzwerkname, VLAN, Netzwerk, NWSTANDORT, NETNAME, MAIN, SUBNETZ) VALUES ('" & NeuerStandortNameIntern & "', '0', '" & TxtNetzwerkintern.Text & "', '" & NeuerStandortName & "', 'Intern', '1', '255.255.255.0')"
|
|
cmd.ExecuteNonQuery()
|
|
Class1.Absender = "Standorthinzu"
|
|
NWEdit.Show()
|
|
End If
|
|
|
|
Catch ex As Exception
|
|
MsgBox(ex.Message)
|
|
End Try
|
|
con.Close()
|
|
Me.Close()
|
|
End Function
|
|
|
|
Private Sub TxtStandort_TextChanged(sender As Object, e As EventArgs) Handles TxtStandort.TextChanged
|
|
|
|
End Sub
|
|
End Class |