示例#1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            Etudiant etudiant = new Etudiant(txtFirst_name.Text, txtLast_name.Text,
                                             txtDateNais.Text, txtLieu.Text, txtContact.Text, txtEmail.Text, null, null);
            EtudiantBLO etudiantBLO = new EtudiantBLO(ConfigurationManager.AppSettings["DbFolder"]);

            etudiantBLO.CreateEtudiant(etudiant);

            MessageBox.Show
            (
                "Save done",
                "Confimation",
                MessageBoxButtons.OK,
                MessageBoxIcon.Information
            );
            if (Callback != null)
            {
                Callback();
            }
            txtFirst_name.Clear();
            txtLast_name.Clear();
            txtDateNais.Clear();
            txtLieu.Clear();
            txtContact.Clear();
            txtEmail.Clear();
        }
示例#2
0
        private void btnsave_Click(object sender, EventArgs e)
        {
            Etudiant etudiant = new Etudiant(
                txtmatricule.Text,
                txtnom.Text, txtprenom.Text,
                int.Parse(txtcontact.Text),
                txtecole.Text,
                txtdatedenaissance.Text);
            EtudiantBLO etudiantBLO = new EtudiantBLO(ConfigurationManager.AppSettings["DbFolder"]);

            etudiantBLO.CreateEtudiant(etudiant);
            MessageBox.Show(
                "save done!",
                "confirmation",
                MessageBoxButtons.OK,
                MessageBoxIcon.Information);

            txtmatricule.Clear();
            txtnom.Clear();
            txtprenom.Clear();
            txtcontact.Clear();
            txtecole.Clear();
            txtdatedenaissance.Clear();
            txtmatricule.Focus();
        }
示例#3
0
        static void Main(string[] args)
        {
            string choice = "y";

            do
            {
                Console.Clear();
                Console.WriteLine("----------------------------Create a New student----------------------------");

                Console.Write("Enter Lastname\t:");
                string lastname = Console.ReadLine();
                Console.Write("Enter Firstname\t:");
                string firstname = Console.ReadLine();
                Console.Write("Born on\t:");
                string bornOn = Console.ReadLine();
                Console.Write("At\t:");
                string at = Console.ReadLine();
                Console.Write("Enter Identified\t:");
                string identified = Console.ReadLine();
                Console.Write("Enter Contact\t:");
                long contact = long.Parse(Console.ReadLine());
                Console.Write("Enter Email\t:");
                string email = Console.ReadLine();

                Etudiant    etudiant    = new Etudiant(lastname, firstname, bornOn, at, identified, contact, email, null);
                EtudiantBLO etudiantBLO = new EtudiantBLO(ConfigurationManager.AppSettings["DbFolder"]);
                etudiantBLO.CreateEtudiant(etudiant);

                IEnumerable <Etudiant> etudiants = etudiantBLO.GetAllEtudiants();
                foreach (Etudiant p in etudiants)
                {
                    Console.WriteLine($"{p.LastName}\t{p.FirstName}\t{p.BornOn}\t{p.At}\t{p.Identified}\t{p.Contact}\t{p.Email}");
                }

                Console.Write("Create another student?[y/n]:");
                choice = Console.ReadLine();
            }   while (choice.ToLower() != "n");
            Console.WriteLine("Program end !");

            Console.ReadKey();
        }
示例#4
0
        static void Main(string[] args)
        {
            string choice = "y";

            do
            {
                Console.Clear();
                Console.WriteLine("-------------------------------------Create Etudiant-------------------------------------");
                Console.Write("Enter Matricule:\t");
                string Matricule = Console.ReadLine();
                Console.Write("Enter First_Name:\t");
                string First_Name = Console.ReadLine();
                Console.Write("Enter Last_Name:\t");
                string Last_Name = Console.ReadLine();
                Console.Write("Enter DateNais:\t");
                string DateNais = Console.ReadLine();
                Console.Write("Enter LieuNais:\t");
                string LieuNais = Console.ReadLine();
                Console.Write("Enter Contact:\t");
                string Contact = Console.ReadLine();
                Console.Write("Enter Email:\t");
                string Email = Console.ReadLine();

                Etudiant    etudiant    = new Etudiant(First_Name, Last_Name, DateNais, LieuNais, Contact, Email, null, null);
                EtudiantBLO etudiantBLO = new EtudiantBLO(ConfigurationManager.AppSettings["DbFolder"]);
                etudiantBLO.CreateEtudiant(etudiant);
                IEnumerable <Etudiant> etudiants = etudiantBLO.GetAllEtudiants();
                foreach (Etudiant E in etudiants)
                {
                    Console.WriteLine($"{E.First_Name}\t{E.Last_Name}");
                }
                Console.WriteLine("Create another Etudiant ? [y/n]");
                choice = Console.ReadLine();
            } while (choice.ToLower() != "n");
            Console.WriteLine("Program end !");

            Console.ReadKey();
        }
