Exemplo n.º 1
0
 public FrmStudentCardList()
 {
     InitializeComponent();
     dataGridView1.AutoGenerateColumns = false;
     studentBLO = new StudentBLO(ConfigurationManager.AppSettings["DbFolder"]);
   
 }
Exemplo n.º 2
0
 public FrmStudent()
 {
     InitializeComponent();
     dataGridView1.AutoGenerateColumns = false;
     studentBLO    = new StudentBLO(ConfigurationManager.AppSettings["DbFolder"]);
     universityBLO = new UniversityBLO(ConfigurationManager.AppSettings["DbFolder"]);
     pb            = new PictureBox();
 }
Exemplo n.º 3
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                Student newStudent = new Student
                                     (
                    txtUniversity.Text.ToUpper(),
                    txtFirstname.Text,
                    txtLastname.Text,
                    txtDate.Text,
                    txtLocationStudent.Text,
                    long.Parse(txtContactStudent.Text),
                    !string.IsNullOrEmpty(pictureBoxStudent.ImageLocation) ? File.ReadAllBytes(pictureBoxStudent.ImageLocation) : this.oldStudent?.Picture
                                     );

                StudentBLO productBLO = new StudentBLO(ConfigurationManager.AppSettings["DbFolder"]);

                if (this.oldStudent == null)
                {
                    productBLO.CreateStudent(newStudent);
                }
                else
                {
                    productBLO.EditStudent(oldStudent, newStudent);
                }

                MessageBox.Show
                (
                    "Save done !",
                    "Confirmation",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Information
                );

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

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

                txtUniversity.Clear();
                txtLastname.Clear();
                txtFirstname.Clear();
                txtDate.Clear();
                txtContactStudent.Clear();
                txtLocationStudent.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.º 4
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                checkForm();
                string sex;

                if (radioButton1.Checked)
                {
                    sex = radioButton1.Text;
                }
                else if (radioButton2.Checked)
                {
                    sex = radioButton2.Text;
                }
                else
                {
                    sex = "";
                }


                Student newStudent = new Student(
                    txtFirstName.Text,
                    txtLastName.Text,
                    txtEmail.Text,
                    long.Parse(txtTel.Text),
                    sex,
                    Convert.ToDateTime(dateTimePicker1.Value),
                    txtAt.Text,
                    !string.IsNullOrEmpty(pictureBox1.ImageLocation) ? File.ReadAllBytes(pictureBox1.ImageLocation) : this.oldStudent?.Photo,
                    !string.IsNullOrEmpty(pb.ImageLocation) ? File.ReadAllBytes(pb.ImageLocation) : this.oldStudent?.QrCode
                    );

                QRCodeGenerator qr   = new QRCodeGenerator();
                QRCodeData      data = qr.CreateQrCode(newStudent.Matricule, QRCodeGenerator.ECCLevel.Q);
                QRCode          code = new QRCode(data);
                pb.Image = code.GetGraphic(20);


                StudentBLO studentBLO = new StudentBLO(ConfigurationManager.AppSettings["DbFolder"]);

                if (this.oldStudent == null)
                {
                    studentBLO.CreateStudent(newStudent);
                }
                else
                {
                    studentBLO.EditStudent(oldStudent, newStudent);
                }


                MessageBox.Show(
                    "Save Done !",
                    "Confirmation",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Information
                    );


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

                //if (oldStudent != null)
                //    Close();

                txtFirstName.Clear();
                txtLastName.Clear();
                radioButton1.Checked = false;
                radioButton2.Checked = false;
                txtAt.Clear();
                dateTimePicker1.Value     = DateTime.Now;
                pictureBox1.ImageLocation = null;
                txtTel.Clear();
                txtEmail.Clear();
                txtFirstName.Focus();
                loadData();

                //QRCodeGenerator qr = new QRCodeGenerator();
                //QRCodeData data = qr.CreateQrCode(oldStudent.Matricule, QRCodeGenerator.ECCLevel.Q);
                //QRCode code = new QRCode(data);
            }
            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.º 5
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);
                }
                Student newStudent = new Student
                                     (
                    txtMatricule.Text.ToUpper(),
                    txtNom.Text,
                    txtPrenom.Text,
                    txtDate.Text,
                    txtLieu.Text,
                    long.Parse(txtContact.Text),
                    !string.IsNullOrEmpty(pictureBox1.ImageLocation) ? File.ReadAllBytes(pictureBox1.ImageLocation) : this.oldStudent?.Photo
                                     );

                StudentBLO studentBLO = new StudentBLO(ConfigurationManager.AppSettings["DbFolder"]);

                if (this.oldStudent == null)
                {
                    studentBLO.CreateStudent(newStudent);
                }
                else
                {
                    studentBLO.EditStudent(oldStudent, newStudent);
                }

                MessageBox.Show
                (
                    "Save done !",
                    "Confirmation",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Information
                );

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

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

                txtNom.Clear();
                txtPrenom.Clear();
                txtDate.Clear();
                txtContact.Clear();
                txtLieu.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.º 6
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                checkForm();

                Student newStudent = new Student
                                     (
                    txtMatricule.Text.ToUpper(),
                    txtNom.Text,
                    txtPrenom.Text,
                    DateTime.Parse(txtDateNaisssance.Text),
                    txtLieu.Text,
                    txtEmail.Text,
                    txtContact.Text,
                    !string.IsNullOrEmpty(pictureBox1.ImageLocation) ? File.ReadAllBytes(pictureBox1.ImageLocation) : this.oldStudent?.Photo
                                     );

                StudentBLO studentBLO = new StudentBLO(ConfigurationManager.AppSettings["DbFolder"]);

                if (this.oldStudent == null)
                {
                    studentBLO.CreateStudent(newStudent);
                }
                else
                {
                    studentBLO.EditStudent(oldStudent, newStudent);
                }

                MessageBox.Show
                (
                    "Save done !",
                    "Confirmation",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Information
                );

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

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

                txtMatricule.Clear();
                txtNom.Clear();
                txtPrenom.Clear();
                txtDateNaisssance.Clear();
                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();
                MessageBox.Show
                (
                    "An error occurred! Please try again later.",
                    "Erreur",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error
                );
            }
        }
