Problem:
I am having trouble with the trip = new Trips() the dist and qtygal are not functioning properly I don't know why the result outcome is both dist and qtygal is 0
Desired result:
each trip in the triplist should only have either dist to equal 0 or qtygal equal 0 not both. or even better if i can combine the two loop together
private void CalculateMiGa()
{
Trips trip;
triplist = new List<Trips>();
double dist=0;
double qtygal=0;
if (lstTruckNum != null)
{
for (int i = 0; i < states.Length-1; i++)
{
foreach(string il in lstTruckNum.Items)
{
foreach(var li in truckstopProductQty)
{
if(li.STATE==states[i])
{
if (li.Vehicle.ToString() == il)
{
qtygal += li.Quanty;
}
}
trip = new Trips(li.Vehicle, li.STATE, dist, qtygal);
triplist.Add(trip);
}
qtygal = 0;
}
}
foreach (var i in vehiclesStateDistance)
{
dist = i.Distance;
trip = new Trips(i.Vehicle, i.State, dist, qtygal);
triplist.Add(trip);
}
}
}

Aucun commentaire:
Enregistrer un commentaire