Torna al Thread
Imports System.IO
Imports System.Xml
Imports System.Linq
Imports System.Xml.Linq
Imports System.Xml.Schema
Partial Class Setting
Inherits System.Web.UI.Page
Private ConfigPathname As String = AppDomain.CurrentDomain.BaseDirectory + "App_Code\Settings\String.Settings"
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
If New FileInfo(ConfigPathname).Exists Then
Dim xDS As New Settings
Dim xRow As Settings.MainRow
xDS.ReadXml(ConfigPathname, System.Data.XmlReadMode.IgnoreSchema)
If xDS.Main.Rows.Count > 0 Then
xRow = xDS.Main.Rows.Item(0)
If Not xRow.IshostNull() Then
TextBox1.Text = xRow.host
End If
If Not xRow.IsusernameNull() Then
TextBox2.Text = xRow.username
End If
If Not xRow.IspasswordNull() Then
TextBox3.Text = xRow.password
End If
If Not xRow.IsportNull() Then
TextBox4.Text = xRow.port
End If
End If
End If
End Sub
Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Try
Dim xDS As New Settings
Dim xRow As Settings.MainRow
xRow = xDS.Main.NewMainRow
xRow.host = TextBox1.Text.Trim()
xRow.username = TextBox2.Text.Trim()
xRow.password = TextBox3.Text.Trim()
xRow.port = TextBox4.Text.Trim()
xDS.Main.AddMainRow(xRow)
xDS.WriteXml(ConfigPathname, System.Data.XmlWriteMode.IgnoreSchema)
MsgBox("Operazione eseguita con successo!")
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
End Class