private void Button_Click(object sender, RoutedEventArgs e)
 {
     if (sender == btnOk)
     {
         _result = MessageBoxResult.OK;
     }
     else if (sender == btnYes)
     {
         _result = MessageBoxResult.Yes;
     }
     else if (sender == btnNo)
     {
         _result = MessageBoxResult.No;
     }
     else if (sender == btnCancel)
     {
         _result = MessageBoxResult.Cancel;
     }
     else
     {
         _result = MessageBoxResult.None;
     }
     _messageBox.Close();
     _messageBox = null;
 }
Exemplo n.º 2
0
        private void CreateScreenShot(UIElement visual, string file)
        // Création de capture d'écran automatique
        {
            double width  = Convert.ToDouble(visual.GetValue(FrameworkElement.WidthProperty));
            double height = Convert.ToDouble(visual.GetValue(FrameworkElement.HeightProperty));

            if (double.IsNaN(width) || double.IsNaN(height))

            {
                throw new FormatException("Erreur !!");
            }

            RenderTargetBitmap render = new RenderTargetBitmap(
                Convert.ToInt32(width),
                Convert.ToInt32(visual.GetValue(FrameworkElement.HeightProperty)), 96, 96, PixelFormats.Pbgra32);

            // Indicate which control to render in the image
            render.Render(visual);
            try
            {
                using (FileStream stream = new FileStream(file, FileMode.Create))

                {
                    PngBitmapEncoder encoder = new PngBitmapEncoder();
                    encoder.Frames.Add(BitmapFrame.Create(render));
                    encoder.Save(stream);
                    //  WpfMessageBox.Show("Réussi", "Capture prise avec succés", MessageBoxButton.OK, WpfMessageBox.MessageBoxImage.Information);
                }
            }
            catch (Exception)
            {
                WpfMessageBox.Show("Erreur", "Echec de la sauvegarde !", MessageBoxButton.OK, WpfMessageBox.MessageBoxImage.Error);
                // WpfMessageBox.Show("Erreur", "Echec de la sauvegarde !", MessageBoxButton.OK, WpfMessageBox.MessageBoxImage.Error);
            }
        }
        /* private void worker_ProgressChanged(object sender, ProgressChangedEventArgs e)
         * {
         *   progressBar.Value = e.ProgressPercentage;
         *   ProgressTextBlock.Text = (string)e.UserState;
         * }*/

        /*  private void worker_DoWork(object sender, DoWorkEventArgs e)
         * {
         *
         *    var worker = sender as BackgroundWorker;
         *    worker.ReportProgress(0, String.Format("Processing Iteration 1."));
         *    //for (int i = 0; i < 10; i++)
         *  //  {
         *       Thread.Sleep(1000);
         *       worker.ReportProgress((l)*10 , String.Format("Processing Iteration {0}.", l + 1));
         *   // }
         *
         *     worker.ReportProgress(100, "Done Processing.");
         * }*/

        /*  private void worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
         * {
         *    MessageBox.Show("All Done!");
         *   // progressBar.Value = 0;
         *    ProgressTextBlock.Text = "";
         * }*/

        //Regénerer la BDD si elle n'existe pas
        private void GenerateDatabase()
        {
            demarre.Visibility = Visibility.Hidden;
            WpfMessageBox.Show("Pour générer la BDD cliquez sur Start progress", " ", MessageBoxButton.OK, WpfMessageBox.MessageBoxImage.Warning);
            btnProgress.Visibility       = Visibility.Visible;
            progressBar.Visibility       = Visibility.Visible;
            ProgressTextBlock.Visibility = Visibility.Visible;
        }
Exemplo n.º 4
0
 //Regénerer la BDD si elle n'existe pas
 private void GenerateDatabase()
 {
     demarre.Visibility = Visibility.Hidden;
     WpfMessageBox.Show(" Information ", "La base de données n'existe pas. Pour la générer  cliquez sur 'Création BDD'", MessageBoxButton.OK, WpfMessageBox.MessageBoxImage.Information);
     btnProgress.Visibility       = Visibility.Visible;
     progressBar.Visibility       = Visibility.Visible;
     ProgressTextBlock.Visibility = Visibility.Visible;
 }
 public static MessageBoxResult Show(string caption, string text, MessageBoxButton button, MessageBoxImage image)
 {
     _messageBox = new WpfMessageBox
     {
         txtMsg = { Text = text }, MessageTitle = { Text = caption }
     };
     SetVisibilityOfButtons(button);
     SetImageOfMessageBox(image);
     _messageBox.ShowDialog();
     return(_result);
 }
