Exemplo n.º 1
0
        void Onb2Click(object sender, RoutedEventArgs e)
        {
            InsertDataWindow insertdata = new InsertDataWindow(false, cne.Text, EditWindow.current.filiere);

            insertdata.Show();
            img.Source = null;
            img        = null;
            GC.Collect();
        }
Exemplo n.º 2
0
        private void addStudent_Click(object sender, RoutedEventArgs e)
        {
            InsertDataWindow ins = new InsertDataWindow(true, "", filiere);

            ins.Show();
        }
        public InsertDataWindow(Boolean ajoute, string cneCard, int selecedFiliere)
        {
            InitializeComponent();
            this.selectedFiliere = selecedFiliere;
            this.cneCard         = cneCard;
            op = new OpenFileDialog();

            if (countWindow > 0)
            {
                currentInsertWindow.Close();
                currentInsertWindow = this;
            }
            countWindow++; // fentres active actuelement

            //connexion au server
            string SaadServer = "DESKTOP-SL2AUNJ";

            connString           = "Data Source =" + SaadServer + "; Initial Catalog = Gestion_Etudiant; Integrated Security = true;";
            con                  = new SqlConnection();
            con.ConnectionString = connString;
            con.Open();

            this.ajoute         = ajoute;
            currentInsertWindow = this;
            existingCNE         = new List <string>();

            SqlCommand    comm = new SqlCommand("Select cne From Etudiant", con);
            SqlDataReader read = comm.ExecuteReader();

            while (read.Read())
            {
                existingCNE.Add(read.GetString(0));
            }
            read.Close();

            //test si la fenetre est pour l'ajout ou bien pour la modification
            if (ajoute)
            {
                modifier.Visibility = Visibility.Collapsed;
                title.Text          = "Ajouter un Etudiant";
                comm = new SqlCommand("Select * From Etudiant where cne = '" + cneCard + "'", con);
                read = comm.ExecuteReader();
                while (read.Read())
                {
                    photoPath = read.GetString(5);
                }
                read.Close();
            }
            else
            {
                ajouter.Visibility = Visibility.Hidden;
                title.Text         = "Modifier cet Etudiant";
                //felling the informations of the clicked student to modify
                comm = new SqlCommand("Select * From Etudiant where cne = '" + cneCard + "'", con);
                read = comm.ExecuteReader();
                while (read.Read())
                {
                    cneField.Text    = read.GetString(0);
                    nomField.Text    = read.GetString(1);
                    prenomField.Text = read.GetString(2);
                    if (read[3].ToString() == "M")
                    {
                        sexeComboBox.SelectedIndex = 0;
                    }
                    else
                    {
                        sexeComboBox.SelectedIndex = 1;
                    }
                    dateField.SelectedDate = read.GetDateTime(4);
                    photoPath       = read.GetString(5);
                    photoExtension  = photoPath.Substring(photoPath.LastIndexOf('.'), photoPath.Length - photoPath.LastIndexOf('.'));
                    emailField.Text = read.GetString(6);

                    anneeComboBox.SelectedIndex = read.GetInt32(8) - 1;
                }
                read.Close();
            }
        }