// Decompiled with JetBrains decompiler
// Type: SE0085.CTdB.clsOrderCosting
// Assembly: SE0085CTdB, Version=1.0.0.1, Culture=neutral, PublicKeyToken=null
// MVID: F67560B6-58CB-4471-AAC9-80007CA3AF52
// Assembly location: C:\Users\Abishek\Downloads\SchneiderCode_Breaker_09292016\Breaker Schedule-20160930T014118Z\Breaker Schedule\Solution for gathering Breaker Data\DMS\bin\Debug\SE0085CTdB.dll

using SE0085.StCl;
using System;
using System.Collections.Generic;

namespace SE0085.CTdB
{
  public class clsOrderCosting
  {
    private scOrderData _OrderData;
    private scOrderLinesExt _OrderLineExt;
    private List<scOrdSectionData> _OrdSectsData;
    private int _OrdLineSTDMin;

    public int OrderLineSTDMin
    {
      get
      {
        return this._OrdLineSTDMin;
      }
    }

    public int SectionCount
    {
      get
      {
        return this._OrdSectsData.Count;
      }
    }

    public scOrderData OrderData
    {
      get
      {
        return this._OrderData;
      }
      set
      {
        this._OrderData = value;
      }
    }

    public scOrderLinesExt OrderLineExt
    {
      get
      {
        return this._OrderLineExt;
      }
      set
      {
        this._OrderLineExt = value;
      }
    }

    public List<scOrdSectionData> OrderSections
    {
      get
      {
        return this._OrdSectsData;
      }
      set
      {
        this._OrdSectsData = value;
      }
    }

    public double OrderProgressNet
    {
      get
      {
        List<scOrdSectionData>.Enumerator enumerator;
        double num;
        try
        {
          enumerator = this._OrdSectsData.GetEnumerator();
          while (enumerator.MoveNext())
          {
            scOrdSectionData current = enumerator.Current;
            num += current.OrdSectWIPCompNet;
          }
        }
        finally
        {
          enumerator.Dispose();
        }
        return num;
      }
    }

    public double OrderProgressBook
    {
      get
      {
        List<scOrdSectionData>.Enumerator enumerator;
        double num;
        try
        {
          enumerator = this._OrdSectsData.GetEnumerator();
          while (enumerator.MoveNext())
          {
            scOrdSectionData current = enumerator.Current;
            num += current.OrdSectWIPCompBook;
          }
        }
        finally
        {
          enumerator.Dispose();
        }
        return num;
      }
    }

    public double OrderProgressPct
    {
      get
      {
        List<scOrdSectionData>.Enumerator enumerator;
        double num;
        try
        {
          enumerator = this._OrdSectsData.GetEnumerator();
          while (enumerator.MoveNext())
          {
            scOrdSectionData current = enumerator.Current;
            num += (double) current.OrdSectCompleteMin;
          }
        }
        finally
        {
          enumerator.Dispose();
        }
        return num / (double) this._OrdLineSTDMin;
      }
    }

    public clsOrderCosting()
    {
      this._OrderData = new scOrderData();
      this._OrderLineExt = new scOrderLinesExt();
      this._OrdSectsData = new List<scOrdSectionData>();
    }

    public clsOrderCosting(string FOLineSLSS, DateTime CutoffDate)
    {
      clsEngineCTdB clsEngineCtdB = new clsEngineCTdB();
      clsRoutings clsRoutings = new clsRoutings();
      this._OrderData = clsEngineCtdB.rtnOrderData(FOLineSLSS);
      this._OrderLineExt = clsEngineCtdB.rtnOrderLineExtById(this._OrderData.OrderLineId);
      this._OrdSectsData = clsEngineCtdB.rtnOrderSectsDataByLineId(this._OrderData.OrderLineId);
      List<scOrdSectionData>.Enumerator enumerator1;
      try
      {
        enumerator1 = this._OrdSectsData.GetEnumerator();
        while (enumerator1.MoveNext())
        {
          scOrdSectionData current = enumerator1.Current;
          current.OrdSectsCurrWorkCtr = clsRoutings.rtnWIPWC4Date(this._OrderData.AssemLineAbbrv, current.OrdSectsId, CutoffDate);
          current.OrdSectTotalSTDMin = clsRoutings.rtnRoutingTotalSTDMin(this._OrderData.AssemLineAbbrv, current.OrdSectsId);
          current.OrdSectCompleteMin = clsRoutings.rtnRoutingCompletedMin(this._OrderData.AssemLineAbbrv, current.OrdSectsId, CutoffDate);
          scOrdSectionData scOrdSectionData = current;
          scOrdSectionData.OrdSectCompleteMin = checked ((int) Math.Round(unchecked ((double) scOrdSectionData.OrdSectCompleteMin + (double) clsRoutings.rtnRoutingInProcessMin(this._OrderData.AssemLineAbbrv, current.OrdSectsId, CutoffDate) / 2.0)));
        }
      }
      finally
      {
        enumerator1.Dispose();
      }
      List<scOrdSectionData>.Enumerator enumerator2;
      int num;
      try
      {
        enumerator2 = this._OrdSectsData.GetEnumerator();
        while (enumerator2.MoveNext())
        {
          scOrdSectionData current = enumerator2.Current;
          checked { num += current.OrdSectTotalSTDMin; }
        }
      }
      finally
      {
        enumerator2.Dispose();
      }
      this._OrdLineSTDMin = num;
      List<scOrdSectionData>.Enumerator enumerator3;
      try
      {
        enumerator3 = this._OrdSectsData.GetEnumerator();
        while (enumerator3.MoveNext())
        {
          scOrdSectionData current = enumerator3.Current;
          current.OrdSectPercent = (double) current.OrdSectTotalSTDMin / (double) this._OrdLineSTDMin;
          current.OrdSectWIPCostNet = current.OrdSectPercent * Convert.ToDouble(this._OrderLineExt.OrderLineNet);
          current.OrdSectWIPCostBook = current.OrdSectPercent * Convert.ToDouble(this._OrderLineExt.OrderLineBook);
        }
      }
      finally
      {
        enumerator3.Dispose();
      }
    }

    public scOrdSectionData get_OrderSect(int Index)
    {
      return this._OrdSectsData[Index];
    }

    public void set_OrderSect(int Index, scOrdSectionData value)
    {
      this._OrdSectsData[Index] = value;
    }
  }
}