示例#5
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     try {
         checkForm();
         string filename = null;
         if (!string.IsNullOrEmpty(pictureBox1.ImageLocation))//hum
         {
             string ext = Path.GetExtension(pictureBox1.ImageLocation);
             filename = Guid.NewGuid().ToString() + ext;
             FileInfo fileSource = new FileInfo(pictureBox1.ImageLocation);
             string   filePath   = Path.Combine(ConfigurationManager.AppSettings["DbFolder"], "logo", filename);
             FileInfo fileDest   = new FileInfo(filePath);
             if (!fileDest.Directory.Exists)
             {
                 fileDest.Directory.Create();
             }
             fileSource.CopyTo(fileDest.FullName);
         }
         Etudiant newEtudiant = new Etudiant(
             textBoxNom.Text,
             textBoxPrenom.Text,
             dateTimePicker1.Text,
             textBoxLieuNaiss.Text,
             textBoxMatricule.Text.ToUpper(),
             long.Parse(textBoxContact.Text),
             textBoxEmail.Text,
             !string.IsNullOrEmpty(pictureBox1.ImageLocation) ? File.ReadAllBytes(pictureBox1.ImageLocation) : this.oldEtudiant?.Photo
             );
         EtudiantBLO eblo = new EtudiantBLO(ConfigurationManager.AppSettings["DbFolder"]);
         if (this.oldEtudiant == null)
         {
             eblo.CreateEtudiant(newEtudiant);
         }
         else
         {
             eblo.EditEtudiant(oldEtudiant, newEtudiant);
         }
         MessageBox.Show(
             "Save done !",
             "Confirm",
             MessageBoxButtons.OK,
             MessageBoxIcon.Information
             );
         if (callBack != null)
         {
             callBack();
         }
         if (oldEtudiant != null)
         {
             Close();
         }
         textBoxMatricule.Clear();
         textBoxNom.Clear();
         textBoxContact.Clear();
         textBoxEmail.Clear();
         textBoxLieuNaiss.Clear();
         textBoxMatricule.Focus();
     }
     catch (DuplicateNameException ex)
     {
         MessageBox.Show
         (
             ex.Message,
             "Duplicate error",
             MessageBoxButtons.OK,
             MessageBoxIcon.Warning
         );
     }
     catch (KeyNotFoundException ex)
     {
         MessageBox.Show
         (
             ex.Message,
             "Not found error",
             MessageBoxButtons.OK,
             MessageBoxIcon.Warning
         );
     }
     catch (Exception ex)
     {
         ex.WriteToFile();
         MessageBox.Show
         (
             "An error occurred! Please try again later.",
             "Erreur",
             MessageBoxButtons.OK,
             MessageBoxIcon.Error
         );
     }
 }
