private void button2_Click(object sender, EventArgs e) { Form3 MyForm = new Form3(); MyForm.Show(); this.Hide(); }
private void TakeQuiz_Click(object sender, EventArgs e) { Form3 f3 = new Form3(); f3.Show(); this.Close(); }
private void Button_Click(object sender, EventArgs e) { Button button = sender as Button; if (button.Text == "Ok") { User user_ = new User(); bool a = true; bool b = true; foreach (var item in Controls) { if (item is TextBox textBox) { if (textBox.Text != string.Empty && textBox.Name == "Mail") { string pattern = @"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$"; string q = Users.FindAll(x => x.Mail == textBox.Text).ToString(); if (Regex.IsMatch(textBox.Text, pattern) && q != "0") { user_.Mail = textBox.Text; a = false; } } if (textBox.Text != string.Empty && textBox.Name == "Password") { user_.Password = textBox.Text; b = false; } } } if (!a && !b) { Users.Add(user_); string json = JsonConvert.SerializeObject(Users); if (Directory.Exists("User")) { System.IO.File.WriteAllText("User.json", json); } else { System.IO.File.WriteAllText("User.json", json); } ResetForm(); Login(); } } if (button.Text == "Registr") { ResetForm(); TextBox textBox = new TextBox(); textBox.Location = new Point(400, 87); textBox.Size = new Size(400, 20); textBox.MouseClick += TextBox_MouseClick; textBox.MouseLeave += TextBox_MouseLeave; textBox.Text = "Enter Mail"; textBox.Name = "Mail"; TextBox textBox1 = new TextBox(); this.Controls.Add(textBox); textBox1.Location = new Point(400, 141); textBox1.Size = new Size(400, 20); textBox1.MouseClick += TextBox1_MouseClick; textBox1.MouseLeave += TextBox1_MouseLeave; textBox1.Text = "Enter Password"; textBox1.Name = "Password"; this.Controls.Add(textBox1); point.X = 100; point.Y = 60; createButton("Ok", true); } if (button.Text == "Sign in") { bool a = true; bool b = true; if (File.Exists("User.json")) { string user = File.ReadAllText("User.json"); Users = JsonConvert.DeserializeObject <List <User> >(user); foreach (var item in Controls) { if (item is TextBox textBox) { if (textBox.Text != string.Empty) { string q = Users.FindAll(x => x.Mail == textBox.Text).ToString(); if (q != "0") { a = false; } } string t = Users.FindAll(x => x.Password == textBox.Text).ToString(); if (t != "0") { b = false; } } } if (!a && !b) { ResetForm(); ProgramLoad(); } } } if (button.Text == "Quiz") { ResetForm(); Form2 form2 = new Form2(); form2.ShowDialog(); } if (button.Text == "Create Test") { ResetForm(); Form3 form3 = new Form3(); this.Visible = false; form3.ShowDialog(); } }