示例#1
0
        private void mise_ajr(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 mise = new connexion(wilaya, output_out);

            mise.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen;

            mise.ShowDialog();
            this.Close();
        }
示例#2
0
        /***********************************************************************************************************
        *        Les raccourcis clavier
        * *********************************************************************************************************/
        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:
            {
                meteo_jour ev = new meteo_jour(wilaya, output_out);
                ev.Show();
                this.Close();
            }
            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:
            {
                connexion ev = new connexion(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;
            }
        }
示例#3
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);
                }
            }
        }