Exemplo n.º 6
0
        private void meteo(object sender, RoutedEventArgs e)
        {
            StreamReader sr  = new StreamReader(@"son.txt");
            string       str = sr.ReadLine();

            sr.Close();
            if (str == "Activé")
            {
                MediaPlayer player = new MediaPlayer();
                player.Open(new Uri(@"..\..\click.mp3", UriKind.RelativeOrAbsolute));
                player.Play();
            }
            if (InfoJour.test_cnx() == 1)
            {
                meteo_jour nvv = new meteo_jour(wilaya, output_out);
                nvv.Show();
                this.Close();
            }
            else
            {
                WpfMessageBox.Show("Vous ne disposez pas de connexion internet");
            }
        }
Exemplo n.º 7
0
 private void confirmer_click(object sender, RoutedEventArgs e)//pour confirmer le nouveau mot de passe
 {
     if ((passeaconfirmed.Password == "") || (passeactuel.Password == "") || (passenouv.Password == ""))
     {
         textbk.Visibility = Visibility.Visible;
         textbk.Text       = "   Vous devez remplir tous les champs";//si un champ est vide un message d'alerte sera afficher
     }
     else
     {
         if (icon1.Visibility == Visibility.Visible)
         {
             pass1.Text = passeactuel.Password;
         }
         else
         {
             passeactuel.Password = pass1.Text;
         }
         if (icon3.Visibility == Visibility.Visible)
         {
             pass2.Text = passenouv.Password;
         }
         else
         {
             passenouv.Password = pass2.Text;
         }
         if (icon5.Visibility == Visibility.Visible)
         {
             pass3.Text = passeaconfirmed.Password;
         }
         else
         {
             passeaconfirmed.Password = pass3.Text;
         }
         StreamReader rd    = new StreamReader(@"passwd.txt");//lire le mot de passe à partir d'un fichier passwd.txt
         string       essay = rd.ReadLine();
         if (passeactuel.Password != essay)
         {
             textbk.Visibility = Visibility.Visible;
             textbk.Text       = "    Mot de Passe incorrect";
             rd.Close();
         }
         else
         {
             rd.Close();
             if (passenouv.Password != passeaconfirmed.Password)
             {
                 textbk.Visibility = Visibility.Visible;
                 textbk.Text       = "   Mot de Passe n'est pas confirmé";
                 passeaconfirmed.Clear();
                 passenouv.Clear();
                 pass2.Text = "";
                 pass3.Text = "";
             }
             else
             {
                 if (passenouv.Password.Length <= 5)
                 {
                     textbk.Visibility = Visibility.Visible;
                     textbk.Text       = "Mot de Passe Faible,Il faut qu'il contient au mois 6 caractères";
                     passeaconfirmed.Clear();
                     passenouv.Clear();
                     pass2.Text = "";
                     pass3.Text = "";
                 }
                 else
                 {
                     textbk.Visibility = Visibility.Hidden;
                     StreamWriter sr = new StreamWriter(@"passwd.txt");
                     sr.Close();
                     StreamWriter sr2 = new StreamWriter(@"passwd.txt");
                     sr2.WriteLine(passenouv.Password);
                     sr2.Close();
                     passeaconfirmed.Clear();
                     passeactuel.Clear();
                     passenouv.Clear();
                     pass1.Text = "";
                     pass2.Text = "";
                     pass3.Text = "";
                     WpfMessageBox.Show("Réussi", "Mot de passe modifié avec succées", MessageBoxButton.OK, WpfMessageBox.MessageBoxImage.Information);
                 }
             }
         }
     }
 }
