コード例 #1
0
        /// <summary>
        /// Ouvre la facture séléctionnée à l'aide d'une nouvelle fenêtre
        /// </summary>
        public Facture_Libre Open()
        {
            if (this._DataGridMain.SelectedItem != null)
            {
                if (this._DataGridMain.SelectedItems.Count == 1)
                {
                    //Affichage du message "modification en cours"
                    ((App)App.Current)._theMainWindow.progressBarMainWindow.IsIndeterminate = true;
                    ((App)App.Current)._theMainWindow.changementTexteStatusBar("Modification d'une facture en cours ...");

                    //Création de la fenêtre
                    FactureLibreWindow factureWindow = new FactureLibreWindow();

                    //Initialisation du Datacontext en Commande_Fournisseur et association à la Commande_Fournisseur sélectionnée
                    factureWindow.DataContext = new Facture_Libre();
                    factureWindow.DataContext = (Facture_Libre)this._DataGridMain.SelectedItem;

                    //booléen nullable vrai ou faux ou null
                    bool? dialogResult = factureWindow.ShowDialog();

                    if (dialogResult.HasValue && dialogResult.Value == true)
                    {
                        //Si j'appuie sur le bouton Ok, je renvoi l'objet DAO se trouvant dans le datacontext de la fenêtre
                        return (Facture_Libre)factureWindow.DataContext;
                    }
                    else
                    {
                        //Je récupère les anciennes données de la base sur les modifications effectuées
                        ((App)App.Current).mySitaffEntities.Refresh(System.Data.Objects.RefreshMode.StoreWins, (Facture_Libre)(this._DataGridMain.SelectedItem));
                        //La commande étant un objet "critique" au niveau des associations, je refresh l'edmx et je relance le filtrage s'il y en avait un afin d'avoir les mêmes infos (invisible pour l'user)
                        ((App)App.Current).refreshEDMXSansVidage();
                        this.filtrage();

                        //Si j'appuie sur le bouton annuler, je préviens que j'annule ma modification
                        ((App)App.Current)._theMainWindow.progressBarMainWindow.IsIndeterminate = false;
                        this.recalculMax();
                        ((App)App.Current)._theMainWindow.changementTexteStatusBar("Modification d'une facture annulée : " + this.listFacture.Count() + " / " + this.max);

                        return null;
                    }
                }
                else
                {
                    MessageBox.Show("Vous ne devez sélectionner qu'une seule facture.", "Attention", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                    return null;
                }
            }
            else
            {
                MessageBox.Show("Vous devez sélectionner une facture.", "Attention", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                return null;
            }
        }
コード例 #2
0
        /// <summary>
        /// duplique une Commande_Fournisseur à la liste à l'aide d'une nouvelle fenêtre
        /// </summary>
        public Facture_Libre Duplicate()
        {
            if (this._DataGridMain.SelectedItem != null)
            {
                if (this._DataGridMain.SelectedItems.Count == 1)
                {
                    //Affichage du message "ajout en cours"
                    ((App)App.Current)._theMainWindow.progressBarMainWindow.IsIndeterminate = true;
                    ((App)App.Current)._theMainWindow.changementTexteStatusBar("Dupliquer une facture en cours ...");

                    //Création de la fenêtre
                    FactureLibreWindow factureWindow = new FactureLibreWindow();

                    //Duplication de la commande sélectionnée
                    Facture_Libre tmp = new Facture_Libre();
                    tmp = duplicateCommande((Facture_Libre)this._DataGridMain.SelectedItem);

                    //Association de l'élement dupliqué au datacontext de la fenêtre
                    factureWindow.DataContext = tmp;

                    //booléen nullable vrai ou faux ou null
                    bool? dialogResult = factureWindow.ShowDialog();

                    if (dialogResult.HasValue && dialogResult.Value == true)
                    {
                        return (Facture_Libre)factureWindow.DataContext;
                    }
                    else
                    {
                        try
                        {
                            //On détache la commande
                            ((App)App.Current).mySitaffEntities.Detach((Facture_Libre)factureWindow.DataContext);
                        }
                        catch (Exception)
                        {
                        }

                        //Si j'appuie sur le bouton annuler, je préviens que j'annule mon ajout
                        ((App)App.Current)._theMainWindow.progressBarMainWindow.IsIndeterminate = false;
                        this.recalculMax();
                        ((App)App.Current)._theMainWindow.changementTexteStatusBar("Dupliquer une facture annulé : " + this.listFacture.Count() + " / " + this.max);

                        return null;
                    }
                }
                else
                {
                    MessageBox.Show("Vous ne devez sélectionner qu'une seule facture.", "Attention", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                    return null;
                }
            }
            else
            {
                MessageBox.Show("Vous devez sélectionner une facture.", "Attention", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                return null;
            }
        }
コード例 #3
0
        /// <summary>
        /// Ouvre la facture séléctionnée en lecture seule à l'aide d'une nouvelle fenêtre
        /// </summary>
        public Facture_Libre Look()
        {
            if (this._DataGridMain.SelectedItem != null)
            {
                if (this._DataGridMain.SelectedItems.Count == 1)
                {
                    //Affichage du message "affichage en cours"
                    ((App)App.Current)._theMainWindow.progressBarMainWindow.IsIndeterminate = true;
                    ((App)App.Current)._theMainWindow.changementTexteStatusBar("Affichage d'une facture en cours ...");

                    //Création de la fenêtre
                    FactureLibreWindow factureWindow = new FactureLibreWindow();

                    //Initialisation du Datacontext en Commande_Fournisseur et association à la Commande_Fournisseur sélectionnée
                    factureWindow.DataContext = new Facture_Libre();
                    factureWindow.DataContext = (Facture_Libre)this._DataGridMain.SelectedItem;

                    //Je positionne la lecture seule sur la fenêtre
                    factureWindow.lectureSeule();
                    factureWindow.soloLecture = true;

                    //J'affiche la fenêtre
                    bool? dialogResult = factureWindow.ShowDialog();

                    //Affichage du message "affichage en cours"
                    ((App)App.Current)._theMainWindow.progressBarMainWindow.IsIndeterminate = false;
                    ((App)App.Current)._theMainWindow.changementTexteStatusBar("Affichage d'une facture terminé : " + this.listFacture.Count() + " / " + this.max);

                    //Renvoi null
                    return null;
                }
                else
                {
                    MessageBox.Show("Vous ne devez sélectionner qu'une seule facture.", "Attention", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                    return null;
                }
            }
            else
            {
                MessageBox.Show("Vous devez sélectionner une facture.", "Attention", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                return null;
            }
        }
コード例 #4
0
        /// <summary>
        /// Ajoute une nouvelle Facture à la liste à l'aide d'une nouvelle fenêtre
        /// </summary>
        public Facture_Libre Add()
        {
            //Affichage du message "ajout en cours"
            ((App)App.Current)._theMainWindow.progressBarMainWindow.IsIndeterminate = true;
            ((App)App.Current)._theMainWindow.changementTexteStatusBar("Ajout d'une facture en cours ...");

            //Initialisation de la fenêtre
            FactureLibreWindow factureWindow = new FactureLibreWindow();

            //Création de l'objet temporaire
            Facture_Libre tmp = new Facture_Libre();

            //Mise de l'objet temporaire dans le datacontext
            factureWindow.DataContext = tmp;

            //booléen nullable vrai ou faux ou null
            bool? dialogResult = factureWindow.ShowDialog();

            if (dialogResult.HasValue && dialogResult.Value == true)
            {
                //Si j'appuie sur le bouton Ok, je renvoi l'objet Facture_Libre se trouvant dans le datacontext de la fenêtre
                return (Facture_Libre)factureWindow.DataContext;
            }
            else
            {
                try
                {
                    //On détache la Facture_Libre
                    ((App)App.Current).mySitaffEntities.Detach(((Facture_Libre)factureWindow.DataContext).Litige_Facture_Client_Libre);
                    ((App)App.Current).mySitaffEntities.Detach((Facture_Libre)factureWindow.DataContext);
                }
                catch (Exception)
                {
                    try
                    {
                        //On détache la Facture_Libre
                        ((App)App.Current).mySitaffEntities.Detach((Facture_Libre)factureWindow.DataContext);
                        ((App)App.Current).mySitaffEntities.Detach(((Facture_Libre)factureWindow.DataContext).Litige_Facture_Client_Libre);
                    }
                    catch (Exception)
                    {
                    }
                }

                //Si j'appuie sur le bouton annuler, je préviens que j'annule mon ajout
                ((App)App.Current)._theMainWindow.progressBarMainWindow.IsIndeterminate = false;
                this.recalculMax();
                ((App)App.Current)._theMainWindow.changementTexteStatusBar("Ajout d'une facture annulé : " + this.listFacture.Count() + " / " + this.max);

                return null;
            }
        }