示例#6
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                checkForm();
                Etudiant etudiant = new Etudiant(txtNom.Text.ToUpper(), txtPrenom.Text,
                                                 DateTime.Parse(dateTim.Text), txtA.Text, txtMatricule.Text, txtemail.Text, txtcontact.Text, !string.IsNullOrEmpty(pictureBox1.ImageLocation) ? File.ReadAllBytes(pictureBox1.ImageLocation):this.oldetudiant?.Photo);
                EtudiantBLO etudiantBLO = new EtudiantBLO(ConfigurationManager.AppSettings["DbFolder"]);
                etudiantBLO.CreateEtudiant(etudiant);
                MessageBox.Show(
                    "Save done !",
                    "Confirm",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Information

                    );
                if (Callback != null)
                {
                    Callback();
                }
                if (oldetudiant != null)
                {
                    Close();
                }
                txtMatricule.Clear();
                txtNom.Clear();
                txtPrenom.Clear();
                txtcontact.Clear();
                txtemail.Clear();
                txtNom.Focus();
            }
            catch (TypingException ex)
            {
                MessageBox.Show
                (
                    ex.Message,
                    "Typing error",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Warning
                );
            }
            catch (DuplicateNameException ex)
            {
                MessageBox.Show
                (
                    ex.Message,
                    "Duplicate error",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Warning
                );
            }
            catch (Exception ex)
            {
                using (StreamWriter sw = new StreamWriter("APP.LOG", true))
                {
                    sw.WriteLine($"{ DateTime.Now}\n{ex}");
                }

                MessageBox.Show
                (
                    ex.Message,
                    "Erreur d'occurence",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error
                );
            }
        }
示例#7
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                checkForm();

                Etudiants newProduct = new Etudiants
                                       (
                    txtNom.Text,
                    txtPrenom.Text,
                    txtContact.Text,
                    txtSexe.Text,
                    txtEmail.Text,
                    txtLieuxNaissance.Text,
                    txtDatedeNaissance.Text,
                    txtIdentifiant.Text


                                       );

                EtudiantBLO productBLO = new EtudiantBLO(ConfigurationManager.AppSettings["DbFolder"]);

                if (this.oldEtudiant == null)
                {
                    productBLO.CreateEtudiant(newProduct);
                }
                else
                {
                    productBLO.EditEtudiants(oldEtudiant, newProduct);
                }

                MessageBox.Show
                (
                    "Save done !",
                    "Confirmation",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Information
                );

                if (callBack != null)
                {
                    callBack();
                }

                if (oldEtudiant != null)
                {
                    Close();
                }

                txtNom.Clear();
                txtPrenom.Clear();
                txtEmail.Clear();
                txtDatedeNaissance.Clear();
                txtNom.Focus();
                txtLieuxNaissance.Clear();
                txtIdentifiant.Clear();
                txtSexe.Clear();
            }
            catch (TypingException ex)
            {
                MessageBox.Show
                (
                    ex.Message,
                    "Typing error",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Warning
                );
            }
            catch (DuplicateNameException ex)
            {
                MessageBox.Show
                (
                    ex.Message,
                    "Duplicate error",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Warning
                );
            }
            catch (KeyNotFoundException ex)
            {
                MessageBox.Show
                (
                    ex.Message,
                    "Not found error",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Warning
                );
            }

            /* catch (Exception ex)
             * {
             *   ex.WriteToFile();
             *   MessageBox.Show
             *  (
             *      "An error occurred! Please try again later.",
             *      "Erreur",
             *      MessageBoxButtons.OK,
             *      MessageBoxIcon.Error
             *  );
             * }*/
        }
示例#8
0
        private void btnEnregistrer_Click(object sender, EventArgs e)
        {
            try
            {
                checkForm();

                Etudiant newEtudiant = new Etudiant
                                       (
                    txtMatricule.Text.ToUpper(),
                    txtNom.Text,
                    txtPrenom.Text,
                    txtLieu.Text,
                    !string.IsNullOrEmpty(pictureBox1.ImageLocation) ? File.ReadAllBytes(pictureBox1.ImageLocation) : this.oldEtudiant?.CarteEtudiant,
                    txtEmail.Text,
                    int.Parse(txtContact.Text),
                    dateTimePicker1.Value.Date
                                       );

                EtudiantBLO etudiantBLO = new EtudiantBLO(ConfigurationManager.AppSettings["DbFolder"]);

                if (this.oldEtudiant == null)
                {
                    etudiantBLO.CreateEtudiant(newEtudiant);
                }
                else
                {
                    etudiantBLO.EditEtudiant(oldEtudiant, newEtudiant);
                }

                MessageBox.Show
                (
                    "Save done !",
                    "Confirmation",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Information
                );

                if (callBack != null)
                {
                    callBack();
                }

                if (oldEtudiant != null)
                {
                    Close();
                }

                txtMatricule.Clear();
                txtNom.Clear();
                txtPrenom.Clear();
                txtEmail.Clear();
                txtContact.Clear();
                txtLieu.Clear();

                txtMatricule.Focus();
            }
            catch (TypingException ex)
            {
                MessageBox.Show
                (
                    ex.Message,
                    "Typing error",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Warning
                );
            }
            catch (DuplicateNameException ex)
            {
                MessageBox.Show
                (
                    ex.Message,
                    "Duplicate error",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Warning
                );
            }
            catch (KeyNotFoundException ex)
            {
                MessageBox.Show
                (
                    ex.Message,
                    "Not found error",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Warning
                );
            }
            catch (Exception ex)
            {
                ex.WriteToFile();
                MessageBox.Show
                (
                    "An error occurred! Please try again later.",
                    "Erreur",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error
                );
            }
        }
