有关我的项目的帮助 [英] Help needed regarding my Project
本文介绍了有关我的项目的帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好. .
我的项目需要一些帮助. .关于在线商店. .假设我有5个客户. .他们应该能够登录到我的网站并从我的网站更改其商店的内容或菜单,价格. .因此,每当他们需要添加/删除某些内容时,他们都会登录到我的网站并可以进行更改. .每个商店都是不同的. .我应该如何开始呢?我很困惑:(
Hello Everyone . .
I need some help in my project . . Its regarding online store . . Suppose there are 5 clients of mine . . They should be able to login to my website and change the contents or menu''s, price of their store from my website . . so whenever they need to add/delete something they will login to my website and can change things. . Each store is different . . How should i start with this ? i am confused :(
推荐答案
您可以使用IsolatedStorage为每个用户创建应用程序设置.以下是存储和检索应用程序设置的示例代码:
You can create the application setting for each user using IsolatedStorage. Here is the sample code to store and retrieve the application settings:
Public Class AppSettings
Private _configFileName As String 'local var to hold the config file name
Private _configFileType As Config 'local var to hold the config file type (private or shared)
'config file options
Public Enum Config
SharedFile 'all users use the same config file
PrivateFile 'each user has their own config file
End Enum
'constructor
Public Sub New(ByVal ConfigFileType As Config)
_configFileType = ConfigFileType 'remember this setting
InitializeConfigFile() 'setup the filename and location
End Sub
'initialize the apps config file, create it if it doesn't exist
Private Sub InitializeConfigFile()
Dim sb As New Text.StringBuilder
'build the path\filename depending on the location of the config file
Select Case _configFileType
Case Config.PrivateFile 'each user has their own personal settings
'use "\documents and settings\username\application data" for the config file directory
sb.Append(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData))
Case Config.SharedFile 'all users share the same settings
'use "\documents and settings\All Users\application data" for the config file directory
sb.Append(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData))
End Select
'add the product name
sb.Append("\")
sb.Append(Application.ProductName)
'create the directory if it isn't there
If Not IO.Directory.Exists(sb.ToString) Then
IO.Directory.CreateDirectory(sb.ToString)
End If
'finish building the file name
sb.Append("\")
sb.Append(Application.ProductName)
sb.Append(".config")
_configFileName = sb.ToString 'completed config filename
'if the file doesn't exist, create a blank xml
If Not IO.File.Exists(_configFileName) Then
Dim fn As New IO.StreamWriter(IO.File.Open(_configFileName, IO.FileMode.Create))
fn.WriteLine("")
fn.WriteLine("<configuration>")
fn.WriteLine(" <appsettings>")
fn.WriteLine(" <!-- User application and configured property settings go here.-->")
fn.WriteLine(" <!-- Example: <add key=""settingName"" value=""settingValue""/> -->")
fn.WriteLine(" </appsettings>")
fn.WriteLine("</configuration>")
fn.Close() 'all done
End If
End Sub
'get an application setting by key value
Public Function GetSetting(ByVal key As String) As String
'xml document object
Dim xd As New Xml.XmlDocument
'load the xml file
xd.Load(_configFileName)
'query for a value
Dim Node As Xml.XmlNode = xd.DocumentElement.SelectSingleNode( _
"/configuration/appSettings/add[@key=""" & key & """]")
'return the value or nothing if it doesn't exist
If Not Node Is Nothing Then
Return Node.Attributes.GetNamedItem("value").Value
Else
Return Nothing
End If
End Function
'save an application setting, takes a key and a value
Public Sub SaveSetting(ByVal key As String, ByVal value As String)
'xml document object
Dim xd As New Xml.XmlDocument
'load the xml file
xd.Load(_configFileName)
'get the value
Dim Node As Xml.XmlElement = CType(xd.DocumentElement.SelectSingleNode( _
"/configuration/appSettings/add[@key=""" & _
key & """]"), Xml.XmlElement)
If Not Node Is Nothing Then
'key found, set the value
Node.Attributes.GetNamedItem("value").Value = value
Else
'key not found, create it
Node = xd.CreateElement("add")
Node.SetAttribute("key", key)
Node.SetAttribute("value", value)
'look for the appsettings node
Dim Root As Xml.XmlNode = xd.DocumentElement.SelectSingleNode("/configuration/appSettings")
'add the new child node (this key)
If Not Root Is Nothing Then
Root.AppendChild(Node)
Else
Try
'appsettings node didn't exist, add it before adding the new child
Root = xd.DocumentElement.SelectSingleNode("/configuration")
Root.AppendChild(xd.CreateElement("appSettings"))
Root = xd.DocumentElement.SelectSingleNode("/configuration/appSettings")
Root.AppendChild(Node)
Catch ex As Exception
'failed adding node, throw an error
Throw New Exception("Could not set value", ex)
End Try
End If
End If
'finally, save the new version of the config file
xd.Save(_configFileName)
End Sub
End Class
感谢Ganesan Senthilvel. .
我可以获取您的电子邮件地址吗?
Thanks Ganesan Senthilvel . .
Can i get your Email Address ?
我没有从何处开始该项目. .我是新来的 . .如果您能给我一些资源,那对您会很好. .我是从头开始的. . :(请帮助我!
I am not getting from where to start on this project . . i am new to this . . If you can give me some resources then that ll be nice of you . . I am doint it from scratch . . :( Please help me !
这篇关于有关我的项目的帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文