Ok I have been reading tutorials and searching Google but it just seems like there's 10 different ways to save and open xml documents and I'm getting confused on how to apply this to what I'm trying to do.
The Controls that I have on the form:
1 Combo box (cbxRep)
2 Check Boxes (chkLooseFill and chkRetroFoam)
1 READ ONLY text box (txtEstNumber)
1 Month Calendar (Calendar)
3 Textboxes (txtFirstName, txtLastName and txtComments)
3 Buttons (btnOpen, btnSave and btnCancel)
1 savefiledialog (sfdBox)
1 openfiledialog (ofdBox)
What my form looks like:
![Name: reichel-test-log.jpg
Views: 67
Size: 96.9 KB]()
What I'm trying to achieve:
I want to be able to do three different things here.
1: I want to be able to save the information (I already partially have this working but I'm not sure if this is the best way to achieve the results) to an XML file.
2: have the program append any information if it already exists (update customer information)
3: When the open button is clicked I need the ofdBox to open and when the file is clicked I need a window to open listing out all the information from the file separated into each customers information so that they can select the right customer estimate that they want.
Sorry if this seems confusing or like a lot I try to be thorough when I post something to clear up any confusion people may have...
If it needs to be broken up or something let me know. I'm trying to figure this out but it's proving to be more than I thought it would be...
Code I've used so far:
' Checks to see if the folder and file exist if not creates them.
' Writes out the information to an XML File (but overwrites the file everytime.
The Controls that I have on the form:
1 Combo box (cbxRep)
2 Check Boxes (chkLooseFill and chkRetroFoam)
1 READ ONLY text box (txtEstNumber)
1 Month Calendar (Calendar)
3 Textboxes (txtFirstName, txtLastName and txtComments)
3 Buttons (btnOpen, btnSave and btnCancel)
1 savefiledialog (sfdBox)
1 openfiledialog (ofdBox)
What my form looks like:
What I'm trying to achieve:
I want to be able to do three different things here.
1: I want to be able to save the information (I already partially have this working but I'm not sure if this is the best way to achieve the results) to an XML file.
2: have the program append any information if it already exists (update customer information)
3: When the open button is clicked I need the ofdBox to open and when the file is clicked I need a window to open listing out all the information from the file separated into each customers information so that they can select the right customer estimate that they want.
Sorry if this seems confusing or like a lot I try to be thorough when I post something to clear up any confusion people may have...
If it needs to be broken up or something let me know. I'm trying to figure this out but it's proving to be more than I thought it would be...
Code I've used so far:
' Checks to see if the folder and file exist if not creates them.
Code:
'UNIVERSAL VARIABLES
'Get current year and month
Dim thisYear As Integer = Now.Year
Dim thisMonth As Integer = Now.Month
'NEW SUB
Sub New()
' This call is required by the Windows Form Designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
txtEstNumber.Text = 0
End Sub
'MAINWINDOW FORM LOAD
Private Sub testLog_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Dir(My.Computer.FileSystem.SpecialDirectories.MyDocuments & "\Reichel Log Files\" & thisYear & "\", FileAttribute.Directory) = "" Then
MkDir(Path:=My.Computer.FileSystem.SpecialDirectories.MyDocuments & "\Reichel Log Files\" & thisYear)
My.Computer.FileSystem.CopyDirectory(My.Computer.FileSystem.SpecialDirectories.MyDocuments & "\Reichel Log Files\" & "Default\*", My.Computer.FileSystem.SpecialDirectories.MyDocuments & "\Reichel Log Files\" & thisYear & "\", True)
Else
Exit Sub
End If
End Sub
Code:
'Save Button
Private Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click
Dim writer As New XmlTextWriter(My.Computer.FileSystem.SpecialDirectories.MyDocuments & "\Reichel Log Files\" & thisYear & "\" & thisMonth & "\Reichel_Test_Log.rei", System.Text.Encoding.UTF8)
writer.WriteStartDocument(True)
writer.Formatting = Formatting.Indented
writer.Indentation = 2
writer.WriteStartElement("Customer Information")
createNode(txtFirstName.Text, txtLastName.Text, txtComments.Text, writer)
writer.WriteEndElement()
writer.WriteEndDocument()
writer.Close()
End Sub
Private Sub createNode(ByVal txtFirstName As String, ByVal txtLastName As String, ByVal txtComments As String, ByVal writer As XmlTextWriter)
writer.WriteStartElement("Estimate Number")
writer.WriteString(txtEstNumber.Text)
writer.WriteEndElement()
writer.WriteStartElement("Date Created")
writer.WriteStartElement("Date")
writer.WriteString(Now.Date)
writer.WriteEndElement()
writer.WriteStartElement("Time")
writer.WriteString(TimeOfDay)
writer.WriteEndElement()
writer.WriteEndElement()
writer.WriteStartElement("Sales Rep")
writer.WriteString(cbxRep.SelectedItem)
writer.WriteEndElement()
writer.WriteStartElement("JobsChecked")
writer.WriteStartElement("Loosefill")
writer.WriteString(chkLooseFill.CheckState)
writer.WriteEndElement()
writer.WriteStartElement("RetroFoam")
writer.WriteString(chkRetroFoam.CheckState)
writer.WriteEndElement()
writer.WriteEndElement()
writer.WriteStartElement("FirstName")
writer.WriteString(txtFirstName)
writer.WriteEndElement()
writer.WriteStartElement("LastName")
writer.WriteString(txtLastName)
writer.WriteEndElement()
writer.WriteStartElement("Comments")
writer.WriteString(txtComments)
writer.WriteEndElement()
End Sub