Exemplo n.º 1
0
        private void viewbtn_Click(object sender, EventArgs e)
        {
            ViewReservation VR = new ViewReservation();

            VR.Show();
            this.Hide();
        }
Exemplo n.º 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 reserveddb 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);
                        deletedtablenumber = customerdetailslist.SelectedRows[0].Cells["table_number"].Value.ToString();
                    }
                }
                catch
                {
                    MetroFramework.MetroMessageBox.Show(this, "Database Error!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                    dataTable.Clear();
                }
                finally
                {
                    Connection.ConnectionDB.Close();
                }
            }

            ViewReservation VR = new ViewReservation();

            VR.Show();
            this.Hide();
        }