예제 #1
0
        private void btn_Valider_Click(object sender, RoutedEventArgs e)
        {
            this.SwipeMessages();
            string    nom        = this.tb_nom.Text;
            DateTime  _dateDebut = this.dp_dateDebut.SelectedDate.GetValueOrDefault();
            DateTime  _dateFin   = this.dp_dateFin.SelectedDate.GetValueOrDefault();
            Formation _formation = null;

            if (this.cb_lstFormations.SelectedItem != null)
            {
                _formation = LstFormations[(String)(this.cb_lstFormations.SelectedItem)];
            }
            try
            {
                Promotion promotion = PromotionDAO.CreerPromotion(nom, _dateDebut, _dateFin, _formation);
            }
            catch (Exception error)
            {
                this.tbk_error.Text       = "Erreur : " + error.Message;
                this.tbk_error.Visibility = Visibility.Visible;
                return;
            }
            this.tbk_statut.Text       = "Promotion Ajoutée.";
            this.tbk_statut.Visibility = Visibility.Visible;
        }
예제 #2
0
        private void searchPromotionsButton_Click(object sender = null, EventArgs e = null)
        {
            isSearch = true;

            promotions = PromotionDAO.GetPromotionsByMake((Make)makeDropDownBox.SelectedItem);
            updatePromotionsListBox(promotions);
        }
예제 #3
0
        //Get all promotions and update the list box
        private void allPromotionsButton_Click(object sender = null, EventArgs e = null)
        {
            isSearch = false;

            promotions = PromotionDAO.GetAllPromotions();
            updatePromotionsListBox(promotions);
        }
예제 #4
0
        //load all promotions by the make of the current vehicle
        private void initializePromotions()
        {
            List <Promotion> allPromotions = new List <Promotion>();

            allPromotions.Add(new Promotion());
            allPromotions.AddRange(PromotionDAO.GetPromotionsByMake(currentVehicle.Model.Make));
            promotionComboBox.DataSource = allPromotions;
        }
예제 #5
0
 private void mi_ajout_eleve_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         AjoutEleve ajoutEleve = new AjoutEleve(PromotionDAO.GetAll());
         this.Ajout.Content = ajoutEleve;
     }
     catch (Exception error)
     {
         this.error_message.Text = error.Message;
     }
 }
예제 #6
0
        private void confirmButton_Click(object sender, EventArgs e)
        {
            int discAmt = 0;

            try
            {
                discAmt = Int32.Parse(discountAmountTextBox.Text);

                if (mode == ADD_PROMOTION)
                {
                    Promotion promotion = new Promotion();
                    promotion.Make           = (Make)makeDropDownBox.SelectedItem;
                    promotion.discountAmount = discAmt;

                    if (promotion.Make != null && promotion.discountAmount != 0 && promotion.discountAmount > 0)
                    {
                        PromotionDAO.AddPromotion(promotion);
                        promotionsForm.ReloadPromotions();
                        this.Close();
                    }
                    else
                    {
                        //TODO: should show a different error message depending on what value is null
                        MessageBox.Show("Invalid input!", "Invalid Input", MessageBoxButtons.OK);
                    }
                }
                else if (mode == EDIT_PROMOTION)
                {
                    currentPromotion.Make           = (Make)makeDropDownBox.SelectedItem;
                    currentPromotion.discountAmount = discAmt;

                    if (currentPromotion.Make != null && currentPromotion.discountAmount != 0 && currentPromotion.discountAmount > 0)
                    {
                        PromotionDAO.EditPromotion(currentPromotion);
                        promotionsForm.ReloadPromotions();
                        this.Close();
                    }
                    else
                    {
                        //TODO: should show a different error message depending on what value is null
                        MessageBox.Show("Invalid input!", "Invalid Input", MessageBoxButtons.OK);
                    }
                }
            }
            catch
            {
                MessageBox.Show("Invalid input!", "Invalid Input", MessageBoxButtons.OK);
            }
        }
예제 #7
0
        private void removePromotionButton_Click(object sender, EventArgs e)
        {
            //confirm deletion of the promotion
            var confirmResult = MessageBox.Show("Are you sure to delete this promotion?", "Confirm Deletion of Promotion", MessageBoxButtons.YesNo);

            if (confirmResult == DialogResult.Yes)
            {
                PromotionDAO.RemovePromotion((Promotion)promotionsListBox.SelectedItem);
                Promotion deletedPromotion = (Promotion)promotionsListBox.SelectedItem;
                promotions.Remove(deletedPromotion);

                promotionsListBox.DataSource = null;
                promotionsListBox.DataSource = promotions;

                Console.WriteLine("Promotion successfully deleted");
            }
        }
 public InformationDichVu()
 {
     this._promotionDAO = (PromotionDAO) new PromotionDAOImpl();
     this._giftDAO      = (GiftDAO) new GiftDAOImpl();
 }