示例#9
0
        private void btnSave_Click_1(object sender, EventArgs e)
        {
            try
            {
                Etudiant newEtudiant = new Etudiant(
                    txtNom.Text,
                    txtPrenom.Text,
                    dtpNaissance.Text,
                    dtpAdmission.Text,
                    !string.IsNullOrEmpty(imgMatricule.ImageLocation) ? File.ReadAllBytes(imgMatricule.ImageLocation) : this.oldEtudiant?.Matricule,
                    int.Parse(txtTel.Text),
                    txtEmail.Text,
                    txtEtablissement.Text,
                    txtDepartement.Text,
                    !string.IsNullOrEmpty(imgPhoto.ImageLocation) ? File.ReadAllBytes(imgPhoto.ImageLocation) : this.oldEtudiant?.Photo,
                    txtSex.Text
                    );
                dataGridView1.DataSource = newEtudiant;

                EtudiantBLO etudiantBLO = new EtudiantBLO(ConfigurationManager.AppSettings["DbFolder"]);

                if (this.oldEtudiant == null)
                {
                    etudiantBLO.CreateEtudiant(newEtudiant);
                }
                else
                {
                    etudiantBLO.EditEtudiant(oldEtudiant, newEtudiant);
                }


                MessageBox.Show(
                    "Save Done !",
                    "Confirmation",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Information
                    );
                loadData();

                if (callback != null)
                {
                    callback();
                }

                if (oldEtudiant != null)
                {
                    Close();
                }

                txtNom.Clear();
                txtPrenom.Clear();
                dtpNaissance.Value = DateTime.Now;
                dtpAdmission.Value = DateTime.Now;
                txtTel.Clear();
                txtEmail.Clear();
                txtEtablissement.Clear();
                txtDepartement.Clear();
                imgMatricule.ImageLocation = null;
                imgPhoto.ImageLocation     = null;
                txtTel.Clear();
                txtEmail.Clear();
                txtNom.Focus();
            }
            catch (TypingException ex)
            {
                MessageBox.Show(
                    ex.Message,
                    "Typing error",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Warning
                    );
            }
            catch (DuplicateNameException ex)
            {
                MessageBox.Show(
                    ex.Message,
                    "Duplicate error",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Warning
                    );
            }
            catch (KeyNotFoundException ex)
            {
                MessageBox.Show(
                    ex.Message,
                    "key not found error",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Warning
                    );
            }
            catch (Exception ex)
            {
                ex.WriteToFile();
                MessageBox.Show(
                    "An error occured please try again",
                    "Error",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error
                    );
            }
        }