Exemplo n.º 8
0
        private void Envoyer_Click(object sender, RoutedEventArgs e)
        {
            StreamReader sr  = new StreamReader(@"son.txt");
            string       str = sr.ReadLine();

            sr.Close();
            if (str == "Activé")
            {
                MediaPlayer player = new MediaPlayer();
                player.Open(new Uri(@"..\..\click.mp3", UriKind.RelativeOrAbsolute));
                player.Play();
            }
            string name  = NameTextBox.Text;
            string email = EmailTextBox.Text;
            string mes   = MesTextBox.Text;

            if (email.Length == 0)
            {
                EmailBorder.BorderBrush = Brushes.Red;
            }
            else
            {
                if (!invalidEmail(email))
                {
                    EmailBorder.BorderBrush = Brushes.Red;
                }
                else
                {
                    if (mes.Length == 0)
                    {
                        MesBorder.BorderBrush = Brushes.Red;
                        Tooltip1_Opened(this.tooltip1, null);
                    }
                    else // Envoie du mail
                    {
                        if (InfoJour.test_cnx() == 1)
                        {
                            string Emailexped = "*****@*****.**";
                            string Emaildest  = "*****@*****.**";
                            string Sujet      = "Commentaire";
                            string Mess       = "Emailsender :" + email + Environment.NewLine +
                                                "Commentaire : " + mes;

                            MailMessage mail = new MailMessage(Emailexped, Emaildest, Sujet, Mess);

                            SmtpClient stpc = new SmtpClient("smtp.gmail.com", 587);

                            stpc.Credentials = new System.Net.NetworkCredential("*****@*****.**", "kyuxpdmsiukmcdax");
                            stpc.EnableSsl   = true;
                            try
                            {
                                stpc.Send(mail);
                                WpfMessageBox.Show("Réussi", "Commentaire envoyé avec succés !", MessageBoxButton.OK, WpfMessageBox.MessageBoxImage.Information);
                            }
                            catch (Exception)
                            {
                                WpfMessageBox.Show("Erreur", "Echec de l'envoi !", MessageBoxButton.OK, WpfMessageBox.MessageBoxImage.Error);
                            }
                        }
                        else
                        {
                            WpfMessageBox.Show("Erreur", "Vous n'êtes pas connectés ! ", MessageBoxButton.OK, WpfMessageBox.MessageBoxImage.Error);
                        }
                    }
                }
            }
        }
