private void _buttonGaucheDroiteCommande_Click(object sender, RoutedEventArgs e) { if (this._dataGridCommandeGauche.SelectedItem != null) { if (this._dataGridCommandeGauche.SelectedItems.Count == 1) { Facture_Fournisseur_Contenu temp = new Facture_Fournisseur_Contenu(); temp.Contenu_Commande_Fournisseur1 = ((Contenu_Commande_Fournisseur)this._dataGridCommandeGauche.SelectedItem); temp.Designation = ((Contenu_Commande_Fournisseur)this._dataGridCommandeGauche.SelectedItem).Designation; temp.Reference_Fournisseur = ((Contenu_Commande_Fournisseur)this._dataGridCommandeGauche.SelectedItem).Reference; temp.Qte_Commandee = ((Contenu_Commande_Fournisseur)this._dataGridCommandeGauche.SelectedItem).Quantite; temp.Qte_Livree = 0; temp.Qte_Facturee = ((Contenu_Commande_Fournisseur)this._dataGridCommandeGauche.SelectedItem).QuantiteRestante; temp.Prix_Unitaire_Commande_HT = ((Contenu_Commande_Fournisseur)this._dataGridCommandeGauche.SelectedItem).Prix_Unitaire; temp.Prix_Unitaire_Remise_HT = ((Contenu_Commande_Fournisseur)this._dataGridCommandeGauche.SelectedItem).Prix_Remise; temp.Prix_Unitaire_Facture_HT = ((Contenu_Commande_Fournisseur)this._dataGridCommandeGauche.SelectedItem).Prix_Remise; temp.Prix_Total_Facture_HT = 0; temp.Diff = 0; temp.Affaire1 = ((Contenu_Commande_Fournisseur)this._dataGridCommandeGauche.SelectedItem).Commande_Fournisseur1.Affaire1; ((Facture_Fournisseur)this.DataContext).Facture_Fournisseur_Contenu.Add(temp); Facture_Fournisseur_Contenu_Commande_Fournisseur tmp = new Facture_Fournisseur_Contenu_Commande_Fournisseur(); tmp.Contenu_Commande_Fournisseur1 = (Contenu_Commande_Fournisseur)this._dataGridCommandeGauche.SelectedItem; tmp.Facture_Fournisseur1 = (Facture_Fournisseur)this.DataContext; //((Facture_Fournisseur)this.DataContext).Facture_Fournisseur_Contenu_Commande_Fournisseur.Add(); } else { foreach (Contenu_Commande_Fournisseur ligne in this._dataGridCommandeGauche.SelectedItems.OfType<Contenu_Commande_Fournisseur>()) { Facture_Fournisseur_Contenu temp = new Facture_Fournisseur_Contenu(); temp.Contenu_Commande_Fournisseur1 = ligne; temp.Designation = ligne.Designation; temp.Reference_Fournisseur = ligne.Reference; temp.Qte_Commandee = ligne.Quantite; temp.Qte_Livree = 0; temp.Qte_Facturee = ligne.QuantiteRestante; temp.Prix_Unitaire_Commande_HT = ligne.Prix_Unitaire; temp.Prix_Unitaire_Remise_HT = ligne.Prix_Remise; temp.Prix_Unitaire_Facture_HT = ligne.Prix_Remise; temp.Prix_Total_Facture_HT = 0; temp.Diff = 0; temp.Affaire1 = ligne.Commande_Fournisseur1.Affaire1; ((Facture_Fournisseur)this.DataContext).Facture_Fournisseur_Contenu.Add(temp); Facture_Fournisseur_Contenu_Commande_Fournisseur tmp = new Facture_Fournisseur_Contenu_Commande_Fournisseur(); tmp.Contenu_Commande_Fournisseur1 = ligne; tmp.Facture_Fournisseur1 = (Facture_Fournisseur)this.DataContext; } } } this.SelectionAutoLigneCommande(); _verrouillerFacture(); this.calculChaqueLigne(); this.calculResume(); }
public ObservableCollection<Facture_Fournisseur_Contenu> PasteDataFactureFournisseurWindow() { if (Clipboard.ContainsText(TextDataFormat.Text)) { ObservableCollection<Facture_Fournisseur_Contenu> toReturn = new ObservableCollection<Facture_Fournisseur_Contenu>(); String data = Clipboard.GetText(); ObservableCollection<String> listLignes = new ObservableCollection<string>(data.Split('\n')); int nbLignes = 1; int ligneToIgnore = listLignes.Count(); foreach (String ligne in listLignes) { if (nbLignes != ligneToIgnore) { if (this.verifNombreColonnes(ligne, 4)) { ObservableCollection<String> listColonnes = new ObservableCollection<string>(ligne.Split('\t')); int i = 1; Facture_Fournisseur_Contenu toAdd = new Facture_Fournisseur_Contenu(); toAdd.Qte_Commandee = 0; toAdd.Qte_Livree = 0; toAdd.Prix_Unitaire_Commande_HT = 0; toAdd.Prix_Unitaire_Remise_HT = 0; foreach (String colonne in listColonnes) { if (i == 1) { toAdd.Reference_Fournisseur = colonne; } if (i == 2) { toAdd.Designation = colonne; } if (i == 3) { double val; if (double.TryParse(colonne.Replace(".", ","), out val)) { toAdd.Qte_Facturee = double.Parse(colonne.Replace(".", ",")); } else { MessageBox.Show("Le collage s'arrete car à la ligne n°" + nbLignes + ", vous essayez de rentrer une quantité qui n'est pas un chiffre", "Coller : erreur !", MessageBoxButton.OK, MessageBoxImage.Error); return null; } } if (i == 4) { double val; if (double.TryParse(colonne.Replace(".", ","), out val)) { toAdd.Prix_Unitaire_Facture_HT = double.Parse(colonne.Replace(".", ",")); } else { MessageBox.Show("Le collage s'arrete car à la ligne n°" + nbLignes + ", vous essayez de rentrer un prix unitaire qui n'est pas un chiffre", "Coller : erreur !", MessageBoxButton.OK, MessageBoxImage.Error); return null; } } toReturn.Add(toAdd); i = i + 1; } nbLignes = nbLignes + 1; } else { MessageBox.Show("Le collage s'arrete car à la ligne n°" + nbLignes + ", le nombre de colonne n'est pas bon, il doit y en avoir 4 (Référence, désignation, Quantité, Prix unitaire).", "Coller : erreur !", MessageBoxButton.OK, MessageBoxImage.Error); return null; } } } return toReturn; } else { return null; } }
private void _buttonGaucheDroiteBL_Click(object sender, RoutedEventArgs e) { if (this._dataGridBLGauche.SelectedItem != null) { if (this._dataGridBLGauche.SelectedItems.Count == 1) { foreach (Bon_Livraison_Contenu_Commande item in ((MatriceBL)this._dataGridBLGauche.SelectedItem).bon_livraison.Bon_Livraison_Contenu_Commande) { Facture_Fournisseur_Contenu temp = new Facture_Fournisseur_Contenu(); temp.Bon_Livraison_Contenu_Commande1 = item; temp.Designation = item.Contenu_Commande_Fournisseur.Designation; temp.Reference_Fournisseur = item.Contenu_Commande_Fournisseur.Reference; temp.Qte_Commandee = item.Contenu_Commande_Fournisseur.Quantite; temp.Qte_Livree = item.Quantite; temp.Qte_Facturee = item.Quantite; temp.Prix_Unitaire_Commande_HT = item.Contenu_Commande_Fournisseur.Prix_Unitaire; temp.Prix_Unitaire_Remise_HT = item.Contenu_Commande_Fournisseur.Prix_Remise; temp.Prix_Unitaire_Facture_HT = item.Contenu_Commande_Fournisseur.Prix_Remise; temp.Prix_Total_Facture_HT = 0; temp.Diff = 0; temp.Affaire1 = item.Bon_Livraison1.Affaire1; ((Facture_Fournisseur)this.DataContext).Facture_Fournisseur_Contenu.Add(temp); } foreach (Bon_Livraison_Contenu_Commande_Supplementaire item in ((MatriceBL)this._dataGridBLGauche.SelectedItem).bon_livraison.Bon_Livraison_Contenu_Commande_Supplementaire) { Facture_Fournisseur_Contenu temp = new Facture_Fournisseur_Contenu(); temp.Bon_Livraison_Contenu_Commande_Supplementaire1 = item; temp.Designation = item.Designation; temp.Reference_Fournisseur = item.Reference; temp.Qte_Commandee = 0; temp.Qte_Livree = item.Quantite; temp.Qte_Facturee = item.Quantite; temp.Prix_Unitaire_Commande_HT = item.Prix_Unitaire; temp.Prix_Unitaire_Remise_HT = item.Prix_Remise; temp.Prix_Unitaire_Facture_HT = item.Prix_Remise; temp.Prix_Total_Facture_HT = 0; temp.Diff = 0; temp.Affaire1 = item.Bon_Livraison1.Affaire1; ((Facture_Fournisseur)this.DataContext).Facture_Fournisseur_Contenu.Add(temp); } ((MatriceBL)this._dataGridBLGauche.SelectedItem).bon_livraison.Facture_Fournisseur1 = (Facture_Fournisseur)this.DataContext; } else { foreach (MatriceBL ligne in this._dataGridBLGauche.SelectedItems.OfType<MatriceBL>()) { foreach (Bon_Livraison_Contenu_Commande item in ligne.bon_livraison.Bon_Livraison_Contenu_Commande) { Facture_Fournisseur_Contenu temp = new Facture_Fournisseur_Contenu(); temp.Bon_Livraison_Contenu_Commande1 = item; temp.Designation = item.Contenu_Commande_Fournisseur.Designation; temp.Reference_Fournisseur = item.Contenu_Commande_Fournisseur.Reference; temp.Qte_Commandee = item.Contenu_Commande_Fournisseur.Quantite; temp.Qte_Livree = item.Quantite; temp.Qte_Facturee = item.Quantite; temp.Prix_Unitaire_Commande_HT = item.Contenu_Commande_Fournisseur.Prix_Unitaire; temp.Prix_Unitaire_Remise_HT = item.Contenu_Commande_Fournisseur.Prix_Remise; temp.Prix_Unitaire_Facture_HT = item.Contenu_Commande_Fournisseur.Prix_Remise; temp.Prix_Total_Facture_HT = 0; temp.Diff = 0; temp.Affaire1 = item.Bon_Livraison1.Affaire1; ((Facture_Fournisseur)this.DataContext).Facture_Fournisseur_Contenu.Add(temp); } foreach (Bon_Livraison_Contenu_Commande_Supplementaire item in ligne.bon_livraison.Bon_Livraison_Contenu_Commande_Supplementaire) { Facture_Fournisseur_Contenu temp = new Facture_Fournisseur_Contenu(); temp.Bon_Livraison_Contenu_Commande_Supplementaire1 = item; temp.Designation = item.Designation; temp.Reference_Fournisseur = item.Reference; temp.Qte_Commandee = 0; temp.Qte_Livree = item.Quantite; temp.Qte_Facturee = item.Quantite; temp.Prix_Unitaire_Commande_HT = item.Prix_Unitaire; temp.Prix_Unitaire_Remise_HT = item.Prix_Remise; temp.Prix_Unitaire_Facture_HT = item.Prix_Remise; temp.Prix_Total_Facture_HT = 0; temp.Diff = 0; temp.Affaire1 = item.Bon_Livraison1.Affaire1; ((Facture_Fournisseur)this.DataContext).Facture_Fournisseur_Contenu.Add(temp); } ligne.bon_livraison.Facture_Fournisseur1 = (Facture_Fournisseur)this.DataContext; } } } this.SelectionAutoBL(); _verrouillerFacture(); this.calculChaqueLigne(); this.calculResume(); }