Exemplo n.º 1
0
        private void SignOk_Click(object sender, EventArgs e)
        {
            string Fam = "", Nam = "", Log = "", Pas = "";

            if (SecondNameStudent.Text != "Фамилия")
            {
                Fam = SecondNameStudent.Text;
            }
            if (NameStudent.Text != "Имя")
            {
                Nam = NameStudent.Text;
            }
            if (NewLogin.Text != "Логин")
            {
                Log = NewLogin.Text;
            }
            if (newPassword.Text != "Пароль")
            {
                Pas = newPassword.Text;
            }

            if (Fam != "" && Nam != "" && Log != "" && Pas != "" && Fam != " " && Nam != " " && Log != " " && Pas != " ")
            {
                XmlDocument xDoc = new XmlDocument();
                xDoc.Load("users.xml");
                XmlElement xRoot = xDoc.DocumentElement;

                XmlNode Reg;
                Reg = xRoot.ChildNodes[1];
                XmlNodeList node = Reg.ChildNodes;
                int         Number_of_Students = Convert.ToInt32(Reg.LastChild.Attributes["id"].Value);

                XmlElement   user     = xDoc.CreateElement("user");
                XmlAttribute attr     = xDoc.CreateAttribute("id");
                XmlText      idname   = xDoc.CreateTextNode(Convert.ToString(Number_of_Students + 1));
                XmlElement   login    = xDoc.CreateElement("login");
                XmlText      log      = xDoc.CreateTextNode(Log);
                XmlElement   password = xDoc.CreateElement("password");
                XmlText      pass     = xDoc.CreateTextNode(Pas);
                XmlElement   Inform   = xDoc.CreateElement("name");
                XmlText      Inf      = xDoc.CreateTextNode(Fam + " " + Nam);

                XmlElement test       = xDoc.CreateElement("test");
                XmlElement cycles     = xDoc.CreateElement("cycles");
                XmlText    cyc        = xDoc.CreateTextNode("нет");
                XmlElement array      = xDoc.CreateElement("arrays");
                XmlText    arr        = xDoc.CreateTextNode("нет");
                XmlElement strings    = xDoc.CreateElement("strings");
                XmlText    str        = xDoc.CreateTextNode("нет");
                XmlElement recursion  = xDoc.CreateElement("recursion");
                XmlText    rec        = xDoc.CreateTextNode("нет");
                XmlElement structures = xDoc.CreateElement("structures");
                XmlText    structs    = xDoc.CreateTextNode("нет");
                XmlElement files      = xDoc.CreateElement("files");
                XmlText    fil        = xDoc.CreateTextNode("нет");
                XmlElement pointers   = xDoc.CreateElement("pointers");
                XmlText    point      = xDoc.CreateTextNode("нет");
                XmlElement dynamic    = xDoc.CreateElement("dynamic");
                XmlText    dyn        = xDoc.CreateTextNode("нет");

                XmlElement total = xDoc.CreateElement("total");
                XmlText    tot   = xDoc.CreateTextNode("нет");
                XmlElement grade = xDoc.CreateElement("grade");
                XmlText    gr    = xDoc.CreateTextNode("нет");

                attr.AppendChild(idname);
                login.AppendChild(log);
                password.AppendChild(pass);
                Inform.AppendChild(Inf);
                cycles.AppendChild(cyc);
                array.AppendChild(arr);
                strings.AppendChild(str);
                recursion.AppendChild(rec);
                structures.AppendChild(structs);
                files.AppendChild(fil);
                pointers.AppendChild(point);
                dynamic.AppendChild(dyn);
                total.AppendChild(tot);
                grade.AppendChild(gr);

                user.Attributes.Append(attr);
                user.AppendChild(login);
                user.AppendChild(password);
                user.AppendChild(Inform);
                user.AppendChild(test);
                test.AppendChild(cycles);
                test.AppendChild(array);
                test.AppendChild(strings);
                test.AppendChild(recursion);
                test.AppendChild(structures);
                test.AppendChild(files);
                test.AppendChild(pointers);
                test.AppendChild(dynamic);
                user.AppendChild(total);
                user.AppendChild(grade);

                Reg.AppendChild(user);

                xDoc.Save("users.xml");

                listofStudents.Items.Clear();
                ListBoxTitle();
            }
            registrNo();
        }