Exemplo n.º 1
0
 public FormListEtudiant()
 {
     InitializeComponent();
     dataGridView1.AutoGenerateColumns = false;
     etudiantBLO = new EtudiantBLO(ConfigurationManager.AppSettings["DbFolder"]);
     ecoleBLO    = new EcoleBLO(ConfigurationManager.AppSettings["DbFolder"]);
 }
Exemplo n.º 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();
        }
Exemplo n.º 3
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();
        }
Exemplo n.º 4
0
        private void btnEnregistrer_Click(object sender, EventArgs e)
        {
            try
            {
                Etudiant etudiant = new Etudiant
                                    (
                    txtnom.Text,
                    txtprenom.Text,
                    txtid.Text,
                    int.Parse(txtcontact.Text),
                    txtemail.Text
                                    );
                EtudiantBLO etudiantBLO = new EtudiantBLO(ConfigurationManager.AppSettings["DbFolder"]);
                etudiantBLO.CreateProduct(etudiant);

                MessageBox.Show
                (
                    "L'étudiant a été ajouté",
                    "Confirmation",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Information
                );
                txtnom.Clear();
                txtprenom.Clear();
                txtid.Clear();
                txtcontact.Clear();
                txtemail.Clear();
            }
            catch (TypingException ex)
            {
                MessageBox.Show
                (
                    ex.Message,
                    "Typing error",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error
                );
            }
            catch (Exception ex)
            {
                using (StreamWriter sw = new StreamWriter("app.log", true))
                {
                    sw.WriteLine(ex.ToString());
                }
                MessageBox.Show
                (
                    "Une erreur a encore  été detectée !",
                    "Erreur",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error
                );
            }
        }
Exemplo n.º 5
0
 private void button2_Click(object sender, EventArgs e)
 {
     if (dataGridView1.SelectedRows.Count > 0)
     {
         if (
             MessageBox.Show
             (
                 "Voulez-vous vraiment supprimer cet etudiant ?",
                 "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Question
             ) == DialogResult.Yes
             )
         {
             for (int i = 0; i < dataGridView1.SelectedRows.Count; i++)
             {
                 EtudiantBLO.DeleteEtudiant(dataGridView1.SelectedRows[i].DataBoundItem as Etudiant);
             }
             loadData();
         }
     }
 }
Exemplo n.º 6
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();
        }
Exemplo n.º 7
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();
        }
Exemplo n.º 8
0
        static void Main(string[] args)
        {
            string choice = "y";

            do
            {
                Console.Clear();
                Console.WriteLine("--------------------------------------------------create a etudiant--------------------------------------------------");
                Console.Write("entrer votre nom");
                string nom = Console.ReadLine();
                Console.Write("entrer votre prenom");
                string prenom = Console.ReadLine();
                Console.Write("entrer votre lieu de naissance");
                string lieu = Console.ReadLine();
                Console.Write("entrer votre annee de naissance");
                double nee = double.Parse(Console.ReadLine());
                Console.Write("entrer votre identifiant");
                double identifiant = double.Parse(Console.ReadLine());
                Console.Write("entrer votre contact");
                double contact = double.Parse(Console.ReadLine());



                Etudiant    etudiant    = new Etudiant(nom, prenom, nee, lieu, identifiant, contact);
                EtudiantBLO etudiantBLO = new EtudiantBLO(ConfigurationManager.AppSettings["DbFolder"]);
                etudiantBLO.CreateProduct(etudiant);

                IEnumerable <Etudiant> etudiants = etudiantBLO.GetAllEtudiants();
                foreach (Etudiant e in etudiants)
                {
                    Console.WriteLine($"{ e.Identifiant}\t{e.Nom }");
                }
                Console.WriteLine("Create another etudiant?[y/n];");
            }while (choice.ToLower() != "n");
            Console.WriteLine("Program end!");

            Console.ReadKey();
        }
Exemplo n.º 9
0
        static void Main(string[] args)
        {
            string choice = "y";

            do
            {
                Console.Clear();
                Console.WriteLine("----------------------------Ajoutez des étudiants----------------------------");
                Console.Write("Entrer le nom  \t:");
                string nom = Console.ReadLine();
                Console.Write("Entrer le prenom \t:");
                string prenom = Console.ReadLine();
                Console.Write("Entrer l'identifiant \t:");
                string identifiant = Console.ReadLine();
                Console.Write("Entrer votre contact \t:");
                int contact = int.Parse(Console.ReadLine());
                Console.Write("Entrer l'email \t:");
                string email = Console.ReadLine();

                Etudiant    etudiant    = new Etudiant(nom, prenom, identifiant, contact, email);
                EtudiantBLO etudiantBLO = new EtudiantBLO(ConfigurationManager.AppSettings["DbFolder"]);
                etudiantBLO.CreateProduct(etudiant);

                IEnumerable <Etudiant> etudiants = etudiantBLO.GetAllEtudiant();
                foreach (Etudiant p in etudiants)
                {
                    Console.WriteLine($"{p.Nom}\t{p.Prenom}\t{p.Email}\t{p.Contact}");
                }

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

            Console.ReadKey();
        }
Exemplo n.º 10
0
 public FrmEcoleEdit()
 {
     InitializeComponent();
     etudiantsBLO = new EtudiantBLO(ConfigurationManager.AppSettings["DbFolder"]);
     ecoleBLO     = new EcoleBLO(ConfigurationManager.AppSettings["DbFolder"]);
 }
Exemplo n.º 11
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
         );
     }
 }
Exemplo n.º 12
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);
        }
Exemplo n.º 13
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
                );
            }
        }
Exemplo n.º 14
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
                );
            }
        }
Exemplo n.º 15
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
             *  );
             * }*/
        }
Exemplo n.º 16
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
                    );
            }
        }
Exemplo n.º 17
0
 public FrmEtudiantList()
 {
     InitializeComponent();
     dataGridView1.DataSource = false;
     etudiantBLO = new EtudiantBLO(ConfigurationManager.AppSettings["DbFolder"]);
 }
Exemplo n.º 18
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
                );
            }
        }
Exemplo n.º 19
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
                    );
            }
        }
Exemplo n.º 20
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                checkForm();
                Etudiant newEtudiant = new Etudiant
                                           (txtNom.Text,
                                           txtPrenom.Text,
                                           txtNee.Text,
                                           double.Parse(txtLieu.Text),
                                           double.Parse(txtIdentifiant.Text),
                                           double.Parse(txtContact.Text)
                                           );
                EtudiantBLO etudiantBLO = new EtudiantBLO(ConfigurationManager.AppSettings["DbFolder"]);

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

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

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

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

                txtContact.Clear();
                txtIdentifiant.Clear();
                txtLieu.Clear();
                txtNee.Clear();
                txtNom.Clear();
                txtPrenom.Clear();
                txtNom.Focus();
            }
            catch (TypingException ex)
            {
                MessageBox.Show(
                    ex.Message,
                    "erreur de saisie",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Warning);
            }
            catch (DuplicateNameException ex)
            {
                MessageBox.Show(
                    ex.Message,
                    "duplicate error",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Warning);
            }
            catch (Exception ex)
            {
                ex.WriteToFile();
                MessageBox.Show(
                    " une erreur est survenue svp reessayer",
                    "erreur",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error);
            }
            catch (KeyNotFoundException ex)
            {
                MessageBox.Show(
                    ex.Message,
                    " une erreur est survenue svp reessayer",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error);
            }
        }
Exemplo n.º 21
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
             * );*/
        }