private void loadDataFromDb() { receipts = DatabaseOperations.getReceipts().ToList(); if (receipts != null && receipts.Any()) { foreach (var data in receipts) { totalPrice += data.amountPayable; } totalPriceTextBox.Text = FormatPrice.format(totalPrice); new UpdateDataGridView().addReceiptsToDataGridView(receipts, dataGridView1); } }
public void IdEnEmail_ValuesZijnUniek_IdEnEmailIsGelijkInBeideObjecten() { //Arrange Lesgever lesgever = new Lesgever(); //Act lesgever.Id = 1; lesgever.Email = "*****@*****.**"; Lesgever ophalenLesgever = DatabaseOperations.OphalenLesgeverViaId(lesgever.Id); //Assert Assert.AreEqual(lesgever, ophalenLesgever); }
private void cmbCategorie_SelectionChanged(object sender, SelectionChangedEventArgs e) { Categorie categorie = cmbCategorie.SelectedItem as Categorie; // pas wanneer een categorie is ingevuld kan men een onderwerp selecteren omdat dit een recrusieve relatie is in de databank en deze van elkaar afhangen if (categorie == null) { MessageBox.Show("Gelieve eerst een categorie te kiezen"); } else { cmbOnderwerpen.ItemsSource = DatabaseOperations.OphalenOnderwerpenViaCatId(categorie.Id); } }
private void CursusBijzonderheidAanpassen(string checkboxNaam, ref string msg) { //Cursus bijzonderheden worden opgehaald en een lokale variable gestoken Cursus_Bijzonderheid cursusBijzonderheid = new Cursus_Bijzonderheid(); cursusBijzonderheid.Cursus_Id = cursus.Id; Bijzonderheid bijzonderheid = DatabaseOperations.OphalenBijzonderheidViaNaam(checkboxNaam); cursusBijzonderheid.Bijzonderheid_Id = bijzonderheid.Id; if (DatabaseOperations.ToevoegenCursusBijzonderheid(cursusBijzonderheid) <= 0)//het aantal toe te voegen cursussen moet groter zijn dan 0 { msg += $"Uw bijzonderheid {checkboxNaam} is niet aangepast in de cursus." + Environment.NewLine; } }
public void TestCreateRFData_InvalidIntensity() { data1.Intensity = -239458; DatabaseOperations.CreateRFData(appt.Id, data1); // update appt appt = DatabaseOperations.GetListOfAppointmentsForRadioTelescope(NumRTInstances).Find(x => x.Id == appt.Id); RFData testData = appt.RFDatas.ToList().Find(x => x.Id == data1.Id); Assert.AreEqual(null, testData); }
public DataServiceDto(string connectionString, MetadataSrv.Metadata metadataSrv) { this.MetadataSrv = metadataSrv; var dialect = metadataSrv.Dialect(); var databaseOperations = new DatabaseOperations(connectionString, dialect); var dataAdapterRead = new DataAdapterRead(databaseOperations, dialect, metadataSrv); var dataAdapterCud = new DataAdapterCud(dataAdapterRead, databaseOperations, dialect, metadataSrv); this.DataViewDto = new DataViewDto(dataAdapterRead, dataAdapterCud, metadataSrv); this.ResultSerialUtils = new ResultSerialUtils(this.DataViewDto, "crud", metadataSrv); this.ApiProviderDto = new ApiProviderDto(this.DataViewDto, this.ResultSerialUtils, metadataSrv); }
/// <summary> /// Constructor used to initialize a SensorNetworkClient, which will allow the SensorNetworkServer /// to use this to send data to the Sensor Network. /// </summary> /// <param name="clientIPAddress">IP address that the client will connect to.</param> /// <param name="clientPort">Port that the client will connect to.</param> /// <param name="telescopeId">The ID of the Radio Telescope so we know what config to grab.</param> public SensorNetworkClient(string clientIPAddress, int clientPort, int telescopeId) { IPAddress = clientIPAddress; Port = clientPort; SensorNetworkConfig = DatabaseOperations.RetrieveSensorNetworkConfigByTelescopeId(telescopeId); // if the config doesn't exist, create a new one if (SensorNetworkConfig == null) { SensorNetworkConfig = new SensorNetworkConfig(telescopeId); DatabaseOperations.AddSensorNetworkConfig(SensorNetworkConfig); } }
private async void getDataByCategoryId(string categoryId) { stockComboBox.Items.Clear(); stocks = await DatabaseOperations.getStocksByCategoryId(categoryId); if (stocks != null && stocks.Any()) { foreach (var data in stocks) { stockComboBox.Items.Add(data.name); } } }
private void Window_Closed(object sender, EventArgs e) { //verschil start playtime en eind playtime, updaten in DB voor PlayedTime Player player = DatabaseOperations.GetPlayer(PlayerInformation.PlayerId); TimeSpan sessionPlaytime = (DateTime.Now - startPlayTime); player.PlayedTime += sessionPlaytime; DatabaseOperations.UpdatePlayer(player); App.Current.Shutdown(); }
private void btnDelete_Click(object sender, RoutedEventArgs e) { //Delete functionaliteit uitvoeren if (DatabaseOperations.RemovePokemonFromGroup(CurrentPkmParty) != 0) { MessageBox.Show($"{CurrentPkm.Nickname} succesfully removed from the party of {currentTrainer.TrainerName}"); Close(); } else { MessageBox.Show("Deletion failed"); } }
public static Kullanicilar getKullanicilar(int id) { //id istenen kullaniciyi listeler Kullanicilar sonuc = null; if (id > 0) { sonuc = DatabaseOperations.QueryExecute <Kullanicilar>( "Select * from \"Kullanicilar\" where id=" + id ).FirstOrDefault(); } return(sonuc); }
public IActionResult Send(string Title, string Receivers, string Content, string Sender) { var rec = Receivers .Replace(" ", "") .Replace("@gachimail.com", "") .Split(';'); DatabaseOperations.SendMail(Title, Content, DateTime.Now, Sender, rec); return(RedirectToAction("ListMessages", "Mailbox", new { mtype = "Sent" })); }
public void TestCreateRFData_InvalidDate() { data1.TimeCaptured = DateTime.UtcNow.AddDays(1); DatabaseOperations.CreateRFData(appt.Id, data1); // update appt appt = DatabaseOperations.GetListOfAppointmentsForRadioTelescope(NumRTInstances).Find(x => x.Id == appt.Id); RFData testData = appt.RFDatas.ToList().Find(x => x.Id == data1.Id); Assert.AreEqual(null, testData); }
private void Page_Loaded(object sender, RoutedEventArgs e) { DataContext = this; cntrlHeader.Subtitle = Evt.Name; //lijst van artiesten opvullen List <Artist> lijst = DatabaseOperations.GetArtists(Evt); //lijst maken die met binding update Artists = new ObservableCollection <Artist>(lijst); ToggleVisibility(); }
public void TestMoneyOwned() { List <Trainer> alltrainers = new List <Trainer>(); List <Trainer> MoneyOwnedToCheck = new List <Trainer>(); alltrainers = DatabaseOperations.GetTrainerList(); foreach (Trainer trainer in alltrainers) { MoneyOwnedToCheck = DatabaseOperations.SelectMoneyOwnedFromTrainer(trainer); Assert.IsTrue(MoneyOwnedToCheck.Count > 0); } }
public static Kullanicilar getKullanicilar(string KullaniciAdi) { //kullanici adi ile istenen kullaniciyi listeler Kullanicilar sonuc = null; if (KullaniciAdi != "") { sonuc = DatabaseOperations.QueryExecute <Kullanicilar>( "Select * from \"Kullanicilar\" where lower(\"KullaniciAdi\")='" + KullaniciAdi.ToLower() + "'" ).FirstOrDefault(); } return(sonuc); }
private bool CursusBijzonderheidVerwijderen(string checkboxNaam, ref string msg) { bool gelukt = true; Bijzonderheid bijzonderheid = DatabaseOperations.OphalenBijzonderheidViaNaam(checkboxNaam); Cursus_Bijzonderheid cursusBijzonderheid = DatabaseOperations.OphalenCursusBijzonderheidViaCursusIdEnBijzonderheidId(cursus.Id, bijzonderheid.Id); if (DatabaseOperations.VerwijderenCursusBijzonderheid(cursusBijzonderheid) <= 0)//verwijderen van de cursus bijzonderheden en indien dit niet mogelijk dat er een fout wordt gegooit { msg += $"Uw bijzonderheid {checkboxNaam} is niet verwijderd." + Environment.NewLine; gelukt = false; } return(gelukt); }
private void btnRemove_Click(object sender, RoutedEventArgs e) { if (DatabaseOperations.RemoveItemFromList(lstInventory[lvInventory.SelectedIndex]) != 0) { MessageBox.Show("deletion successful"); OnLoad(); Close(); } else { MessageBox.Show("Deletion failed"); } }
private void LoadDefaultMoves(int pokemonID) { DefaultMoves1.Id = DatabaseOperations.CurrentLearnedMoves() + 1; DefaultMoves2.Id = DatabaseOperations.CurrentLearnedMoves() + 2; DefaultMoves1.CurrentPP = 30; DefaultMoves1.MoveId = 42; DefaultMoves1.Position = 1; DefaultMoves2.CurrentPP = 30; DefaultMoves2.MoveId = 10; DefaultMoves2.Position = 2; DefaultMoves1.PokemonId = pokemonID; DefaultMoves2.PokemonId = pokemonID; }
private void btnAdd_Click(object sender, RoutedEventArgs e) { string error = Validate(); if (!string.IsNullOrWhiteSpace(error)) { MessageBox.Show(error); } else { //Create new item Items item = new Items { //nieuwe id geven aan het nieuwe item Id = DatabaseOperations.CurrentItems() + 1, ItemName = txtItemName.Text, //van het geselecteerde item pak je de categorie die aangeduid is in de combobox Catagory = cbChooseCategory.SelectedItem.ToString() }; //doen voor items en playerinvtory want items is een collectie die in playerinventory zit dus we moeten het aangemaakte item daarna ook nog in playerinventory zetten //Create a new player inventory PlayerInventory playerInventory = new PlayerInventory(); //quantity nemen van textbox int quantity = int.Parse(txtQuantity.Text); playerInventory.Quantity = quantity; playerInventory.ItemID = item.Id; playerInventory.PlayerId = trainerToAddTo.Id; playerInventory.id = DatabaseOperations.CurrentPlayerItems() + 1; if (DatabaseOperations.AddItem(item) != 0)//validatie als de addition failt en dus 0 geeft --> zie else { MessageBox.Show($"{item} is succesfully added to the itemlist."); Close(); } else { MessageBox.Show("Addition failed"); } if (DatabaseOperations.AddPlayerinvtoryItem(playerInventory) != 0) { MessageBox.Show($"{item} is succesfully added to the playerinventory."); Close(); } else { MessageBox.Show("Addition failed"); } lvInventory.Items.Refresh();//refreshen om te zien of het item bij in de lijst is gekomen } }
internal async Task <Article> GetArticleAsync(string headLine, string category) { Article article = new Article(); bool foundArticle = false; if (_listofCategories.Count > 0) { var categoryDetails = _listofCategories.FirstOrDefault(o => o.CategoryName.ToLower() == category.ToLower()); if (categoryDetails != null) { if (categoryDetails.Articles != null && categoryDetails.Articles.Count > 0) { CurrentArticle = article = categoryDetails.Articles.FirstOrDefault(o => o.HeadLine == headLine); foundArticle = true; } } } else if (_listofCategories == null) { List <Category> categories = await DatabaseOperations.GetInstance().GetCategoriesAsync(); if (categories != null && categories.Count > 0) { _listofCategories.AddRange(categories); } else { InitializeCategories(); } } if (foundArticle == false || CurrentArticle == null) { var categoryArticles = await DatabaseOperations.GetInstance().GetCategoryArticlesAsync(category); if (categoryArticles != null && categoryArticles.Count > 0) { if (_listofCategories.FirstOrDefault(o => o.CategoryName.ToLower() == category.ToLower()).Articles == null) { _listofCategories.FirstOrDefault(o => o.CategoryName.ToLower() == category.ToLower()).Articles = new ObservableCollection <Article>(); } categoryArticles.ForEach(o => { _listofCategories.FirstOrDefault(l => l.CategoryName.ToLower() == category.ToLower()).Articles.Add(o); }); CurrentArticle = article = categoryArticles.FirstOrDefault(o => o.HeadLine == headLine); } } return(article); }
public void LoadAdvancements(int functie) { player = DatabaseOperations.OphalenAdvancements(playerId); Style brown = (Style)FindResource("normalAdvancementBrown"); Style specialbrown = (Style)FindResource("specialAdvancementBrown"); Style grey = (Style)FindResource("normalAdvancementGrey"); Style specialgrey = (Style)FindResource("specialAdvancementGrey"); var count = 0; foreach (Player_Advancement advancement in player.Player_Advancement) { if (advButtons[count].IsChecked == true && functie == 2 && advancement.advancementObtained) { advancement.advancementObtained = false; DatabaseOperations.UpdatePlayerAdvancement(advancement); } if (advButtons[count].IsChecked == true && functie == 1 && !advancement.advancementObtained) { advancement.advancementObtained = true; DatabaseOperations.UpdatePlayerAdvancement(advancement); } advButtons[count].IsChecked = false; if (advancement.advancementObtained) { if (advancement.Advancement.type == "normal") { advButtons[count].Style = brown; } else { advButtons[count].Style = specialbrown; } } else { if (advancement.Advancement.type == "normal") { advButtons[count].Style = grey; } else { advButtons[count].Style = specialgrey; } } count++; } }
private void TaskInterface_Load(object sender, EventArgs e) { BackgroundImage = new Bitmap(@"\Program Files\GPSReminder\Images\BlackImage.jpg"); SubjectCombo.Items.Add("Complete"); SubjectCombo.Items.Add("Work On"); SubjectCombo.Items.Add("Buy"); SubjectCombo.Items.Add("Update"); SubjectCombo.Items.Add("Study"); SubjectCombo.Items.Add("Call"); SubjectCombo.Items.Add("Plan"); SubjectCombo.Items.Add("Request"); SubjectCombo.Items.Add("Contact"); ReminderHourCombo.Items.Add("No Alarm"); ReminderMinutesCombo.Items.Add("No Alarm"); ReminderHourCombo.Items.Add("00"); for (int i = 1; i <= 23; i++) { if (i <= 9) { ReminderHourCombo.Items.Add("0" + i.ToString()); } else { ReminderHourCombo.Items.Add(i.ToString()); } } //////////////////////////////////////////// for (int i = 0; i < 60; i++) { if (i <= 9) { ReminderMinutesCombo.Items.Add("0" + i.ToString()); } else { ReminderMinutesCombo.Items.Add(i.ToString()); } } place_list = DatabaseOperations.GetAllPlaces(); PlaceCombo.Items.Clear(); foreach (Place p in place_list) { PlaceCombo.Items.Add(p.PlaceNameProp.ToString()); } }
private async void processData(bool isEdit) { string name = nametextBox.Text; string phone = phoneMaskedTextBox.Text; string address = addresstextBox.Text; string email = emailTextBox.Text; string company = companytextBox.Text; string other = othertextBox.Text; if (isEdit) { supplierModel.name = name; supplierModel.phone = phone; supplierModel.address = address; supplierModel.company = company; supplierModel.email = email; supplierModel.other = other; if (!MessagePrompt.displayPrompt("Edit", "edit this supplier")) { return; } MessageBox.Show(await DatabaseOperations.editSupplier(supplierModel) ? "Data updated successfully" : "Data updating failed"); } else { DatabaseOperations.addSuppliers(new SupplierDataModel { name = name, phone = phone, address = address, company = company, email = email, other = other }); if (!MessagePrompt.displayPrompt("Create New", "create a new supplier")) { return; } MessageBox.Show("Supplier saved successfully"); nametextBox.Clear(); phoneMaskedTextBox.Clear(); addresstextBox.Clear(); emailTextBox.Clear(); companytextBox.Clear(); othertextBox.Clear(); } }
private void btnZoekGereedschapOpNaam_Click(object sender, RoutedEventArgs e) { string foutmeldingen = Valideer("naam"); if (!string.IsNullOrWhiteSpace(txtZoekOpNaam.Text)) { List <a_Gereedschap> lijstNamenGereedschap = DatabaseOperations.OphalenGereedschapOpNaam(txtZoekOpNaam.Text); DataGridGereedschap.ItemsSource = lijstNamenGereedschap; } else { MessageBox.Show(foutmeldingen, "Opgelet", MessageBoxButton.OK, MessageBoxImage.Error); } }
public KansVerwijderen() { InitializeComponent(); List <Monopoly_DAL.Kans> kanskaarten = DatabaseOperations.OphalenKanskaarten(); if (kanskaarten != null) { datagridKanskaarten.ItemsSource = kanskaarten; } else { MessageBox.Show("Er zijn geen kanskaarten gevonden"); } }
private void createNewDimensions(World world) { List <string> dimensions = new List <string> { "overworld", "the_nether", "the_end" }; for (int i = 0; i < dimensions.Count; i++) { Dimension dimension = new Dimension(); dimension.name = dimensions[i]; dimension.worldId = world.id; DatabaseOperations.AddDimension(dimension); } }
public void TestUpdateTelescope() { RadioTelescope telescope = new RadioTelescope(); // saved in the database telescope.online = 0; telescope.CurrentOrientation = new Orientation(0, 0); telescope.CalibrationOrientation = new Orientation(0, 0); telescope.Location = new Location(0, 0, 0, ""); telescope._TeleType = RadioTelescopeTypeEnum.NONE; DatabaseOperations.AddRadioTelescope(telescope); RadioTelescope retrievedTele = DatabaseOperations.FetchLastRadioTelescope(); // not saved in the database telescope.SpectraCyberController = new SpectraCyberController(new SpectraCyber()); telescope.PLCDriver = new TestPLCDriver(PLCConstants.LOCAL_HOST_IP, PLCConstants.LOCAL_HOST_IP, 8089, 8089, false); // saved in the database telescope.Id = retrievedTele.Id; telescope.online = 1; telescope.CurrentOrientation = new Orientation(25, 25); telescope.CalibrationOrientation = new Orientation(30, 30); telescope.Location = new Location(1, 2, 3, "test"); telescope._TeleType = RadioTelescopeTypeEnum.SLIP_RING; DatabaseOperations.UpdateTelescope(telescope); retrievedTele = DatabaseOperations.FetchLastRadioTelescope(); // online Assert.IsTrue(telescope.online == retrievedTele.online); // type Assert.IsTrue(telescope.teleType == retrievedTele.teleType); // location Assert.IsTrue(telescope.Location.Latitude == retrievedTele.Location.Latitude); Assert.IsTrue(telescope.Location.Longitude == retrievedTele.Location.Longitude); Assert.IsTrue(telescope.Location.Altitude == retrievedTele.Location.Altitude); Assert.IsTrue(telescope.Location.Name == retrievedTele.Location.Name); // current orientation (not yet implemented) Assert.IsTrue(telescope.CurrentOrientation.Azimuth == retrievedTele.CurrentOrientation.Azimuth); Assert.IsTrue(telescope.CurrentOrientation.Elevation == retrievedTele.CurrentOrientation.Elevation); // calibration orientation (not yet implemented) Assert.IsTrue(telescope.CalibrationOrientation.Azimuth == retrievedTele.CalibrationOrientation.Azimuth); Assert.IsTrue(telescope.CalibrationOrientation.Elevation == retrievedTele.CalibrationOrientation.Elevation); }
private void displayRecipe() { recipeData = DatabaseOperations.getRecipes().ToList(); if (recipeData != null && recipeData.Any()) { for (int i = 0; i < recipeData.Count(); i++) { Button button = new Button(); button.Click += new EventHandler(ItemClicked); this.RecipeFlowLayoutPanel.Controls.Add(new RecipeItemPanel(recipeData.ElementAt(i).name, i, FormatPrice.format(recipeData.ElementAt(i).price), button)); } } }
private bool NakijkenEmail(string mail, Student student) //nakijken of het e-mailadres hetzelfde is met de huidige student die wordt aangepast, //anders kan dit e-mailadres al in gebruik zijn door iemand anders en mag deze instantie niet worden aangepast om e-mailadres unique is. { if (!string.IsNullOrEmpty(txtEmailAdres.Text)) { Student vergelijkStudent = DatabaseOperations.OphalenStudentViaEmail(mail); if (vergelijkStudent.Id == student.Id) { return(true); } } return(false); }