Exemplo n.º 7
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            //string barCode = txtRegisterNumber.Text;
            //Zen.Barcode.Code128BarcodeDraw brCode = Zen.Barcode.BarcodeDrawFactory.Code128WithChecksum;
            //pictureBox2 .Image = brCode.Draw(barCode, 60);

            try
            {
                checkForm();
                Student newStudent = new Student
                                     (
                    txtRegisterNumber.Text,
                    txtName.Text,
                    txtSurname.Text,
                    DateTime.Parse(dtpBirthday.Text),
                    txtPlaceBirth.Text,
                    long.Parse(txtTelephone.Text),
                    txtEmail.Text,
                    txtNameSchool.Text,
                    !string.IsNullOrEmpty(pictureBox1.ImageLocation) ? File.ReadAllBytes(pictureBox1.ImageLocation) : this.oldStudent?.Picture
                                     );
                StudentBLO studentBLO1 = new StudentBLO(ConfigurationManager.AppSettings["DbFolder"]);
                StudentBLO studentBLO  = studentBLO1;

                if (this.oldStudent == null)
                {
                    studentBLO.CreateStudent(newStudent);
                }
                else
                {
                    studentBLO.EditStudent(oldStudent, newStudent);
                }

                MessageBox.Show
                (
                    "Save done !",
                    "Confirmation",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Information
                );

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

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

                txtRegisterNumber.Clear();
                txtName.Clear();
                txtSurname.Clear();
                txtPlaceBirth.Clear();
                txtTelephone.Clear();
                txtEmail.Clear();
                txtNameSchool.Clear();
                txtRegisterNumber.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
                );
            }
        }