//------------------------------------------------------------------- public override CResultAErreur TraitementAvantSauvegarde(CContexteDonnee contexte) { CResultAErreur result = base.TraitementAvantSauvegarde(contexte); if (!result) { return(result); } DataTable table = contexte.Tables[CValorisationElement.c_nomTable]; if (table == null) { return(result); } ArrayList lst = new ArrayList(table.Rows); foreach (DataRow row in lst) { if (row.RowState != DataRowState.Unchanged) { ///Cherche les impacts sur les couts CValorisationElement valorisation = new CValorisationElement(row); if (row.RowState == DataRowState.Deleted) { valorisation.VersionToReturn = DataRowVersion.Original; } CLotValorisation lot = valorisation.LotValorisation; if (lot.Row.RowState == DataRowState.Deleted) { lot.VersionToReturn = DataRowVersion.Original; } foreach (CLivraisonLotValorisation livs in lot.RelationsLivraisons) { CLivraisonEquipement livraison = livs.Livraison; if (livraison == null) { continue; } if (livraison.Row.RowState == DataRowState.Deleted) { livraison.VersionToReturn = DataRowVersion.Original; } CCommande commande = livraison.Commande; if (commande == null || commande.Row.RowState == DataRowState.Deleted) { continue;//la commande a été supprimée } CListeObjetsDonnees lignes = commande.Lignes; foreach (CLigneCommande ligne in lignes) { if (ligne.Row.RowState != DataRowState.Deleted) { CUtilElementACout.OnChangeCout(ligne, true, false);//changement du cout réel } } } } } return(result); }
public CResultAErreur InitChamps(CLotValorisation lot) { CResultAErreur result = CResultAErreur.True; m_lotValorisation = lot; m_extLinkField.FillDialogFromObjet(lot); m_ctrlValorisations.Init(m_lotValorisation); return(result); }
protected override CResultAErreur MyInitChamps(CCustomizableListItem item) { CResultAErreur result = CResultAErreur.True; if (item == null) { return(result); } CValorisationElement ligne = item.Tag as CValorisationElement; if (ligne == null || !ligne.IsValide()) { MyInitChamps(null); return(result); } CLotValorisation lot = ligne.LotValorisation; m_selectTypeEquipement.InitMultiple(new CConfigTextBoxFiltreRapide[] { new CConfigTextBoxFiltreRapide( typeof(CTypeEquipement), null, "Libelle"), new CConfigTextBoxFiltreRapide( typeof(CTypeConsommable), null, "Libelle"), new CConfigTextBoxFiltreRapide( typeof(CTypeOperation), null, "Libelle") }, false); m_selectTypeEquipement.ElementSelectionne = ligne.ElementValorisé as CObjetDonnee; if (ligne != null && ligne.EquipementsLies.Count > 0) { m_extModeEdition.SetModeEdition(m_selectTypeEquipement, TypeModeEdition.Autonome); m_selectTypeEquipement.LockEdition = true; } else { m_extModeEdition.SetModeEdition(m_selectTypeEquipement, TypeModeEdition.EnableSurEdition); m_selectTypeEquipement.LockEdition = !m_extModeEdition.ModeEdition; } m_txtValeur.DoubleValue = ligne != null ? (double?)ligne.Valeur : null; if (ligne != null && ligne.IsNew() && ligne.Valeur == 0) { m_txtValeur.DoubleValue = null; } UpdateQuantite(); return(result); }
//------------------------------------------------------------------- public override CResultAErreur VerifieDonnees(CObjetDonnee objet) { CResultAErreur result = CResultAErreur.True; try { CLotValorisation lotValorisation = (CLotValorisation)objet; } catch (Exception e) { result.EmpileErreur(new CErreurException(e)); } return(result); }
//------------------------------------------------------------------ public void Init(CLotValorisation lot) { m_listeLignes.CancelEdit(); m_lotValorisation = lot; List <CCustomizableListItem> lstItems = new List <CCustomizableListItem>(); foreach (CValorisationElement ligne in m_lotValorisation.Valorisations) { CCustomizableListItem item = new CCustomizableListItem(); item.Tag = ligne; lstItems.Add(item); } m_listeLignes.Items = lstItems.ToArray(); m_listeLignes.Refresh(); }
public double GetValuationForDate(DateTime dt) { CListeObjetsDonnees lstValOp = Valorisations; CListeObjetsDonnees lstLot = lstValOp.GetDependances("LotValorisation"); if (lstValOp.Count == 0) { return(0); } lstLot.Tri = CLotValorisation.c_champDateLot; CLotValorisation lot = lstLot[0] as CLotValorisation; if (lot != null && lot.DateLot.Date.AddMinutes(-1) > dt)//Premier plus récent->premier { CValorisationElement val = lot.GetValorisation(this); if (val != null) { return(val.Valeur); } return(0); } lstLot.InterditLectureInDB = true; lstLot.Filtre = new CFiltreData(CLotValorisation.c_champDateLot + "<@1", dt.Date.AddDays(1)); lstLot.Tri = CLotValorisation.c_champDateLot; if (lstLot.Count > 0) { lot = lstLot[lstLot.Count - 1] as CLotValorisation; if (lot != null) { CValorisationElement val = lot.GetValorisation(this); if (val != null) { return(val.Valeur); } } } return(0); }
//------------------------------------------------------------------------ public double GetValuationForDate(DateTime dt, CValeurUnite quantite) { CListeObjetsDonnees lstValEqpt = Valorisations; CListeObjetsDonnees lstLot = lstValEqpt.GetDependances("LotValorisation"); double fQuantite = 1; if (quantite != null && Unite != null) { if (quantite.IUnite == null) { fQuantite = quantite.Valeur; } else { fQuantite = quantite.ConvertTo(Unite.GlobalId).Valeur; } } if (lstValEqpt.Count == 0) { return(0); } lstLot.Tri = CLotValorisation.c_champDateLot; CLotValorisation lot = lstLot[0] as CLotValorisation; if (lot != null && lot.DateLot.Date.AddMinutes(-1) > dt)//Premier plus récent->premier { CValorisationElement val = lot.GetValorisation(this); if (val != null) { return(val.Valeur * fQuantite); } return(0); } lstLot.InterditLectureInDB = true; lstLot.Filtre = new CFiltreData(CLotValorisation.c_champDateLot + "<@1", dt.Date.AddDays(1)); lstLot.Tri = CLotValorisation.c_champDateLot; if (lstLot.Count > 0) { lot = lstLot[lstLot.Count - 1] as CLotValorisation; if (lot != null) { CValorisationElement val = lot.GetValorisation(this); if (val != null) { CValeurUnite v = val.QuantiteEtUnite; IUnite monUnite = Unite; if (v != null && monUnite != null) { v = v.ConvertTo(monUnite.GlobalId); if (v.Valeur != 0) { return(val.Valeur / v.Valeur * fQuantite); } } return(val.Valeur * fQuantite); } } } return(0); }
//------------------------------------------------------------------------- public CFormEditionLotValorisation(CLotValorisation LotValorisation, CListeObjetsDonnees liste) : base(LotValorisation, liste) { // Cet appel est requis par le Concepteur Windows Form. InitializeComponent(); }
//------------------------------------------------------------------------- public CFormEditionLotValorisation(CLotValorisation LotValorisation) : base(LotValorisation) { // Cet appel est requis par le Concepteur Windows Form. InitializeComponent(); }