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 ); } }
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 ); } }
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 ); } }
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); } }
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 * );*/ }
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 ); } }
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 ); } }
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); }