Beispiel #1
0
        private void ButtonSubmit_Click(object sender, RoutedEventArgs e)
        {
            if (this.ListBoxFournisseur.SelectedItem != null)
            {
                Model.Local.SupplierRepository SupplierRepository = new Model.Local.SupplierRepository();
                if (SupplierRepository.ExistSag_Id(((Model.Sage.F_COMPTET) this.ListBoxFournisseur.SelectedItem).cbMarq))
                {
                    Model.Local.Supplier Supplier = SupplierRepository.ReadSag_Id(((Model.Sage.F_COMPTET) this.ListBoxFournisseur.SelectedItem).cbMarq);

                    Supplier.Sup_Name            = Core.Global.RemovePurge(this.TextBoxName.Text, 128);
                    Supplier.Sup_Description     = Core.Global.RemovePurge(this.TextBoxDescription.Text, 10000);
                    Supplier.Sup_MetaTitle       = Core.Global.RemovePurge(this.TextBoxTitle.Text, 70);
                    Supplier.Sup_MetaDescription = Core.Global.RemovePurge(this.TextBoxDescription.Text, 160);
                    Supplier.Sup_MetaKeyword     = Core.Global.RemovePurgeMeta(this.TextBoxMetaKeyword.Text, 255);
                    Supplier.Sup_Active          = this.CheckBoxActive.IsChecked.Value;
                    Supplier.Sup_Sync            = this.RadioButtonSync.IsChecked.Value;
                    Supplier.Sup_Date            = DateTime.Now;

                    SupplierRepository.Save();
                    MessageBox.Show("Fournisseur mis à jour avec succès", "Fournisseur", MessageBoxButton.OK);
                }
                else
                {
                    MessageBox.Show("Fournisseur non valide !", "Fournisseur", MessageBoxButton.OK);
                }
            }
        }
Beispiel #2
0
        private void ListBoxFournisseur_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (this.ListBoxFournisseur.SelectedItem != null)
            {
                if (this.ListBoxFournisseur.SelectedItem is Model.Sage.F_COMPTET)
                {
                    this.isValid = false;
                    Model.Local.SupplierRepository SupplierRepository = new Model.Local.SupplierRepository();
                    Model.Local.Supplier           Supplier           = new Model.Local.Supplier();
                    if (SupplierRepository.ExistSag_Id(((Model.Sage.F_COMPTET) this.ListBoxFournisseur.SelectedItem).cbMarq))
                    {
                        this.groupBoxSupplierDetail.IsEnabled = true;
                        Supplier = SupplierRepository.ReadSag_Id(((Model.Sage.F_COMPTET) this.ListBoxFournisseur.SelectedItem).cbMarq);
                        this.TextBoxName.Text            = Supplier.Sup_Name;
                        this.TextBoxDescription.Text     = Supplier.Sup_Description;
                        this.TextBoxTitle.Text           = Supplier.Sup_MetaTitle;
                        this.TextBoxMetaKeyword.Text     = Supplier.Sup_MetaKeyword;
                        this.TextBoxMetaDescription.Text = Supplier.Sup_MetaDescription;
                        this.CheckBoxActive.IsChecked    = Supplier.Sup_Active;
                        this.RadioButtonSync.IsChecked   = Supplier.Sup_Sync;

                        if (Supplier.Pre_Id != null)
                        {
                            Model.Prestashop.PsSupplierRepository PsSupplierRepository = new Model.Prestashop.PsSupplierRepository();
                            if (PsSupplierRepository.ExistId(Convert.ToInt32(Supplier.Pre_Id)) == false)
                            {
                                MessageBoxResult Result = MessageBox.Show("Le fournisseur Prestashop n'existe plus. Voulez-vous le recréer ?", "Fournisseur", MessageBoxButton.YesNo);
                                if (Result == MessageBoxResult.Yes)
                                {
                                    Supplier.Pre_Id = null;
                                    SupplierRepository.Save();
                                }
                            }
                        }
                    }
                    else
                    {
                        this.LoadComponent();
                        this.groupBoxSupplierDetail.IsEnabled = false;
                    }
                }
                else
                {
                    this.LoadComponent();
                    this.groupBoxSupplierDetail.IsEnabled = false;
                }
            }
            else
            {
                this.LoadComponent();
                this.groupBoxSupplierDetail.IsEnabled = false;
            }
        }