Esempio n. 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == string.Empty || textBox3.Text == string.Empty || textBox4.Text == string.Empty)
            {
                MessageBox.Show("You must fill all the form");
            }
            else
            {
                if (!textBox3.Text.Equals(textBox4.Text))
                {
                    MessageBox.Show("Password does not match.");
                }
                else
                {
                    foreach (USER u in _mainForm.userList)
                    {
                        if (textBox1.Text == u.LoginID)
                        { MessageBox.Show("LoginName has already existed in database");return;}
                    }
                    USER user = new USER(textBox1.Text, textBox2.Text, textBox3.Text);
                    this._mainForm.userList.Add(user);
                    XmlDocument USERTable = this._mainForm.USERTable;
                    AddUserXml(user, USERTable, this._mainForm.path);

                    this._mainForm.PopulateTreeView();
                    this.Hide();

                }

            }
        }
Esempio n. 2
0
        private void AddUserXml(USER user, XmlDocument table,string path)
        {
            XmlNode USERNode= table.CreateNode(XmlNodeType.Element,"user",null);
            XmlElement nodeLogin = table.CreateElement("loginName");
            nodeLogin.InnerText = user.LoginID;
            XmlElement nodeUsername = table.CreateElement("userName");
            nodeUsername.InnerText = user.FullName;
            XmlElement nodePass = table.CreateElement("passwd");
            nodePass.InnerText = user.Password;

            USERNode.AppendChild(nodeLogin);
            USERNode.AppendChild(nodeUsername);
            USERNode.AppendChild(nodePass);

            table.DocumentElement.AppendChild(USERNode);
            table.Save(path);
        }
Esempio n. 3
0
        private void XmlLoad(XmlNode xmlNode)
        {
            foreach (XmlNode node in xmlNode)
            {
                if (node.Name == "user")
                {
                    string logName = node.ChildNodes[0].InnerText;
                    string Name = node.ChildNodes[1].InnerText;
                    string Pass = node.ChildNodes[2].InnerText;
                    USER user = new USER(logName, Name);
                    user.Password = Pass;
                    userList.Add(user);

                }
            }
        }