Ejemplo n.º 1
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            MySqlConnection connection = new MySqlConnection("datasource = localhost; port = 3306; username = root; password = "******"SELECT * FROM cinema_ticket_system.users WHERE user_name = '" + txtUsername.Text + "' and password = '******'", connection);
                DataTable        dataTable = new System.Data.DataTable();
                adapter.Fill(dataTable);

                if (dataTable.Rows.Count == 1)
                {
                    this.Hide();

                    var moviesForm = new MoviesForm();
                    moviesForm.Show();
                    this.Hide();
                }
                else
                {
                    MessageBox.Show("Please check username and password!");
                }
            }
            else if (radioBtnStaff.Checked)
            {
                MySqlDataAdapter adapter   = new MySqlDataAdapter("SELECT * FROM cinema_ticket_system.staff WHERE staff_name = '" + txtUsername.Text + "' and staff_password = '******'", connection);
                DataTable        dataTable = new System.Data.DataTable();
                adapter.Fill(dataTable);

                if (dataTable.Rows.Count == 1)
                {
                    this.Hide();

                    var staffViewForm = new StaffViewForm();
                    staffViewForm.Show();
                    this.Hide();
                }
                else
                {
                    MessageBox.Show("Please check username and password!");
                }
            }
        }
Ejemplo n.º 2
0
        private void btnSignup_Click(object sender, EventArgs e)
        {
            if (txtSPassword.Text == txtRePassword.Text)
            {
                if (radioBtnCustomer.Checked)
                {
                    string insertQuery = "INSERT INTO cinema_ticket_system.users(user_name, password, retype_password) VALUES('" + txtUsername.Text + "', '" + txtSPassword.Text + "', '" + txtRePassword.Text + "')";
                    connection.Open();
                    MySqlCommand command = new MySqlCommand(insertQuery, connection);
                    try
                    {
                        if (command.ExecuteNonQuery() == 1)
                        {
                            MessageBox.Show("Sign up compelete...");
                        }
                        else
                        {
                            MessageBox.Show("Sorry! Sign up fail...");
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }

                    connection.Close();

                    var moviesForm = new MoviesForm();
                    moviesForm.Show();
                    this.Hide();
                }
                else if (radioBtnStaff.Checked)
                {
                    string insertQuery = "INSERT INTO cinema_ticket_system.staff(staff_name, staff_password, staff_retype_password) VALUES('" + txtUsername.Text + "', '" + txtSPassword.Text + "', '" + txtRePassword.Text + "')";
                    connection.Open();
                    MySqlCommand command = new MySqlCommand(insertQuery, connection);
                    try
                    {
                        if (command.ExecuteNonQuery() == 1)
                        {
                            MessageBox.Show("Sign up compelete...");
                        }
                        else
                        {
                            MessageBox.Show("Sorry! Sign up fail...");
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }

                    connection.Close();

                    var staffViewForm = new StaffViewForm();
                    staffViewForm.Show();
                }
                this.Hide();
            }
            else
            {
                MessageBox.Show("Your password mismatch!");
            }
        }