コード例 #1
0
 public FormStudentList()
 {
     InitializeComponent();
     dataGridView1.AutoGenerateColumns = false;
     studentBLO = new StudentBLO(ConfigurationManager.AppSettings["DbFolder"]);
     schoolBLO  = new SchoolBLO(ConfigurationManager.AppSettings["DbFolder"]);
 }
コード例 #2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                School newSchool = new School
                                   (
                    txtName.Text.ToUpper(),
                    txtLocalisation.Text,
                    long.Parse(txtContact.Text),
                    pictureBox1.ImageLocation
                                   );

                SchoolBLO schoolBLO = new SchoolBLO(ConfigurationManager.AppSettings["DbFolder"]);
                if (this.oldSchool == null)
                {
                    SchoolBLO.CreateSchool(oldSchool, newSchool);
                }
                else
                {
                    SchoolDAO.EditSchool(oldSchool, newSchool);
                }

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

                Close();
            }
            catch (TypingException ex)
            {
                MessageBox.Show
                (
                    ex.Message,
                    "Typing error",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Warning
                );
            }
            catch (Exception ex)
            {
                ex.WriteToFile();
                MessageBox.Show
                (
                    "An error occurred! Please try again later.",
                    "Erreur",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error
                );
            }
        }
コード例 #3
0
 public FormSchoolEdit()
 {
     InitializeComponent();
     schoolBLO = new SchoolBLO(ConfigurationManager.AppSettings["DbFolder"]);
     oldSchool = schoolBLO.GetSchool();
     if (oldSchool != null)
     {
         txtEmail.Text             = oldSchool.EmailSchool;
         txtName.Text              = oldSchool.NameSchool;
         txtContact.Text           = oldSchool.ContactSchool.ToString();
         pictureBox1.ImageLocation = oldSchool.Logo;
     }
 }
コード例 #4
0
ファイル: FrmSchoolEdit.cs プロジェクト: willytchana/CCC01
 public FrmSchoolEdit()
 {
     InitializeComponent();
     schoolBLO = new SchoolBLO();
 }
コード例 #5
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                checkForm();

                School newSchool = new School
                                   (
                    txtNom.Text,
                    txtEmail.Text,
                    int.Parse(txtTel.Text),
                    txtContact.Text,
                    !string.IsNullOrEmpty(pictureBox1.ImageLocation) ? File.ReadAllBytes(pictureBox1.ImageLocation) : this.oldSchool?.Photo
                                   );

                SchoolBLO schoolBLO = new SchoolBLO(ConfigurationManager.AppSettings["DbFolder"]);

                if (this.oldSchool == null)
                {
                    schoolBLO.CreateSchool(newSchool);
                }
                else
                {
                    schoolBLO.EditSchool(oldSchool, newSchool);
                }

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

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

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

                txtNom.Clear();
                txtEmail.Clear();
                txtTel.Clear();
                txtContact.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
                );
            }
        }