Exemplo n.º 9
0
        private void ComboBox1_DropDownClosed(object sender, EventArgs e)
        {
            StreamReader sr   = new StreamReader(@"son.txt");
            string       str1 = sr.ReadLine();

            sr.Close();
            if (str1 == "Activé")
            {
                MediaPlayer player = new MediaPlayer();
                player.Open(new Uri(@"..\..\click.mp3", UriKind.RelativeOrAbsolute));
                player.Play();
            }

            ComboBox1.BorderBrush = Brushes.White;

            string str    = ComboBox1.Text;
            string wilaya = "";

            switch (str)
            {
            case "Adrar":
                wilaya = "adrar";
                break;

            case "Ain Defla":
                wilaya = "ain-defla";
                break;

            case "Ain Témouchent":
                wilaya = "ain-temouchent";
                break;

            case "Alger":
                wilaya = "alger";
                break;

            case "Annaba":
                wilaya = "annaba";
                break;

            case "Batna":
                wilaya = "batna";
                break;

            case "Béchar":
                wilaya = "bechar";
                break;

            case "Béjaia":
                wilaya = "bejaia";
                break;

            case "Biskra":
                wilaya = "biskra";
                break;

            case "Blida":
                wilaya = "blida";
                break;

            case "Bordj Bou Arréridj":
                wilaya = "bordj-bou-arreridj";
                break;

            case "Bouira":
                wilaya = "bouira";
                break;

            case "Chlef":
                wilaya = "chlef";
                break;

            case "Boumerdès":
                wilaya = "boumerdes";
                break;

            case "Constantine":
                wilaya = "constantine";
                break;

            case "Djelfa":
                wilaya = "djelfa";
                break;

            case "El Bayadh":
                wilaya = "el-bayadh";
                break;

            case "El Taref":
                wilaya = "el-taref";
                break;

            case "El-Oued":
                wilaya = "el-oued";
                break;

            case "Guelma":
                wilaya = "guelma";
                break;

            case "Illizi":
                wilaya = "illizi";
                break;

            case "Jijel":
                wilaya = "jijel";
                break;

            case "Laghouat":
                wilaya = "laghouat";
                break;

            case "Khenchela":
                wilaya = "khenchela";
                break;

            case "M’Sila":
                wilaya = "msila";
                break;

            case "Mascara":
                wilaya = "mascara";
                break;

            case "Médéa":
                wilaya = "medea";
                break;

            case "Mila":
                wilaya = "mila";
                break;

            case "Mostaganem":
                wilaya = "mostaganem";
                break;

            case "Naâma":
                wilaya = "naama";
                break;

            case "Oran":
                wilaya = "oran";
                break;

            case "Ouargla":
                wilaya = "ouargla";
                break;

            case "Oum El Bouaghi":
                wilaya = "oum-el-bouaghi";
                break;

            case "Relizane":
                wilaya = "relizane";
                break;

            case "Saida":
                wilaya = "saida";
                break;

            case "Sidi BelAbbès":
                wilaya = "sidi-bel-abbes";
                break;

            case "Skikda":
                wilaya = "skikda";
                break;

            case "Souk Ahras":
                wilaya = "souk-ahras";
                break;

            case "Tamanrasset":
                wilaya = "tamanrasset";
                break;

            case "Tiaret":
                wilaya = "tiaret";
                break;

            case "Tindouf":
                wilaya = "tindouf";
                break;

            case "Tébessa":
                wilaya = "tebessa";
                break;

            case "Tipaza":
                wilaya = "tipaza";
                break;

            case "Tissemsilt":
                wilaya = "tissemssilt";
                break;

            case "Tizi-Ouzou":
                wilaya = "tizi-ouzou";
                break;

            case "Tlemcen":
                wilaya = "tlemcen";
                break;

            case "Ghardaia":
                wilaya = "ghardaia";
                break;
            }


            //SqlConnection connection;
            SqlCommand command;
            //string connectionString = @"Data Source = INFO\SQLEXPRESS ; Initial Catalog =weather1 ; User ID =sa ; password =kerem1987";
            //string connectionString = @"Data Source = PC\SQLEXPRESS ; Initial Catalog =weather ; User ID =sa ; password =esi2018";
            ///string connectionString = @"Data Source = ABCOMPUTER-PC\SQLEXPRESS ; Initial Catalog = weather ; User ID =sa ; password = ayaz oyku";

            SqlConnection connection = new SqlConnection(@"Data Source = .\SQLEXPRESS;Initial Catalog=weather;Integrated Security=True");


            DataSet data = new DataSet(); // contiendra les données

            //connection = new SqlConnection(connectionString);
            command = new SqlCommand("Select DATE,MAX_TEMPERATURE_C,MIN_TEMPERATURE_C,WINDSPEED_MAX_KMH,TEMPERATURE_MORNING_C,TEMPERATURE_NOON_C,TEMPERATURE_EVENING_C,PRECIP_TOTAL_DAY_MM,HUMIDITY_MAX_PERCENT,VISIBILITY_AVG_KM,HEATINDEX_MAX_C,DEWPOINT_MAX_C,WINDTEMP_MAX_C,PRESSURE_MAX_MB,CLOUDCOVER_AVG_PERCENT from[dbo].[export-" + wilaya + "] ", connection);
            SqlDataAdapter adapter = new SqlDataAdapter();

            adapter.SelectCommand = command;
            DataTableCollection tables;

            try
            {
                connection.Open();
                adapter.Fill(data, wilaya);
                tables = data.Tables;
                DataView view = new DataView(tables[0]);
                dataGrid1.ItemsSource = view;
            }
            catch (Exception)
            {
                //MessageBox.Show("Echec de la connexion !", "Erreur");
                WpfMessageBox.Show("Erreur", "Echec de la connexion à la base de données !", MessageBoxButton.OK, WpfMessageBox.MessageBoxImage.Error);
            }
            command.Dispose();
            connection.Close();
            //MessageBox.Show(str);

            dataGrid1.Columns[0].Header  = "Date";
            dataGrid1.Columns[1].Header  = "TempMax";
            dataGrid1.Columns[2].Header  = "TempMin";
            dataGrid1.Columns[3].Header  = "VitesseVent";
            dataGrid1.Columns[4].Header  = "TempMatin";
            dataGrid1.Columns[5].Header  = "TempAprésMidi";
            dataGrid1.Columns[6].Header  = "TempSoir";
            dataGrid1.Columns[7].Header  = "Précipitation";
            dataGrid1.Columns[8].Header  = "Humdité";
            dataGrid1.Columns[9].Header  = "Visibilité";
            dataGrid1.Columns[10].Header = "IndiceDeChaleur";
            dataGrid1.Columns[11].Header = "PointDeRosée";
            dataGrid1.Columns[12].Header = "TempVent";
            dataGrid1.Columns[13].Header = "Pression";
            dataGrid1.Columns[14].Header = "CouverturNuageuse";
            ComboBox1.BorderBrush        = Brushes.White;
        }
