/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BtnSupprimerReleve(object sender, RoutedEventArgs e) { BusinessReleve releveARetirer = gridReleve.SelectedItem as BusinessReleve; MessageBoxResult messageBoxResult = MessageBox.Show("Voulez-vous supprimer le revelé selectionné?", "Supprimer ?", MessageBoxButton.YesNoCancel, MessageBoxImage.Question); if (releveARetirer != null) { if (messageBoxResult == MessageBoxResult.Yes) { ServiceReleve.DeleteReleve(releveARetirer); } gridLigneReleve.ItemsSource = null; gridReleve.ItemsSource = ServiceReleve.GetReleveByCapteurId(releveARetirer.CapteurID); } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BtnSelectCapteur(object sender, RoutedEventArgs e) { BusinessCapteur businessCapteur = gridCapteur.SelectedItem as BusinessCapteur; try { if (businessCapteur != null) { gridReleve.ItemsSource = ServiceReleve.GetReleveByCapteurId(businessCapteur.IdCapteur); } else { MessageBox.Show("Veuillez selectionner un capteur"); } } catch (Exception error) { MessageBox.Show(error.Message); } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void SaveReleveToBDD(object sender, RoutedEventArgs e) { if (gridCapteur.SelectedItem == null) { MessageBox.Show("Veuillez choisir un capteur"); return; } BusinessReleve businessReleve = new BusinessReleve { CapteurID = ((BusinessCapteur)gridCapteur.SelectedItem).IdCapteur, }; ServiceReleve.AddReleve(businessReleve); List <BusinessLigneReleve> lignesReleve = new List <BusinessLigneReleve>(); foreach (var item in listBoxReleve.Items) { string[] list = Regex.Split(item.ToString(), @"\s+"); BusinessLigneReleve businessLigneReleve = new BusinessLigneReleve { DateLigneReleve = DateTime.Parse(list[1]), HeureLigneReleve = TimeSpan.Parse(list[2]), Temperature = double.Parse(list[3].Replace(".", ",")), Hygrometrie = double.Parse(list[4].Remove(list[4].Length - 1).Replace(".", ",")), ReleveID = businessReleve.IdReleve }; lignesReleve.Add(businessLigneReleve); } ServiceLigneReleve.AddLignesReleve(lignesReleve); MessageBox.Show("Fichier TXT associé au capteur"); listBoxReleve.Items.Clear(); gridReleve.ItemsSource = ServiceReleve.GetReleveByCapteurId(businessReleve.IdReleve); }