Example #1
0
 public UserInformation(Authrorization frm)
 {
     InitializeComponent();
     groupBox1.Text   = "Information on \"" + frm.list[frm.position].Name + '\"';
     textBox1.Text    = frm.list[frm.position].Name;
     textBox2.Text    = frm.list[frm.position].LastName;
     textBox3.Text    = frm.list[frm.position].e_mail;
     textBox1.Enabled = textBox2.Enabled = textBox3.Enabled = false;
 }
Example #2
0
        private void Create_Click(object sender, EventArgs e)
        {
            try
            {
                string name   = textBox_Username.Text;
                string pass   = textBox_Password.Text;
                string pass_1 = textBox_ConfimPassword.Text;
                if (name == "0" || pass == "0" || pass_1 == "0")
                {
                    throw new Exception("the fields are not filled!");
                }
                if (pass != pass_1)
                {
                    throw new Exception("the passwords do not match!");
                }

                Authrorization frm       = (Authrorization)Owner;
                XmlSerializer  formatter = new XmlSerializer(typeof(List <Person>));
                try
                {
                    FileStream file = new FileStream(@"C:\Projekts\C#\лабораторные\lab 5\2\2\Login_Password.xml", FileMode.Open);
                    frm.list = (List <Person>)formatter.Deserialize(file);
                    file.Close();
                }
                catch { frm.list.Clear(); }

                Person person = new Person(name, pass);

                for (int i = 0; i < frm.list.Count; i++)
                {
                    if (frm.list[i].Name == person.Name)
                    {
                        throw new Exception("such a person already has.");
                    }
                }

                frm.list.Add(person);
                try
                {
                    FileStream file = new FileStream(@"C:\Projekts\C#\лабораторные\lab 5\2\2\Login_Password.xml", FileMode.Create);
                    formatter.Serialize(file, frm.list);
                    file.Close();
                }
                catch { }
                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return;
            }
        }
Example #3
0
        private void Logout_Click(object sender, EventArgs e)
        {
            Authrorization frm = (Authrorization)Owner;

            frm.list[frm.position].Name     = textBox1.Text;
            frm.list[frm.position].LastName = textBox2.Text;
            frm.list[frm.position].e_mail   = textBox3.Text;
            XmlSerializer formatter = new XmlSerializer(typeof(List <Person>));

            try
            {
                FileStream file = new FileStream(@"C:\Projekts\C#\лабораторные\lab 5\2\2\Login_Password.xml", FileMode.Create);
                formatter.Serialize(file, frm.list);
                file.Close();
            }
            catch { }
            this.Close();
        }