Ejemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            NewUserForm form2 = new NewUserForm();

            form2.Show();
            this.Hide();
        }
Ejemplo n.º 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            String        filePath = @"..\login.txt";
            List <string> lines    = File.ReadAllLines(filePath).ToList();

            string username1         = textBox1.Text;                     //MessageBox.Show(username,"Name");
            string password1         = textBox2.Text;                     //MessageBox.Show(password, "Name");
            string reEnteredPassword = textBox3.Text;                     //MessageBox.Show(reEnteredPassword, "Name");
            string firstName1        = textBox4.Text;                     //MessageBox.Show(firstName, "Name");
            string lastName1         = textBox5.Text;                     //MessageBox.Show(lastName, "Name");
            string date1             = dateTimePicker1.Text;              //MessageBox.Show(date, "Name");
            string userType1         = comboBox1.SelectedItem.ToString(); //MessageBox.Show(userType, "Name");

            if (password1 == reEnteredPassword)
            {
                // Add new User's detail to login.txt file
                List <Person> people = new List <Person>();
                people.Add(new Person {
                    UserName = username1, Password = password1, UserType = userType1, FirstName = firstName1, Lastname = lastName1, Date = date1
                });

                foreach (var person in people)
                {
                    lines.Add($"{person.UserName},{person.Password},{person.UserType},{person.FirstName},{person.Lastname},{person.Date}");
                }
                File.WriteAllLines(filePath, lines);
                MessageBox.Show("Your Username and Password has been saved", "New Account Generated");
                LoginForm form1 = new LoginForm();
                MessageBox.Show("You can now LogIn", "New Account Created", MessageBoxButtons.OK, MessageBoxIcon.Information);
                form1.Show();
                this.Hide();
            }
            else
            {
                MessageBox.Show("Please be Careful. Password and Re-entered Password are not same", "Alert");
                this.Close();
                NewUserForm form2 = new NewUserForm();
                form2.Show();
            }
        }