示例#10
0
        private void buttonSauvegarder_Click(object sender, EventArgs e)
        {
            try
            {
                checkForm();

                Etudiant newetudiant = new Etudiant
                                       (
                    textBoxfirstname.Text,
                    textBoxlastname.Text,
                    textBoxBorn.Text,
                    textBoxA.Text,
                    textBoxId.Text.ToUpper(),
                    double.Parse(textBoxContact.Text),
                    textBoxEmail.Text,
                    textBoxNomEcole.Text,
                    !string.IsNullOrEmpty(pictureBox1.ImageLocation) ? File.ReadAllBytes(pictureBox1.ImageLocation) : this.oldEtudiant?.Picture

                                       );

                EtudiantBLO etudiantBLO = new EtudiantBLO(ConfigurationManager.AppSettings["DbFolder"]);

                if (this.oldEtudiant == null)
                {
                    etudiantBLO.CreateEtudiant(newetudiant);
                }
                else
                {
                    etudiantBLO.EditEtudiant(oldEtudiant, newetudiant);
                }

                MessageBox.Show
                (
                    "Sauvergade reussi !",
                    "Confirmation",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Information
                );

                if (callBack != null)
                {
                    callBack();
                }

                if (oldEtudiant != null)
                {
                    Close();
                }

                textBoxA.Clear();
                textBoxContact.Clear();
                textBoxEmail.Clear();
                textBoxfirstname.Clear();
                textBoxId.Clear();
                textBoxlastname.Clear();
                textBoxNomEcole.Clear();
                textBoxBorn.Clear();
            }

            catch (TypingException ex)
            {
                MessageBox.Show
                (
                    ex.Message,
                    "Typing error",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Warning
                );
            }

            /*catch (DuplicateNameException ex)
             * {
             *  MessageBox.Show
             * (
             *     ex.Message,
             *     "Duplicate error",
             *     MessageBoxButtons.OK,
             *     MessageBoxIcon.Warning
             * );
             * }
             *
             * catch (KeyNotFoundException ex)
             * {
             *  MessageBox.Show
             * (
             *     ex.Message,
             *     "Not found error",
             *     MessageBoxButtons.OK,
             *     MessageBoxIcon.Warning
             * );
             * }
             *
             * catch (Exception ex)
             * {
             *  ex.WriteToFile();
             *  MessageBox.Show
             * (
             *     "An error occurred! Please try again later.",
             *     "Erreur",
             *     MessageBoxButtons.OK,
             *     MessageBoxIcon.Error
             * );*/
        }
示例#11
0
        private void bunifuThinButton22_Click(object sender, EventArgs e)
        {
            try
            {
                checkForm();
                string sex;

                if (checkBox1.Checked)
                {
                    sex = checkBox1.Text;
                }
                else if (checkBox2.Checked)
                {
                    sex = checkBox2.Text;
                }
                else
                {
                    sex = "";
                }



                Etudiant newEtudiant = new Etudiant(
                    txtFirstName.Text,
                    txtLastName.Text,
                    txtEmail.Text,
                    int.Parse(txtTel.Text),
                    sex,
                    Convert.ToDateTime(bunifuDatepicker1.Value),
                    txtAt.Text,
                    !string.IsNullOrEmpty(pictureBox1.ImageLocation) ? File.ReadAllBytes(pictureBox1.ImageLocation) : this.oldEtudiant?.Photo,
                    ecole
                    );


                EtudiantBLO etudiantBLO = new EtudiantBLO(ConfigurationManager.AppSettings["DbFolder"]);

                if (this.oldEtudiant == null)
                {
                    etudiantBLO.CreateEtudiant(newEtudiant);
                }
                else
                {
                    etudiantBLO.EditEtudiant(oldEtudiant, newEtudiant);
                }


                MessageBox.Show(
                    "Save Done !",
                    "Confirmation",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Information
                    );


                if (callback != null)
                {
                    callback();
                }
                txtFirstName.Clear();
                txtLastName.Clear();
                checkBox1.Checked = false;
                checkBox2.Checked = false;
                txt.Clear();
                bunifuDatepicker1.Value   = DateTime.Now;
                pictureBox1.ImageLocation = null;
                txtTel.Clear();
                txtEmail.Clear();
                txtFirstName.Focus();
                loadData();
            }
            catch (TypingException ex)
            {
                MessageBox.Show(
                    ex.Message,
                    "Typing error",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Warning
                    );
            }
            catch (DuplicateNameException ex)
            {
                MessageBox.Show(
                    ex.Message,
                    "Duplicate error",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Warning
                    );
            }
            catch (KeyNotFoundException ex)
            {
                MessageBox.Show(
                    ex.Message,
                    "key not found error",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Warning
                    );
            }
            catch (Exception ex)
            {
                ex.WriteToFile();

                MessageBox.Show(
                    "An error occured please try again",
                    "Error",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error
                    );
            }
        }
