Beispiel #1
0
        private void metroButton1_Click(object sender, EventArgs e)
        {
            Mainframe a = new Mainframe();

            a.Show();
            this.Hide();
        }
Beispiel #2
0
        private 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 course where CourseName = '" + metroTextBox2.Text + "'";
                MySqlDataReader read = command.ExecuteReader();

                int count = 0;
                while (read.Read())
                {
                    count++;
                }
                if (count == 1)
                {
                    MessageBox.Show("It seems that the course name is already used. Please try another one.");


                    conn.Close();
                }
                else if (count > 1)
                {
                    MessageBox.Show("It seems that the course name is already used. Please try another one.'");
                    metroTextBox1.Text = "";

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

                    command2.CommandText = "insert into course (Course,CourseName) values ( '" + metroTextBox1.Text + "','" + metroTextBox2.Text + "')";
                    command2.ExecuteNonQuery();
                    MessageBox.Show("Registered Successfully");
                    conn.Close();


                    metroTextBox1.Text = "";
                    metroTextBox2.Text = "";
                    Mainframe a = new Mainframe();
                    a.Show();
                    this.Hide();
                }
                conn.Close();
            }
        }
Beispiel #3
0
        public void login()
        {
            MySqlConnection connection = new MySqlConnection(myConnection);

            connection.Open();
            MySqlCommand Command = connection.CreateCommand();

            Command.Connection  = connection;
            Command.CommandText = "select * from users where user = '******' and password = '******'";

            MySqlDataReader read   = Command.ExecuteReader();
            int             count1 = 0;

            while (read.Read())
            {
                count1++;
            }
            connection.Close();
            if (count1 == 1)
            {
                MySqlCommand copro3 = new MySqlCommand();
                connection.Open();
                copro3.Connection  = connection;
                copro3.CommandText = "select * from users where user = '******' and password = '******'";
                MySqlDataReader copro = copro3.ExecuteReader();
                while (copro.Read())
                {
                    string user = (copro["user"].ToString());
                    string pass = (copro["password"].ToString());
                    if (user == metroTextBox1.Text && pass == textBox1.Text)
                    {
                        MessageBox.Show(this, " Successfully Logged in", "Accessed", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                        this.Hide();
                        Mainframe mainframe = new Mainframe();
                        mainframe.Show();
                    }
                }
            }
            else //if (user == txUsername.Text ||pass == txtPassword.Text)
            {
                metroTextBox1.Text = "";
                textBox1.Text      = "";
                //        MessageBox.Show("Incorrect Login, Please Try Again");
                MessageBox.Show(this, "Either username and password is incorrect", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            connection.Close();
        }
Beispiel #4
0
        public void Add()
        {
            if (metroTextBox1.Text == "" || metroTextBox2.Text == "" || metroTextBox3.Text == "" || metroTextBox4.Text == "" ||
                metroTextBox5.Text == "" || metroComboBox1.Text == "" || metroComboBox2.Text == "")
            {
                MessageBox.Show("Please Complete the Form");
            }
            else if (this.dateTimePicker1.Value.Date == DateTime.Now)
            {
                MessageBox.Show("Cant create account whose age is zero");
            }
            else if (metroTextBox1.Text != "" || metroTextBox2.Text != "" || metroTextBox3.Text != "" || metroTextBox4.Text != "" ||
                     metroTextBox5.Text != "" || metroComboBox1.Text != "" || metroComboBox2.Text != "")
            {
                MySqlConnection conn = new MySqlConnection(myConnection);
                conn.Close();
                conn.Open();
                MySqlCommand command = conn.CreateCommand();
                command.CommandText = "select * from users where user = '******'";
                MySqlDataReader read = command.ExecuteReader();

                int count = 0;
                while (read.Read())
                {
                    count++;
                }
                if (count == 1)
                {
                    MessageBox.Show("It seem that the username you want isn't available. Please try another one.");


                    conn.Close();
                }
                else if (count > 1)
                {
                    MessageBox.Show("It seem that the username you want isn't available. Please try another one.'");
                    metroTextBox7.Text = "";
                    metroTextBox7.Focus();
                    conn.Close();
                }
                else
                {
                    conn.Close();
                    conn.Open();
                    MySqlCommand command2 = conn.CreateCommand();

                    command2.CommandText = "insert into users (firstname,middlename,lastname,address,dob,contactno,yearlvl,course,user,password) values ( '" + metroTextBox1.Text + "','" + metroTextBox2.Text + "','" + metroTextBox3.Text + "','" + metroTextBox5.Text + "','" + dateTimePicker1.Text + "','" + metroTextBox4.Text + "','" + metroComboBox1.Text + "','" + metroComboBox2.Text + "','" + metroTextBox7.Text + "','" + metroTextBox8.Text + "' )";
                    command2.ExecuteNonQuery();
                    MessageBox.Show("Registered Successfully");
                    conn.Close();

                    metroTextBox1.Text  = "";
                    metroTextBox2.Text  = "";
                    metroTextBox3.Text  = "";
                    metroTextBox4.Text  = "";
                    metroTextBox5.Text  = "";
                    metroTextBox7.Text  = "";
                    metroTextBox8.Text  = "";
                    metroTextBox9.Text  = "";
                    metroComboBox1.Text = "";
                    metroComboBox2.Text = "";
                    Mainframe a = new Mainframe();
                    a.Show();
                    this.Hide();
                }
                conn.Close();
            }
        }