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

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

            vehi.SelectedData = null;

            this.Close();
        }
Exemplo 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("CanEditTypePrix"))
                        {
                            viewM = this.Main.DataContext as TypePrixViewModel;

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

                            if (view.Msg == "OK")
                            {
                                MessageBox.Show("Opération effectuée avec succès", "TypePrix", MessageBoxButton.OK, MessageBoxImage.Information);
                                viewM.Refresh();
                            }
                            else if (view.Msg == "Error")
                            {
                                MessageBox.Show("    Echec Opération    ", "TypePrix", 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);
                    }
                }
            }
        }
Exemplo n.º 4
0
        public InsertData(string etat, TypePrix ele, TypePrixViewModel view)
        {
            InitializeComponent();

            this.DataContext = viewVM = view;

            Etat = etat;

            if (etat == "AJOUT")
            {
                this.Title = "Enregistrement d'un Quartier";
            }
            else
            {
                this.Title = "Modification d'un Quartier";
            }
        }
Exemplo n.º 5
0
        private void btnValider_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                TypePrixViewModel vm  = this.DataContext as TypePrixViewModel;
                TypePrix          ent = vm.SelectedData;

                if (Etat == "AJOUT")
                {
                    try
                    {
                        ent.Etat    = "ACTIF";
                        ent.idHotel = 1;
                        viewVM.model.TypePrix.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)
            {
            }
        }
Exemplo n.º 6
0
        private void btnEdit_Click(object sender, RoutedEventArgs e)
        {
            if (dataGrid.SelectedItem != null)
            {
                try
                {
                    //if (GlobalData.VerificationDroit("CanAddTypePrix"))
                    //{
                    viewM = this.Main.DataContext as TypePrixViewModel;
                    InsertData view = new InsertData("MOD", viewM.SelectedData, viewM);
                    view.ShowDialog();

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

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

            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 TypePrixViewModel;
                        TypePrix ent = dataGrid.SelectedItem as TypePrix;
                        ent.Etat = "SUPPRIMER";

                        viewM.model.SaveChanges();

                        viewM.Refresh();

                        MessageBox.Show("Opération effectuée avec succès", "TypePrix", MessageBoxButton.OK, MessageBoxImage.Information);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, "TypePrix", MessageBoxButton.OK, MessageBoxImage.Warning);
                        viewM.Refresh();
                    }
                }
                else
                {
                    MessageBox.Show("Aucune ligne selectionnée dans la liste", "TypePrix", MessageBoxButton.OK, MessageBoxImage.Warning);
                }
            }
            //}
        }
Exemplo n.º 8
0
 private void btnRefresh_Click(object sender, RoutedEventArgs e)
 {
     viewM = this.Main.DataContext as TypePrixViewModel;
     viewM.Refresh();
 }