Beispiel #1
0
        private void modifier_Click(object sender, EventArgs e)
        {
            try
            {
                int val;
                int index = emploi_ens.CurrentCell.RowIndex;
                val = (int)emploi_ens[0, index].Value;
                emploi_enseignant t1 = db.emploi_enseignants.Single(x => x.id_tache == val);
                t1.id_tache = (int)emploi_ens[0, index].Value;

                var query = from emploi_enseignant in db.emploi_enseignants
                            where emploi_enseignant.id_tache == t1.id_tache
                            select emploi_enseignant;
                foreach (emploi_enseignant emp in query)
                {
                    emp.type      = (string)emploi_ens[1, index].Value;
                    emp.date      = (DateTime)emploi_ens[2, index].Value;
                    emp.heure_deb = (string)emploi_ens[3, index].Value;
                    emp.heure_fin = (string)emploi_ens[4, index].Value;
                    emp.salle     = (string)emploi_ens[5, index].Value;
                    emp.id_ens    = (string)emploi_ens[6, index].Value;
                }

                // modifier une notification après chaque modification d'une  tache existante
                Notification n = new Notification();

                var query2 = from Notification in db.Notifications
                             select Notification;


                foreach (Notification not in query2)
                {
                    not.description = (string)emploi_ens[1, index].Value + " (a été modifiée !!)";
                    not.date        = (DateTime)emploi_ens[2, index].Value;
                }


                db.SubmitChanges();


                MessageBox.Show("Tache et notification Modifiées !");
                emploi_ens.DataSource = null;
                emploi_ens.DataSource = db.emploi_enseignants;
            }

            catch (SqlException ex)
            {
                MessageBox.Show("ID enseignant est  non compatible ");
            }
        }
Beispiel #2
0
        private void bunifuThinButton21_Click(object sender, EventArgs e)
        {
            try
            {
                db = new loginteachDataContext();
                int val;
                int index = dataGridView1.CurrentCell.RowIndex;
                val = (int)dataGridView1[0, index].Value;
                mec t1 = new mec();

                t1.id     = (int)dataGridView1[0, index].Value;
                t1.cin    = (string)dataGridView1[1, index].Value;
                t1.module = (string)dataGridView1[2, index].Value;
                t1.classe = (int)dataGridView1[3, index].Value;
                if (t1 == null)
                {
                    MessageBox.Show("veuillez saisir les champs");
                }
                else
                {
                    db.mecs.InsertOnSubmit(t1);
                    db.SubmitChanges();
                    MessageBox.Show("Module affecté à " + t1.cin);
                    dataGridView1.DataSource = null;
                    dataGridView1.DataSource = db.mecs;
                }
            }
            catch (Exception ex) { MessageBox.Show(ex.Message); }
        }
Beispiel #3
0
        private void ajouter_Click(object sender, EventArgs e)
        {
            try
            {
                db = new loginteachDataContext();
                int val;
                int index = emploi_ens.CurrentCell.RowIndex;
                val = (int)emploi_ens[0, index].Value;
                emploi_enseignant t1 = new emploi_enseignant();

                t1.id_tache  = (int)emploi_ens[0, index].Value;
                t1.type      = (string)emploi_ens[1, index].Value;
                t1.date      = (DateTime)emploi_ens[2, index].Value;
                t1.heure_deb = (string)emploi_ens[3, index].Value;
                t1.heure_fin = (string)emploi_ens[4, index].Value;
                t1.salle     = (string)emploi_ens[5, index].Value;
                t1.id_ens    = (string)emploi_ens[6, index].Value;

                db.emploi_enseignants.InsertOnSubmit(t1);

                // ajouter une notification après chaque insertion d'une nouvelle tache
                Notification n = new Notification();
                n.description = (string)emploi_ens[1, index].Value + " ( Nouvelle !!!) ";
                n.date        = (DateTime)emploi_ens[2, index].Value;
                n.id_ens      = (string)emploi_ens[6, index].Value;
                db.Notifications.InsertOnSubmit(n);

                db.SubmitChanges();
                MessageBox.Show("Tache et notification ajoutées");
                emploi_ens.DataSource = null;
                emploi_ens.DataSource = db.emploi_enseignants;
            }
            catch (Exception ex) { MessageBox.Show(ex.Message); }
        }
