示例#1
0
        private void assigntablesbtn_Click(object sender, EventArgs e)
        {
            AssignTable AS = new AssignTable();

            AS.Show();
            this.Hide();
        }
示例#2
0
        private void deletebtn_Click(object sender, EventArgs e)
        {
            if (customerdetailslist.SelectedRows.Count == 0)
            {
                MetroFramework.MetroMessageBox.Show(this, "Select a reservation to delete", "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                return;
            }
            else
            {
                try
                {
                    MySqlCommand cmd = new MySqlCommand();
                    cmd.Connection = Connection.ConnectionDB;

                    cmd.CommandText = "DELETE FROM websitereservationdb WHERE ID = ?id";
                    cmd.Parameters.Add("?id", MySqlDbType.VarChar).Value = customerdetailslist.SelectedRows[0].Cells["ID"].Value.ToString();

                    if (Connection.ConnectionDB.State == ConnectionState.Closed)
                    {
                        Connection.ConnectionDB.Open();
                    }
                    int success = cmd.ExecuteNonQuery();
                    if (success == 0) // Error
                    {
                        MetroFramework.MetroMessageBox.Show(this, "Failed!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                    }
                    else
                    {
                        MetroFramework.MetroMessageBox.Show(this, "You have deleted a reservation!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                catch
                {
                    MetroFramework.MetroMessageBox.Show(this, "Database Error!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                    dataTable.Clear();
                }
                finally
                {
                    Connection.ConnectionDB.Close();
                }

                AssignTable AS = new AssignTable();
                AS.Show();
                this.Hide();
            }
        }