示例#12
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                checkForm();

                Etudiant newEtudiant = new Etudiant
                                       (
                    txtIdentified.Text.ToUpper(),
                    txtLastName.Text,
                    txtFirstName.Text,
                    txtBornOn.Text,
                    txtAt.Text,
                    long.Parse(txtContact.Text),
                    txtEmail.Text,
                    !string.IsNullOrEmpty(pictureBox1.ImageLocation) ? File.ReadAllBytes(pictureBox1.ImageLocation) : this.oldEtudiant?.Picture
                                       );

                EtudiantBLO etudiantBLo = new EtudiantBLO(ConfigurationManager.AppSettings["DbFolder"]);

                if (this.oldEtudiant == null)
                {
                    etudiantBLo.CreateEtudiant(newEtudiant);
                }
                else
                {
                    etudiantBLo.EditEtudiant(oldEtudiant, newEtudiant);
                }

                MessageBox.Show
                (
                    "Save done !",
                    "Confirmation",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Information
                );

                if (callBack != null)
                {
                    callBack();
                }

                if (oldEtudiant != null)
                {
                    Close();
                }

                txtIdentified.Clear();
                txtLastName.Clear();
                txtFirstName.Clear();
                txtBornOn.Clear();
                txtAt.Clear();
                txtContact.Clear();
                txtEmail.Clear();
            }
            catch (TypingException ex)
            {
                MessageBox.Show
                (
                    ex.Message,
                    "Typing error",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Warning
                );
            }
            catch (DuplicateNameException ex)
            {
                MessageBox.Show
                (
                    ex.Message,
                    "Duplicate error",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Warning
                );
            }
            catch (KeyNotFoundException ex)
            {
                MessageBox.Show
                (
                    ex.Message,
                    "Not found error",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Warning
                );
            }
            catch (Exception ex)
            {
                ex.WriteToFile();
                MessageBox.Show
                (
                    "An error occurred! Please try again later.",
                    "Erreur",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error
                );
            }
        }
示例#13
0
        private void btnEnregistrer_Click(object sender, EventArgs e)
        {
            try
            {
                checkForm();

                Etudiant newEtu = new Etudiant(
                    txtMatricule.Text.ToUpper(),
                    txtNom.Text,
                    txtPrenom.Text,
                    dateTimePicker1.Text,
                    txtLieu.Text,
                    txtEmail.Text,
                    long.Parse(txtContact.Text),
                    !String.IsNullOrEmpty(pictureBox1.ImageLocation) ? File.ReadAllBytes(pictureBox1.ImageLocation) : this.oldEtu?.Photo

                    );

                EtudiantBLO etuBlo = new EtudiantBLO(ConfigurationManager.AppSettings["DbFolder"]);
                if (this.oldEtu == null)
                {
                    etuBlo.CreateEtudiant(newEtu);
                }
                else
                {
                    etuBlo.EditEtudiant(oldEtu, newEtu);
                }
                // etuBlo.CreateEtudiant(newEtu);
                MessageBox.Show(
                    "Enregistrement éffectué !",
                    "Confirmé",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Information
                    );
                if (callback != null)
                {
                    callback();
                }

                if (oldEtu != null)
                {
                    Close();
                }
                txtMatricule.Clear();
                txtNom.Clear();
                txtPrenom.Clear();
                dateTimePicker1.Refresh();
                txtLieu.Clear();
                txtEmail.Clear();
                txtContact.Clear();
                txtMatricule.Focus();
            }
            catch (TypingException ex)
            {
                MessageBox.Show
                (
                    ex.Message,
                    "Typing error",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Warning
                );
            }
            catch (DuplicateNameException ex)
            {
                MessageBox.Show
                (
                    ex.Message,
                    "Duplicate error",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Warning
                );
            }
            catch (KeyNotFoundException ex)
            {
                MessageBox.Show
                (
                    ex.Message,
                    "Not found error",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Warning
                );
            }

            catch (Exception ex)
            {
                ex.WriteToFile();
                using (StreamWriter sw = new StreamWriter("app.log", true))
                {
                    sw.WriteLine(ex.ToString());
                }
                MessageBox.Show
                (
                    "An Error occured! Please try again",
                    "Erreur",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error
                );
            }
            loadData();
            QRCoder.QRCodeGenerator qr = new QRCoder.QRCodeGenerator();
            var mydata = qr.CreateQrCode(txtMatricule.Text, QRCoder.QRCodeGenerator.ECCLevel.H);
            var code   = new QRCoder.QRCode(mydata);

            pictureBoxQR.Image = code.GetGraphic(50);
        }