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
 public FormEditEcole()
 {
     InitializeComponent();
     ecoleBLO = new EcoleBLO(ConfigurationManager.AppSettings["DbFolder"]);
     oldEcole = ecoleBLO.GetEcole();
     if (oldEcole != null)
     {
         txtNom.Text               = oldEcole.Nom;
         txtIdentifiant.Text       = oldEcole.Identifiant;
         pictureBox1.ImageLocation = oldEcole.Logo;
     }
 }
Exemplo n.º 3
0
 public FrmCreateEcole()
 {
     InitializeComponent();
     ecoleBLO = new EcoleBLO(ConfigurationManager.AppSettings["DbFolder"]);
     oldEcole = ecoleBLO.GetEcole();
     if (oldEcole != null)
     {
         email.Text        = oldEcole.email;
         NomEcole.Text     = oldEcole.NomEcole;
         localisation.Text = oldEcole.lieu;
         tel.Text          = oldEcole.tel.ToString();
         BP.Text           = oldEcole.BP;
     }
 }
Exemplo n.º 4
0
 public FrmEcoleEdit()
 {
     InitializeComponent();
     etudiantsBLO = new EtudiantBLO(ConfigurationManager.AppSettings["DbFolder"]);
     ecoleBLO     = new EcoleBLO(ConfigurationManager.AppSettings["DbFolder"]);
 }
Exemplo n.º 5
0
        private void btnSave_Click_1(object sender, EventArgs e)
        {
            try
            {
                checkForm();

                Ecole newEcole = new Ecole
                                 (
                    txtName.Text.ToUpper(),
                    txtPostalCode.Text,
                    long.Parse(txtPhone.Text),
                    txtEmail.Text,
                    !string.IsNullOrEmpty(pictureBox1.ImageLocation) ? File.ReadAllBytes(pictureBox1.ImageLocation) : this.oldEcole?.Logo
                                 );

                EcoleBLO ecoleBLO = new EcoleBLO(ConfigurationManager.AppSettings["DbFolder"]);

                if (this.oldEcole == null)
                {
                    ecoleBLO.CreateEcole(newEcole);
                }
                else
                {
                    ecoleBLO.EditEcole(oldEcole, newEcole);
                }

                MessageBox.Show
                (
                    "Save done !",
                    "Confirmation",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Information
                );
                if (callBack != null)
                {
                    callBack();
                }

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

                txtName.Clear();
                txtPhone.Clear();
                txtPostalCode.Focus();
                txtEmail.Clear();
            }
            catch (TypingException ex)
            {
                MessageBox.Show
                (
                    ex.Message,
                    "Typing error",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Warning
                );
            }
            catch (Exception ex)
            {
                MessageBox.Show
                (
                    ex.Message,
                    "Duplicate error",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Warning
                );
            }
        }
Exemplo n.º 6
0
        private void btnEnregistrer_Click(object sender, EventArgs e)
        {
            try
            {
                CheckForm();

                Ecole newEco = new Ecole(
                    !String.IsNullOrEmpty(pictureBoxLogo.ImageLocation) ? File.ReadAllBytes(pictureBoxLogo.ImageLocation) : this.oldEco?.Logo,
                    txtNomEcole.Text.ToUpper(),
                    long.Parse(txtContactEcole.Text),
                    txtEmailEcole.Text
                    );

                EcoleBLO ecoBlo = new EcoleBLO(ConfigurationManager.AppSettings["DbFolder"]);
                if (this.oldEco == null)
                {
                    ecoBlo.CreateEcole(newEco);
                }
                else
                {
                    ecoBlo.EditEcole(oldEco, newEco);
                }
                ecoBlo.CreateEcole(newEco);
                MessageBox.Show(
                    "Enregistrement éffectué !",
                    "Confirmé",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Information
                    );
                if (callback != null)
                {
                    callback();
                }

                if (oldEco != null)
                {
                    Close();
                }
                txtNomEcole.Clear();
                txtEmailEcole.Clear();
                txtContactEcole.Clear();
                txtNomEcole.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();
        }
Exemplo n.º 7
0
 public FormListEcole()
 {
     InitializeComponent();
     ecoleBLO = new EcoleBLO(ConfigurationManager.AppSettings["DbFolder"]);
 }
Exemplo n.º 8
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     try
     {
         checkForm();
         string filename = null;
         if (!string.IsNullOrEmpty(pictureBox2.ImageLocation))//hum
         {
             string ext = Path.GetExtension(pictureBox2.ImageLocation);
             filename = Guid.NewGuid().ToString() + ext;
             FileInfo fileSource = new FileInfo(pictureBox2.ImageLocation);
             string   filePath   = Path.Combine(ConfigurationManager.AppSettings["DbFolder"], "logoE", filename);
             FileInfo fileDest   = new FileInfo(filePath);
             if (!fileDest.Directory.Exists)
             {
                 fileDest.Directory.Create();
             }
             fileSource.CopyTo(fileDest.FullName);
         }
         Ecole newEcole = new Ecole(
             textBoxIntitule.Text.ToUpper(),
             long.Parse(textBoxTelephone.Text),
             textBoxEcomail.Text,
             !string.IsNullOrEmpty(pictureBox2.ImageLocation) ? File.ReadAllBytes(pictureBox2.ImageLocation) : this.oldEcole?.Logo
             );
         EcoleBLO ecoblo = new EcoleBLO(ConfigurationManager.AppSettings["DbFolder"]);
         if (this.oldEcole == null)
         {
             ecoblo.CreateEtudiant(newEcole);
         }
         else
         {
             ecoblo.EditEtudiant(oldEcole, newEcole);
         }
         MessageBox.Show(
             "Save done !",
             "Confirm",
             MessageBoxButtons.OK,
             MessageBoxIcon.Information
             );
         if (callBack != null)
         {
             callBack();
         }
         if (oldEcole != null)
         {
             Close();
         }
         textBoxIntitule.Clear();
         textBoxEcomail.Clear();
         textBoxTelephone.Clear();
     }
     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
         );
     }
 }