Ejemplo n.º 1
0
 public FrmEvenementList()
 {
     InitializeComponent();
     guna2DataGridViewEvenement.AutoGenerateColumns = false;
     evenementBLO = new EvenementBLO(ConfigurationManager.AppSettings["DbFolder"]);
 }
Ejemplo n.º 2
0
        private void guna2GradientCreer_Click(object sender, EventArgs e)
        {
            try
            {
                checkForm();

                Evenement newEvenement = new Evenement
                                         (
                    guna2TxtTitre.Text,
                    guna2TxtDescription.Text,
                    DateTime.Parse(guna2DateTimePickerDateEvenement.Text),
                    guna2TxtLieux.Text,
                    int.Parse(guna2TxtMontant.Text)
                                         );

                EvenementBLO evenementBLO = new EvenementBLO(ConfigurationManager.AppSettings["DbFolder"]);

                if (this.oldEvenement == null)
                {
                    evenementBLO.CreateEvenement(newEvenement);
                }
                else
                {
                    evenementBLO.EditEvenement(oldEvenement, newEvenement);
                }

                MessageBox.Show
                (
                    "Echeance creer !",
                    "Confirmation",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Information
                );

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

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

                guna2TxtTitre.Clear();
                guna2TxtDescription.Clear();
                guna2TxtMontant.Clear();
                guna2TxtLieux.Clear();

                guna2TxtTitre.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
                );
            }
        }