Exemplo n.º 10
0
        /* Pour ajouter une données veuillez la saisir à la fin de la base de données
         * par ailleurs vous ne pouvez pas supprimer des ou modifier les données deja insérées */

        private void Enregistrer_Click(object sender, RoutedEventArgs e)
        {
            StreamReader sr  = new StreamReader(@"son.txt");
            string       str = sr.ReadLine();

            sr.Close();
            if (str == "Activé")
            {
                MediaPlayer player = new MediaPlayer();
                player.Open(new Uri(@"..\..\click.mp3", UriKind.RelativeOrAbsolute));
                player.Play();
            }
            connexion connex = new connexion();

            connex.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen;

            connex.ShowDialog();

            if (connex.confirme == true)
            {
                str = ComboBox1.Text;
                string wilaya = "";
                switch (str)
                {
                case "Adrar":
                    wilaya = "adrar";
                    break;

                case "Ain Defla":
                    wilaya = "ain-defla";
                    break;

                case "Ain Témouchent":
                    wilaya = "ain-temouchent";
                    break;

                case "Alger":
                    wilaya = "alger";
                    break;

                case "Annaba":
                    wilaya = "annaba";
                    break;

                case "Batna":
                    wilaya = "batna";
                    break;

                case "Béchar":
                    wilaya = "bechar";
                    break;

                case "Béjaia":
                    wilaya = "bejaia";
                    break;

                case "Biskra":
                    wilaya = "biskra";
                    break;

                case "Blida":
                    wilaya = "blida";
                    break;

                case "Bordj Bou Arréridj":
                    wilaya = "bordj-bou-arreridj";
                    break;

                case "Bouira":
                    wilaya = "bouira";
                    break;

                case "Boumerdès":
                    wilaya = "boumerdes";
                    break;

                case "Constantine":
                    wilaya = "constantine";
                    break;

                case "Chlef":
                    wilaya = "chlef";
                    break;

                case "Djelfa":
                    wilaya = "djelfa";
                    break;

                case "El Bayadh":
                    wilaya = "el-bayadh";
                    break;

                case "El Taref":
                    wilaya = "el-taref";
                    break;

                case "El-Oued":
                    wilaya = "el-oued";
                    break;

                case "Guelma":
                    wilaya = "guelma";
                    break;

                case "Illizi":
                    wilaya = "illizi";
                    break;

                case "Jijel":
                    wilaya = "jijel";
                    break;

                case "Khenchela":
                    wilaya = "khenchela";
                    break;

                case "Laghouat":
                    wilaya = "laghouat";
                    break;

                case "M’Sila":
                    wilaya = "msila";
                    break;

                case "Mascara":
                    wilaya = "mascara";
                    break;

                case "Médéa":
                    wilaya = "medea";
                    break;

                case "Mila":
                    wilaya = "mila";
                    break;

                case "Mostaganem":
                    wilaya = "mostaganem";
                    break;

                case "Naâma":
                    wilaya = "naama";
                    break;

                case "Oran":
                    wilaya = "oran";
                    break;

                case "Ouargla":
                    wilaya = "ouargla";
                    break;

                case "Oum El Bouaghi":
                    wilaya = "oum-el-bouaghi";
                    break;

                case "Relizane":
                    wilaya = "relizane";
                    break;

                case "Saida":
                    wilaya = "saida";
                    break;

                case "Sidi BelAbbès":
                    wilaya = "sidi-bel-abbes";
                    break;

                case "Skikda":
                    wilaya = "skikda";
                    break;

                case "Souk Ahras":
                    wilaya = "souk-ahras";
                    break;

                case "Tamanrasset":
                    wilaya = "tamanrasset";
                    break;

                case "Tiaret":
                    wilaya = "tiaret";
                    break;

                case "Tindouf":
                    wilaya = "tindouf";
                    break;

                case "Tébessa":
                    wilaya = "tebessa";
                    break;

                case "Tipaza":
                    wilaya = "tipaza";
                    break;

                case "Tissemsilt":
                    wilaya = "tissemssilt";
                    break;

                case "Tizi-Ouzou":
                    wilaya = "tizi-ouzou";
                    break;

                case "Tlemcen":
                    wilaya = "tlemcen";
                    break;
                }
                SqlConnection connection;
                SqlCommand    command;

                connection = new SqlConnection(@"Data Source = .\SQLEXPRESS;Initial Catalog=weather;Integrated Security=True");

                DataGridRow row; string ch1;

                try
                {
                    row = DataGridViewHelper.GetRow(dataGrid1, dataGrid1.SelectedIndex);

                    ch1 = DataGridViewHelper.extraire(DataGridViewHelper.GetCell(dataGrid1, row, 0).ToString());
                }
                catch (Exception)
                {
                    WpfMessageBox.Show("Erreur", "Vous n'avez saisi aucune donnée !", MessageBoxButton.OK, WpfMessageBox.MessageBoxImage.Error);

                    return;
                }
                if (DataGridViewHelper.IsDate(ch1))
                {
                    command = new SqlCommand("Select * from[dbo].[export-" + wilaya + "] where DATE =@p1 ", connection);
                    command.Parameters.AddWithValue("@p1", ch1);
                    DataSet data = new DataSet();
                    try
                    {
                        connection.Open();
                        SqlDataAdapter adapter = new SqlDataAdapter(command);
                        adapter.Fill(data, "export-" + wilaya);
                    }
                    catch (Exception)
                    {
                        WpfMessageBox.Show("Erreur", "Echec de la connexion à la base de données  !", MessageBoxButton.OK, WpfMessageBox.MessageBoxImage.Error);
                    }
                    command.Dispose();
                    connection.Close();
                    if (data.Tables[0].Rows.Count == 0)
                    {
                        try
                        {
                            command = new SqlCommand("INSERT INTO [export-" + wilaya + "] VALUES (@p1,@p2,@p3,@p4,@p5,@p6,@p7,@p8,@p9,@p10,@p11,@p12,@p13,@p14,@p15)", connection);
                            command.Parameters.AddWithValue("@p1", ch1);
                            command.Parameters.AddWithValue("@p2", DataGridViewHelper.extraire(DataGridViewHelper.GetCell(dataGrid1, row, 1).ToString()));
                            command.Parameters.AddWithValue("@p3", DataGridViewHelper.extraire(DataGridViewHelper.GetCell(dataGrid1, row, 2).ToString()));
                            command.Parameters.AddWithValue("@p4", DataGridViewHelper.extraire(DataGridViewHelper.GetCell(dataGrid1, row, 3).ToString()));
                            command.Parameters.AddWithValue("@p5", DataGridViewHelper.extraire(DataGridViewHelper.GetCell(dataGrid1, row, 4).ToString()));
                            command.Parameters.AddWithValue("@p6", DataGridViewHelper.extraire(DataGridViewHelper.GetCell(dataGrid1, row, 5).ToString()));
                            command.Parameters.AddWithValue("@p7", DataGridViewHelper.extraire(DataGridViewHelper.GetCell(dataGrid1, row, 6).ToString()));
                            command.Parameters.AddWithValue("@p8", DataGridViewHelper.extraire(DataGridViewHelper.GetCell(dataGrid1, row, 7).ToString()));
                            command.Parameters.AddWithValue("@p9", DataGridViewHelper.extraire(DataGridViewHelper.GetCell(dataGrid1, row, 8).ToString()));
                            command.Parameters.AddWithValue("@p10", DataGridViewHelper.extraire(DataGridViewHelper.GetCell(dataGrid1, row, 9).ToString()));
                            command.Parameters.AddWithValue("@p11", DataGridViewHelper.extraire(DataGridViewHelper.GetCell(dataGrid1, row, 10).ToString()));
                            command.Parameters.AddWithValue("@p12", DataGridViewHelper.extraire(DataGridViewHelper.GetCell(dataGrid1, row, 11).ToString()));
                            command.Parameters.AddWithValue("@p13", DataGridViewHelper.extraire(DataGridViewHelper.GetCell(dataGrid1, row, 12).ToString()));
                            command.Parameters.AddWithValue("@p14", DataGridViewHelper.extraire(DataGridViewHelper.GetCell(dataGrid1, row, 13).ToString()));
                            command.Parameters.AddWithValue("@p15", DataGridViewHelper.extraire(DataGridViewHelper.GetCell(dataGrid1, row, 14).ToString()));
                            connection.Open();
                            command.Dispose();
                            connection.Close();
                            WpfMessageBox.Show("", "Données ajoutées avec succées", MessageBoxButton.OK, WpfMessageBox.MessageBoxImage.Error);
                        }
                        catch (Exception)
                        {
                            WpfMessageBox.Show("Erreur", "Echec de la connexion à la base de données !", MessageBoxButton.OK, WpfMessageBox.MessageBoxImage.Error);
                        }
                    }
                    else
                    {
                        WpfMessageBox.Show("Date existante", "Veuillez inserer une autre date !", MessageBoxButton.OK, WpfMessageBox.MessageBoxImage.Error);
                    }
                }
                else
                {
                    WpfMessageBox.Show("Date erronée", "Veuillez inserer une autre date !", MessageBoxButton.OK, WpfMessageBox.MessageBoxImage.Error);
                }
            }
        }
