Beispiel #1
0
        private void buttonLoginSave_Click(object sender, EventArgs e)
        {
            ProfileLog log = ProfileLog.Create;
            Profile    p   = new Profile();

            try
            {
                var x = new MailAddress(textBoxuserID.Text);
                p.Email    = x.Address;
                p.Password = textBoxpassword.Text;
            }
            catch (FormatException)
            {
                textBoxErrorLogin.Text = "Email Format not Accepted";
                return;
            }
            catch (ArgumentNullException)
            {
                textBoxErrorLogin.Text = "Email can not be empty";
                return;
            }
            if (log.IsContainsProfile(p.Email) == true)
            {
                textBoxErrorLogin.Text = "Email is already reistered";
            }
            else
            {
                log.Add(p);
                log.TurnActive(p.Email);
                comboBoxEmails.Items.Add(p.Email);
                textBoxErrorLogin.Text = "Succeded";
                textBoxuserID.Text     = "";
                textBoxpassword.Text   = "";
            }
        }
Beispiel #2
0
        private void buttonLoginSave_Click(object sender, EventArgs e)
        {
            Profile p = new Profile();

            p.Email    = textBoxuserID.Text;
            p.Password = textBoxpassword.Text;
            ProfileLog.Add(p);
        }
        public void Deserialize()
        {
            try
            {
                using (Stream stream = File.Open("data.bin", FileMode.Open))
                {
                    BinaryFormatter bin      = new BinaryFormatter();
                    var             profiles = (HashSet <Profile>)bin.Deserialize(stream);

                    foreach (var x in profiles)
                    {
                        Profile p = new Profile();
                        p.Email    = x.Email;
                        p.Password = x.Password;
                        ProfileLog.Add(p);
                    }
                }
            }
            catch (IOException)
            {
            }
        }