private void DelUserButton_Click(object sender, RoutedEventArgs e) { DataRowView selectedUser = (DataRowView)UsersData.SelectedItem; int id = Convert.ToInt32(selectedUser["ID"]); string sqlRequest = $"DELETE FROM `users` WHERE `users`.`ID` = {id}"; XApp.openDBConnection(); MySqlCommand cmd = XApp.connection.CreateCommand(); cmd.CommandText = sqlRequest; cmd.ExecuteNonQuery(); XApp.closeDBConnection(); UpdateTable(); }
private void DelRoomButton_Click(object sender, RoutedEventArgs e) { DataRowView selectedRoom = (DataRowView)RoomsData.SelectedItem; int Number = Convert.ToInt32(selectedRoom["Number"]); string sqlRequest = $"DELETE FROM `rooms` WHERE `rooms`.`Number` = {Number};"; XApp.openDBConnection(); MySqlCommand cmd = XApp.connection.CreateCommand(); cmd.CommandText = sqlRequest; cmd.ExecuteNonQuery(); XApp.closeDBConnection(); UpdateTable(); }
private void SaveButton_Click(object sender, RoutedEventArgs e) { newUser.Login = UserLoginTextBox.Text; newUser.Password = UserPassTextBox.Text; newUser.Role = RoleTextBox.Text; string sqlRequest = $"INSERT INTO `users` (`ID`, `Login`, `Password`, `Role`)" + $" VALUES (NULL, '{newUser.Login}', '{newUser.Password}', '{newUser.Role}');"; XApp.openDBConnection(); MySqlCommand cmd = XApp.connection.CreateCommand(); cmd.CommandText = sqlRequest; cmd.ExecuteNonQuery(); XApp.closeDBConnection(); ownerWin.UpdateTable(); this.Close(); }
private void SaveButton_Click(object sender, RoutedEventArgs e) { newRoom.Cost = Convert.ToInt32(CostTextBox.Text); newRoom.Number = Convert.ToInt32(RoomNumTextBox.Text); newRoom.Person = Convert.ToInt32(RoomPersonNumTextBox.Text); string sqlRequest = $"INSERT INTO `rooms` (`ID`, `Number`, `Person`, `BusyStatus`, `CleanStatus`, " + $"`BookingStatus`, `Cost`) VALUES (NULL, '{newRoom.Number}', '{newRoom.Person}'," + $" '{newRoom.BusyStatus}', '{newRoom.CleanStatus}', '{newRoom.BookingStatus}', '{newRoom.Cost}');"; XApp.openDBConnection(); MySqlCommand cmd = XApp.connection.CreateCommand(); cmd.CommandText = sqlRequest; cmd.ExecuteNonQuery(); XApp.closeDBConnection(); ownerWin.UpdateTable(); this.Close(); }