Exemplo n.º 11
0
        private void Window_KeyDown(object sender, KeyEventArgs e)
        {
            switch (e.Key)
            {
            case Key.A:
            {
                accueil ev = new accueil(wilaya, output_out);
                ev.Show();
                this.Close();
            }
            break;

            case Key.M:
            {
                if (InfoJour.test_cnx() == 1)           // si connexion ==> météo du jour
                {
                    meteo_jour nvv = new meteo_jour(wilaya, output_out);
                    nvv.Show();
                    this.Close();
                }
                else
                {
                    WpfMessageBox.Show("Vous ne disposez pas de connexion internet!");
                }
            }
            break;

            case Key.P:
            {
                prevision ev = new prevision(wilaya, output_out);
                ev.Show();
                this.Close();
            }
            break;

            case Key.E:
            {
                evolution ev = new evolution(wilaya, output_out);
                ev.Show();
                this.Close();
            }
            break;

            case Key.T:
            {
                Contact ev = new Contact(wilaya, output_out);
                ev.Show();
                this.Close();
            }
            break;

            case Key.R:
            {
                parametre ev = new parametre(wilaya, output_out);
                ev.Show();
                this.Close();
            }
            break;

            case Key.O:
            {
                apropos ev = new apropos(wilaya, output_out);
                ev.Show();
                this.Close();
            }
            break;

            case Key.D:
            {
                credit ev = new credit(wilaya, output_out);
                ev.Show();
                this.Close();
            }
            break;

            case Key.Z:
            {
                mise_a_jour ev = new mise_a_jour(wilaya, output_out);
                ev.Show();
                this.Close();
            }
            break;

            case Key.S:
            {
                StreamReader sr  = new StreamReader(@"son.txt");
                string       str = sr.ReadLine();
                sr.Close();
                if (str == "Activé")
                {
                    MediaPlayer player = new MediaPlayer();
                    player.Open(new Uri(@"..\..\screen.mp3", UriKind.RelativeOrAbsolute));
                    player.Play();
                }
                //déclaration et instanciation de la fenêtre parcourir
                SaveFileDialog parcourir = new SaveFileDialog();
                parcourir.DefaultExt = "png";
                //je spécifie que seul les images .png sont selectionnables
                parcourir.Filter = " Fichier PNG (*.PNG)|*.png";
                //ouverture de la fenêtre parcourir
                parcourir.ShowDialog();
                CreateScreenShot(this, parcourir.FileName);
            }
            break;
            }
        }