Ejemplo n.º 1
0
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                viewM = this.Main.DataContext as ReductionsViewModel;
                viewM.SelectedData = new Reductions();
                InsertData view = new InsertData("AJOUT", viewM.SelectedData, viewM);
                view.ShowDialog();

                if (view.Msg == "OK")
                {
                    MessageBox.Show("Opération effectuée avec succès", "Reductions", MessageBoxButton.OK, MessageBoxImage.Information);
                    viewM.Refresh();
                }
                else if (view.Msg == "Error")
                {
                    MessageBox.Show("   Echec Opération    ", "Reductions ", MessageBoxButton.OK, MessageBoxImage.Warning);
                    viewM.Refresh();
                }
                else
                {
                    viewM.Refresh();
                }
                //}
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Reductions", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }
Ejemplo n.º 2
0
        private void btnAnnuler_Click(object sender, RoutedEventArgs e)
        {
            ReductionsViewModel vehi = this.DataContext as ReductionsViewModel;

            vehi.SelectedData = null;

            this.Close();
        }
Ejemplo n.º 3
0
        //Evenement double clic du RadGridview
        void OnGridMouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            FrameworkElement originalSender = e.OriginalSource as FrameworkElement;

            if (originalSender != null)
            {
                //var cell = originalSender.ParentOfType<GridViewCell>();
                //if (cell != null)
                //{
                //    MessageBox.Show("The double-clicked cell is " + cell.Value);
                //}

                var row = originalSender.ParentOfType <GridViewRow>();
                if (row != null)
                {
                    try
                    {
                        if (GlobalData.VerificationDroit("CanEditReductions"))
                        {
                            viewM = this.Main.DataContext as ReductionsViewModel;

                            InsertData view = new InsertData("MOD", viewM.SelectedData, viewM);
                            view.ShowDialog();

                            if (view.Msg == "OK")
                            {
                                MessageBox.Show("Opération effectuée avec succès", "Reductions", MessageBoxButton.OK, MessageBoxImage.Information);
                                viewM.Refresh();
                            }
                            else if (view.Msg == "Error")
                            {
                                MessageBox.Show("    Echec Opération    ", "Reductions", MessageBoxButton.OK, MessageBoxImage.Warning);
                                viewM.Refresh();
                            }
                            else
                            {
                                viewM.Refresh();
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message + "Veuillez fermer le formulaire puis recommencer.", "CATEGORIE", MessageBoxButton.OK, MessageBoxImage.Warning);
                    }
                }
            }
        }
Ejemplo n.º 4
0
        public InsertData(string etat, Reductions ele, ReductionsViewModel view)
        {
            InitializeComponent();

            this.DataContext = viewVM = view;

            Etat = etat;

            if (etat == "AJOUT")
            {
                this.Title = "Enregistrement d'un Quartier";
            }
            else
            {
                this.Title = "Modification d'un Quartier";
            }
        }
Ejemplo n.º 5
0
        private void btnEdit_Click(object sender, RoutedEventArgs e)
        {
            if (dataGrid.SelectedItem != null)
            {
                try
                {
                    //if (GlobalData.VerificationDroit("CanAddReductions"))
                    //{
                    viewM = this.Main.DataContext as ReductionsViewModel;
                    InsertData view = new InsertData("MOD", viewM.SelectedData, viewM);
                    view.ShowDialog();

                    if (view.Msg == "OK")
                    {
                        MessageBox.Show("Opération effectuée avec succès", "Reductions", MessageBoxButton.OK, MessageBoxImage.Information);
                        viewM.Refresh();
                    }
                    else if (view.Msg == "Error")
                    {
                        MessageBox.Show("    Echec Opération    ", "Reductions", MessageBoxButton.OK, MessageBoxImage.Warning);
                        viewM.Refresh();
                    }
                    else
                    {
                        viewM.Refresh();
                    }

                    //}
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Reductions", MessageBoxButton.OK, MessageBoxImage.Warning);
                }
            }
            else
            {
                MessageBox.Show("Aucune ligne selectionnée dans la liste", "Reductions", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }
Ejemplo n.º 6
0
        private void btnDelete_Click(object sender, RoutedEventArgs e)
        {
            //if (GlobalData.VerificationDroit("CanAddReductions"))
            //{

            var result = MessageBox.Show("Voulez vous vraiment supprimer ?", "Message", MessageBoxButton.YesNo, MessageBoxImage.Question);

            if (result == MessageBoxResult.Yes)
            {
                if (dataGrid.SelectedItem != null)
                {
                    try
                    {
                        viewM = this.Main.DataContext as ReductionsViewModel;
                        Reductions ent = dataGrid.SelectedItem as Reductions;
                        ent.Etat = "SUPPRIMER";

                        viewM.model.SaveChanges();

                        viewM.Refresh();

                        MessageBox.Show("Opération effectuée avec succès", "Reductions", MessageBoxButton.OK, MessageBoxImage.Information);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, "Reductions", MessageBoxButton.OK, MessageBoxImage.Warning);
                        viewM.Refresh();
                    }
                }
                else
                {
                    MessageBox.Show("Aucune ligne selectionnée dans la liste", "Reductions", MessageBoxButton.OK, MessageBoxImage.Warning);
                }
            }
            //}
        }
Ejemplo n.º 7
0
        private void btnValider_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                ReductionsViewModel vm  = this.DataContext as ReductionsViewModel;
                Reductions          ent = vm.SelectedData;

                if (Etat == "AJOUT")
                {
                    try
                    {
                        if (prct.IsChecked == true)
                        {
                            ent.Type = 2;
                        }
                        else
                        {
                            ent.Type = 1;
                        }

                        if (open.IsChecked == true)
                        {
                            ent.OpenReduction = true;
                        }
                        else
                        {
                            ent.OpenReduction = false;
                        }

                        ent.Etat    = "ACTIF";
                        ent.idHotel = 1;
                        viewVM.model.Reductions.Add(ent);
                        viewVM.model.SaveChanges();
                        Msg = "OK";
                        this.Close();
                    }
                    catch (Exception ex)
                    {
                        Msg      = "Error";
                        ErrorMsg = ex.Message;
                    }
                }
                else
                {
                    try
                    {
                        viewVM.model.SaveChanges();

                        Msg = "OK";
                        this.Close();
                    }
                    catch (Exception ex)
                    {
                        Msg      = "Error";
                        ErrorMsg = ex.Message;
                    }
                }
            }
            catch (Exception)
            {
            }
        }
Ejemplo n.º 8
0
 private void btnRefresh_Click(object sender, RoutedEventArgs e)
 {
     viewM = this.Main.DataContext as ReductionsViewModel;
     viewM.Refresh();
 }