Exemplo n.º 1
0
        private void MenuItem_Click(object sender, RoutedEventArgs e)
        {
            if (CommandeSelectionne != null && CommandeSelectionne.Sync)
            {
                if (MessageBox.Show("Voulez-vous supprimer le marquage de la commande n° " + CommandeSelectionne.id_order
                                    + " afin de la recréer dans Sage ?\n\nAttention au statut de la commande !", "Suppression mappage commande",
                                    MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes)
                {
                    Model.Local.OrderRepository OrderRepository = new Model.Local.OrderRepository();
                    if (OrderRepository.ExistPrestashop((int)CommandeSelectionne.id_order))
                    {
                        OrderRepository.Delete(OrderRepository.ReadPrestashop((int)CommandeSelectionne.id_order));
                    }

                    Model.Local.OrderPaymentRepository OrderPayementRepository = new Model.Local.OrderPaymentRepository();
                    foreach (Model.Local.OrderPayment OrderPayment in OrderPayementRepository.ListOrder((int)CommandeSelectionne.id_order))
                    {
                        OrderPayementRepository.Delete(OrderPayment);
                    }
                }
            }
        }
Exemplo n.º 2
0
        public SynchronisationPaiement()
        {
            this.InitializeComponent();
            this.LabelInformation.Content = "Recherche des paiements à copier ...";

            this.worker.WorkerReportsProgress = true;
            this.worker.DoWork += delegate(object s, DoWorkEventArgs args)
            {
                if (Core.Global.GetConfig().SyncReglementActif)
                {
                    this.worker.ReportProgress(-42);
                    Connexion = Core.Global.GetODBC();

                    if (Connexion != null)
                    {
                        Model.Prestashop.PsOrdersRepository       PsOrdersRepository       = new Model.Prestashop.PsOrdersRepository();
                        Model.Prestashop.PsOrderPaymentRepository PsOrderPaymentRepository = new Model.Prestashop.PsOrderPaymentRepository();

                        Model.Local.OrderRepository        OrderRepository        = new Model.Local.OrderRepository();
                        Model.Local.OrderPaymentRepository OrderPaymentRepository = new Model.Local.OrderPaymentRepository();

                        Model.Sage.F_DOCENTETERepository F_DOCENTETERepository = new Model.Sage.F_DOCENTETERepository();

                        List <Model.Prestashop.order_payment> list_order = PsOrdersRepository.ListIDPayment(Core.Global.CurrentShop.IDShop);

                        foreach (Model.Prestashop.order_payment order in list_order)
                        {
                            try
                            {
                                // comparaison nombre de paiements PrestaShop avec ceux déjà transférés
                                if (OrderRepository.ExistPrestashop((int)order.id_order) &&
                                    F_DOCENTETERepository.ExistWeb(order.id_order.ToString()) &&
                                    PsOrderPaymentRepository.CountOrderReference(order.reference) > OrderPaymentRepository.CountOrder((int)order.id_order))
                                // pour ne pas prendre en compte les articles non suivi en stock
                                {
                                    // récupération du dernier document Sage
                                    Model.Sage.F_DOCENTETE F_DOCENTETE = F_DOCENTETERepository.ListWeb(order.id_order.ToString()).FirstOrDefault();

                                    ABSTRACTION_SAGE.F_DOCENTETE.Obj ObjF_DOCENTETE = new ABSTRACTION_SAGE.F_DOCENTETE.Obj()
                                    {
                                        DO_Domaine = (ABSTRACTION_SAGE.F_DOCENTETE.Obj._Enum_DO_Domaine)F_DOCENTETE.DO_Domaine,
                                        DO_Type    = (ABSTRACTION_SAGE.F_DOCENTETE.Obj._Enum_DO_Type)F_DOCENTETE.DO_Type,
                                        DO_Piece   = F_DOCENTETE.DO_Piece
                                    };

                                    ObjF_DOCENTETE.ReadDO_Domaine_DO_Type_DO_Piece(Connexion, false);
                                    if (ObjF_DOCENTETE != null)
                                    {
                                        Model.Prestashop.PsOrders         PsOrders = PsOrdersRepository.ReadOrder((int)order.id_order);
                                        Core.Sync.SynchronisationCommande form     = new Core.Sync.SynchronisationCommande();
                                        bool exist_payment;
                                        form.ExecReglement(PsOrders, Connexion, ObjF_DOCENTETE, out exist_payment);
                                    }
                                }
                            }
                            catch (Exception ex)
                            {
                                Core.Error.SendMailError("[SYNCHRONISATION REGLEMENTS]" + ex.ToString());
                            }
                            lock (this)
                            {
                                this.CurrentCount += 1;
                            }
                            this.worker.ReportProgress((this.CurrentCount * 100 / list_order.Count));
                        }
                    }
                }
            };

            this.worker.ProgressChanged += delegate(object s, ProgressChangedEventArgs args)
            {
                if (args.ProgressPercentage >= 0)
                {
                    this.ProgressBar.Value        = args.ProgressPercentage;
                    this.LabelInformation.Content = "Informations : " + args.ProgressPercentage + " %";
                }
                else if (args.ProgressPercentage == -42)
                {
                    this.LabelInformation.Content = "Ouverture connexion ODBC Sage...";
                }
            };

            this.worker.RunWorkerCompleted += delegate(object s, RunWorkerCompletedEventArgs args)
            {
                if (Connexion != null)
                {
                    Connexion.Close_Connexion();
                }
                this.Close();
            };

            // Insérez le code requis pour la création d’objet sous ce point.
            this.worker.RunWorkerAsync();
        }