예제 #1
0
 private void btnValider_Click(object sender, EventArgs e)
 {
     if (this.useMode == "Ajout")
     {
         try
         {
             ValidateData();
             BLInscription.AddNew(getInscriptionFromInterface());
             MessageBox.Show("Inscription ajoutée avec succès", "Ajout d'inscription", MessageBoxButtons.OK, MessageBoxIcon.Information);
             reset();
         }
         catch (DataValidationException Exp)
         {
             MessageBox.Show(Exp.ExceptionMessage, "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
             AppearanceHandler.SetErrorAppearance(ErrorCtrls, ToolTipErrorInfo);
         }
     }
     else
     {
         BLInscription.Update(this.I.ID, getInscriptionFromInterface());
         MessageBox.Show("Inscription mis à jour avec succès", "Mise à jour d'inscription", MessageBoxButtons.OK, MessageBoxIcon.Information);
         this.Dispose();
     }
 }
예제 #2
0
        public static void ReadExcel(string fileName, string fileExt)
        {
            string conn = string.Empty;

            if (fileExt.CompareTo(".xls") == 0)
            {
                conn = @"provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + fileName + ";Extended Properties='Excel 8.0;HRD=Yes;IMEX=1';"; //for below excel 2007
            }
            else
            {
                conn = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + fileName + ";Extended Properties='Excel 12.0;HDR=Yes';"; //for above excel 2007
            }
            using (OleDbConnection con = new OleDbConnection(conn))
            {
                try
                {
                    Diplome           D;
                    FicheInformations FI;
                    Inscription       I;

                    Excel.Application xlApp = new Excel.Application();
                    Excel.Workbook    xlBook;
                    Excel.Worksheet   xlSheet;

                    xlBook        = xlApp.Workbooks.Open(fileName);
                    xlApp.Visible = true;
                    xlSheet       = xlBook.ActiveSheet;

                    for (int i = 2; i <= xlSheet.UsedRange.Rows.Count; i++)
                    {
                        D  = new Diplome();
                        FI = new FicheInformations();
                        I  = new Inscription();

                        FI.CIN                          = readCell(i, "B", xlSheet);
                        FI.NOMPRENOM                    = readCell(i, "C", xlSheet);
                        FI.CIVILITE                     = readCell(i, "E", xlSheet);
                        FI.DATENAISSANCE                = readCell(i, "D", xlSheet);
                        FI.VILLENAISSANCE               = readCell(i, "BB", xlSheet);
                        FI.PAYSORIGINE                  = readCell(i, "G", xlSheet);
                        FI.NATIONALITE                  = readCell(i, "F", xlSheet);
                        FI.ADRESSE                      = readCell(i, "H", xlSheet);
                        FI.VILLE                        = readCell(i, "J", xlSheet);
                        FI.CODEPOSTAL                   = readCell(i, "K", xlSheet);
                        FI.GOUVERNORAT                  = readCell(i, "I", xlSheet);
                        FI.TELEPHONE                    = readCell(i, "L", xlSheet);
                        FI.EMAIL                        = readCell(i, "M", xlSheet);
                        FI.PROFESSION                   = readCell(i, "N", xlSheet);
                        FI.EMPLOYEUR                    = readCell(i, "O", xlSheet);
                        FI.SPECIALITE                   = readCell(i, "P", xlSheet);
                        FI.LABOUNITEERECHERCHE          = readCell(i, "Q", xlSheet);
                        FI.LABOUNITEERECHERCHECOTUTELLE = readCell(i, "S", xlSheet);
                        FI.ENCADRANT                    = readCell(i, "T", xlSheet);
                        FI.COENCADRANT                  = readCell(i, "U", xlSheet);
                        FI.SUJET                        = readCell(i, "V", xlSheet);

                        BLFicheInformation.AddNew(FI);

                        if (xlSheet.UsedRange.Cells[i, "AG"].Value != null)
                        {
                            D.ANNEE       = readCell(i, "AG", xlSheet);
                            D.DIPLOME     = readCell(i, "AI", xlSheet);
                            D.SPECIALITE  = readCell(i, "AH", xlSheet);
                            D.MENTION     = "";
                            D.INSTITUTION = readCell(i, "AJ", xlSheet);
                            D.CIN         = readCell(i, "B", xlSheet);

                            BLDiplome.AddNew(D);
                        }

                        if (xlSheet.UsedRange.Cells[i, "AK"].Value != null)
                        {
                            D.ANNEE       = readCell(i, "AK", xlSheet);
                            D.DIPLOME     = readCell(i, "AM", xlSheet);
                            D.SPECIALITE  = readCell(i, "AL", xlSheet);
                            D.MENTION     = "";
                            D.INSTITUTION = readCell(i, "AN", xlSheet);
                            D.CIN         = readCell(i, "B", xlSheet);

                            BLDiplome.AddNew(D);
                        }

                        if (xlSheet.UsedRange.Cells[i, "AO"].Value != null)
                        {
                            D.ANNEE       = readCell(i, "AO", xlSheet);
                            D.DIPLOME     = readCell(i, "AQ", xlSheet);
                            D.SPECIALITE  = readCell(i, "AP", xlSheet);
                            D.MENTION     = "";
                            D.INSTITUTION = readCell(i, "AR", xlSheet);
                            D.CIN         = readCell(i, "B", xlSheet);

                            BLDiplome.AddNew(D);
                        }

                        if (xlSheet.UsedRange.Cells[i, "AS"].Value != null)
                        {
                            D.ANNEE       = readCell(i, "AS", xlSheet);
                            D.DIPLOME     = readCell(i, "AU", xlSheet);
                            D.SPECIALITE  = readCell(i, "AT", xlSheet);
                            D.MENTION     = "";
                            D.INSTITUTION = readCell(i, "AV", xlSheet);
                            D.CIN         = readCell(i, "B", xlSheet);

                            BLDiplome.AddNew(D);
                        }

                        if (xlSheet.UsedRange.Cells[i, "AW"].Value != null)
                        {
                            D.ANNEE       = readCell(i, "AW", xlSheet);
                            D.DIPLOME     = readCell(i, "AY", xlSheet);
                            D.SPECIALITE  = readCell(i, "AX", xlSheet);
                            D.MENTION     = "";
                            D.INSTITUTION = readCell(i, "AZ", xlSheet);
                            D.CIN         = readCell(i, "B", xlSheet);

                            BLDiplome.AddNew(D);
                        }

                        if (xlSheet.UsedRange.Cells[i, "W"].Value != null)
                        {
                            I.ANNEEUNIVERSITAIRE = readCell(i, "W", xlSheet);
                            I.NIVEAU             = readCell(i, "X", xlSheet);
                            I.COMMENTAIRE        = "";
                            I.CIN = readCell(i, "B", xlSheet);

                            BLInscription.AddNew(I);
                        }

                        if (xlSheet.UsedRange.Cells[i, "Y"].Value != null)
                        {
                            I.ANNEEUNIVERSITAIRE = readCell(i, "Y", xlSheet);
                            I.NIVEAU             = readCell(i, "Z", xlSheet);
                            I.COMMENTAIRE        = "";
                            I.CIN = readCell(i, "B", xlSheet);

                            BLInscription.AddNew(I);
                        }

                        if (xlSheet.UsedRange.Cells[i, "AA"].Value != null)
                        {
                            I.ANNEEUNIVERSITAIRE = readCell(i, "AA", xlSheet);
                            I.NIVEAU             = readCell(i, "AB", xlSheet);
                            I.COMMENTAIRE        = "";
                            I.CIN = readCell(i, "B", xlSheet);

                            BLInscription.AddNew(I);
                        }

                        if (xlSheet.UsedRange.Cells[i, "AC"].Value != null)
                        {
                            I.ANNEEUNIVERSITAIRE = readCell(i, "AC", xlSheet);
                            I.NIVEAU             = readCell(i, "AD", xlSheet);
                            I.COMMENTAIRE        = "";
                            I.CIN = readCell(i, "B", xlSheet);

                            BLInscription.AddNew(I);
                        }

                        if (xlSheet.UsedRange.Cells[i, "AE"].Value != null)
                        {
                            I.ANNEEUNIVERSITAIRE = readCell(i, "AE", xlSheet);
                            I.NIVEAU             = readCell(i, "AF", xlSheet);
                            I.COMMENTAIRE        = "";
                            I.CIN = readCell(i, "B", xlSheet);

                            BLInscription.AddNew(I);
                        }
                    }

                    xlBook.Close();
                    xlApp.Quit();
                }
                catch (Exception ex)
                {
                    System.Windows.Forms.MessageBox.Show(ex.Message);
                }
            }
        }
예제 #3
0
        private void BGProgressBar_DoWork(object sender, DoWorkEventArgs e)
        {
            Thread demoThread, demoThread1, demoThread2;

            if (this.deletedSubject == "Doctorant")
            {
                for (int i = 0; i < listDoctorants.Count; i++)
                {
                    if (nbElementSelectionnes > 0)
                    {
                        Thread.Sleep(rand.Next(500, 2000));
                        demoThread  = new Thread(() => ThreadProcSafeNbDeletedElements((i + 1).ToString()));
                        demoThread1 = new Thread(() => ThreadProcSafeIdentifier(listDoctorants[i].NOMPRENOM));
                        demoThread2 = new Thread(() => ThreadProcSafeDeletedStudentCIN(listDoctorants[i].CIN));
                        ImageUtilities.getPhoto(pbDoctorant, listDoctorants[i].CIN);
                        demoThread.Start();
                        demoThread1.Start();
                        demoThread2.Start();
                        BLFicheInformation.delete(listDoctorants[i].CIN);
                        ImageUtilities.deletePhoto(listDoctorants[i].CIN);
                        BGProgressBar.ReportProgress((i + 1) * 100 / nbElementSelectionnes);
                    }
                }
            }
            else if (this.deletedSubject == "Inscription")
            {
                ImageUtilities.getPhoto(pbDoctorant, listInscriptions[0].CIN);
                demoThread2 = new Thread(() => ThreadProcSafeDeletedStudentCIN(listInscriptions[0].CIN));
                demoThread2.Start();
                for (int i = 0; i < listInscriptions.Count; i++)
                {
                    if (nbElementSelectionnes > 0)
                    {
                        Thread.Sleep(rand.Next(500, 2000));
                        demoThread  = new Thread(() => ThreadProcSafeNbDeletedElements((i + 1).ToString()));
                        demoThread1 = new Thread(() => ThreadProcSafeIdentifier(listInscriptions[i].ID));
                        demoThread.Start();
                        demoThread1.Start();
                        BLInscription.Delete(listInscriptions[i].ID);
                        BGProgressBar.ReportProgress((i + 1) * 100 / nbElementSelectionnes);
                    }
                }
            }
            else
            {
                ImageUtilities.getPhoto(pbDoctorant, listDiplomes[0].CIN);
                demoThread2 = new Thread(() => ThreadProcSafeDeletedStudentCIN(listDiplomes[0].CIN));
                demoThread2.Start();
                for (int i = 0; i < listDiplomes.Count; i++)
                {
                    if (nbElementSelectionnes > 0)
                    {
                        Thread.Sleep(rand.Next(500, 2000));
                        demoThread  = new Thread(() => ThreadProcSafeNbDeletedElements((i + 1).ToString()));
                        demoThread1 = new Thread(() => ThreadProcSafeIdentifier(listDiplomes[i].ID));
                        demoThread.Start();
                        demoThread1.Start();
                        BLDiplome.Delete(listDiplomes[i].ID);
                        BGProgressBar.ReportProgress((i + 1) * 100 / nbElementSelectionnes);
                    }
                }
            }

            MessageBox.Show("Suppression terminée", "Suppression", MessageBoxButtons.OK, MessageBoxIcon.Information);
            this.deleted = true;
            this.Invoke((Action)(() => { this.Dispose(); }));
        }