Beispiel #4
0
        private void bunifuThinButton22_Click(object sender, EventArgs e)
        {
            try
            {
                string val = (string)textBox1.Text;

                /*mec t2 = db.mec.Single(x => x.cin == val);
                 * if (t2 != null)
                 * db.mec.DeleteOnSubmit(t2);*/
                var query = from enseignant in db.enseignants
                            where enseignant.cin == val
                            select enseignant;
                List <enseignant> ListeEns = query.ToList();
                if (ListeEns.Count == 0)
                {
                    MessageBox.Show("Enseignant n'est pas trouvé vérifier CIN !");
                }
                else
                {
                    enseignant sup = ListeEns[0];
                    db.enseignants.DeleteOnSubmit(sup);
                    db.SubmitChanges();
                    MessageBox.Show("Enseignant supprimé!");
                }
            }
            catch (Exception ex) { MessageBox.Show(ex.Message); }
        }
Beispiel #5
0
        private void bunifuThinButton22_Click(object sender, EventArgs e)
        {
            try
            {
                int val;
                int index = dataGridView1.CurrentCell.RowIndex;
                val = (int)dataGridView1[0, index].Value;
                classe t1 = db.classes.Single(x => x.id_classe == val);
                db.classes.DeleteOnSubmit(t1);
                db.SubmitChanges();


                MessageBox.Show("Classe Supprimé !");
                dataGridView1.DataSource = null;
                db = new loginteachDataContext();
                dataGridView1.DataSource = db.classes;
            }
            catch (Exception ex) { MessageBox.Show(ex.Message); }
        }
Beispiel #6
0
        private void bunifuThinButton22_Click(object sender, EventArgs e)
        {
            int    val;
            int    index = dataGridView1.CurrentCell.RowIndex;
            string cin   = "";

            if (index < 0)
            {
                MessageBox.Show("selectionnez une ligne svp!");
            }
            else
            {
                val = (int)dataGridView1[0, index].Value;
                mec t1 = db.mecs.Single(x => x.id == val);
                t1.id = (int)dataGridView1[0, index].Value;

                var query = from mec in db.mecs
                            where mec.id == t1.id
                            select mec;

                foreach (mec emp in query)
                {
                    //emp.cin_enseignant = (string)dataGridView1[0, index].Value;
                    emp.cin    = (string)dataGridView1[1, index].Value;
                    cin        = emp.cin;
                    emp.module = (string)dataGridView1[2, index].Value;
                    emp.classe = (int)dataGridView1[3, index].Value;
                    //emp.classe = (string)dataGridView1[4, index].Value;
                }

                db.SubmitChanges();


                MessageBox.Show(text: "Module Modifiée pour " + cin);
                dataGridView1.DataSource = null;

                dataGridView1.DataSource = db.mecs;
            }
        }
