1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
|
//Création de variables de niveau page pour le calcul de totaux dans le GridViewDetailVente
double _totalTTC = 0;
double _totalHT = 0;
double _totalGeneral = 0;
int _NbreElements = 0;
int _idVente = 0;
protected void GridViewDetailVente_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
// Reference the DetailVenteRow via the e.Row.DataItem property
Vente.T_VENTE_DETAILRow _detailVente = (Vente.T_VENTE_DETAILRow)
((System.Data.DataRowView)e.Row.DataItem).Row;
//définition du coefficient multiplicateur de prix : quantité
int _Qte = 0;
if (_detailVente.IsID_ARTICLENull()||_detailVente.ID_ARTICLE==0)
_Qte = 1;
else
_Qte = _detailVente.Quantite;
// Increment the running totals (if they're not NULL!)
if (!_detailVente.IsPrix_Unitaire_HTNull())
{
_totalHT += (_detailVente.Prix_Unitaire_HT * _Qte);
_totalTTC += (_detailVente.Prix_Unitaire_TTC * _Qte);
_totalGeneral += (_detailVente.Total_Article * _Qte);
}
//incrémente le nombre d'élément même si la valeur est NULL
_NbreElements+=_Qte;
}
else if (e.Row.RowType == DataControlRowType.Footer)
{
e.Row.Cells[0].Text = "Nbre d'élts:" + _NbreElements.ToString();
e.Row.Cells[1].Text = "Total:";
e.Row.Cells[2].Text = _totalHT.ToString("c");
e.Row.Cells[4].Text = _totalTTC.ToString("c");
e.Row.Cells[6].Text = _totalGeneral.ToString("c");
}
//Récupération de l'ID_VENTE du détailsview
VenteBLL _Vente = new VenteBLL();
DetailsView Dv = (DetailsView)DetailsViewVente;
int _idVenteDv = (int)Dv.DataKey.Value;
_Vente.UpdateTotalByIDVente(_totalHT, _totalTTC, _idVenteDv);
Dv.DataBind();
} |
Partager