Exemplo n.º 1
0
        public void add()
        {
            {
                if (metroTextBox1.Text == "")
                {
                    MessageBox.Show("Please Complete the Form");
                }
                else if (metroTextBox1.Text != "")
                {
                    MySqlConnection conn = new MySqlConnection(myConnection);
                    conn.Close();
                    conn.Open();
                    MySqlCommand command = conn.CreateCommand();
                    command.CommandText = "select * from yearlvl where id = '" + metroTextBox1.Text + "'";
                    MySqlDataReader read = command.ExecuteReader();

                    int count = 0;
                    while (read.Read())
                    {
                        count++;
                    }
                    if (count == 1)
                    {
                        MessageBox.Show("It seems that the year lvl is already there.");


                        conn.Close();
                    }
                    else if (count > 1)
                    {
                        MessageBox.Show("It seems that the year lvl is already there.");
                        metroTextBox1.Text = "";

                        conn.Close();
                    }
                    else
                    {
                        conn.Close();
                        conn.Open();
                        MySqlCommand command2 = conn.CreateCommand();

                        command2.CommandText = "insert into yearlvl (yearlvl) values ( '" + metroTextBox1.Text + "')";
                        command2.ExecuteNonQuery();
                        MessageBox.Show("Registered Successfully");

                        this.Hide();
                        RegisterForm a = new RegisterForm();
                        a.Show();
                        this.Hide();
                        conn.Close();
                        metroTextBox1.Text = "";
                    }
                    conn.Close();
                }
            }
        }
Exemplo n.º 2
0
        private void llblRegister_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            RegisterForm registerForm = new RegisterForm();

            registerForm.ShowDialog();
        }