//Создание строки в БД public void createGuest() { string[] guest = CreateGuest.Create(); MessageBox.Show(guest[1].ToString()); string query = "INSERT INTO гость (`ФИО`, `Дата рождения`, `Паспортные данные`, `Информация о прошлых заездах`," + "`Привилегии`, `Номер телефона`) VALUES ('" + guest[0] + "','" + guest[1] + "','" + guest[2] + "','" + guest[3] + "','" + guest[4] + "','" + guest[5] + "')"; MySqlCommand command = new MySqlCommand(query, connection); command.CommandTimeout = 60; MySqlDataReader reader; try { connection.Open(); reader = command.ExecuteReader(); // Succesfully deleted connection.Close(); } catch (Exception ex) { // Ops, maybe the id doesn't exists ? MessageBox.Show(ex.Message); } }
//Обработка нажатия на кнопки private void AddBtn_Click(object sender, EventArgs e) { CreateGuest CreateGuestForm = new CreateGuest(); RoomForm CreateRoomForm = new RoomForm(); if (dataGridView1.Visible) { CreateGuestForm.Show(); } if (dataGridView2.Visible) { CreateRoomForm.Show(); } }