Beispiel #7
0
        private void bunifuFlatButton1_Click(object sender, EventArgs e)
        {
            allgood = true;
            foreach (Control c in panel1.Controls)
            {
                if (c is TextBox)
                {
                    if (c.Text.Length == 0)
                    {
                        MessageBox.Show("veuillez remplir tout les champs !");
                        c.Focus();
                        allgood = false;
                        break;
                    }
                    else if (c == textBox1 && textBox1.Text.Length < 8)
                    {
                        MessageBox.Show("cin doit être composé de 8 chiffres !", "erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        allgood = false;
                    }
                }
            }
            if (allgood)
            {
                bool emailverif = true;
                try
                {
                    var m = new System.Net.Mail.MailAddress(textBox5.Text);
                }
                catch (System.FormatException f)
                {
                    MessageBox.Show("email incorrect !");
                    emailverif = false;
                }
                if (emailverif)
                {
                    if (gerer_ens.s.mots_de_passe != textBox4.Text && qrgenerated == false)
                    {
                        MessageBox.Show("générer votre QR code svp !", "erreur", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                    else
                    {
                        try
                        {
                            db = new loginteachDataContext();
                            enseignant ens = new enseignant();
                            ens.cin = textBox1.Text;
                            var query = from enseignant in db.enseignants
                                        where enseignant.cin == ens.cin
                                        select enseignant;
                            List <enseignant> listeEns = query.ToList <enseignant>();



                            foreach (enseignant ex in query)
                            {
                                ex.nom           = textBox2.Text;
                                ex.prenom        = textBox3.Text;
                                ex.mots_de_passe = textBox4.Text;
                                ex.mail          = textBox5.Text;
                                MemoryStream ms = new MemoryStream();
                                bunifuImageButton1.Image.Save(ms, ImageFormat.Jpeg);
                                byte[] pic_array = new byte[ms.Length];
                                ms.Position = 0;
                                ms.Read(pic_array, 0, pic_array.Length);
                                ex.photo = pic_array;

                                MemoryStream mss = new MemoryStream();
                                pictureBox1.Image.Save(mss, ImageFormat.Bmp);
                                byte[] qr_array = new byte[mss.Length];
                                mss.Position = 0;
                                mss.Read(qr_array, 0, qr_array.Length);
                                ex.code_a_bar = qr_array;
                            }

                            db.SubmitChanges();
                            // len = ens.photo.ToString().Length;

                            MessageBox.Show("modification réussite !");
                        }
                        catch (Exception exx)
                        {
                            MessageBox.Show(text: "erreur d'insertion " + exx.Message, caption: "Erreur", buttons: MessageBoxButtons.OK, icon: MessageBoxIcon.Error);
                        }
                    }
                }
            }
        }
        private void bunifuFlatButton1_Click(object sender, EventArgs e)
        {
            allgood = true;
            foreach (Control c in panel1.Controls)
            {
                if (c is TextBox)
                {
                    if (c.Text.Length == 0)
                    {
                        MessageBox.Show("veuillez remplir tout les champs !");
                        c.Focus();
                        allgood = false;
                        break;
                    }
                    else if (c == textBox1 && textBox1.Text.Length < 8)
                    {
                        MessageBox.Show("cin doit être composé de 8 chiffres !", "erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        allgood = false;
                    }
                }
            }
            if (allgood)
            {
                bool emailverif = true;
                try
                {
                    var m = new System.Net.Mail.MailAddress(textBox5.Text);
                }
                catch (System.FormatException f)
                {
                    MessageBox.Show("email incorrect !");
                    emailverif = false;
                }
                if (emailverif)
                {
                    if (picturechanged == false && pictureBox1.Image == null)
                    {
                        MessageBox.Show("insérer votre image et votre QR code svp !", "erreur", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                    else if (picturechanged == false)
                    {
                        MessageBox.Show("insérer votre image svp !", "erreur", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                    else if (pictureBox1.Image == null)
                    {
                        MessageBox.Show("générer votre QR code svp !", "erreur", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                    else
                    {
                        try
                        {
                            db = new loginteachDataContext();
                            enseignant ens = new enseignant();
                            ens.cin = textBox1.Text;
                            var query = from enseignant in db.enseignants
                                        where enseignant.cin == ens.cin
                                        select enseignant;
                            List <enseignant> listeEns = query.ToList <enseignant>();
                            if (listeEns.Count != 0)
                            {
                                MessageBox.Show("vous êtes déjà inscrit !");
                            }
                            else
                            {
                                ens.mail          = textBox5.Text;
                                ens.mots_de_passe = textBox4.Text;
                                ens.nom           = textBox2.Text;
                                ens.prenom        = textBox3.Text;

                                MemoryStream ms = new MemoryStream();
                                photo.Image.Save(ms, ImageFormat.Jpeg);
                                byte[] pic_array = new byte[ms.Length];
                                ms.Position = 0;
                                ms.Read(pic_array, 0, pic_array.Length);
                                ens.photo = pic_array;

                                MemoryStream mss = new MemoryStream();
                                pictureBox1.Image.Save(mss, ImageFormat.Bmp);
                                byte[] qr_array = new byte[mss.Length];
                                mss.Position = 0;
                                mss.Read(qr_array, 0, qr_array.Length);
                                ens.code_a_bar = qr_array;
                                if (fbIsUsed) //si facebook est utilisé dans l'inscription
                                {
                                    ens.fbid = fbid;
                                }
                                if (gmailIsUsed)
                                {
                                    ens.gmailid = gmailid;
                                }
                                db.enseignants.InsertOnSubmit(ens);
                                db.SubmitChanges();
                                // len = ens.photo.ToString().Length;

                                MessageBox.Show("inscription réussite !");
                            }
                        }
                        catch (Exception exx)
                        {
                            MessageBox.Show(text: "erreur d'insertion " + exx.Message, caption: "Erreur", buttons: MessageBoxButtons.OK, icon: MessageBoxIcon.Error);
                        }
                    }

                    //MessageBox.Show(len.ToString());

                    /*
                     * var optionss = new ZXing.Common.EncodingOptions
                     * {
                     * PureBarcode = true,
                     * Height = 30,
                     * Width = 100,
                     * };
                     *
                     * var writerr = new BarcodeWriter();
                     * writerr.Format = BarcodeFormat.CODE_128;
                     * writerr.Options = optionss;
                     * var qrr = new BarcodeWriter();
                     * qrr.Options = optionss;
                     * qrr.Format = ZXing.BarcodeFormat.CODE_128;
                     * var resultt = new Bitmap(qrr.Write(textBox1.Text.Trim()));
                     * pictureBox2.Image = resultt;
                     *
                     * var reader = new BarcodeReader();
                     * var x=reader.Decode(resultt);
                     * textBox6.Text= x.ToString();
                     */
                }
            }
        }