using Microsoft.VisualBasic;
using Microsoft.VisualBasic.CompilerServices;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;

//namespace SE0085.CTdB
namespace FAS_LIB
{
    public class clsBackorders
    {
        private scLevels _Plant;
        private scLevels _AssemblyLine;
        private clsLogWriter lcLogWriter;

        public clsBackorders(scLevels Plant, scLevels AssemblyLine)
        {
            this._Plant = Plant;
            this._AssemblyLine = AssemblyLine;
            this.lcLogWriter = new clsLogWriter("C:\\LogFiles\\BOUImport.log");
            //this.lcBWT2 = new ecDataInterface();
            //clsDBC clsDbc = new clsDBC();
            //clsDbc.GetServer((object)"SE0085CTEntities1");
            //this._CTConnection = Conversions.ToString(clsDbc.ConnectionString);
        }

        public void InsertBackOrderLines(scOrderImportInfo BackOrders)
        {
            string str1 = "";
            OrderLine ldOrderLine;
            clsEngineMES clsEngineMes = new clsEngineMES(this._Plant, this._AssemblyLine);
            scOrderImportInfo ldBackOrder = new scOrderImportInfo();
            ldBackOrder = BackOrders;

            using (SE0085CTEntities1 se0085CtEntities1 = new SE0085CTEntities1())
            {
                //ParameterExpression parameterExpression1;                
                //IQueryable<AssemblyLine> source1 = (IQueryable<AssemblyLine>)Queryable.Select(Queryable.Where((IQueryable<M0>)Queryable.Join((IQueryable<M0>)se0085CtEntities1.SEPlants, (IEnumerable<M1>)se0085CtEntities1.AssemblyLines, (Expression<Func<M0, M2>>)(p => p.SEPlantId), (Expression<Func<M1, M2>>)(a => a.SEPlant.SEPlantId), (Expression<Func<M0, M1, M3>>)((p, a) => new { p = p, a = a })), (Expression<Func<M0, bool>>)Expression.Lambda<Func<AnonymousType_5<SEPlant, AssemblyLine>, bool>>((Expression)Expression.Equal(It.a.AssemLineId, ldBackOrder.AssemblyLine.LevelId, true, (MethodInfo)null), new ParameterExpression[1]
                //{
                //  parameterExpression1
                //})), (Expression<Func<M0, M1>>)(data => data.a));

               


                IQueryable<AssemblyLine> source1 = (from sp in se0085CtEntities1.SEPlants
                                                    join al in se0085CtEntities1.AssemblyLines
                                                    on sp.SEPlantId equals al.SEPlant.SEPlantId
                                                    where al.AssemLineId == ldBackOrder.AssemblyLine.LevelId
                                                    //&& sp.SEPlantActive == 1
                                                    select new clsIAssemblyLine
                                                    {
                                                        AssemLineId = al.AssemLineId,
                                                        SEPlantId = sp.SEPlantId,
                                                        AssemLineAbbrv = al.AssemLineAbbrv,
                                                        AssemLineName = al.AssemLineName,
                                                        AssemLineValue = al.AssemLineValue,
                                                        AssemLineActive = al.AssemLineActive
                                                    }).AsQueryable<clsIAssemblyLine>();

                if (source1.Count<AssemblyLine>() == 0)
                {
                  int num1 = (int) Interaction.MsgBox((object) ("Error loading Assembly Line data, aborting MES import for AssemblyLineId; " + Conversions.ToString(ldBackOrder.AssemblyLine.LevelId)), MsgBoxStyle.Information, (object) "ONE QMS MES Import Error - E0001");
                }
                else if (source1.Count<AssemblyLine>() == 1)
                {
                    AssemblyLine assemblyLine = source1.First<AssemblyLine>();                    
                    //IQueryable<SEOrder> source2 = (IQueryable<SEOrder>)Queryable.Select<SEOrder, SEOrder>(Queryable.Where<SEOrder>((IQueryable<M0>)se0085CtEntities1.SEOrders, (Expression<Func<M0, bool>>)(o => Expression.Call((Expression)null, (MethodInfo)MethodBase.GetMethodFromHandle(__methodref(Operators.CompareString)), o.OrderFO, closure95.ldBackOrder.OrderFO, false) == 0)), (Expression<Func<M0, M1>>)(o => o));
                    IQueryable<SEOrder> source2 = (from s in se0085CtEntities1.SEOrders
                                                   where string.Equals(s.OrderFO, ldBackOrder.OrderFO)
                                                   select new clsISEOrder
                                                   {
                                                       OrderId = s.OrderId,
                                                       OrderFO = s.OrderFO,
                                                       OrderJobName = s.OrderJobName,
                                                       OrderPurchaser = s.OrderPurchaser
                                                   }).AsQueryable<clsISEOrder>();
                    SEOrder entity;
                    if (source2.Count<SEOrder>() == 0)
                    {
                        //ADD
                        if (DateTime.Compare(ldBackOrder.OrderLineShipDt, Conversions.ToDate("12/31/2039")) == 0)
                            return;
                        entity = new SEOrder();
                        entity.OrderFO = ldBackOrder.OrderFO;
                        entity.OrderJobName = ldBackOrder.OrderJobName;
                        entity.OrderPurchaser = ldBackOrder.OrderPurchaser;
                        se0085CtEntities1.SEOrders.Add(entity);
                        se0085CtEntities1.SaveChanges();
                    }
                    else if (source2.Count<SEOrder>() == 1)
                    {
                        //UPDATE
                        entity = source2.First<SEOrder>();
                        if (!(Operators.CompareString(entity.OrderJobName, ldBackOrder.OrderJobName, false) == 0 & Operators.CompareString(entity.OrderPurchaser, ldBackOrder.OrderPurchaser, false) == 0))
                        {
                            if (!ldBackOrder.OrderJobName.Contains("Part"))
                            {
                                entity.OrderJobName = ldBackOrder.OrderJobName;
                            }
                            entity.OrderPurchaser = ldBackOrder.OrderPurchaser;
                            se0085CtEntities1.SaveChanges();
                        }
                    }
                    else
                    {
                        int num2 = (int)Interaction.MsgBox((object)("Multiple Order numbers found, aborting MES import for Order; " + ldBackOrder.OrderFO), MsgBoxStyle.Information, (object)"ONE QMS MES Import Error - E0001");
                        return;
                    }


                    //IQueryable<OrderLine> source3 = (IQueryable<OrderLine>)Queryable.Select(Queryable.Where((IQueryable<M0>)Queryable.Join((IQueryable<M0>)se0085CtEntities1.SEOrders, (IEnumerable<M1>)se0085CtEntities1.OrderLines, (Expression<Func<M0, M2>>)(o => o.OrderId), (Expression<Func<M1, M2>>)(l => l.SEOrder.OrderId), (Expression<Func<M0, M1, M3>>)((o, l) => new { o = o, l = l })), (Expression<Func<M0, bool>>)(data => Expression.Call((Expression)null, (MethodInfo)MethodBase.GetMethodFromHandle(__methodref(Operators.CompareString)), data.o.OrderFO, closure95.ldBackOrder.OrderFO, false) == 0 & Expression.Call((Expression)null, (MethodInfo)MethodBase.GetMethodFromHandle(__methodref(Operators.CompareString)), data.l.OrderLineNum, closure95.ldBackOrder.OrderLineNum, false) == 0 & Expression.Call((Expression)null, (MethodInfo)MethodBase.GetMethodFromHandle(__methodref(Operators.CompareString)), data.l.OrderLineSL, closure95.ldBackOrder.OrderLineSL, false) == 0 & Expression.Call((Expression)null, (MethodInfo)MethodBase.GetMethodFromHandle(__methodref(Operators.CompareString)), data.l.OrderLineSS, closure95.ldBackOrder.OrderLineSS, false) == 0)), (Expression<Func<M0, M1>>)(data => data.l));
                    
                    IQueryable<OrderLine> source3 = (from or in se0085CtEntities1.SEOrders
                                                     join ol in se0085CtEntities1.OrderLines
                                                     on or.OrderId equals ol.SEOrder.OrderId
                                                     where string.Equals(or.OrderFO, ldBackOrder.OrderFO)
                                                     && string.Equals(ol.OrderLineNum,ldBackOrder.OrderLineNum)
                                                     && string.Equals(ol.OrderLineSL,ldBackOrder.OrderLineSL)
                                                     && string.Equals(ol.OrderLineSS,ldBackOrder.OrderLineSS)
                                                     select new clsIOrderLine
                                                     {
                                                         OrderLineId = ol.OrderLineId,
                                                         OrderId = or.OrderId,
                                                         AssemLineId = ol.AssemLineId,
                                                         OrderLineNum =ol.OrderLineNum,
                                                         OrderLineQty = ol.OrderLineQty,
                                                         OrderLineSL = ol.OrderLineSL,
                                                         OrderLineSS = ol.OrderLineSS,
                                                         OrderLineTargetDt = ol.OrderLineTargetDt,
                                                         OrderLineShipDt = ol.OrderLineShipDt,
                                                         OrderLineShippedDt = ol.OrderLineShippedDt,
                                                         OrderLineShipped = ol.OrderLineShipped,
                                                         OrderLineSER = ol.OrderLineSER,
                                                         OrderLineAssyStartDt = ol.OrderLineAssyStartDt,
                                                     }).AsQueryable<clsIOrderLine>();
                    DateTime? nullable1;
                    bool? nullable2;
                    bool? nullable3;
                    bool? nullable4;
                    bool? nullable5;
                    bool? nullable6;
                    bool? nullable7;
                    bool? nullable8;
                    bool? nullable9;
                    bool? nullable10;
                    DateTime? nullable11;

                    //BLOCK 2 STARTS
                    if (source3.Count<OrderLine>() == 0)
                      {
                        //ADD
                        if (DateTime.Compare(ldBackOrder.OrderLineShipDt, Conversions.ToDate("12/31/2039")) == 0)
                          return;
                        ldOrderLine = new OrderLine();
                        ldOrderLine.OrderLineNum = ldBackOrder.OrderLineNum;
                        ldOrderLine.OrderLineQty = (int?) ldBackOrder.OrderLineQty;
                        ldOrderLine.OrderLineShipDt = (DateTime?) ldBackOrder.OrderLineShipDt;
                        ldOrderLine.OrderLineShipped = (bool?) ldBackOrder.OrderLineShipped;
                        ldOrderLine.OrderLineShippedDt = (DateTime?) ldBackOrder.OrderLineShippedDt;
                        ldOrderLine.OrderLineSL = ldBackOrder.OrderLineSL;
                        ldOrderLine.OrderLineSS = ldBackOrder.OrderLineSS;
                        ldOrderLine.OrderLineTargetDt = (DateTime?) ldBackOrder.OrderLineTargetDt;
                        ldOrderLine.OrderLineAssyStartDt = (DateTime?) ldBackOrder.OrderLineOrgAssyStDt;
                        entity.OrderLines.Add(ldOrderLine);
                        assemblyLine.OrderLines.Add(ldOrderLine);

                        int num2 = 1;
                        int ordSectsCnt = ldBackOrder.OrdSectsCnt;
                        int ldCounter01 = num2;
                        while (ldCounter01 <= ordSectsCnt)
                        {
                          ldOrderLine.OrdSections.Add(new OrdSection()
                          {
                            OrdSectsNum = ldCounter01,
                            OrdSectShipSpt = (int?) 0,
                            OrdSectsRelActDt = (DateTime?) Conversions.ToDate("01/01/1901"),
                            OrdSectsRelSchDt = (DateTime?) Conversions.ToDate("01/01/1901"),
                            OrdSectsFabActDt = (DateTime?) Conversions.ToDate("01/01/1901"),
                            OrdSectsFabSchDt = (DateTime?) Conversions.ToDate("01/01/1901"),
                            OrdSectsRelMfg = (DateTime?) Conversions.ToDate("01/01/1901")
                          });
                          checked { ++ldCounter01; }
                        }
                        se0085CtEntities1.SaveChanges();
                      }
                      else if (source3.Count<OrderLine>() == 1)
                      {
                          //UPDATE
                        ldOrderLine = source3.First<OrderLine>();
                        ldOrderLine.OrderLineQty = (int?) ldBackOrder.OrderLineQty;
                        DateTime orderLineShipDt1 = ldBackOrder.OrderLineShipDt;
                        nullable1 = ldOrderLine.OrderLineShipDt;
                        bool? nullable12;
                        if (!nullable1.HasValue)
                        {
                          nullable12 = new bool?();
                        }
                        else
                        {
                          nullable2 = new bool?(DateTime.Compare(nullable1.GetValueOrDefault(), orderLineShipDt1) == 0);
                          nullable12 = nullable2;
                        }
                        nullable3 = nullable12;
                        DateTime date1 = Conversions.ToDate("01/01/1901");
                        DateTime? orderLineShipDt2 = ldOrderLine.OrderLineShipDt;
                        bool? nullable13;
                        if (!orderLineShipDt2.HasValue)
                        {
                          nullable13 = new bool?();
                        }
                        else
                        {
                          nullable4 = new bool?(DateTime.Compare(orderLineShipDt2.GetValueOrDefault(), date1) == 0);
                          nullable13 = nullable4;
                        }
                        nullable5 = nullable13;
                        bool? nullable14;
                        if (!nullable3.HasValue || !nullable3.GetValueOrDefault())
                        {
                          if (!nullable5.HasValue)
                            nullable14 = new bool?();
                          else if (!nullable5.GetValueOrDefault())
                          {
                            nullable14 = nullable3;
                          }
                          else
                          {
                            nullable6 = new bool?(true);
                            nullable14 = nullable6;
                          }
                        }
                        else
                        {
                          nullable7 = new bool?(true);
                          nullable14 = nullable7;
                        }
                        nullable8 = nullable14;
                        bool? nullable15;
                        if (!nullable8.HasValue)
                        {
                          nullable15 = new bool?();
                        }
                        else
                        {
                          nullable9 = new bool?(!nullable8.GetValueOrDefault());
                          nullable15 = nullable9;
                        }
                        nullable10 = nullable15;
                        if (nullable10.GetValueOrDefault())
                        {
                          clsLogWriter lcLogWriter = this.lcLogWriter;
                          string[] strArray1 = new string[6]
                          {
                            "Order ",
                             ldBackOrder.FOLineSLSS,
                            " Data Changed - Current Ship Date From; ",
                            null,
                            null,
                            null
                          };
                          string[] strArray2 = strArray1;
                          int index = 3;
                          nullable11 = ldOrderLine.OrderLineShipDt;
                          string str2 = nullable11.HasValue ? Conversions.ToString(nullable11.GetValueOrDefault()) : (string) null;
                          strArray2[index] = str2;
                          strArray1[4] = " To: ";
                          strArray1[5] = Conversions.ToString(ldBackOrder.OrderLineShipDt);
                          string logMessage = string.Concat(strArray1);
                          lcLogWriter.logData(logMessage);
                        }
                        ldOrderLine.OrderLineShipDt = (DateTime?) ldBackOrder.OrderLineShipDt;
                        ldOrderLine.OrderLineShipped = (bool?) ldBackOrder.OrderLineShipped;
                        DateTime orderLineShippedDt1 = ldBackOrder.OrderLineShippedDt;
                        nullable11 = ldOrderLine.OrderLineShippedDt;
                        bool? nullable16;
                        if (!nullable11.HasValue)
                        {
                          nullable16 = new bool?();
                        }
                        else
                        {
                          nullable8 = new bool?(DateTime.Compare(nullable11.GetValueOrDefault(), orderLineShippedDt1) == 0);
                          nullable16 = nullable8;
                        }
                        nullable6 = nullable16;
                        DateTime date2 = Conversions.ToDate("01/01/1901");
                        DateTime? orderLineShippedDt2 = ldOrderLine.OrderLineShippedDt;
                        bool? nullable17;
                        if (!orderLineShippedDt2.HasValue)
                        {
                          nullable17 = new bool?();
                        }
                        else
                        {
                          nullable10 = new bool?(DateTime.Compare(orderLineShippedDt2.GetValueOrDefault(), date2) == 0);
                          nullable17 = nullable10;
                        }
                        nullable5 = nullable17;
                        bool? nullable18;
                        if (!nullable6.HasValue || !nullable6.GetValueOrDefault())
                        {
                          if (!nullable5.HasValue)
                            nullable18 = new bool?();
                          else if (!nullable5.GetValueOrDefault())
                          {
                            nullable18 = nullable6;
                          }
                          else
                          {
                            nullable3 = new bool?(true);
                            nullable18 = nullable3;
                          }
                        }
                        else
                        {
                          nullable9 = new bool?(true);
                          nullable18 = nullable9;
                        }
                        nullable2 = nullable18;
                        bool? nullable19;
                        if (!nullable2.HasValue)
                        {
                          nullable19 = new bool?();
                        }
                        else
                        {
                          nullable7 = new bool?(!nullable2.GetValueOrDefault());
                          nullable19 = nullable7;
                        }
                        nullable4 = nullable19;
                        if (nullable4.GetValueOrDefault())
                        {
                          clsLogWriter lcLogWriter = this.lcLogWriter;
                          string[] strArray1 = new string[6]
                          {
                            "Order ",
                            ldBackOrder.FOLineSLSS,
                            " Data Changed - Shipped Date From; ",
                            null,
                            null,
                            null
                          };
                          string[] strArray2 = strArray1;
                          int index = 3;
                          nullable1 = ldOrderLine.OrderLineShippedDt;
                          string str2 = nullable1.HasValue ? Conversions.ToString(nullable1.GetValueOrDefault()) : (string) null;
                          strArray2[index] = str2;
                          strArray1[4] = " To: ";
                          strArray1[5] = Conversions.ToString(ldBackOrder.OrderLineShippedDt);
                          string logMessage = string.Concat(strArray1);
                          lcLogWriter.logData(logMessage);
                        }
                        ldOrderLine.OrderLineShippedDt = (DateTime?) ldBackOrder.OrderLineShippedDt;
                        DateTime orderLineTargetDt1 = ldBackOrder.OrderLineTargetDt;
                        nullable11 = ldOrderLine.OrderLineTargetDt;
                        bool? nullable20;
                        if (!nullable11.HasValue)
                        {
                          nullable20 = new bool?();
                        }
                        else
                        {
                          nullable8 = new bool?(DateTime.Compare(nullable11.GetValueOrDefault(), orderLineTargetDt1) == 0);
                          nullable20 = nullable8;
                        }
                        nullable6 = nullable20;
                        DateTime date3 = Conversions.ToDate("01/01/1901");
                        DateTime? orderLineTargetDt2 = ldOrderLine.OrderLineTargetDt;
                        bool? nullable21;
                        if (!orderLineTargetDt2.HasValue)
                        {
                          nullable21 = new bool?();
                        }
                        else
                        {
                          nullable10 = new bool?(DateTime.Compare(orderLineTargetDt2.GetValueOrDefault(), date3) == 0);
                          nullable21 = nullable10;
                        }
                        nullable5 = nullable21;
                        bool? nullable22;
                        if (!nullable6.HasValue || !nullable6.GetValueOrDefault())
                        {
                          if (!nullable5.HasValue)
                            nullable22 = new bool?();
                          else if (!nullable5.GetValueOrDefault())
                          {
                            nullable22 = nullable6;
                          }
                          else
                          {
                            nullable3 = new bool?(true);
                            nullable22 = nullable3;
                          }
                        }
                        else
                        {
                          nullable9 = new bool?(true);
                          nullable22 = nullable9;
                        }
                        nullable2 = nullable22;
                        bool? nullable23;
                        if (!nullable2.HasValue)
                        {
                          nullable23 = new bool?();
                        }
                        else
                        {
                          nullable7 = new bool?(!nullable2.GetValueOrDefault());
                          nullable23 = nullable7;
                        }
                        nullable4 = nullable23;
                        if (nullable4.GetValueOrDefault())
                        {
                          clsLogWriter lcLogWriter = this.lcLogWriter;
                          string[] strArray1 = new string[6]
                          {
                            "Order ",
                            ldBackOrder.FOLineSLSS,
                            " Data Changed - MES/Org Target Date From; ",
                            null,
                            null,
                            null
                          };
                          string[] strArray2 = strArray1;
                          int index = 3;
                          nullable1 = ldOrderLine.OrderLineTargetDt;
                          string str2 = nullable1.HasValue ? Conversions.ToString(nullable1.GetValueOrDefault()) : (string) null;
                          strArray2[index] = str2;
                          strArray1[4] = " To: ";
                          strArray1[5] = Conversions.ToString(ldBackOrder.OrderLineTargetDt);
                          string logMessage = string.Concat(strArray1);
                          lcLogWriter.logData(logMessage);
                        }
                        ldOrderLine.OrderLineTargetDt = (DateTime?) ldBackOrder.OrderLineTargetDt;
                        DateTime orderLineOrgAssyStDt = ldBackOrder.OrderLineOrgAssyStDt;
                        nullable11 = ldOrderLine.OrderLineAssyStartDt;
                        bool? nullable24;
                        if (!nullable11.HasValue)
                        {
                          nullable24 = new bool?();
                        }
                        else
                        {
                          nullable8 = new bool?(DateTime.Compare(nullable11.GetValueOrDefault(), orderLineOrgAssyStDt) == 0);
                          nullable24 = nullable8;
                        }
                        nullable6 = nullable24;
                        DateTime date4 = Conversions.ToDate("01/01/1901");
                        DateTime? orderLineAssyStartDt = ldOrderLine.OrderLineAssyStartDt;
                        bool? nullable25;
                        if (!orderLineAssyStartDt.HasValue)
                        {
                          nullable25 = new bool?();
                        }
                        else
                        {
                          nullable10 = new bool?(DateTime.Compare(orderLineAssyStartDt.GetValueOrDefault(), date4) == 0);
                          nullable25 = nullable10;
                        }
                        nullable5 = nullable25;
                        bool? nullable26;
                        if (!nullable6.HasValue || !nullable6.GetValueOrDefault())
                        {
                          if (!nullable5.HasValue)
                            nullable26 = new bool?();
                          else if (!nullable5.GetValueOrDefault())
                          {
                            nullable26 = nullable6;
                          }
                          else
                          {
                            nullable3 = new bool?(true);
                            nullable26 = nullable3;
                          }
                        }
                        else
                        {
                          nullable9 = new bool?(true);
                          nullable26 = nullable9;
                        }
                        nullable2 = nullable26;
                        bool? nullable27;
                        if (!nullable2.HasValue)
                        {
                          nullable27 = new bool?();
                        }
                        else
                        {
                          nullable7 = new bool?(!nullable2.GetValueOrDefault());
                          nullable27 = nullable7;
                        }
                        nullable4 = nullable27;
                        if (nullable4.GetValueOrDefault())
                        {
                          clsLogWriter lcLogWriter = this.lcLogWriter;
                          string[] strArray1 = new string[6]
                          {
                            "Order ",
                            ldBackOrder.FOLineSLSS,
                            " Data Changed - Orig Assembly Start Date From; ",
                            null,
                            null,
                            null
                          };
                          string[] strArray2 = strArray1;
                          int index = 3;
                          nullable1 = ldOrderLine.OrderLineAssyStartDt;
                          string str2 = nullable1.HasValue ? Conversions.ToString(nullable1.GetValueOrDefault()) : (string) null;
                          strArray2[index] = str2;
                          strArray1[4] = " To: ";
                          strArray1[5] = Conversions.ToString(ldBackOrder.OrderLineOrgAssyStDt);
                          string logMessage = string.Concat(strArray1);
                          lcLogWriter.logData(logMessage);
                        }
                        ldOrderLine.OrderLineAssyStartDt = (DateTime?) ldBackOrder.OrderLineOrgAssyStDt;
                        se0085CtEntities1.SaveChanges();
                        //Database changes occurs IN ORDERLINES TABLE
                        


                        if (ldBackOrder.OrdSectsCnt > 0)
                        {
                          //ParameterExpression parameterExpression2;
                          //if (((IQueryable<OrdSection>) Queryable.Select<OrdSection, OrdSection>(Queryable.Where<OrdSection>((IQueryable<M0>) se0085CtEntities1.OrdSections, (Expression<Func<M0, bool>>) Expression.Lambda<Func<OrdSection, bool>>((Expression) Expression.Equal(s.OrderLine.OrderLineId, closure96.ldOrderLine.OrderLineId, true, (MethodInfo) null), new ParameterExpression[1]
                          //{
                          //  parameterExpression2
                          //})), (Expression<Func<M0, M1>>) (s => s))).Count<OrdSection>() == 0)
                         if((from s in se0085CtEntities1.OrdSections where string.Equals(s.OrderLine.OrderLineId,ldOrderLine.OrderLineId) select s).ToList().Count() == 0)
                          {
                            int num2 = 1;
                            int ordSectsCnt = ldBackOrder.OrdSectsCnt;
                            int ldCounter01 = num2;
                            while (ldCounter01 <= ordSectsCnt)
                            {
                              //ParameterExpression parameterExpression3;
                              //IQueryable<OrdSection> source4 = (IQueryable<OrdSection>) Queryable.Select<OrdSection, OrdSection>(Queryable.Where<OrdSection>((IQueryable<M0>) se0085CtEntities1.OrdSections, (Expression<Func<M0, bool>>) Expression.Lambda<Func<OrdSection, bool>>((Expression) Expression.And((Expression) Expression.Equal(s.OrderLine.OrderLineId, closure96.ldOrderLine.OrderLineId, true, (MethodInfo) null), (Expression) Expression.Equal((Expression) Expression.Property((Expression) parameterExpression3, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrdSection.get_OrdSectsNum))), (Expression) Expression.Field((Expression) Expression.Constant((object) closure95, typeof (clsBackorders._Closure\u0024__95)), FieldInfo.GetFieldFromHandle(__fieldref (clsBackorders._Closure\u0024__95.ldCounter01))), true, (MethodInfo) null)), new ParameterExpression[1]
                              //{
                              //  parameterExpression3
                              //})), (Expression<Func<M0, M1>>) (s => s));

                              IQueryable<OrdSection> source4 = (from os in se0085CtEntities1.OrdSections
                                                               where string.Equals(os.OrderLine.OrderLineId,ldOrderLine.OrderLineId)
                                                               select new OrdSection
                                                               {
                                                                   OrdSectsNum=os.OrdSectsNum
                                                               }).AsQueryable<OrdSection>();

                              if (source4 != null && source4.Count<OrdSection>() == 0)
                              {
                                ldOrderLine.OrdSections.Add(new OrdSection()
                                {
                                  OrdSectsNum = ldCounter01
                                });
                                se0085CtEntities1.SaveChanges();
                              }
                              checked { ++ldCounter01; }
                            }
                          }
                        }


                        //ParameterExpression parameterExpression4;
                        //IQueryable<AnonymousType_44<Associate, AssocAssignType>> source5 = Queryable.Select(Queryable.Where((IQueryable<M0>) Queryable.Join((IQueryable<M0>) Queryable.Join((IQueryable<M0>) se0085CtEntities1.AssocLookups, (IEnumerable<M1>) se0085CtEntities1.AssocAssignTypes, (Expression<Func<M0, M2>>) (o => o.AssocAssignType.AssocAssignTypeId), (Expression<Func<M1, M2>>) (t => t.AssocAssignTypeId), (Expression<Func<M0, M1, M3>>) ((o, t) => new{ o = o, t = t })), (IEnumerable<M1>) se0085CtEntities1.Associates, (Expression<Func<M0, M2>>) (data => data.o.Associate.AssocId), (Expression<Func<M1, M2>>) (a => a.AssocId), (Expression<Func<M0, M1, M3>>) ((data, a) => new
                        //{
                        //  o = data.o,
                        //  t = data.t,
                        //  a = a
                        //})), (Expression<Func<M0, bool>>) Expression.Lambda<Func<AnonymousType_43<AssocLookup, AssocAssignType, Associate>, bool>>((Expression) Expression.And(Expression.Call((Expression) null, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (Operators.CompareString)), It.o.AssocLookupField, closure95.ldBackOrder.OrderLineOE.AssocLaborName, false) == 0, (Expression) Expression.Equal(It.t.AssocAssignTypeValue, 1, true, (MethodInfo) null)), new ParameterExpression[1]
                        //{
                        //  parameterExpression4
                        //})), (Expression<Func<M0, M1>>) (data => new{ a = data.a, t = data.t }));

                        IQueryable<Associate> source5 = (from al in se0085CtEntities1.AssocLookups
                                    join at in se0085CtEntities1.AssocAssignTypes
                                    on al.AssocAssignTypeId equals at.AssocAssignTypeId
                                    join ae in se0085CtEntities1.Associates
                                    on al.AssocId equals ae.AssocId
                                    where at.AssocAssignTypeValue == 1
                                    select new clsIAssociate
                                    {
                                        AssocId = ae.AssocId,
                                        AssocEmpId = ae.AssocEmpId,
                                        AssocLaborName = ae.AssocLaborName,
                                        AssocFirstName = ae.AssocFirstName,
                                        AssocLastName = ae.AssocLastName,
                                        AssocLogin = ae.AssocLogin,
                                        AssocSESA = ae.AssocSESA,
                                        AssocUserPriv = ae.AssocUserPriv,
                                        AssocEmail = ae.AssocEmail,
                                        AssocQCInsp = ae.AssocQCInsp,
                                        AssocActive = ae.AssocActive,
                                        AssocPhone = ae.AssocPhone,
                                        AssocExt = ae.AssocExt
                                    }).AsQueryable<clsIAssociate>();

                          IQueryable<AssocAssignType> src5 = (from al in se0085CtEntities1.AssocLookups
                                    join at in se0085CtEntities1.AssocAssignTypes
                                    on al.AssocAssignTypeId equals at.AssocAssignTypeId
                                    join ae in se0085CtEntities1.Associates
                                    on al.AssocId equals ae.AssocId
                                    where at.AssocAssignTypeValue == 1
                                    select new clsIAssocAssignType
                                    {
                                        AssocAssignTypeId = at.AssocAssignTypeId,
                                        AssocAssignTypeDesc = at.AssocAssignTypeDesc,
                                        AssocAssignTypeCode = at.AssocAssignTypeCode,
                                        AssocAssignTypeActive = at.AssocAssignTypeActive,
                                        AssocAssignTypeValue = at.AssocAssignTypeValue
                                    }).AsQueryable<clsIAssocAssignType>();


                        if (source5 != null && source5.Count() > 0 && src5 != null && src5.Count() > 0)
                        {
                          // ISSUE: object of a compiler-generated type is created
                          // ISSUE: variable of a compiler-generated type
                          //clsBackorders._Closure\u0024__95._Closure\u0024__96._Closure\u0024__97 closure97 = new clsBackorders._Closure\u0024__95._Closure\u0024__96._Closure\u0024__97();
                          
                          Associate ldOEAssoc = new Associate();
                          
                          AssocAssignType ldOEAssignType = new AssocAssignType();
                          
                          //ldOEAssoc = source5.First().a;
                          //ldOEAssignType = source5.First().t;
                          ldOEAssoc = source5.First();
                          ldOEAssignType = src5.First();
                          
                          //ParameterExpression parameterExpression2;
                          //if (((IQueryable<OrdLineAssocAssigned>) Queryable.Select<OrdLineAssocAssigned, OrdLineAssocAssigned>(Queryable.Where<OrdLineAssocAssigned>((IQueryable<M0>) se0085CtEntities1.OrdLineAssocAssigneds, (Expression<Func<M0, bool>>) Expression.Lambda<Func<OrdLineAssocAssigned, bool>>((Expression) Expression.And((Expression) Expression.And((Expression) Expression.Equal(q.Associate.AssocId, closure97.ldOEAssoc.AssocId, true, (MethodInfo) null), (Expression) Expression.Equal((Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrdLineAssocAssigned.get_AssocAssignType))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (AssocAssignType.get_AssocAssignTypeId))), (Expression) Expression.Property((Expression) Expression.Field((Expression) Expression.Constant((object) closure97, typeof (clsBackorders._Closure\u0024__95._Closure\u0024__96._Closure\u0024__97)), FieldInfo.GetFieldFromHandle(__fieldref (clsBackorders._Closure\u0024__95._Closure\u0024__96._Closure\u0024__97.ldOEAssignType))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (AssocAssignType.get_AssocAssignTypeId))), true, (MethodInfo) null)), (Expression) Expression.Equal((Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrdLineAssocAssigned.get_OrderLine))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderLine.get_OrderLineId))), (Expression) Expression.Property((Expression) Expression.Field((Expression) Expression.Constant((object) closure96, typeof (clsBackorders._Closure\u0024__95._Closure\u0024__96)), FieldInfo.GetFieldFromHandle(__fieldref (clsBackorders._Closure\u0024__95._Closure\u0024__96.ldOrderLine))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderLine.get_OrderLineId))), true, (MethodInfo) null)), new ParameterExpression[1]
                          //{
                          //  parameterExpression2
                          //})), (Expression<Func<M0, M1>>) (q => q))).Count<OrdLineAssocAssigned>() == 0)
                        IQueryable<OrdLineAssocAssigned> src51 = (from or in se0085CtEntities1.OrdLineAssocAssigneds
                                                            where or.Associate.AssocId == ldOEAssoc.AssocId
                                                            select new clsIOrdLineAssocAssigned
                                                            {
                                                                AssocAsgId = or.AssocAsgId,
                                                                AssocId = or.AssocId,
                                                                OrderLineId = or.OrderLineId,
                                                                AssocAssignTypeId = or.AssocAssignTypeId
                                                            }).AsQueryable<clsIOrdLineAssocAssigned>();
                        if(src51 != null && src51.Count() == 0)
                          {
                            se0085CtEntities1.OrdLineAssocAssigneds.Add(new OrdLineAssocAssigned()
                            {
                              Associate = ldOEAssoc,
                              AssocAssignType = ldOEAssignType,
                              OrderLine = ldOrderLine
                            });
                            se0085CtEntities1.SaveChanges();
                          }
                          ldOEAssoc = (Associate) null;
                          ldOEAssignType = (AssocAssignType) null;
                        }


                        //ParameterExpression parameterExpression5;
                        //IQueryable<AnonymousType_44<Associate, AssocAssignType>> source6 = Queryable.Select(Queryable.Where((IQueryable<M0>) Queryable.Join((IQueryable<M0>) Queryable.Join((IQueryable<M0>) se0085CtEntities1.AssocLookups, (IEnumerable<M1>) se0085CtEntities1.AssocAssignTypes, (Expression<Func<M0, M2>>) (o => o.AssocAssignType.AssocAssignTypeId), (Expression<Func<M1, M2>>) (t => t.AssocAssignTypeId), (Expression<Func<M0, M1, M3>>) ((o, t) => new{ o = o, t = t })), (IEnumerable<M1>) se0085CtEntities1.Associates, (Expression<Func<M0, M2>>) (data => data.o.Associate.AssocId), (Expression<Func<M1, M2>>) (a => a.AssocId), (Expression<Func<M0, M1, M3>>) ((data, a) => new
                        //{
                        //  o = data.o,
                        //  t = data.t,
                        //  a = a
                        //})), (Expression<Func<M0, bool>>) Expression.Lambda<Func<AnonymousType_43<AssocLookup, AssocAssignType, Associate>, bool>>((Expression) Expression.And(Expression.Call((Expression) null, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (Operators.CompareString)), It.o.AssocLookupField, closure95.ldBackOrder.OrderLineME.AssocLaborName, false) == 0, (Expression) Expression.Equal(It.t.AssocAssignTypeValue, 2, true, (MethodInfo) null)), new ParameterExpression[1]
                        //{
                        //  parameterExpression5
                        //})), (Expression<Func<M0, M1>>) (data => new{ a = data.a, t = data.t }));

                          IQueryable<Associate> source6 = (from al in se0085CtEntities1.AssocLookups
                                    join at in se0085CtEntities1.AssocAssignTypes
                                    on al.AssocAssignTypeId equals at.AssocAssignTypeId
                                    join ae in se0085CtEntities1.Associates
                                    on al.AssocId equals ae.AssocId
                                    where at.AssocAssignTypeValue == 2
                                    select new clsIAssociate
                                    {
                                        AssocId = ae.AssocId,
                                        AssocEmpId = ae.AssocEmpId,
                                        AssocLaborName = ae.AssocLaborName,
                                        AssocFirstName = ae.AssocFirstName,
                                        AssocLastName = ae.AssocLastName,
                                        AssocLogin = ae.AssocLogin,
                                        AssocSESA = ae.AssocSESA,
                                        AssocUserPriv = ae.AssocUserPriv,
                                        AssocEmail = ae.AssocEmail,
                                        AssocQCInsp = ae.AssocQCInsp,
                                        AssocActive = ae.AssocActive,
                                        AssocPhone = ae.AssocPhone,
                                        AssocExt = ae.AssocExt
                                    }).AsQueryable<clsIAssociate>();

                          IQueryable<AssocAssignType> src6 = (from al in se0085CtEntities1.AssocLookups
                                    join at in se0085CtEntities1.AssocAssignTypes
                                    on al.AssocAssignTypeId equals at.AssocAssignTypeId
                                    join ae in se0085CtEntities1.Associates
                                    on al.AssocId equals ae.AssocId
                                    where at.AssocAssignTypeValue == 2
                                    select new clsIAssocAssignType
                                    {
                                        AssocAssignTypeId = at.AssocAssignTypeId,
                                        AssocAssignTypeDesc = at.AssocAssignTypeDesc,
                                        AssocAssignTypeCode = at.AssocAssignTypeCode,
                                        AssocAssignTypeActive = at.AssocAssignTypeActive,
                                        AssocAssignTypeValue = at.AssocAssignTypeValue
                                    }).AsQueryable<clsIAssocAssignType>();
                        if (source6 != null && source6.Count() > 0 && src6 != null && src6.Count() > 0)
                        {
                          //clsBackorders closure98 = new clsBackorders();
                          Associate ldMEAssoc = new Associate();
                          AssocAssignType ldMEAssignType = new AssocAssignType();
                          //closure98.ldMEAssoc = source6.First().a;
                          //closure98.ldMEAssignType = source6.First().t;
                          ldMEAssoc = source6.First();
                          ldMEAssignType = src6.First();
                          //ParameterExpression parameterExpression2;
                          //if (((IQueryable<OrdLineAssocAssigned>) Queryable.Select<OrdLineAssocAssigned, OrdLineAssocAssigned>(Queryable.Where<OrdLineAssocAssigned>((IQueryable<M0>) se0085CtEntities1.OrdLineAssocAssigneds, (Expression<Func<M0, bool>>) Expression.Lambda<Func<OrdLineAssocAssigned, bool>>((Expression) Expression.And((Expression) Expression.And((Expression) Expression.Equal(q.Associate.AssocId, closure98.ldMEAssoc.AssocId, true, (MethodInfo) null), (Expression) Expression.Equal((Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrdLineAssocAssigned.get_AssocAssignType))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (AssocAssignType.get_AssocAssignTypeId))), (Expression) Expression.Property((Expression) Expression.Field((Expression) Expression.Constant((object) closure98, typeof (clsBackorders._Closure\u0024__95._Closure\u0024__96._Closure\u0024__98)), FieldInfo.GetFieldFromHandle(__fieldref (clsBackorders._Closure\u0024__95._Closure\u0024__96._Closure\u0024__98.ldMEAssignType))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (AssocAssignType.get_AssocAssignTypeId))), true, (MethodInfo) null)), (Expression) Expression.Equal((Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrdLineAssocAssigned.get_OrderLine))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderLine.get_OrderLineId))), (Expression) Expression.Property((Expression) Expression.Field((Expression) Expression.Constant((object) closure96, typeof (clsBackorders._Closure\u0024__95._Closure\u0024__96)), FieldInfo.GetFieldFromHandle(__fieldref (clsBackorders._Closure\u0024__95._Closure\u0024__96.ldOrderLine))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderLine.get_OrderLineId))), true, (MethodInfo) null)), new ParameterExpression[1]
                          //{
                          //  parameterExpression2
                          //})), (Expression<Func<M0, M1>>) (q => q))).Count<OrdLineAssocAssigned>() == 0)
                            IQueryable<OrdLineAssocAssigned> src61 = (from or in se0085CtEntities1.OrdLineAssocAssigneds
                                                            where or.Associate.AssocId == ldMEAssoc.AssocId
                                                            select new clsIOrdLineAssocAssigned
                                                            {
                                                                AssocAsgId = or.AssocAsgId,
                                                                AssocId = or.AssocId,
                                                                OrderLineId = or.OrderLineId,
                                                                AssocAssignTypeId = or.AssocAssignTypeId
                                                            }).AsQueryable<clsIOrdLineAssocAssigned>();
                        if(src61 != null && src61.Count() == 0)
                          {
                            se0085CtEntities1.OrdLineAssocAssigneds.Add(new OrdLineAssocAssigned()
                            {
                              Associate = ldMEAssoc,
                              AssocAssignType = ldMEAssignType,
                              OrderLine = ldOrderLine
                            });
                            se0085CtEntities1.SaveChanges();
                          }
                          ldMEAssoc = (Associate) null;
                          ldMEAssignType = (AssocAssignType) null;
                        }


                        //ParameterExpression parameterExpression6;
                        //IQueryable<AnonymousType_44<Associate, AssocAssignType>> source7 = Queryable.Select(Queryable.Where((IQueryable<M0>) Queryable.Join((IQueryable<M0>) Queryable.Join((IQueryable<M0>) se0085CtEntities1.AssocLookups, (IEnumerable<M1>) se0085CtEntities1.AssocAssignTypes, (Expression<Func<M0, M2>>) (o => o.AssocAssignType.AssocAssignTypeId), (Expression<Func<M1, M2>>) (t => t.AssocAssignTypeId), (Expression<Func<M0, M1, M3>>) ((o, t) => new{ o = o, t = t })), (IEnumerable<M1>) se0085CtEntities1.Associates, (Expression<Func<M0, M2>>) (data => data.o.Associate.AssocId), (Expression<Func<M1, M2>>) (a => a.AssocId), (Expression<Func<M0, M1, M3>>) ((data, a) => new
                        //{
                        //  o = data.o,
                        //  t = data.t,
                        //  a = a
                        //})), (Expression<Func<M0, bool>>) Expression.Lambda<Func<AnonymousType_43<AssocLookup, AssocAssignType, Associate>, bool>>((Expression) Expression.And(Expression.Call((Expression) null, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (Operators.CompareString)), It.o.AssocLookupField, closure95.ldBackOrder.OrderLineAE.AssocLaborName, false) == 0, (Expression) Expression.Equal(It.t.AssocAssignTypeValue, 3, true, (MethodInfo) null)), new ParameterExpression[1]
                        //{
                        //  parameterExpression6
                        //})), (Expression<Func<M0, M1>>) (data => new{ a = data.a, t = data.t }));

                        IQueryable<Associate> source7 = (from al in se0085CtEntities1.AssocLookups
                                    join at in se0085CtEntities1.AssocAssignTypes
                                    on al.AssocAssignTypeId equals at.AssocAssignTypeId
                                    join ae in se0085CtEntities1.Associates
                                    on al.AssocId equals ae.AssocId
                                    where at.AssocAssignTypeValue == 3
                                    select new clsIAssociate
                                    {
                                        AssocId = ae.AssocId,
                                        AssocEmpId = ae.AssocEmpId,
                                        AssocLaborName = ae.AssocLaborName,
                                        AssocFirstName = ae.AssocFirstName,
                                        AssocLastName = ae.AssocLastName,
                                        AssocLogin = ae.AssocLogin,
                                        AssocSESA = ae.AssocSESA,
                                        AssocUserPriv = ae.AssocUserPriv,
                                        AssocEmail = ae.AssocEmail,
                                        AssocQCInsp = ae.AssocQCInsp,
                                        AssocActive = ae.AssocActive,
                                        AssocPhone = ae.AssocPhone,
                                        AssocExt = ae.AssocExt
                                    }).AsQueryable<clsIAssociate>();

                          IQueryable<AssocAssignType> src7 = (from al in se0085CtEntities1.AssocLookups
                                    join at in se0085CtEntities1.AssocAssignTypes
                                    on al.AssocAssignTypeId equals at.AssocAssignTypeId
                                    join ae in se0085CtEntities1.Associates
                                    on al.AssocId equals ae.AssocId
                                    where at.AssocAssignTypeValue == 3
                                    select new clsIAssocAssignType
                                    {
                                        AssocAssignTypeId = at.AssocAssignTypeId,
                                        AssocAssignTypeDesc = at.AssocAssignTypeDesc,
                                        AssocAssignTypeCode = at.AssocAssignTypeCode,
                                        AssocAssignTypeActive = at.AssocAssignTypeActive,
                                        AssocAssignTypeValue = at.AssocAssignTypeValue
                                    }).AsQueryable<clsIAssocAssignType>();
                        if (source7 != null && source7.Count() > 0 && src7 != null && src7.Count() > 0)
                        {
                          Associate ldAEAssoc = new Associate();
                          AssocAssignType ldAEAssignType = new AssocAssignType();
                          ldAEAssoc = source7.First();
                          ldAEAssignType = src7.First();
                          //ParameterExpression parameterExpression2;
                          //if (((IQueryable<OrdLineAssocAssigned>) Queryable.Select<OrdLineAssocAssigned, OrdLineAssocAssigned>(Queryable.Where<OrdLineAssocAssigned>((IQueryable<M0>) se0085CtEntities1.OrdLineAssocAssigneds, (Expression<Func<M0, bool>>) Expression.Lambda<Func<OrdLineAssocAssigned, bool>>((Expression) Expression.And((Expression) Expression.And((Expression) Expression.Equal(q.Associate.AssocId, closure99.ldAEAssoc.AssocId, true, (MethodInfo) null), (Expression) Expression.Equal((Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrdLineAssocAssigned.get_AssocAssignType))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (AssocAssignType.get_AssocAssignTypeId))), (Expression) Expression.Property((Expression) Expression.Field((Expression) Expression.Constant((object) closure99, typeof (clsBackorders._Closure\u0024__95._Closure\u0024__96._Closure\u0024__99)), FieldInfo.GetFieldFromHandle(__fieldref (clsBackorders._Closure\u0024__95._Closure\u0024__96._Closure\u0024__99.ldAEAssignType))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (AssocAssignType.get_AssocAssignTypeId))), true, (MethodInfo) null)), (Expression) Expression.Equal((Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrdLineAssocAssigned.get_OrderLine))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderLine.get_OrderLineId))), (Expression) Expression.Property((Expression) Expression.Field((Expression) Expression.Constant((object) closure96, typeof (clsBackorders._Closure\u0024__95._Closure\u0024__96)), FieldInfo.GetFieldFromHandle(__fieldref (clsBackorders._Closure\u0024__95._Closure\u0024__96.ldOrderLine))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderLine.get_OrderLineId))), true, (MethodInfo) null)), new ParameterExpression[1]
                          //{
                          //  parameterExpression2
                          //})), (Expression<Func<M0, M1>>) (q => q))).Count<OrdLineAssocAssigned>() == 0)
                          IQueryable<OrdLineAssocAssigned> src71 = (from or in se0085CtEntities1.OrdLineAssocAssigneds
                                                                    where or.Associate.AssocId == ldAEAssoc.AssocId
                                                                    select new clsIOrdLineAssocAssigned
                                                                    {
                                                                        AssocAsgId = or.AssocAsgId,
                                                                        AssocId = or.AssocId,
                                                                        OrderLineId = or.OrderLineId,
                                                                        AssocAssignTypeId = or.AssocAssignTypeId
                                                                    }).AsQueryable<clsIOrdLineAssocAssigned>();
                            if(src71 != null && src71.Count() == 0)
                            {
                                se0085CtEntities1.OrdLineAssocAssigneds.Add(new OrdLineAssocAssigned()
                                {
                                    Associate = ldAEAssoc,
                                    AssocAssignType = ldAEAssignType,
                                    OrderLine = ldOrderLine
                                });
                                se0085CtEntities1.SaveChanges();
                            }
                          ldAEAssoc = (Associate) null;
                          ldAEAssignType = (AssocAssignType) null;
                        }


                        //ParameterExpression parameterExpression7;
                        //IQueryable<AnonymousType_44<Associate, AssocAssignType>> source8 = Queryable.Select(Queryable.Where((IQueryable<M0>) Queryable.Join((IQueryable<M0>) Queryable.Join((IQueryable<M0>) se0085CtEntities1.AssocLookups, (IEnumerable<M1>) se0085CtEntities1.AssocAssignTypes, (Expression<Func<M0, M2>>) (o => o.AssocAssignType.AssocAssignTypeId), (Expression<Func<M1, M2>>) (t => t.AssocAssignTypeId), (Expression<Func<M0, M1, M3>>) ((o, t) => new{ o = o, t = t })), (IEnumerable<M1>) se0085CtEntities1.Associates, (Expression<Func<M0, M2>>) (data => data.o.Associate.AssocId), (Expression<Func<M1, M2>>) (a => a.AssocId), (Expression<Func<M0, M1, M3>>) ((data, a) => new
                        //{
                        //  o = data.o,
                        //  t = data.t,
                        //  a = a
                        //})), (Expression<Func<M0, bool>>) Expression.Lambda<Func<AnonymousType_43<AssocLookup, AssocAssignType, Associate>, bool>>((Expression) Expression.And(Expression.Call((Expression) null, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (Operators.CompareString)), It.o.AssocLookupField, closure95.ldBackOrder.OrderLineDM.AssocLaborName, false) == 0, (Expression) Expression.Equal(It.t.AssocAssignTypeValue, 4, true, (MethodInfo) null)), new ParameterExpression[1]
                        //{
                        //  parameterExpression7
                        //})), (Expression<Func<M0, M1>>) (data => new{ a = data.a, t = data.t }));
                        IQueryable<Associate> source8 = (from al in se0085CtEntities1.AssocLookups
                                                         join at in se0085CtEntities1.AssocAssignTypes
                                                         on al.AssocAssignTypeId equals at.AssocAssignTypeId
                                                         join ae in se0085CtEntities1.Associates
                                                         on al.AssocId equals ae.AssocId
                                                         where at.AssocAssignTypeValue == 4
                                                         select new clsIAssociate
                                                         {
                                                             AssocId = ae.AssocId,
                                                             AssocEmpId = ae.AssocEmpId,
                                                             AssocLaborName = ae.AssocLaborName,
                                                             AssocFirstName = ae.AssocFirstName,
                                                             AssocLastName = ae.AssocLastName,
                                                             AssocLogin = ae.AssocLogin,
                                                             AssocSESA = ae.AssocSESA,
                                                             AssocUserPriv = ae.AssocUserPriv,
                                                             AssocEmail = ae.AssocEmail,
                                                             AssocQCInsp = ae.AssocQCInsp,
                                                             AssocActive = ae.AssocActive,
                                                             AssocPhone = ae.AssocPhone,
                                                             AssocExt = ae.AssocExt
                                                         }).AsQueryable<clsIAssociate>();

                        IQueryable<AssocAssignType> src8 = (from al in se0085CtEntities1.AssocLookups
                                                            join at in se0085CtEntities1.AssocAssignTypes
                                                            on al.AssocAssignTypeId equals at.AssocAssignTypeId
                                                            join ae in se0085CtEntities1.Associates
                                                            on al.AssocId equals ae.AssocId
                                                            where at.AssocAssignTypeValue == 4
                                                            select new clsIAssocAssignType
                                                            {
                                                                AssocAssignTypeId = at.AssocAssignTypeId,
                                                                AssocAssignTypeDesc = at.AssocAssignTypeDesc,
                                                                AssocAssignTypeCode = at.AssocAssignTypeCode,
                                                                AssocAssignTypeActive = at.AssocAssignTypeActive,
                                                                AssocAssignTypeValue = at.AssocAssignTypeValue
                                                            }).AsQueryable<clsIAssocAssignType>();
                        if (source8 != null && source8.Count() > 0 && src8 != null && src8.Count() > 0)
                        {
                          //clsBackorders closure100 = new clsBackorders();
                          Associate ldDMAssoc = new Associate();
                          AssocAssignType ldDMAssignType = new AssocAssignType();
                          ldDMAssoc = source8.First();
                          ldDMAssignType = src8.First();
                          //ParameterExpression parameterExpression2;
                          //if (((IQueryable<OrdLineAssocAssigned>) Queryable.Select<OrdLineAssocAssigned, OrdLineAssocAssigned>(Queryable.Where<OrdLineAssocAssigned>((IQueryable<M0>) se0085CtEntities1.OrdLineAssocAssigneds, (Expression<Func<M0, bool>>) Expression.Lambda<Func<OrdLineAssocAssigned, bool>>((Expression) Expression.And((Expression) Expression.And((Expression) Expression.Equal(q.Associate.AssocId, closure100.ldDMAssoc.AssocId, true, (MethodInfo) null), (Expression) Expression.Equal((Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrdLineAssocAssigned.get_AssocAssignType))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (AssocAssignType.get_AssocAssignTypeId))), (Expression) Expression.Property((Expression) Expression.Field((Expression) Expression.Constant((object) closure100, typeof (clsBackorders._Closure\u0024__95._Closure\u0024__96._Closure\u0024__100)), FieldInfo.GetFieldFromHandle(__fieldref (clsBackorders._Closure\u0024__95._Closure\u0024__96._Closure\u0024__100.ldDMAssignType))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (AssocAssignType.get_AssocAssignTypeId))), true, (MethodInfo) null)), (Expression) Expression.Equal((Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrdLineAssocAssigned.get_OrderLine))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderLine.get_OrderLineId))), (Expression) Expression.Property((Expression) Expression.Field((Expression) Expression.Constant((object) closure96, typeof (clsBackorders._Closure\u0024__95._Closure\u0024__96)), FieldInfo.GetFieldFromHandle(__fieldref (clsBackorders._Closure\u0024__95._Closure\u0024__96.ldOrderLine))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderLine.get_OrderLineId))), true, (MethodInfo) null)), new ParameterExpression[1]
                          //{
                          //  parameterExpression2
                          //})), (Expression<Func<M0, M1>>) (q => q))).Count<OrdLineAssocAssigned>() == 0)
                            IQueryable<OrdLineAssocAssigned> src81 = (from or in se0085CtEntities1.OrdLineAssocAssigneds
                                                                      where or.Associate.AssocId == ldDMAssoc.AssocId
                                                                      select new clsIOrdLineAssocAssigned
                                                                    {
                                                                        AssocAsgId = or.AssocAsgId,
                                                                        AssocId = or.AssocId,
                                                                        OrderLineId = or.OrderLineId,
                                                                        AssocAssignTypeId = or.AssocAssignTypeId
                                                                    }).AsQueryable<clsIOrdLineAssocAssigned>();
                          if(src81 != null && src81.Count() == 0)
                          {
                              //COMMENTED OUT BCZ OF ERROR
                            //se0085CtEntities1.OrdLineAssocAssigneds.Add(new OrdLineAssocAssigned()
                            //{
                            //  Associate = ldDMAssoc,
                            //  AssocAssignType = ldDMAssignType,
                            //  OrderLine = ldOrderLine
                            //});
                            //se0085CtEntities1.SaveChanges();
                          }
                          ldDMAssoc = (Associate) null;
                          ldDMAssignType = (AssocAssignType) null;
                        }

                        //ParameterExpression parameterExpression8;
                        //IQueryable<AnonymousType_44<Associate, AssocAssignType>> source9 = Queryable.Select(Queryable.Where((IQueryable<M0>) Queryable.Join((IQueryable<M0>) Queryable.Join((IQueryable<M0>) se0085CtEntities1.AssocLookups, (IEnumerable<M1>) se0085CtEntities1.AssocAssignTypes, (Expression<Func<M0, M2>>) (o => o.AssocAssignType.AssocAssignTypeId), (Expression<Func<M1, M2>>) (t => t.AssocAssignTypeId), (Expression<Func<M0, M1, M3>>) ((o, t) => new{ o = o, t = t })), (IEnumerable<M1>) se0085CtEntities1.Associates, (Expression<Func<M0, M2>>) (data => data.o.Associate.AssocId), (Expression<Func<M1, M2>>) (a => a.AssocId), (Expression<Func<M0, M1, M3>>) ((data, a) => new
                        //{
                        //  o = data.o,
                        //  t = data.t,
                        //  a = a
                        //})), (Expression<Func<M0, bool>>) Expression.Lambda<Func<AnonymousType_43<AssocLookup, AssocAssignType, Associate>, bool>>((Expression) Expression.And(Expression.Call((Expression) null, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (Operators.CompareString)), It.o.AssocLookupField, closure95.ldBackOrder.OrderLineCSR.AssocLaborName, false) == 0, (Expression) Expression.Equal(It.t.AssocAssignTypeValue, 5, true, (MethodInfo) null)), new ParameterExpression[1]
                        //{
                        //  parameterExpression8
                        //})), (Expression<Func<M0, M1>>) (data => new{ a = data.a, t = data.t }));


                        IQueryable<Associate> source9 = (from al in se0085CtEntities1.AssocLookups
                                                         join at in se0085CtEntities1.AssocAssignTypes
                                                         on al.AssocAssignTypeId equals at.AssocAssignTypeId
                                                         join ae in se0085CtEntities1.Associates
                                                         on al.AssocId equals ae.AssocId
                                                         where at.AssocAssignTypeValue == 5
                                                         select new clsIAssociate
                                                         {
                                                             AssocId = ae.AssocId,
                                                             AssocEmpId = ae.AssocEmpId,
                                                             AssocLaborName = ae.AssocLaborName,
                                                             AssocFirstName = ae.AssocFirstName,
                                                             AssocLastName = ae.AssocLastName,
                                                             AssocLogin = ae.AssocLogin,
                                                             AssocSESA = ae.AssocSESA,
                                                             AssocUserPriv = ae.AssocUserPriv,
                                                             AssocEmail = ae.AssocEmail,
                                                             AssocQCInsp = ae.AssocQCInsp,
                                                             AssocActive = ae.AssocActive,
                                                             AssocPhone = ae.AssocPhone,
                                                             AssocExt = ae.AssocExt
                                                         }).AsQueryable<clsIAssociate>();

                        IQueryable<AssocAssignType> src9 = (from al in se0085CtEntities1.AssocLookups
                                                            join at in se0085CtEntities1.AssocAssignTypes
                                                            on al.AssocAssignTypeId equals at.AssocAssignTypeId
                                                            join ae in se0085CtEntities1.Associates
                                                            on al.AssocId equals ae.AssocId
                                                            where at.AssocAssignTypeValue == 5
                                                            select new clsIAssocAssignType
                                                            {
                                                                AssocAssignTypeId = at.AssocAssignTypeId,
                                                                AssocAssignTypeDesc = at.AssocAssignTypeDesc,
                                                                AssocAssignTypeCode = at.AssocAssignTypeCode,
                                                                AssocAssignTypeActive = at.AssocAssignTypeActive,
                                                                AssocAssignTypeValue = at.AssocAssignTypeValue
                                                            }).AsQueryable<clsIAssocAssignType>();
                        if (source9 != null && source9.Count() > 0 && src9 != null && src9.Count() > 0)
                        {
                          //clsBackorders closure101 = new clsBackorders();
                          Associate ldOSAssoc = new Associate();
                          AssocAssignType ldOSAssignType = new AssocAssignType();
                          ldOSAssoc = source9.First();
                          ldOSAssignType = src9.First();
                          //ParameterExpression parameterExpression2;
                          //if (((IQueryable<OrdLineAssocAssigned>) Queryable.Select<OrdLineAssocAssigned, OrdLineAssocAssigned>(Queryable.Where<OrdLineAssocAssigned>((IQueryable<M0>) se0085CtEntities1.OrdLineAssocAssigneds, (Expression<Func<M0, bool>>) Expression.Lambda<Func<OrdLineAssocAssigned, bool>>((Expression) Expression.And((Expression) Expression.And((Expression) Expression.Equal(q.Associate.AssocId, closure101.ldOSAssoc.AssocId, true, (MethodInfo) null), (Expression) Expression.Equal((Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrdLineAssocAssigned.get_AssocAssignType))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (AssocAssignType.get_AssocAssignTypeId))), (Expression) Expression.Property((Expression) Expression.Field((Expression) Expression.Constant((object) closure101, typeof (clsBackorders._Closure\u0024__95._Closure\u0024__96._Closure\u0024__101)), FieldInfo.GetFieldFromHandle(__fieldref (clsBackorders._Closure\u0024__95._Closure\u0024__96._Closure\u0024__101.ldOSAssignType))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (AssocAssignType.get_AssocAssignTypeId))), true, (MethodInfo) null)), (Expression) Expression.Equal((Expression) Expression.Property((Expression) Expression.Property((Expression) parameterExpression2, (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrdLineAssocAssigned.get_OrderLine))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderLine.get_OrderLineId))), (Expression) Expression.Property((Expression) Expression.Field((Expression) Expression.Constant((object) closure96, typeof (clsBackorders._Closure\u0024__95._Closure\u0024__96)), FieldInfo.GetFieldFromHandle(__fieldref (clsBackorders._Closure\u0024__95._Closure\u0024__96.ldOrderLine))), (MethodInfo) MethodBase.GetMethodFromHandle(__methodref (OrderLine.get_OrderLineId))), true, (MethodInfo) null)), new ParameterExpression[1]
                          //{
                          //  parameterExpression2
                          //})), (Expression<Func<M0, M1>>) (q => q))).Count<OrdLineAssocAssigned>() == 0)
                          IQueryable<OrdLineAssocAssigned> src91 = (from or in se0085CtEntities1.OrdLineAssocAssigneds
                                                                    where or.Associate.AssocId == ldOSAssoc.AssocId
                                                                    select new clsIOrdLineAssocAssigned
                                                                    {
                                                                        AssocAsgId = or.AssocAsgId,
                                                                        AssocId = or.AssocId,
                                                                        OrderLineId = or.OrderLineId,
                                                                        AssocAssignTypeId = or.AssocAssignTypeId
                                                                    }).AsQueryable<clsIOrdLineAssocAssigned>();
                          if (src91 != null && src91.Count() == 0)
                          {
                            se0085CtEntities1.OrdLineAssocAssigneds.Add(new OrdLineAssocAssigned()
                            {
                              Associate = ldOSAssoc,
                              AssocAssignType = ldOSAssignType,
                              OrderLine = ldOrderLine
                            });
                            se0085CtEntities1.SaveChanges();
                          }
                          ldOSAssoc = (Associate) null;
                          ldOSAssignType = (AssocAssignType) null;
                        }
                      }
                      else
                      {
                        int num2 = (int) Interaction.MsgBox((object) ("Multiple Order numbers found, aborting MES import for Order; " + ldBackOrder.OrderFO), MsgBoxStyle.Information, (object) "ONE QMS MES Import Error - E0001");
                        return;
                      }
                    //BLOCK 2 ENDS


                    //BLOCK 3 STARTS
                    //ParameterExpression parameterExpression9;
                    //IQueryable<OrderLinesExt> source10 = (IQueryable<OrderLinesExt>)Queryable.Select<OrderLinesExt, OrderLinesExt>(Queryable.Where<OrderLinesExt>((IQueryable<M0>)se0085CtEntities1.OrderLinesExts, (Expression<Func<M0, bool>>)Expression.Lambda<Func<OrderLinesExt, bool>>((Expression)Expression.Equal(x.OrderLine.OrderLineId, closure96.ldOrderLine.OrderLineId, true, (MethodInfo)null), new ParameterExpression[1]
                    //                                      {
                    //                                        parameterExpression9
                    //                                      })), (Expression<Func<M0, M1>>)(x => x));

                    IQueryable<OrderLinesExt> source10 = (from od in se0085CtEntities1.OrderLinesExts
                                                          where od.OrderLine.OrderLineId == ldOrderLine.OrderLineId
                                                          select new clsIOrderLinesExt
                                                          {
                                                              OrderLineSER = od.OrderLineSER,
                                                              OrderLineBook = od.OrderLineBook,
                                                              OrderLineNet = od.OrderLineNet,
                                                              OrderLineOrgTargetDt = od.OrderLineOrgTargetDt,
                                                              OrderLineCurTargetDt = od.OrderLineCurTargetDt,
                                                              OrderLineOrgShipDt = od.OrderLineOrgShipDt,
                                                              OrderLineOrgAssyStDt = od.OrderLineOrgAssyStDt,
                                                              OrderLineCurAssyStDt = od.OrderLineCurAssyStDt,
                                                              OrderLineActAssyStDt = od.OrderLineActAssyStDt,
                                                              OrderLineOrgEngrRelDt = od.OrderLineOrgEngrRelDt,
                                                              OrderLineCurEngrRelDt = od.OrderLineCurEngrRelDt,
                                                              OrderLineActEngrRelDt = od.OrderLineActEngrRelDt,
                                                              OrderLineNB4Dt = od.OrderLineNB4Dt,
                                                              OrderLineEngrGrp = od.OrderLineEngrGrp,
                                                              OrderLineMechClpx = od.OrderLineMechClpx,
                                                              OrderLineElecClpx = od.OrderLineElecClpx,
                                                              OrderLineEngComposite = (long?)0L,
                                                              OrderLinePeltCode = od.OrderLinePeltCode,
                                                              OrderLineDesc1 = od.OrderLineDesc1,
                                                              OrderStatus = (long?)0L,
                                                              OrderLineOrgCustRelDt = od.OrderLineOrgCustRelDt,
                                                              OrderLineCurCustRelDt = od.OrderLineCurCustRelDt,
                                                              OrderLineActCustRelDt = od.OrderLineActCustRelDt,
                                                              OrderLineOrgMechDDDt = od.OrderLineOrgMechDDDt,
                                                              OrderLineCurMechDDDt = od.OrderLineCurMechDDDt,
                                                              OrderLineActMechDDDt = od.OrderLineActMechDDDt,
                                                              OrderLineOrgAECompDt = od.OrderLineOrgAECompDt,
                                                              OrderLineCurAECompDt = od.OrderLineCurAECompDt,
                                                              OrderLineActAECompDt = od.OrderLineActAECompDt,
                                                              OrderLineOrgEECompDt = od.OrderLineOrgEECompDt,
                                                              OrderLineCurEECompDt = od.OrderLineCurEECompDt,
                                                              OrderLineActEECompDt = od.OrderLineActEECompDt,
                                                              OrderLineOrgAppElecDt = od.OrderLineOrgAppElecDt,
                                                              OrderLineCurAppElecDt = od.OrderLineCurAppElecDt,
                                                              OrderLineActAppElecDt = od.OrderLineActAppElecDt,
                                                              OrderLineOrgAppSentDt = od.OrderLineOrgAppSentDt,
                                                              OrderLineCurAppSentDt = od.OrderLineCurAppSentDt,
                                                              OrderLineActAppSentDt = od.OrderLineActAppSentDt,
                                                              OrderLineCplxA = od.OrderLineCplxA,
                                                              OrderLineCplxB = od.OrderLineCplxB,
                                                              OrderLineCplxC = od.OrderLineCplxC,
                                                              OrderLineAEHrs = od.OrderLineAEHrs,
                                                              OrderLineMDHrs = od.OrderLineMDHrs,
                                                              OrderLineEDHrs = od.OrderLineEDHrs,
                                                              OrderLineCOTPP = od.OrderLineCOTPP
                                                          }).AsQueryable<clsIOrderLinesExt>();
                    if (source10.Count<OrderLinesExt>() == 0)
                    {
                        ldOrderLine.OrderLinesExts.Add(new OrderLinesExt()
                        {
                            OrderLineSER = ldBackOrder.OrderLineSER,
                            OrderLineBook = (Decimal?)ldBackOrder.OrderLineBook,
                            OrderLineNet = (Decimal?)ldBackOrder.OrderLineNet,
                            OrderLineOrgTargetDt = (DateTime?)ldBackOrder.OrderLineOrgTargetDt,
                            OrderLineCurTargetDt = (DateTime?)ldBackOrder.OrderLineCurTargetDt,
                            OrderLineOrgShipDt = (DateTime?)ldBackOrder.OrderLineOrgShipDt,
                            OrderLineOrgAssyStDt = (DateTime?)ldBackOrder.OrderLineOrgAssyStDt,
                            OrderLineCurAssyStDt = (DateTime?)ldBackOrder.OrderLineCurAssyStDt,
                            OrderLineActAssyStDt = (DateTime?)ldBackOrder.OrderLineActAssyStDt,
                            OrderLineOrgEngrRelDt = (DateTime?)ldBackOrder.OrderLineOrgEngrRelDt,
                            OrderLineCurEngrRelDt = (DateTime?)ldBackOrder.OrderLineCurEngrRelDt,
                            OrderLineActEngrRelDt = (DateTime?)ldBackOrder.OrderLineActEngrRelDt,
                            OrderLineNB4Dt = (DateTime?)ldBackOrder.OrderLineNB4Dt,
                            OrderLineEngrGrp = ldBackOrder.OrderLineEngrGrp,
                            OrderLineMechClpx = ldBackOrder.OrderLineMechClpx,
                            OrderLineElecClpx = ldBackOrder.OrderLineElecClpx,
                            OrderLineEngComposite = (long?)0L,
                            OrderLinePeltCode = ldBackOrder.OrderLinePeltCode,
                            OrderLineDesc1 = ldBackOrder.OrderLineDesc1,
                            OrderStatus = (long?)0L,
                            OrderLineOrgCustRelDt = (DateTime?)ldBackOrder.OrderLineOrgCustRelDt,
                            OrderLineCurCustRelDt = (DateTime?)ldBackOrder.OrderLineCurCustRelDt,
                            OrderLineActCustRelDt = (DateTime?)ldBackOrder.OrderLineActCustRelDt,
                            OrderLineOrgMechDDDt = (DateTime?)ldBackOrder.OrderLineOrgMechDDDt,
                            OrderLineCurMechDDDt = (DateTime?)ldBackOrder.OrderLineCurMechDDDt,
                            OrderLineActMechDDDt = (DateTime?)ldBackOrder.OrderLineActMechDDDt,
                            OrderLineOrgAECompDt = (DateTime?)ldBackOrder.OrderLineOrgAECompDt,
                            OrderLineCurAECompDt = (DateTime?)ldBackOrder.OrderLineCurAECompDt,
                            OrderLineActAECompDt = (DateTime?)ldBackOrder.OrderLineActAECompDt,
                            OrderLineOrgEECompDt = (DateTime?)ldBackOrder.OrderLineOrgEECompDt,
                            OrderLineCurEECompDt = (DateTime?)ldBackOrder.OrderLineCurEECompDt,
                            OrderLineActEECompDt = (DateTime?)ldBackOrder.OrderLineActEECompDt,
                            OrderLineOrgAppElecDt = (DateTime?)ldBackOrder.OrderLineOrgAppElecDt,
                            OrderLineCurAppElecDt = (DateTime?)ldBackOrder.OrderLineCurAppElecDt,
                            OrderLineActAppElecDt = (DateTime?)ldBackOrder.OrderLineActAppElecDt,
                            OrderLineOrgAppSentDt = (DateTime?)ldBackOrder.OrderLineOrgAppSentDt,
                            OrderLineCurAppSentDt = (DateTime?)ldBackOrder.OrderLineCurAppSentDt,
                            OrderLineActAppSentDt = (DateTime?)ldBackOrder.OrderLineActAppSentDt,
                            OrderLineCplxA = ldBackOrder.OrderLineCplxA,
                            OrderLineCplxB = ldBackOrder.OrderLineCplxB,
                            OrderLineCplxC = ldBackOrder.OrderLineCplxC,
                            OrderLineAEHrs = (int?)ldBackOrder.OrderLineAEHrs,
                            OrderLineMDHrs = (int?)ldBackOrder.OrderLineMDHrs,
                            OrderLineEDHrs = (int?)ldBackOrder.OrderLineEDHrs,
                            OrderLineCOTPP = ldBackOrder.OrderLineCOTPP
                        });
                        se0085CtEntities1.SaveChanges();
                    }
                    else if (source10.Count<OrderLinesExt>() == 1)
                    {
                        OrderLinesExt orderLinesExt = source10.First<OrderLinesExt>();

                        orderLinesExt.OrderLineSER = ldBackOrder.OrderLineSER;
                        orderLinesExt.OrderLineBook = (Decimal?)ldBackOrder.OrderLineBook;
                        orderLinesExt.OrderLineNet = (Decimal?)ldBackOrder.OrderLineNet;
                        DateTime orderLineOrgTargetDt1 = ldBackOrder.OrderLineOrgTargetDt;
                        nullable11 = orderLinesExt.OrderLineOrgTargetDt;
                        bool? nullable12;
                        if (!nullable11.HasValue)
                        {
                            nullable12 = new bool?();
                        }
                        else
                        {
                            nullable8 = new bool?(DateTime.Compare(nullable11.GetValueOrDefault(), orderLineOrgTargetDt1) == 0);
                            nullable12 = nullable8;
                        }
                        nullable6 = nullable12;

                        DateTime date1 = Conversions.ToDate("01/01/1901");
                        DateTime? orderLineOrgTargetDt2 = orderLinesExt.OrderLineOrgTargetDt;
                        bool? nullable13;
                        if (!orderLineOrgTargetDt2.HasValue)
                        {
                            nullable13 = new bool?();
                        }
                        else
                        {
                            nullable10 = new bool?(DateTime.Compare(orderLineOrgTargetDt2.GetValueOrDefault(), date1) == 0);
                            nullable13 = nullable10;
                        }
                        nullable5 = nullable13;

                        bool? nullable14;
                        if (!nullable6.HasValue || !nullable6.GetValueOrDefault())
                        {
                            if (!nullable5.HasValue)
                                nullable14 = new bool?();
                            else if (!nullable5.GetValueOrDefault())
                            {
                                nullable14 = nullable6;
                            }
                            else
                            {
                                nullable3 = new bool?(true);
                                nullable14 = nullable3;
                            }
                        }
                        else
                        {
                            nullable9 = new bool?(true);
                            nullable14 = nullable9;
                        }
                        nullable2 = nullable14;

                        bool? nullable15;
                        if (!nullable2.HasValue)
                        {
                            nullable15 = new bool?();
                        }
                        else
                        {
                            nullable7 = new bool?(!nullable2.GetValueOrDefault());
                            nullable15 = nullable7;
                        }
                        nullable4 = nullable15;
                        if (nullable4.GetValueOrDefault())
                        {
                            clsLogWriter lcLogWriter = this.lcLogWriter;
                            string[] strArray1 = new string[6]
                                                  {
                                                    "Order ",
                                                    ldBackOrder.FOLineSLSS,
                                                    " Data Changed - Orig Target Date From; ",
                                                    null,
                                                    null,
                                                    null
                                                  };
                            string[] strArray2 = strArray1;
                            int index = 3;
                            nullable1 = orderLinesExt.OrderLineOrgTargetDt;
                            string str2 = nullable1.HasValue ? Conversions.ToString(nullable1.GetValueOrDefault()) : (string)null;
                            strArray2[index] = str2;
                            strArray1[4] = " To: ";
                            strArray1[5] = Conversions.ToString(ldBackOrder.OrderLineOrgTargetDt);
                            string logMessage = string.Concat(strArray1);
                            lcLogWriter.logData(logMessage);
                        }
                        orderLinesExt.OrderLineOrgTargetDt = (DateTime?)ldBackOrder.OrderLineOrgTargetDt;
                        DateTime orderLineCurTargetDt1 = ldBackOrder.OrderLineCurTargetDt;
                        nullable11 = orderLinesExt.OrderLineCurTargetDt;

                        bool? nullable16;
                        if (!nullable11.HasValue)
                        {
                            nullable16 = new bool?();
                        }
                        else
                        {
                            nullable8 = new bool?(DateTime.Compare(nullable11.GetValueOrDefault(), orderLineCurTargetDt1) == 0);
                            nullable16 = nullable8;
                        }
                        nullable6 = nullable16;

                        DateTime date2 = Conversions.ToDate("01/01/1901");
                        DateTime? orderLineCurTargetDt2 = orderLinesExt.OrderLineCurTargetDt;
                        bool? nullable17;
                        if (!orderLineCurTargetDt2.HasValue)
                        {
                            nullable17 = new bool?();
                        }
                        else
                        {
                            nullable10 = new bool?(DateTime.Compare(orderLineCurTargetDt2.GetValueOrDefault(), date2) == 0);
                            nullable17 = nullable10;
                        }
                        nullable5 = nullable17;

                        bool? nullable18;
                        if (!nullable6.HasValue || !nullable6.GetValueOrDefault())
                        {
                            if (!nullable5.HasValue)
                                nullable18 = new bool?();
                            else if (!nullable5.GetValueOrDefault())
                            {
                                nullable18 = nullable6;
                            }
                            else
                            {
                                nullable3 = new bool?(true);
                                nullable18 = nullable3;
                            }
                        }
                        else
                        {
                            nullable9 = new bool?(true);
                            nullable18 = nullable9;
                        }
                        nullable2 = nullable18;

                        bool? nullable19;
                        if (!nullable2.HasValue)
                        {
                            nullable19 = new bool?();
                        }
                        else
                        {
                            nullable7 = new bool?(!nullable2.GetValueOrDefault());
                            nullable19 = nullable7;
                        }
                        nullable4 = nullable19;


                        if (nullable4.GetValueOrDefault())
                        {
                            clsLogWriter lcLogWriter = this.lcLogWriter;
                            string[] strArray1 = new string[6]
                                                  {
                                                    "Order ",
                                                    ldBackOrder.FOLineSLSS,
                                                    " Data Changed - Current Target Date From; ",
                                                    null,
                                                    null,
                                                    null
                                                  };
                            string[] strArray2 = strArray1;
                            int index = 3;
                            nullable1 = orderLinesExt.OrderLineCurTargetDt;
                            string str2 = nullable1.HasValue ? Conversions.ToString(nullable1.GetValueOrDefault()) : (string)null;
                            strArray2[index] = str2;
                            strArray1[4] = " To: ";
                            strArray1[5] = Conversions.ToString(ldBackOrder.OrderLineCurTargetDt);
                            string logMessage = string.Concat(strArray1);
                            lcLogWriter.logData(logMessage);
                            if (DateTime.Compare(ldBackOrder.OrderLineCurTargetDt, DateTime.Today) > 0 & DateTime.Compare(ldBackOrder.OrderLineCurTargetDt, Conversions.ToDate("01/01/2020")) < 0 & (ldBackOrder.AssemblyLineId == 1 | ldBackOrder.AssemblyLineId == 2))
                            {
                                str1 = ldBackOrder.FOLineSLSS;
                            }
                        }
                        orderLinesExt.OrderLineCurTargetDt = (DateTime?)ldBackOrder.OrderLineCurTargetDt;
                        DateTime orderLineOrgShipDt1 = ldBackOrder.OrderLineOrgShipDt;
                        nullable11 = orderLinesExt.OrderLineOrgShipDt;

                        bool? nullable20;
                        if (!nullable11.HasValue)
                        {
                            nullable20 = new bool?();
                        }
                        else
                        {
                            nullable8 = new bool?(DateTime.Compare(nullable11.GetValueOrDefault(), orderLineOrgShipDt1) == 0);
                            nullable20 = nullable8;
                        }
                        nullable6 = nullable20;
                        DateTime date3 = Conversions.ToDate("01/01/1901");
                        DateTime? orderLineOrgShipDt2 = orderLinesExt.OrderLineOrgShipDt;

                        bool? nullable21;
                        if (!orderLineOrgShipDt2.HasValue)
                        {
                            nullable21 = new bool?();
                        }
                        else
                        {
                            nullable10 = new bool?(DateTime.Compare(orderLineOrgShipDt2.GetValueOrDefault(), date3) == 0);
                            nullable21 = nullable10;
                        }
                        nullable5 = nullable21;

                        bool? nullable22;
                        if (!nullable6.HasValue || !nullable6.GetValueOrDefault())
                        {
                            if (!nullable5.HasValue)
                                nullable22 = new bool?();
                            else if (!nullable5.GetValueOrDefault())
                            {
                                nullable22 = nullable6;
                            }
                            else
                            {
                                nullable3 = new bool?(true);
                                nullable22 = nullable3;
                            }
                        }
                        else
                        {
                            nullable9 = new bool?(true);
                            nullable22 = nullable9;
                        }
                        nullable2 = nullable22;


                        bool? nullable23;
                        if (!nullable2.HasValue)
                        {
                            nullable23 = new bool?();
                        }
                        else
                        {
                            nullable7 = new bool?(!nullable2.GetValueOrDefault());
                            nullable23 = nullable7;
                        }
                        nullable4 = nullable23;
                        if (nullable4.GetValueOrDefault())
                        {
                            clsLogWriter lcLogWriter = this.lcLogWriter;
                            string[] strArray1 = new string[6]
                                                  {
                                                    "Order ",
                                                    ldBackOrder.FOLineSLSS,
                                                    " Data Changed - Orig Ship Date From; ",
                                                    null,
                                                    null,
                                                    null
                                                  };
                            string[] strArray2 = strArray1;
                            int index = 3;
                            nullable1 = orderLinesExt.OrderLineOrgShipDt;
                            string str2 = nullable1.HasValue ? Conversions.ToString(nullable1.GetValueOrDefault()) : (string)null;
                            strArray2[index] = str2;
                            strArray1[4] = " To: ";
                            strArray1[5] = Conversions.ToString(ldBackOrder.OrderLineOrgShipDt);
                            string logMessage = string.Concat(strArray1);
                            lcLogWriter.logData(logMessage);
                        }
                        orderLinesExt.OrderLineOrgShipDt = (DateTime?)ldBackOrder.OrderLineOrgShipDt;
                        
                        DateTime orderLineOrgAssyStDt1 = ldBackOrder.OrderLineOrgAssyStDt;
                        nullable11 = orderLinesExt.OrderLineOrgAssyStDt;

                        bool? nullable24;
                        if (!nullable11.HasValue)
                        {
                            nullable24 = new bool?();
                        }
                        else
                        {
                            nullable8 = new bool?(DateTime.Compare(nullable11.GetValueOrDefault(), orderLineOrgAssyStDt1) == 0);
                            nullable24 = nullable8;
                        }
                        nullable6 = nullable24;
                        DateTime date4 = Conversions.ToDate("01/01/1901");
                        DateTime? orderLineOrgAssyStDt2 = orderLinesExt.OrderLineOrgAssyStDt;

                        bool? nullable25;
                        if (!orderLineOrgAssyStDt2.HasValue)
                        {
                            nullable25 = new bool?();
                        }
                        else
                        {
                            nullable10 = new bool?(DateTime.Compare(orderLineOrgAssyStDt2.GetValueOrDefault(), date4) == 0);
                            nullable25 = nullable10;
                        }
                        nullable5 = nullable25;


                        bool? nullable26;
                        if (!nullable6.HasValue || !nullable6.GetValueOrDefault())
                        {
                            if (!nullable5.HasValue)
                                nullable26 = new bool?();
                            else if (!nullable5.GetValueOrDefault())
                            {
                                nullable26 = nullable6;
                            }
                            else
                            {
                                nullable3 = new bool?(true);
                                nullable26 = nullable3;
                            }
                        }
                        else
                        {
                            nullable9 = new bool?(true);
                            nullable26 = nullable9;
                        }
                        nullable2 = nullable26;


                        bool? nullable27;
                        if (!nullable2.HasValue)
                        {
                            nullable27 = new bool?();
                        }
                        else
                        {
                            nullable7 = new bool?(!nullable2.GetValueOrDefault());
                            nullable27 = nullable7;
                        }
                        nullable4 = nullable27;
                        if (nullable4.GetValueOrDefault())
                        {
                            clsLogWriter lcLogWriter = this.lcLogWriter;
                            
                            string[] strArray1 = new string[6]
                                                  {
                                                    "Order ",
                                                    ldBackOrder.FOLineSLSS,
                                                    " Data Changed - Orig Assembly Start Date From; ",
                                                    null,
                                                    null,
                                                    null
                                                  };
                            string[] strArray2 = strArray1;
                            int index = 3;
                            nullable1 = orderLinesExt.OrderLineOrgAssyStDt;
                            string str2 = nullable1.HasValue ? Conversions.ToString(nullable1.GetValueOrDefault()) : (string)null;
                            strArray2[index] = str2;
                            strArray1[4] = " To: ";
                            
                            strArray1[5] = Conversions.ToString(ldBackOrder.OrderLineOrgAssyStDt);
                            string logMessage = string.Concat(strArray1);
                            lcLogWriter.logData(logMessage);
                        }                        
                        orderLinesExt.OrderLineOrgAssyStDt = (DateTime?)ldBackOrder.OrderLineOrgAssyStDt;                        
                        DateTime orderLineCurAssyStDt1 = ldBackOrder.OrderLineCurAssyStDt;
                        nullable11 = orderLinesExt.OrderLineCurAssyStDt;

                        bool? nullable28;
                        if (!nullable11.HasValue)
                        {
                            nullable28 = new bool?();
                        }
                        else
                        {
                            nullable8 = new bool?(DateTime.Compare(nullable11.GetValueOrDefault(), orderLineCurAssyStDt1) == 0);
                            nullable28 = nullable8;
                        }
                        nullable6 = nullable28;
                        DateTime date5 = Conversions.ToDate("01/01/1901");
                        DateTime? orderLineCurAssyStDt2 = orderLinesExt.OrderLineCurAssyStDt;

                        bool? nullable29;
                        if (!orderLineCurAssyStDt2.HasValue)
                        {
                            nullable29 = new bool?();
                        }
                        else
                        {
                            nullable10 = new bool?(DateTime.Compare(orderLineCurAssyStDt2.GetValueOrDefault(), date5) == 0);
                            nullable29 = nullable10;
                        }
                        nullable5 = nullable29;

                        bool? nullable30;
                        if (!nullable6.HasValue || !nullable6.GetValueOrDefault())
                        {
                            if (!nullable5.HasValue)
                                nullable30 = new bool?();
                            else if (!nullable5.GetValueOrDefault())
                            {
                                nullable30 = nullable6;
                            }
                            else
                            {
                                nullable3 = new bool?(true);
                                nullable30 = nullable3;
                            }
                        }
                        else
                        {
                            nullable9 = new bool?(true);
                            nullable30 = nullable9;
                        }
                        nullable2 = nullable30;


                        bool? nullable31;
                        if (!nullable2.HasValue)
                        {
                            nullable31 = new bool?();
                        }
                        else
                        {
                            nullable7 = new bool?(!nullable2.GetValueOrDefault());
                            nullable31 = nullable7;
                        }
                        nullable4 = nullable31;
                        if (nullable4.GetValueOrDefault())
                        {
                            clsLogWriter lcLogWriter = this.lcLogWriter;
                            string[] strArray1 = new string[6]
                                                  {
                                                    "Order ",
                                                    ldBackOrder.FOLineSLSS,
                                                    " Data Changed - Current Assembly Start Date From; ",
                                                    null,
                                                    null,
                                                    null
                                                  };
                            string[] strArray2 = strArray1;
                            int index = 3;
                            nullable1 = orderLinesExt.OrderLineCurAssyStDt;
                            string str2 = nullable1.HasValue ? Conversions.ToString(nullable1.GetValueOrDefault()) : (string)null;
                            strArray2[index] = str2;
                            strArray1[4] = " To: ";
                            strArray1[5] = Conversions.ToString(ldBackOrder.OrderLineCurAssyStDt);
                            string logMessage = string.Concat(strArray1);
                            lcLogWriter.logData(logMessage);
                        }
                        orderLinesExt.OrderLineCurAssyStDt = (DateTime?)ldBackOrder.OrderLineCurAssyStDt;
                        DateTime dateTime = Convert.ToDateTime("01-01-1901");
                        if (Operators.CompareString(ldBackOrder.AssemblyLineAbbrv, "SWBD", false) == 0 | Operators.CompareString(ldBackOrder.AssemblyLineAbbrv, "LVDO", false) == 0 && DateTime.Compare(ldBackOrder.OrderLineActEngrRelDt, Conversions.ToDate("01/01/1901")) > 0)
                        {
                            if ((ldBackOrder.OrderLineActAssyStDt - ldBackOrder.OrderLineActEngrRelDt).TotalDays > 1.0)
                            {
                                this.lcLogWriter.logData("Order " + ldBackOrder.FOLineSLSS + " Data Error - Actual Engr Release and Actual Assembly Start Date don't match, Engr Rel; " + Conversions.ToString(ldBackOrder.OrderLineActEngrRelDt) + " Assy Start; " + Conversions.ToString(ldBackOrder.OrderLineActAssyStDt));
                            }
                            if (DateTime.Compare(ldBackOrder.OrderLineActAssyStDt, dateTime) == 0 && (DateTime.Now - ldBackOrder.OrderLineActEngrRelDt).TotalDays > 1.0)
                            {
                                this.lcLogWriter.logData("Order " + ldBackOrder.FOLineSLSS + " Order Processing Error - Actual Engr Release more than 1 day and Actual Assembly Start Date = 01/01/1901, Engr Rel; " + Conversions.ToString(ldBackOrder.OrderLineActEngrRelDt) + " Assy Start; " + Conversions.ToString(ldBackOrder.OrderLineActAssyStDt));
                            }
                        }
                        DateTime lineOrgEngrRelDt1 = ldBackOrder.OrderLineOrgEngrRelDt;
                        nullable11 = orderLinesExt.OrderLineOrgEngrRelDt;


                        bool? nullable32;
                        if (!nullable11.HasValue)
                        {
                            nullable32 = new bool?();
                        }
                        else
                        {
                            nullable8 = new bool?(DateTime.Compare(nullable11.GetValueOrDefault(), lineOrgEngrRelDt1) == 0);
                            nullable32 = nullable8;
                        }
                        nullable6 = nullable32;
                        DateTime date6 = Conversions.ToDate("01/01/1901");
                        DateTime? lineOrgEngrRelDt2 = orderLinesExt.OrderLineOrgEngrRelDt;

                        bool? nullable33;
                        if (!lineOrgEngrRelDt2.HasValue)
                        {
                            nullable33 = new bool?();
                        }
                        else
                        {
                            nullable10 = new bool?(DateTime.Compare(lineOrgEngrRelDt2.GetValueOrDefault(), date6) == 0);
                            nullable33 = nullable10;
                        }
                        nullable5 = nullable33;

                        bool? nullable34;
                        if (!nullable6.HasValue || !nullable6.GetValueOrDefault())
                        {
                            if (!nullable5.HasValue)
                                nullable34 = new bool?();
                            else if (!nullable5.GetValueOrDefault())
                            {
                                nullable34 = nullable6;
                            }
                            else
                            {
                                nullable3 = new bool?(true);
                                nullable34 = nullable3;
                            }
                        }
                        else
                        {
                            nullable9 = new bool?(true);
                            nullable34 = nullable9;
                        }
                        nullable2 = nullable34;


                        bool? nullable35;
                        if (!nullable2.HasValue)
                        {
                            nullable35 = new bool?();
                        }
                        else
                        {
                            nullable7 = new bool?(!nullable2.GetValueOrDefault());
                            nullable35 = nullable7;
                        }
                        nullable4 = nullable35;
                        if (nullable4.GetValueOrDefault())
                        {
                            clsLogWriter lcLogWriter = this.lcLogWriter;
                            string[] strArray1 = new string[6]
                                                  {
                                                    "Order ",
                                                    ldBackOrder.FOLineSLSS,
                                                    " Data Changed - Orig Engr Rel Date From; ",
                                                    null,
                                                    null,
                                                    null
                                                  };
                            string[] strArray2 = strArray1;
                            int index = 3;
                            nullable1 = orderLinesExt.OrderLineOrgEngrRelDt;
                            string str2 = nullable1.HasValue ? Conversions.ToString(nullable1.GetValueOrDefault()) : (string)null;
                            strArray2[index] = str2;
                            strArray1[4] = " To: ";
                            strArray1[5] = Conversions.ToString(ldBackOrder.OrderLineOrgEngrRelDt);
                            string logMessage = string.Concat(strArray1);
                            lcLogWriter.logData(logMessage);
                        }
                        orderLinesExt.OrderLineOrgEngrRelDt = (DateTime?)ldBackOrder.OrderLineOrgEngrRelDt;
                        DateTime lineCurEngrRelDt1 = ldBackOrder.OrderLineCurEngrRelDt;
                        nullable11 = orderLinesExt.OrderLineCurEngrRelDt;

                        bool? nullable36;
                        if (!nullable11.HasValue)
                        {
                            nullable36 = new bool?();
                        }
                        else
                        {
                            nullable8 = new bool?(DateTime.Compare(nullable11.GetValueOrDefault(), lineCurEngrRelDt1) == 0);
                            nullable36 = nullable8;
                        }
                        nullable6 = nullable36;
                        DateTime date7 = Conversions.ToDate("01/01/1901");
                        DateTime? lineCurEngrRelDt2 = orderLinesExt.OrderLineCurEngrRelDt;
                        //
                        bool? nullable37;
                        if (!lineCurEngrRelDt2.HasValue)
                        {
                            nullable37 = new bool?();
                        }
                        else
                        {
                            nullable10 = new bool?(DateTime.Compare(lineCurEngrRelDt2.GetValueOrDefault(), date7) == 0);
                            nullable37 = nullable10;
                        }
                        nullable5 = nullable37;
                        //
                        bool? nullable38;
                        if (!nullable6.HasValue || !nullable6.GetValueOrDefault())
                        {
                            if (!nullable5.HasValue)
                                nullable38 = new bool?();
                            else if (!nullable5.GetValueOrDefault())
                            {
                                nullable38 = nullable6;
                            }
                            else
                            {
                                nullable3 = new bool?(true);
                                nullable38 = nullable3;
                            }
                        }
                        else
                        {
                            nullable9 = new bool?(true);
                            nullable38 = nullable9;
                        }
                        nullable2 = nullable38;
                        //
                        bool? nullable39;
                        if (!nullable2.HasValue)
                        {
                            nullable39 = new bool?();
                        }
                        else
                        {
                            nullable7 = new bool?(!nullable2.GetValueOrDefault());
                            nullable39 = nullable7;
                        }
                        nullable4 = nullable39;
                        if (nullable4.GetValueOrDefault())
                        {
                            clsLogWriter lcLogWriter = this.lcLogWriter;
                            string[] strArray1 = new string[6]
                                              {
                                                "Order ",
                                                ldBackOrder.FOLineSLSS,
                                                " Data Changed - Current Engr Rel Date From; ",
                                                null,
                                                null,
                                                null
                                              };
                            string[] strArray2 = strArray1;
                            int index = 3;
                            nullable1 = orderLinesExt.OrderLineCurEngrRelDt;
                            string str2 = nullable1.HasValue ? Conversions.ToString(nullable1.GetValueOrDefault()) : (string)null;
                            strArray2[index] = str2;
                            strArray1[4] = " To: ";
                            strArray1[5] = Conversions.ToString(ldBackOrder.OrderLineCurEngrRelDt);
                            string logMessage = string.Concat(strArray1);
                            lcLogWriter.logData(logMessage);
                        }
                        orderLinesExt.OrderLineCurEngrRelDt = (DateTime?)ldBackOrder.OrderLineCurEngrRelDt;
                        DateTime lineActEngrRelDt1 = ldBackOrder.OrderLineActEngrRelDt;
                        nullable11 = orderLinesExt.OrderLineActEngrRelDt;
                        //
                        bool? nullable40;
                        if (!nullable11.HasValue)
                        {
                            nullable40 = new bool?();
                        }
                        else
                        {
                            nullable8 = new bool?(DateTime.Compare(nullable11.GetValueOrDefault(), lineActEngrRelDt1) == 0);
                            nullable40 = nullable8;
                        }
                        nullable6 = nullable40;
                        DateTime date8 = Conversions.ToDate("01/01/1901");
                        DateTime? lineActEngrRelDt2 = orderLinesExt.OrderLineActEngrRelDt;
                        //
                        bool? nullable41;
                        if (!lineActEngrRelDt2.HasValue)
                        {
                            nullable41 = new bool?();
                        }
                        else
                        {
                            nullable10 = new bool?(DateTime.Compare(lineActEngrRelDt2.GetValueOrDefault(), date8) == 0);
                            nullable41 = nullable10;
                        }
                        nullable5 = nullable41;
                        //
                        bool? nullable42;
                        if (!nullable6.HasValue || !nullable6.GetValueOrDefault())
                        {
                            if (!nullable5.HasValue)
                                nullable42 = new bool?();
                            else if (!nullable5.GetValueOrDefault())
                            {
                                nullable42 = nullable6;
                            }
                            else
                            {
                                nullable3 = new bool?(true);
                                nullable42 = nullable3;
                            }
                        }
                        else
                        {
                            nullable9 = new bool?(true);
                            nullable42 = nullable9;
                        }
                        nullable2 = nullable42;
                        //
                        bool? nullable43;
                        if (!nullable2.HasValue)
                        {
                            nullable43 = new bool?();
                        }
                        else
                        {
                            nullable7 = new bool?(!nullable2.GetValueOrDefault());
                            nullable43 = nullable7;
                        }
                        nullable4 = nullable43;
                        if (nullable4.GetValueOrDefault())
                        {
                            clsLogWriter lcLogWriter = this.lcLogWriter;
                            string[] strArray1 = new string[6]
                                                  {
                                                    "Order ",
                                                    ldBackOrder.FOLineSLSS,
                                                    " Data Changed - Actual Engr Rel Date From; ",
                                                    null,
                                                    null,
                                                    null
                                                  };
                            string[] strArray2 = strArray1;
                            int index = 3;
                            nullable1 = orderLinesExt.OrderLineActEngrRelDt;
                            string str2 = nullable1.HasValue ? Conversions.ToString(nullable1.GetValueOrDefault()) : (string)null;
                            strArray2[index] = str2;
                            strArray1[4] = " To: ";
                            strArray1[5] = Conversions.ToString(ldBackOrder.OrderLineActEngrRelDt);
                            string logMessage = string.Concat(strArray1);
                            lcLogWriter.logData(logMessage);
                        }
                        orderLinesExt.OrderLineActEngrRelDt = (DateTime?)ldBackOrder.OrderLineActEngrRelDt;
                        DateTime orderLineNb4Dt1 = ldBackOrder.OrderLineNB4Dt;
                        nullable11 = orderLinesExt.OrderLineNB4Dt;
                        //
                        bool? nullable44;
                        if (!nullable11.HasValue)
                        {
                            nullable44 = new bool?();
                        }
                        else
                        {
                            nullable8 = new bool?(DateTime.Compare(nullable11.GetValueOrDefault(), orderLineNb4Dt1) == 0);
                            nullable44 = nullable8;
                        }
                        nullable6 = nullable44;
                        //
                        DateTime date9 = Conversions.ToDate("01/01/1901");
                        DateTime? orderLineNb4Dt2 = orderLinesExt.OrderLineNB4Dt;
                        bool? nullable45;
                        if (!orderLineNb4Dt2.HasValue)
                        {
                            nullable45 = new bool?();
                        }
                        else
                        {
                            nullable10 = new bool?(DateTime.Compare(orderLineNb4Dt2.GetValueOrDefault(), date9) == 0);
                            nullable45 = nullable10;
                        }
                        nullable5 = nullable45;
                        //
                        bool? nullable46;
                        if (!nullable6.HasValue || !nullable6.GetValueOrDefault())
                        {
                            if (!nullable5.HasValue)
                                nullable46 = new bool?();
                            else if (!nullable5.GetValueOrDefault())
                            {
                                nullable46 = nullable6;
                            }
                            else
                            {
                                nullable3 = new bool?(true);
                                nullable46 = nullable3;
                            }
                        }
                        else
                        {
                            nullable9 = new bool?(true);
                            nullable46 = nullable9;
                        }
                        nullable2 = nullable46;
                        //
                        bool? nullable47;
                        if (!nullable2.HasValue)
                        {
                            nullable47 = new bool?();
                        }
                        else
                        {
                            nullable7 = new bool?(!nullable2.GetValueOrDefault());
                            nullable47 = nullable7;
                        }
                        nullable4 = nullable47;
                        if (nullable4.GetValueOrDefault())
                        {
                            clsLogWriter lcLogWriter = this.lcLogWriter;
                            string[] strArray1 = new string[6]
                                                  {
                                                    "Order ",
                                                    ldBackOrder.FOLineSLSS,
                                                    " Data Changed - NB4 Date From; ",
                                                    null,
                                                    null,
                                                    null
                                                  };
                            string[] strArray2 = strArray1;
                            int index = 3;
                            nullable1 = orderLinesExt.OrderLineNB4Dt;
                            string str2 = nullable1.HasValue ? Conversions.ToString(nullable1.GetValueOrDefault()) : (string)null;
                            strArray2[index] = str2;
                            strArray1[4] = " To: ";
                            strArray1[5] = Conversions.ToString(ldBackOrder.OrderLineNB4Dt);
                            string logMessage = string.Concat(strArray1);
                            lcLogWriter.logData(logMessage);
                        }
                        orderLinesExt.OrderLineNB4Dt = (DateTime?)ldBackOrder.OrderLineNB4Dt;
                        orderLinesExt.OrderLineEngrGrp = ldBackOrder.OrderLineEngrGrp;
                        orderLinesExt.OrderLineMechClpx = ldBackOrder.OrderLineMechClpx;
                        orderLinesExt.OrderLineElecClpx = ldBackOrder.OrderLineElecClpx;
                        orderLinesExt.OrderLineEngComposite = (long?)0L;
                        orderLinesExt.OrderLinePeltCode = ldBackOrder.OrderLinePeltCode;
                        orderLinesExt.OrderLineDesc1 = ldBackOrder.OrderLineDesc1;
                        //
                        DateTime lineOrgCustRelDt1 = ldBackOrder.OrderLineOrgCustRelDt;
                        nullable11 = orderLinesExt.OrderLineOrgCustRelDt;
                        bool? nullable48;
                        if (!nullable11.HasValue)
                        {
                            nullable48 = new bool?();
                        }
                        else
                        {
                            nullable8 = new bool?(DateTime.Compare(nullable11.GetValueOrDefault(), lineOrgCustRelDt1) == 0);
                            nullable48 = nullable8;
                        }
                        nullable6 = nullable48;
                        //
                        DateTime date10 = Conversions.ToDate("01/01/1901");
                        DateTime? lineOrgCustRelDt2 = orderLinesExt.OrderLineOrgCustRelDt;
                        bool? nullable49;
                        if (!lineOrgCustRelDt2.HasValue)
                        {
                            nullable49 = new bool?();
                        }
                        else
                        {
                            nullable10 = new bool?(DateTime.Compare(lineOrgCustRelDt2.GetValueOrDefault(), date10) == 0);
                            nullable49 = nullable10;
                        }
                        nullable5 = nullable49;
                        //
                        bool? nullable50;
                        if (!nullable6.HasValue || !nullable6.GetValueOrDefault())
                        {
                            if (!nullable5.HasValue)
                                nullable50 = new bool?();
                            else if (!nullable5.GetValueOrDefault())
                            {
                                nullable50 = nullable6;
                            }
                            else
                            {
                                nullable3 = new bool?(true);
                                nullable50 = nullable3;
                            }
                        }
                        else
                        {
                            nullable9 = new bool?(true);
                            nullable50 = nullable9;
                        }
                        nullable2 = nullable50;
                        //
                        bool? nullable51;
                        if (!nullable2.HasValue)
                        {
                            nullable51 = new bool?();
                        }
                        else
                        {
                            nullable7 = new bool?(!nullable2.GetValueOrDefault());
                            nullable51 = nullable7;
                        }
                        nullable4 = nullable51;
                        if (nullable4.GetValueOrDefault())
                        {
                            clsLogWriter lcLogWriter = this.lcLogWriter;
                            string[] strArray1 = new string[6]
                                                  {
                                                    "Order ",
                                                    ldBackOrder.FOLineSLSS,
                                                    " Data Changed - Orig Cust Rel Date From; ",
                                                    null,
                                                    null,
                                                    null
                                                  };
                            string[] strArray2 = strArray1;
                            int index = 3;
                            nullable1 = orderLinesExt.OrderLineOrgCustRelDt;
                            string str2 = nullable1.HasValue ? Conversions.ToString(nullable1.GetValueOrDefault()) : (string)null;
                            strArray2[index] = str2;
                            strArray1[4] = " To: ";
                            strArray1[5] = Conversions.ToString(ldBackOrder.OrderLineOrgCustRelDt);
                            string logMessage = string.Concat(strArray1);
                            lcLogWriter.logData(logMessage);
                        }
                        orderLinesExt.OrderLineOrgCustRelDt = (DateTime?)ldBackOrder.OrderLineOrgCustRelDt;
                        //
                        DateTime lineCurCustRelDt1 = ldBackOrder.OrderLineCurCustRelDt;
                        nullable11 = orderLinesExt.OrderLineCurCustRelDt;
                        bool? nullable52;
                        if (!nullable11.HasValue)
                        {
                            nullable52 = new bool?();
                        }
                        else
                        {
                            nullable8 = new bool?(DateTime.Compare(nullable11.GetValueOrDefault(), lineCurCustRelDt1) == 0);
                            nullable52 = nullable8;
                        }
                        nullable6 = nullable52;
                        //
                        DateTime date11 = Conversions.ToDate("01/01/1901");
                        DateTime? lineCurCustRelDt2 = orderLinesExt.OrderLineCurCustRelDt;
                        bool? nullable53;
                        if (!lineCurCustRelDt2.HasValue)
                        {
                            nullable53 = new bool?();
                        }
                        else
                        {
                            nullable10 = new bool?(DateTime.Compare(lineCurCustRelDt2.GetValueOrDefault(), date11) == 0);
                            nullable53 = nullable10;
                        }
                        nullable5 = nullable53;
                        //
                        bool? nullable54;
                        if (!nullable6.HasValue || !nullable6.GetValueOrDefault())
                        {
                            if (!nullable5.HasValue)
                                nullable54 = new bool?();
                            else if (!nullable5.GetValueOrDefault())
                            {
                                nullable54 = nullable6;
                            }
                            else
                            {
                                nullable3 = new bool?(true);
                                nullable54 = nullable3;
                            }
                        }
                        else
                        {
                            nullable9 = new bool?(true);
                            nullable54 = nullable9;
                        }
                        nullable2 = nullable54;
                        //
                        bool? nullable55;
                        if (!nullable2.HasValue)
                        {
                            nullable55 = new bool?();
                        }
                        else
                        {
                            nullable7 = new bool?(!nullable2.GetValueOrDefault());
                            nullable55 = nullable7;
                        }
                        nullable4 = nullable55;
                        if (nullable4.GetValueOrDefault())
                        {
                            clsLogWriter lcLogWriter = this.lcLogWriter;
                            string[] strArray1 = new string[6]
                                                  {
                                                    "Order ",
                                                    ldBackOrder.FOLineSLSS,
                                                    " Data Changed - Current Cust Rel Date From; ",
                                                    null,
                                                    null,
                                                    null
                                                  };
                            string[] strArray2 = strArray1;
                            int index = 3;
                            nullable1 = orderLinesExt.OrderLineCurCustRelDt;
                            string str2 = nullable1.HasValue ? Conversions.ToString(nullable1.GetValueOrDefault()) : (string)null;
                            strArray2[index] = str2;
                            strArray1[4] = " To: ";
                            strArray1[5] = Conversions.ToString(ldBackOrder.OrderLineCurCustRelDt);
                            string logMessage = string.Concat(strArray1);
                            lcLogWriter.logData(logMessage);
                        }
                        orderLinesExt.OrderLineCurCustRelDt = (DateTime?)ldBackOrder.OrderLineCurCustRelDt;
                        //
                        DateTime lineActCustRelDt1 = ldBackOrder.OrderLineActCustRelDt;
                        nullable11 = orderLinesExt.OrderLineActCustRelDt;
                        bool? nullable56;
                        if (!nullable11.HasValue)
                        {
                            nullable56 = new bool?();
                        }
                        else
                        {
                            nullable8 = new bool?(DateTime.Compare(nullable11.GetValueOrDefault(), lineActCustRelDt1) == 0);
                            nullable56 = nullable8;
                        }
                        nullable6 = nullable56;
                        //
                        DateTime date12 = Conversions.ToDate("01/01/1901");
                        DateTime? lineActCustRelDt2 = orderLinesExt.OrderLineActCustRelDt;
                        bool? nullable57;
                        if (!lineActCustRelDt2.HasValue)
                        {
                            nullable57 = new bool?();
                        }
                        else
                        {
                            nullable10 = new bool?(DateTime.Compare(lineActCustRelDt2.GetValueOrDefault(), date12) == 0);
                            nullable57 = nullable10;
                        }
                        nullable5 = nullable57;
                        //
                        bool? nullable58;
                        if (!nullable6.HasValue || !nullable6.GetValueOrDefault())
                        {
                            if (!nullable5.HasValue)
                                nullable58 = new bool?();
                            else if (!nullable5.GetValueOrDefault())
                            {
                                nullable58 = nullable6;
                            }
                            else
                            {
                                nullable3 = new bool?(true);
                                nullable58 = nullable3;
                            }
                        }
                        else
                        {
                            nullable9 = new bool?(true);
                            nullable58 = nullable9;
                        }
                        nullable2 = nullable58;
                        //
                        bool? nullable59;
                        if (!nullable2.HasValue)
                        {
                            nullable59 = new bool?();
                        }
                        else
                        {
                            nullable7 = new bool?(!nullable2.GetValueOrDefault());
                            nullable59 = nullable7;
                        }
                        nullable4 = nullable59;
                        if (nullable4.GetValueOrDefault())
                        {
                            clsLogWriter lcLogWriter = this.lcLogWriter;
                            string[] strArray1 = new string[6]
                                              {
                                                "Order ",
                                                ldBackOrder.FOLineSLSS,
                                                " Data Changed - Actual Cust Rel Date From; ",
                                                null,
                                                null,
                                                null
                                              };
                            string[] strArray2 = strArray1;
                            int index = 3;
                            nullable1 = orderLinesExt.OrderLineActCustRelDt;
                            string str2 = nullable1.HasValue ? Conversions.ToString(nullable1.GetValueOrDefault()) : (string)null;
                            strArray2[index] = str2;
                            strArray1[4] = " To: ";
                            strArray1[5] = Conversions.ToString(ldBackOrder.OrderLineActCustRelDt);
                            string logMessage = string.Concat(strArray1);
                            lcLogWriter.logData(logMessage);
                        }
                        orderLinesExt.OrderLineActCustRelDt = (DateTime?)ldBackOrder.OrderLineActCustRelDt;
                        //
                        DateTime orderLineOrgMechDdDt1 = ldBackOrder.OrderLineOrgMechDDDt;
                        nullable11 = orderLinesExt.OrderLineOrgMechDDDt;
                        bool? nullable60;
                        if (!nullable11.HasValue)
                        {
                            nullable60 = new bool?();
                        }
                        else
                        {
                            nullable8 = new bool?(DateTime.Compare(nullable11.GetValueOrDefault(), orderLineOrgMechDdDt1) == 0);
                            nullable60 = nullable8;
                        }
                        nullable6 = nullable60;
                        //
                        DateTime date13 = Conversions.ToDate("01/01/1901");
                        DateTime? orderLineOrgMechDdDt2 = orderLinesExt.OrderLineOrgMechDDDt;
                        bool? nullable61;
                        if (!orderLineOrgMechDdDt2.HasValue)
                        {
                            nullable61 = new bool?();
                        }
                        else
                        {
                            nullable10 = new bool?(DateTime.Compare(orderLineOrgMechDdDt2.GetValueOrDefault(), date13) == 0);
                            nullable61 = nullable10;
                        }
                        nullable5 = nullable61;
                        //
                        bool? nullable62;
                        if (!nullable6.HasValue || !nullable6.GetValueOrDefault())
                        {
                            if (!nullable5.HasValue)
                                nullable62 = new bool?();
                            else if (!nullable5.GetValueOrDefault())
                            {
                                nullable62 = nullable6;
                            }
                            else
                            {
                                nullable3 = new bool?(true);
                                nullable62 = nullable3;
                            }
                        }
                        else
                        {
                            nullable9 = new bool?(true);
                            nullable62 = nullable9;
                        }
                        nullable2 = nullable62;
                        //
                        bool? nullable63;
                        if (!nullable2.HasValue)
                        {
                            nullable63 = new bool?();
                        }
                        else
                        {
                            nullable7 = new bool?(!nullable2.GetValueOrDefault());
                            nullable63 = nullable7;
                        }
                        nullable4 = nullable63;
                        if (nullable4.GetValueOrDefault())
                        {
                            clsLogWriter lcLogWriter = this.lcLogWriter;
                            string[] strArray1 = new string[6]
                                                  {
                                                    "Order ",
                                                    ldBackOrder.FOLineSLSS,
                                                    " Data Changed - Orig Mech DD Date From; ",
                                                    null,
                                                    null,
                                                    null
                                                  };
                            string[] strArray2 = strArray1;
                            int index = 3;
                            nullable1 = orderLinesExt.OrderLineOrgMechDDDt;
                            string str2 = nullable1.HasValue ? Conversions.ToString(nullable1.GetValueOrDefault()) : (string)null;
                            strArray2[index] = str2;
                            strArray1[4] = " To: ";
                            strArray1[5] = Conversions.ToString(ldBackOrder.OrderLineOrgMechDDDt);
                            string logMessage = string.Concat(strArray1);
                            lcLogWriter.logData(logMessage);
                        }
                        orderLinesExt.OrderLineOrgMechDDDt = (DateTime?)ldBackOrder.OrderLineOrgMechDDDt;
                        //
                        DateTime orderLineCurMechDdDt1 = ldBackOrder.OrderLineCurMechDDDt;
                        nullable11 = orderLinesExt.OrderLineCurMechDDDt;
                        bool? nullable64;
                        if (!nullable11.HasValue)
                        {
                            nullable64 = new bool?();
                        }
                        else
                        {
                            nullable8 = new bool?(DateTime.Compare(nullable11.GetValueOrDefault(), orderLineCurMechDdDt1) == 0);
                            nullable64 = nullable8;
                        }
                        nullable6 = nullable64;
                        //
                        DateTime date14 = Conversions.ToDate("01/01/1901");
                        DateTime? orderLineCurMechDdDt2 = orderLinesExt.OrderLineCurMechDDDt;
                        bool? nullable65;
                        if (!orderLineCurMechDdDt2.HasValue)
                        {
                            nullable65 = new bool?();
                        }
                        else
                        {
                            nullable10 = new bool?(DateTime.Compare(orderLineCurMechDdDt2.GetValueOrDefault(), date14) == 0);
                            nullable65 = nullable10;
                        }
                        nullable5 = nullable65;
                        //
                        bool? nullable66;
                        if (!nullable6.HasValue || !nullable6.GetValueOrDefault())
                        {
                            if (!nullable5.HasValue)
                                nullable66 = new bool?();
                            else if (!nullable5.GetValueOrDefault())
                            {
                                nullable66 = nullable6;
                            }
                            else
                            {
                                nullable3 = new bool?(true);
                                nullable66 = nullable3;
                            }
                        }
                        else
                        {
                            nullable9 = new bool?(true);
                            nullable66 = nullable9;
                        }
                        nullable2 = nullable66;
                        //
                        bool? nullable67;
                        if (!nullable2.HasValue)
                        {
                            nullable67 = new bool?();
                        }
                        else
                        {
                            nullable7 = new bool?(!nullable2.GetValueOrDefault());
                            nullable67 = nullable7;
                        }
                        nullable4 = nullable67;
                        if (nullable4.GetValueOrDefault())
                        {
                            clsLogWriter lcLogWriter = this.lcLogWriter;
                            string[] strArray1 = new string[6]
                                                  {
                                                    "Order ",
                                                    ldBackOrder.FOLineSLSS,
                                                    " Data Changed - Current Mech DD Date From; ",
                                                    null,
                                                    null,
                                                    null
                                                  };
                            string[] strArray2 = strArray1;
                            int index = 3;
                            nullable1 = orderLinesExt.OrderLineCurMechDDDt;
                            string str2 = nullable1.HasValue ? Conversions.ToString(nullable1.GetValueOrDefault()) : (string)null;
                            strArray2[index] = str2;
                            strArray1[4] = " To: ";
                            strArray1[5] = Conversions.ToString(ldBackOrder.OrderLineCurMechDDDt);
                            string logMessage = string.Concat(strArray1);
                            lcLogWriter.logData(logMessage);
                        }
                        orderLinesExt.OrderLineCurMechDDDt = (DateTime?)ldBackOrder.OrderLineCurMechDDDt;
                        //
                        DateTime orderLineActMechDdDt1 = ldBackOrder.OrderLineActMechDDDt;
                        nullable11 = orderLinesExt.OrderLineActMechDDDt;
                        bool? nullable68;
                        if (!nullable11.HasValue)
                        {
                            nullable68 = new bool?();
                        }
                        else
                        {
                            nullable8 = new bool?(DateTime.Compare(nullable11.GetValueOrDefault(), orderLineActMechDdDt1) == 0);
                            nullable68 = nullable8;
                        }
                        nullable6 = nullable68;
                        //
                        DateTime date15 = Conversions.ToDate("01/01/1901");
                        DateTime? orderLineActMechDdDt2 = orderLinesExt.OrderLineActMechDDDt;
                        bool? nullable69;
                        if (!orderLineActMechDdDt2.HasValue)
                        {
                            nullable69 = new bool?();
                        }
                        else
                        {
                            nullable10 = new bool?(DateTime.Compare(orderLineActMechDdDt2.GetValueOrDefault(), date15) == 0);
                            nullable69 = nullable10;
                        }
                        nullable5 = nullable69;
                        //
                        bool? nullable70;
                        if (!nullable6.HasValue || !nullable6.GetValueOrDefault())
                        {
                            if (!nullable5.HasValue)
                                nullable70 = new bool?();
                            else if (!nullable5.GetValueOrDefault())
                            {
                                nullable70 = nullable6;
                            }
                            else
                            {
                                nullable3 = new bool?(true);
                                nullable70 = nullable3;
                            }
                        }
                        else
                        {
                            nullable9 = new bool?(true);
                            nullable70 = nullable9;
                        }
                        nullable2 = nullable70;
                        //
                        bool? nullable71;
                        if (!nullable2.HasValue)
                        {
                            nullable71 = new bool?();
                        }
                        else
                        {
                            nullable7 = new bool?(!nullable2.GetValueOrDefault());
                            nullable71 = nullable7;
                        }
                        nullable4 = nullable71;
                        if (nullable4.GetValueOrDefault())
                        {
                            clsLogWriter lcLogWriter = this.lcLogWriter;
                            string[] strArray1 = new string[6]
                                                  {
                                                    "Order ",
                                                    ldBackOrder.FOLineSLSS,
                                                    " Data Changed - Actual Mech DD Date From; ",
                                                    null,
                                                    null,
                                                    null
                                                  };
                            string[] strArray2 = strArray1;
                            int index = 3;
                            nullable1 = orderLinesExt.OrderLineActMechDDDt;
                            string str2 = nullable1.HasValue ? Conversions.ToString(nullable1.GetValueOrDefault()) : (string)null;
                            strArray2[index] = str2;
                            strArray1[4] = " To: ";
                            strArray1[5] = Conversions.ToString(ldBackOrder.OrderLineActMechDDDt);
                            string logMessage = string.Concat(strArray1);
                            lcLogWriter.logData(logMessage);
                        }
                        
                        orderLinesExt.OrderLineActMechDDDt = (DateTime?)ldBackOrder.OrderLineActMechDDDt;
                        //
                        DateTime orderLineOrgAeCompDt1 = ldBackOrder.OrderLineOrgAECompDt;
                        nullable11 = orderLinesExt.OrderLineOrgAECompDt;
                        bool? nullable72;
                        if (!nullable11.HasValue)
                        {
                            nullable72 = new bool?();
                        }
                        else
                        {
                            nullable8 = new bool?(DateTime.Compare(nullable11.GetValueOrDefault(), orderLineOrgAeCompDt1) == 0);
                            nullable72 = nullable8;
                        }
                        nullable6 = nullable72;
                        //
                        DateTime date16 = Conversions.ToDate("01/01/1901");
                        DateTime? orderLineOrgAeCompDt2 = orderLinesExt.OrderLineOrgAECompDt;
                        bool? nullable73;
                        if (!orderLineOrgAeCompDt2.HasValue)
                        {
                            nullable73 = new bool?();
                        }
                        else
                        {
                            nullable10 = new bool?(DateTime.Compare(orderLineOrgAeCompDt2.GetValueOrDefault(), date16) == 0);
                            nullable73 = nullable10;
                        }
                        nullable5 = nullable73;
                        //
                        bool? nullable74;
                        if (!nullable6.HasValue || !nullable6.GetValueOrDefault())
                        {
                            if (!nullable5.HasValue)
                                nullable74 = new bool?();
                            else if (!nullable5.GetValueOrDefault())
                            {
                                nullable74 = nullable6;
                            }
                            else
                            {
                                nullable3 = new bool?(true);
                                nullable74 = nullable3;
                            }
                        }
                        else
                        {
                            nullable9 = new bool?(true);
                            nullable74 = nullable9;
                        }
                        nullable2 = nullable74;
                        //
                        bool? nullable75;
                        if (!nullable2.HasValue)
                        {
                            nullable75 = new bool?();
                        }
                        else
                        {
                            nullable7 = new bool?(!nullable2.GetValueOrDefault());
                            nullable75 = nullable7;
                        }
                        nullable4 = nullable75;
                        if (nullable4.GetValueOrDefault())
                        {
                            clsLogWriter lcLogWriter = this.lcLogWriter;
                            
                            string[] strArray1 = new string[6]
                                                  {
                                                    "Order ",
                                                    ldBackOrder.FOLineSLSS,
                                                    " Data Changed - Orig AE Comp Date From; ",
                                                    null,
                                                    null,
                                                    null
                                                  };
                            string[] strArray2 = strArray1;
                            int index = 3;
                            nullable1 = orderLinesExt.OrderLineOrgAECompDt;
                            string str2 = nullable1.HasValue ? Conversions.ToString(nullable1.GetValueOrDefault()) : (string)null;
                            strArray2[index] = str2;
                            strArray1[4] = " To: ";
                            
                            strArray1[5] = Conversions.ToString(ldBackOrder.OrderLineOrgAECompDt);
                            string logMessage = string.Concat(strArray1);
                            lcLogWriter.logData(logMessage);
                        }                        
                        orderLinesExt.OrderLineOrgAECompDt = (DateTime?)ldBackOrder.OrderLineOrgAECompDt;
                        //
                        DateTime orderLineCurAeCompDt1 = ldBackOrder.OrderLineCurAECompDt;
                        nullable11 = orderLinesExt.OrderLineCurAECompDt;
                        bool? nullable76;
                        if (!nullable11.HasValue)
                        {
                            nullable76 = new bool?();
                        }
                        else
                        {
                            nullable8 = new bool?(DateTime.Compare(nullable11.GetValueOrDefault(), orderLineCurAeCompDt1) == 0);
                            nullable76 = nullable8;
                        }
                        nullable6 = nullable76;
                        //
                        DateTime date17 = Conversions.ToDate("01/01/1901");
                        DateTime? orderLineCurAeCompDt2 = orderLinesExt.OrderLineCurAECompDt;
                        bool? nullable77;
                        if (!orderLineCurAeCompDt2.HasValue)
                        {
                            nullable77 = new bool?();
                        }
                        else
                        {
                            nullable10 = new bool?(DateTime.Compare(orderLineCurAeCompDt2.GetValueOrDefault(), date17) == 0);
                            nullable77 = nullable10;
                        }
                        nullable5 = nullable77;
                        //
                        bool? nullable78;
                        if (!nullable6.HasValue || !nullable6.GetValueOrDefault())
                        {
                            if (!nullable5.HasValue)
                                nullable78 = new bool?();
                            else if (!nullable5.GetValueOrDefault())
                            {
                                nullable78 = nullable6;
                            }
                            else
                            {
                                nullable3 = new bool?(true);
                                nullable78 = nullable3;
                            }
                        }
                        else
                        {
                            nullable9 = new bool?(true);
                            nullable78 = nullable9;
                        }
                        nullable2 = nullable78;
                        //
                        bool? nullable79;
                        if (!nullable2.HasValue)
                        {
                            nullable79 = new bool?();
                        }
                        else
                        {
                            nullable7 = new bool?(!nullable2.GetValueOrDefault());
                            nullable79 = nullable7;
                        }
                        nullable4 = nullable79;
                        if (nullable4.GetValueOrDefault())
                        {
                            clsLogWriter lcLogWriter = this.lcLogWriter;
                            
                            string[] strArray1 = new string[6]
                                                  {
                                                    "Order ",
                                                    ldBackOrder.FOLineSLSS,
                                                    " Data Changed - Current AE Comp Date From; ",
                                                    null,
                                                    null,
                                                    null
                                                  };
                            string[] strArray2 = strArray1;
                            int index = 3;
                            nullable1 = orderLinesExt.OrderLineCurAECompDt;
                            string str2 = nullable1.HasValue ? Conversions.ToString(nullable1.GetValueOrDefault()) : (string)null;
                            strArray2[index] = str2;
                            strArray1[4] = " To: ";
                            
                            strArray1[5] = Conversions.ToString(ldBackOrder.OrderLineCurAECompDt);
                            string logMessage = string.Concat(strArray1);
                            lcLogWriter.logData(logMessage);
                        }                        
                        orderLinesExt.OrderLineCurAECompDt = (DateTime?)ldBackOrder.OrderLineCurAECompDt;
                        //
                        DateTime orderLineActAeCompDt1 = ldBackOrder.OrderLineActAECompDt;
                        nullable11 = orderLinesExt.OrderLineActAECompDt;
                        bool? nullable80;
                        if (!nullable11.HasValue)
                        {
                            nullable80 = new bool?();
                        }
                        else
                        {
                            nullable8 = new bool?(DateTime.Compare(nullable11.GetValueOrDefault(), orderLineActAeCompDt1) == 0);
                            nullable80 = nullable8;
                        }
                        nullable6 = nullable80;
                        //
                        DateTime date18 = Conversions.ToDate("01/01/1901");
                        DateTime? orderLineActAeCompDt2 = orderLinesExt.OrderLineActAECompDt;
                        bool? nullable81;
                        if (!orderLineActAeCompDt2.HasValue)
                        {
                            nullable81 = new bool?();
                        }
                        else
                        {
                            nullable10 = new bool?(DateTime.Compare(orderLineActAeCompDt2.GetValueOrDefault(), date18) == 0);
                            nullable81 = nullable10;
                        }
                        nullable5 = nullable81;
                        //
                        bool? nullable82;
                        if (!nullable6.HasValue || !nullable6.GetValueOrDefault())
                        {
                            if (!nullable5.HasValue)
                                nullable82 = new bool?();
                            else if (!nullable5.GetValueOrDefault())
                            {
                                nullable82 = nullable6;
                            }
                            else
                            {
                                nullable3 = new bool?(true);
                                nullable82 = nullable3;
                            }
                        }
                        else
                        {
                            nullable9 = new bool?(true);
                            nullable82 = nullable9;
                        }
                        nullable2 = nullable82;
                        //
                        bool? nullable83;
                        if (!nullable2.HasValue)
                        {
                            nullable83 = new bool?();
                        }
                        else
                        {
                            nullable7 = new bool?(!nullable2.GetValueOrDefault());
                            nullable83 = nullable7;
                        }
                        nullable4 = nullable83;
                        if (nullable4.GetValueOrDefault())
                        {
                            clsLogWriter lcLogWriter = this.lcLogWriter;
                            
                            string[] strArray1 = new string[6]
                                                  {
                                                    "Order ",
                                                    ldBackOrder.FOLineSLSS,
                                                    " Data Changed - Actual AE Comp Date From; ",
                                                    null,
                                                    null,
                                                    null
                                                  };
                            string[] strArray2 = strArray1;
                            int index = 3;
                            nullable1 = orderLinesExt.OrderLineActAECompDt;
                            string str2 = nullable1.HasValue ? Conversions.ToString(nullable1.GetValueOrDefault()) : (string)null;
                            strArray2[index] = str2;
                            strArray1[4] = " To: ";
                            
                            strArray1[5] = Conversions.ToString(ldBackOrder.OrderLineActAECompDt);
                            string logMessage = string.Concat(strArray1);
                            lcLogWriter.logData(logMessage);
                        }                        
                        orderLinesExt.OrderLineActAECompDt = (DateTime?)ldBackOrder.OrderLineActAECompDt;
                        //
                        DateTime orderLineOrgEeCompDt1 = ldBackOrder.OrderLineOrgEECompDt;
                        nullable11 = orderLinesExt.OrderLineOrgEECompDt;
                        bool? nullable84;
                        if (!nullable11.HasValue)
                        {
                            nullable84 = new bool?();
                        }
                        else
                        {
                            nullable8 = new bool?(DateTime.Compare(nullable11.GetValueOrDefault(), orderLineOrgEeCompDt1) == 0);
                            nullable84 = nullable8;
                        }
                        nullable6 = nullable84;
                        //
                        DateTime date19 = Conversions.ToDate("01/01/1901");
                        DateTime? orderLineOrgEeCompDt2 = orderLinesExt.OrderLineOrgEECompDt;
                        bool? nullable85;
                        if (!orderLineOrgEeCompDt2.HasValue)
                        {
                            nullable85 = new bool?();
                        }
                        else
                        {
                            nullable10 = new bool?(DateTime.Compare(orderLineOrgEeCompDt2.GetValueOrDefault(), date19) == 0);
                            nullable85 = nullable10;
                        }
                        nullable5 = nullable85;
                        //
                        bool? nullable86;
                        if (!nullable6.HasValue || !nullable6.GetValueOrDefault())
                        {
                            if (!nullable5.HasValue)
                                nullable86 = new bool?();
                            else if (!nullable5.GetValueOrDefault())
                            {
                                nullable86 = nullable6;
                            }
                            else
                            {
                                nullable3 = new bool?(true);
                                nullable86 = nullable3;
                            }
                        }
                        else
                        {
                            nullable9 = new bool?(true);
                            nullable86 = nullable9;
                        }
                        nullable2 = nullable86;
                        //
                        bool? nullable87;
                        if (!nullable2.HasValue)
                        {
                            nullable87 = new bool?();
                        }
                        else
                        {
                            nullable7 = new bool?(!nullable2.GetValueOrDefault());
                            nullable87 = nullable7;
                        }
                        nullable4 = nullable87;
                        if (nullable4.GetValueOrDefault())
                        {
                            clsLogWriter lcLogWriter = this.lcLogWriter;                            
                            string[] strArray1 = new string[6]
                                                  {
                                                    "Order ",
                                                    ldBackOrder.FOLineSLSS,
                                                    " Data Changed - Orig EE Comp Date From; ",
                                                    null,
                                                    null,
                                                    null
                                                  };
                            string[] strArray2 = strArray1;
                            int index = 3;
                            nullable1 = orderLinesExt.OrderLineOrgEECompDt;
                            string str2 = nullable1.HasValue ? Conversions.ToString(nullable1.GetValueOrDefault()) : (string)null;
                            strArray2[index] = str2;
                            strArray1[4] = " To: ";
                            
                            strArray1[5] = Conversions.ToString(ldBackOrder.OrderLineOrgEECompDt);
                            string logMessage = string.Concat(strArray1);
                            lcLogWriter.logData(logMessage);
                        }                        
                        orderLinesExt.OrderLineOrgEECompDt = (DateTime?)ldBackOrder.OrderLineOrgEECompDt;    
                        //
                        DateTime orderLineCurEeCompDt1 = ldBackOrder.OrderLineCurEECompDt;
                        nullable11 = orderLinesExt.OrderLineCurEECompDt;
                        bool? nullable88;
                        if (!nullable11.HasValue)
                        {
                            nullable88 = new bool?();
                        }
                        else
                        {
                            nullable8 = new bool?(DateTime.Compare(nullable11.GetValueOrDefault(), orderLineCurEeCompDt1) == 0);
                            nullable88 = nullable8;
                        }
                        nullable6 = nullable88;
                        //
                        DateTime date20 = Conversions.ToDate("01/01/1901");
                        DateTime? orderLineCurEeCompDt2 = orderLinesExt.OrderLineCurEECompDt;
                        bool? nullable89;
                        if (!orderLineCurEeCompDt2.HasValue)
                        {
                            nullable89 = new bool?();
                        }
                        else
                        {
                            nullable10 = new bool?(DateTime.Compare(orderLineCurEeCompDt2.GetValueOrDefault(), date20) == 0);
                            nullable89 = nullable10;
                        }
                        nullable5 = nullable89;
                        //
                        bool? nullable90;
                        if (!nullable6.HasValue || !nullable6.GetValueOrDefault())
                        {
                            if (!nullable5.HasValue)
                                nullable90 = new bool?();
                            else if (!nullable5.GetValueOrDefault())
                            {
                                nullable90 = nullable6;
                            }
                            else
                            {
                                nullable3 = new bool?(true);
                                nullable90 = nullable3;
                            }
                        }
                        else
                        {
                            nullable9 = new bool?(true);
                            nullable90 = nullable9;
                        }
                        nullable2 = nullable90;
                        //
                        bool? nullable91;
                        if (!nullable2.HasValue)
                        {
                            nullable91 = new bool?();
                        }
                        else
                        {
                            nullable7 = new bool?(!nullable2.GetValueOrDefault());
                            nullable91 = nullable7;
                        }
                        nullable4 = nullable91;
                        if (nullable4.GetValueOrDefault())
                        {
                            clsLogWriter lcLogWriter = this.lcLogWriter;
                            
                            string[] strArray1 = new string[6]
                                                  {
                                                    "Order ",
                                                    ldBackOrder.FOLineSLSS,
                                                    " Data Changed - Current EE Comp Date From; ",
                                                    null,
                                                    null,
                                                    null
                                                  };
                            string[] strArray2 = strArray1;
                            int index = 3;
                            nullable1 = orderLinesExt.OrderLineCurEECompDt;
                            string str2 = nullable1.HasValue ? Conversions.ToString(nullable1.GetValueOrDefault()) : (string)null;
                            strArray2[index] = str2;
                            strArray1[4] = " To: ";                            
                            strArray1[5] = Conversions.ToString(ldBackOrder.OrderLineCurEECompDt);
                            string logMessage = string.Concat(strArray1);
                            lcLogWriter.logData(logMessage);
                        }                        
                        orderLinesExt.OrderLineCurEECompDt = (DateTime?)ldBackOrder.OrderLineCurEECompDt;  
                        //
                        DateTime orderLineActEeCompDt1 = ldBackOrder.OrderLineActEECompDt;
                        nullable11 = orderLinesExt.OrderLineActEECompDt;
                        bool? nullable92;
                        if (!nullable11.HasValue)
                        {
                            nullable92 = new bool?();
                        }
                        else
                        {
                            nullable8 = new bool?(DateTime.Compare(nullable11.GetValueOrDefault(), orderLineActEeCompDt1) == 0);
                            nullable92 = nullable8;
                        }
                        nullable6 = nullable92;
                        //
                        DateTime date21 = Conversions.ToDate("01/01/1901");
                        DateTime? orderLineActEeCompDt2 = orderLinesExt.OrderLineActEECompDt;
                        bool? nullable93;
                        if (!orderLineActEeCompDt2.HasValue)
                        {
                            nullable93 = new bool?();
                        }
                        else
                        {
                            nullable10 = new bool?(DateTime.Compare(orderLineActEeCompDt2.GetValueOrDefault(), date21) == 0);
                            nullable93 = nullable10;
                        }
                        nullable5 = nullable93;
                        //
                        bool? nullable94;
                        if (!nullable6.HasValue || !nullable6.GetValueOrDefault())
                        {
                            if (!nullable5.HasValue)
                                nullable94 = new bool?();
                            else if (!nullable5.GetValueOrDefault())
                            {
                                nullable94 = nullable6;
                            }
                            else
                            {
                                nullable3 = new bool?(true);
                                nullable94 = nullable3;
                            }
                        }
                        else
                        {
                            nullable9 = new bool?(true);
                            nullable94 = nullable9;
                        }
                        nullable2 = nullable94;
                        //
                        bool? nullable95;
                        if (!nullable2.HasValue)
                        {
                            nullable95 = new bool?();
                        }
                        else
                        {
                            nullable7 = new bool?(!nullable2.GetValueOrDefault());
                            nullable95 = nullable7;
                        }
                        nullable4 = nullable95;
                        if (nullable4.GetValueOrDefault())
                        {
                            clsLogWriter lcLogWriter = this.lcLogWriter;                            
                            string[] strArray1 = new string[6]
                                                  {
                                                    "Order ",
                                                    ldBackOrder.FOLineSLSS,
                                                    " Data Changed - Actual EE Comp Date From; ",
                                                    null,
                                                    null,
                                                    null
                                                  };
                            string[] strArray2 = strArray1;
                            int index = 3;
                            nullable1 = orderLinesExt.OrderLineActEECompDt;
                            string str2 = nullable1.HasValue ? Conversions.ToString(nullable1.GetValueOrDefault()) : (string)null;
                            strArray2[index] = str2;
                            strArray1[4] = " To: ";
                            
                            strArray1[5] = Conversions.ToString(ldBackOrder.OrderLineActEECompDt);
                            string logMessage = string.Concat(strArray1);
                            lcLogWriter.logData(logMessage);
                        }                        
                        orderLinesExt.OrderLineActEECompDt = (DateTime?)ldBackOrder.OrderLineActEECompDt;
                        //
                        DateTime lineOrgAppElecDt1 = ldBackOrder.OrderLineOrgAppElecDt;
                        nullable11 = orderLinesExt.OrderLineOrgAppElecDt;
                        bool? nullable96;
                        if (!nullable11.HasValue)
                        {
                            nullable96 = new bool?();
                        }
                        else
                        {
                            nullable8 = new bool?(DateTime.Compare(nullable11.GetValueOrDefault(), lineOrgAppElecDt1) == 0);
                            nullable96 = nullable8;
                        }
                        nullable6 = nullable96;
                        //
                        DateTime date22 = Conversions.ToDate("01/01/1901");
                        DateTime? lineOrgAppElecDt2 = orderLinesExt.OrderLineOrgAppElecDt;
                        bool? nullable97;
                        if (!lineOrgAppElecDt2.HasValue)
                        {
                            nullable97 = new bool?();
                        }
                        else
                        {
                            nullable10 = new bool?(DateTime.Compare(lineOrgAppElecDt2.GetValueOrDefault(), date22) == 0);
                            nullable97 = nullable10;
                        }
                        nullable5 = nullable97;
                        //
                        bool? nullable98;
                        if (!nullable6.HasValue || !nullable6.GetValueOrDefault())
                        {
                            if (!nullable5.HasValue)
                                nullable98 = new bool?();
                            else if (!nullable5.GetValueOrDefault())
                            {
                                nullable98 = nullable6;
                            }
                            else
                            {
                                nullable3 = new bool?(true);
                                nullable98 = nullable3;
                            }
                        }
                        else
                        {
                            nullable9 = new bool?(true);
                            nullable98 = nullable9;
                        }
                        nullable2 = nullable98;
                        //
                        bool? nullable99;
                        if (!nullable2.HasValue)
                        {
                            nullable99 = new bool?();
                        }
                        else
                        {
                            nullable7 = new bool?(!nullable2.GetValueOrDefault());
                            nullable99 = nullable7;
                        }
                        nullable4 = nullable99;
                        if (nullable4.GetValueOrDefault())
                        {
                            clsLogWriter lcLogWriter = this.lcLogWriter;
                            
                            string[] strArray1 = new string[6]
                                                  {
                                                    "Order ",
                                                    ldBackOrder.FOLineSLSS,
                                                    " Data Changed - Orig App Elec Date From; ",
                                                    null,
                                                    null,
                                                    null
                                                  };
                            string[] strArray2 = strArray1;
                            int index = 3;
                            nullable1 = orderLinesExt.OrderLineOrgAppElecDt;
                            string str2 = nullable1.HasValue ? Conversions.ToString(nullable1.GetValueOrDefault()) : (string)null;
                            strArray2[index] = str2;
                            strArray1[4] = " To: ";                            
                            strArray1[5] = Conversions.ToString(ldBackOrder.OrderLineOrgAppElecDt);
                            string logMessage = string.Concat(strArray1);
                            lcLogWriter.logData(logMessage);
                        }                        
                        orderLinesExt.OrderLineOrgAppElecDt = (DateTime?)ldBackOrder.OrderLineOrgAppElecDt;    
                        //
                        DateTime lineCurAppElecDt1 = ldBackOrder.OrderLineCurAppElecDt;
                        nullable11 = orderLinesExt.OrderLineCurAppElecDt;
                        bool? nullable100;
                        if (!nullable11.HasValue)
                        {
                            nullable100 = new bool?();
                        }
                        else
                        {
                            nullable8 = new bool?(DateTime.Compare(nullable11.GetValueOrDefault(), lineCurAppElecDt1) == 0);
                            nullable100 = nullable8;
                        }
                        nullable6 = nullable100;
                        //
                        DateTime date23 = Conversions.ToDate("01/01/1901");
                        DateTime? lineCurAppElecDt2 = orderLinesExt.OrderLineCurAppElecDt;
                        bool? nullable101;
                        if (!lineCurAppElecDt2.HasValue)
                        {
                            nullable101 = new bool?();
                        }
                        else
                        {
                            nullable10 = new bool?(DateTime.Compare(lineCurAppElecDt2.GetValueOrDefault(), date23) == 0);
                            nullable101 = nullable10;
                        }
                        nullable5 = nullable101;
                        //
                        bool? nullable102;
                        if (!nullable6.HasValue || !nullable6.GetValueOrDefault())
                        {
                            if (!nullable5.HasValue)
                                nullable102 = new bool?();
                            else if (!nullable5.GetValueOrDefault())
                            {
                                nullable102 = nullable6;
                            }
                            else
                            {
                                nullable3 = new bool?(true);
                                nullable102 = nullable3;
                            }
                        }
                        else
                        {
                            nullable9 = new bool?(true);
                            nullable102 = nullable9;
                        }
                        nullable2 = nullable102;
                        //
                        bool? nullable103;
                        if (!nullable2.HasValue)
                        {
                            nullable103 = new bool?();
                        }
                        else
                        {
                            nullable7 = new bool?(!nullable2.GetValueOrDefault());
                            nullable103 = nullable7;
                        }
                        nullable4 = nullable103;
                        if (nullable4.GetValueOrDefault())
                        {
                            clsLogWriter lcLogWriter = this.lcLogWriter;
                            
                            string[] strArray1 = new string[6]
                                                  {
                                                    "Order ",
                                                    ldBackOrder.FOLineSLSS,
                                                    " Data Changed - Current App Elec Date From; ",
                                                    null,
                                                    null,
                                                    null
                                                  };
                            string[] strArray2 = strArray1;
                            int index = 3;
                            nullable1 = orderLinesExt.OrderLineCurAppElecDt;
                            string str2 = nullable1.HasValue ? Conversions.ToString(nullable1.GetValueOrDefault()) : (string)null;
                            strArray2[index] = str2;
                            strArray1[4] = " To: ";                            
                            strArray1[5] = Conversions.ToString(ldBackOrder.OrderLineCurAppElecDt);
                            string logMessage = string.Concat(strArray1);
                            lcLogWriter.logData(logMessage);
                        }                        
                        orderLinesExt.OrderLineCurAppElecDt = (DateTime?)ldBackOrder.OrderLineCurAppElecDt;  
                        //
                        DateTime lineActAppElecDt1 = ldBackOrder.OrderLineActAppElecDt;
                        nullable11 = orderLinesExt.OrderLineActAppElecDt;
                        bool? nullable104;
                        if (!nullable11.HasValue)
                        {
                            nullable104 = new bool?();
                        }
                        else
                        {
                            nullable8 = new bool?(DateTime.Compare(nullable11.GetValueOrDefault(), lineActAppElecDt1) == 0);
                            nullable104 = nullable8;
                        }
                        nullable6 = nullable104;
                        //
                        DateTime date24 = Conversions.ToDate("01/01/1901");
                        DateTime? lineActAppElecDt2 = orderLinesExt.OrderLineActAppElecDt;
                        bool? nullable105;
                        if (!lineActAppElecDt2.HasValue)
                        {
                            nullable105 = new bool?();
                        }
                        else
                        {
                            nullable10 = new bool?(DateTime.Compare(lineActAppElecDt2.GetValueOrDefault(), date24) == 0);
                            nullable105 = nullable10;
                        }
                        nullable5 = nullable105;
                        //
                        bool? nullable106;
                        if (!nullable6.HasValue || !nullable6.GetValueOrDefault())
                        {
                            if (!nullable5.HasValue)
                                nullable106 = new bool?();
                            else if (!nullable5.GetValueOrDefault())
                            {
                                nullable106 = nullable6;
                            }
                            else
                            {
                                nullable3 = new bool?(true);
                                nullable106 = nullable3;
                            }
                        }
                        else
                        {
                            nullable9 = new bool?(true);
                            nullable106 = nullable9;
                        }
                        nullable2 = nullable106;
                        //
                        bool? nullable107;
                        if (!nullable2.HasValue)
                        {
                            nullable107 = new bool?();
                        }
                        else
                        {
                            nullable7 = new bool?(!nullable2.GetValueOrDefault());
                            nullable107 = nullable7;
                        }
                        nullable4 = nullable107;
                        if (nullable4.GetValueOrDefault())
                        {
                            clsLogWriter lcLogWriter = this.lcLogWriter;
                            
                            string[] strArray1 = new string[6]
                                                  {
                                                    "Order ",
                                                    ldBackOrder.FOLineSLSS,
                                                    " Data Changed - Actual App Elec Date From; ",
                                                    null,
                                                    null,
                                                    null
                                                  };
                            string[] strArray2 = strArray1;
                            int index = 3;
                            nullable1 = orderLinesExt.OrderLineActAppElecDt;
                            string str2 = nullable1.HasValue ? Conversions.ToString(nullable1.GetValueOrDefault()) : (string)null;
                            strArray2[index] = str2;
                            strArray1[4] = " To: ";
                            
                            strArray1[5] = Conversions.ToString(ldBackOrder.OrderLineActAppElecDt);
                            string logMessage = string.Concat(strArray1);
                            lcLogWriter.logData(logMessage);
                        }                        
                        orderLinesExt.OrderLineActAppElecDt = (DateTime?)ldBackOrder.OrderLineActAppElecDt;
                        //
                        DateTime lineOrgAppSentDt1 = ldBackOrder.OrderLineOrgAppSentDt;
                        nullable11 = orderLinesExt.OrderLineOrgAppSentDt;
                        bool? nullable108;
                        if (!nullable11.HasValue)
                        {
                            nullable108 = new bool?();
                        }
                        else
                        {
                            nullable8 = new bool?(DateTime.Compare(nullable11.GetValueOrDefault(), lineOrgAppSentDt1) == 0);
                            nullable108 = nullable8;
                        }
                        nullable6 = nullable108;
                        DateTime date25 = Conversions.ToDate("01/01/1901");
                        DateTime? lineOrgAppSentDt2 = orderLinesExt.OrderLineOrgAppSentDt;
                        bool? nullable109;
                        if (!lineOrgAppSentDt2.HasValue)
                        {
                            nullable109 = new bool?();
                        }
                        else
                        {
                            nullable10 = new bool?(DateTime.Compare(lineOrgAppSentDt2.GetValueOrDefault(), date25) == 0);
                            nullable109 = nullable10;
                        }
                        nullable5 = nullable109;
                        //
                        bool? nullable110;
                        if (!nullable6.HasValue || !nullable6.GetValueOrDefault())
                        {
                            if (!nullable5.HasValue)
                                nullable110 = new bool?();
                            else if (!nullable5.GetValueOrDefault())
                            {
                                nullable110 = nullable6;
                            }
                            else
                            {
                                nullable3 = new bool?(true);
                                nullable110 = nullable3;
                            }
                        }
                        else
                        {
                            nullable9 = new bool?(true);
                            nullable110 = nullable9;
                        }
                        nullable2 = nullable110;
                        //
                        bool? nullable111;
                        if (!nullable2.HasValue)
                        {
                            nullable111 = new bool?();
                        }
                        else
                        {
                            nullable7 = new bool?(!nullable2.GetValueOrDefault());
                            nullable111 = nullable7;
                        }
                        nullable4 = nullable111;
                        if (nullable4.GetValueOrDefault())
                        {
                            clsLogWriter lcLogWriter = this.lcLogWriter;
                            
                            string[] strArray1 = new string[6]
                                                  {
                                                    "Order ",
                                                    ldBackOrder.FOLineSLSS,
                                                    " Data Changed - Orig App Sent Date From; ",
                                                    null,
                                                    null,
                                                    null
                                                  };
                            string[] strArray2 = strArray1;
                            int index = 3;
                            nullable1 = orderLinesExt.OrderLineOrgAppSentDt;
                            string str2 = nullable1.HasValue ? Conversions.ToString(nullable1.GetValueOrDefault()) : (string)null;
                            strArray2[index] = str2;
                            strArray1[4] = " To: ";
                            
                            strArray1[5] = Conversions.ToString(ldBackOrder.OrderLineOrgAppSentDt);
                            string logMessage = string.Concat(strArray1);
                            lcLogWriter.logData(logMessage);
                        }                        
                        orderLinesExt.OrderLineOrgAppSentDt = (DateTime?)ldBackOrder.OrderLineOrgAppSentDt;
                        //
                        DateTime lineCurAppSentDt1 = ldBackOrder.OrderLineCurAppSentDt;
                        nullable11 = orderLinesExt.OrderLineCurAppSentDt;
                        bool? nullable112;
                        if (!nullable11.HasValue)
                        {
                            nullable112 = new bool?();
                        }
                        else
                        {
                            nullable8 = new bool?(DateTime.Compare(nullable11.GetValueOrDefault(), lineCurAppSentDt1) == 0);
                            nullable112 = nullable8;
                        }
                        nullable6 = nullable112;
                        //
                        DateTime date26 = Conversions.ToDate("01/01/1901");
                        DateTime? lineCurAppSentDt2 = orderLinesExt.OrderLineCurAppSentDt;
                        bool? nullable113;
                        if (!lineCurAppSentDt2.HasValue)
                        {
                            nullable113 = new bool?();
                        }
                        else
                        {
                            nullable10 = new bool?(DateTime.Compare(lineCurAppSentDt2.GetValueOrDefault(), date26) == 0);
                            nullable113 = nullable10;
                        }
                        nullable5 = nullable113;
                        //
                        bool? nullable114;
                        if (!nullable6.HasValue || !nullable6.GetValueOrDefault())
                        {
                            if (!nullable5.HasValue)
                                nullable114 = new bool?();
                            else if (!nullable5.GetValueOrDefault())
                            {
                                nullable114 = nullable6;
                            }
                            else
                            {
                                nullable3 = new bool?(true);
                                nullable114 = nullable3;
                            }
                        }
                        else
                        {
                            nullable9 = new bool?(true);
                            nullable114 = nullable9;
                        }
                        nullable2 = nullable114;
                        //
                        bool? nullable115;
                        if (!nullable2.HasValue)
                        {
                            nullable115 = new bool?();
                        }
                        else
                        {
                            nullable7 = new bool?(!nullable2.GetValueOrDefault());
                            nullable115 = nullable7;
                        }
                        nullable4 = nullable115;
                        if (nullable4.GetValueOrDefault())
                        {
                            clsLogWriter lcLogWriter = this.lcLogWriter;
                            
                            string[] strArray1 = new string[6]
                                                  {
                                                    "Order ",
                                                    ldBackOrder.FOLineSLSS,
                                                    " Data Changed - Current App Sent Date From; ",
                                                    null,
                                                    null,
                                                    null
                                                  };
                            string[] strArray2 = strArray1;
                            int index = 3;
                            nullable1 = orderLinesExt.OrderLineCurAppSentDt;
                            string str2 = nullable1.HasValue ? Conversions.ToString(nullable1.GetValueOrDefault()) : (string)null;
                            strArray2[index] = str2;
                            strArray1[4] = " To: ";                            
                            strArray1[5] = Conversions.ToString(ldBackOrder.OrderLineCurAppSentDt);
                            string logMessage = string.Concat(strArray1);
                            lcLogWriter.logData(logMessage);
                        }                        
                        orderLinesExt.OrderLineCurAppSentDt = (DateTime?)ldBackOrder.OrderLineCurAppSentDt;   
                        //
                        DateTime lineActAppSentDt1 = ldBackOrder.OrderLineActAppSentDt;
                        nullable11 = orderLinesExt.OrderLineActAppSentDt;
                        bool? nullable116;
                        if (!nullable11.HasValue)
                        {
                            nullable116 = new bool?();
                        }
                        else
                        {
                            nullable8 = new bool?(DateTime.Compare(nullable11.GetValueOrDefault(), lineActAppSentDt1) == 0);
                            nullable116 = nullable8;
                        }
                        nullable6 = nullable116;
                        //
                        DateTime date27 = Conversions.ToDate("01/01/1901");
                        DateTime? lineActAppSentDt2 = orderLinesExt.OrderLineActAppSentDt;
                        bool? nullable117;
                        if (!lineActAppSentDt2.HasValue)
                        {
                            nullable117 = new bool?();
                        }
                        else
                        {
                            nullable10 = new bool?(DateTime.Compare(lineActAppSentDt2.GetValueOrDefault(), date27) == 0);
                            nullable117 = nullable10;
                        }
                        nullable5 = nullable117;
                        //
                        bool? nullable118;
                        if (!nullable6.HasValue || !nullable6.GetValueOrDefault())
                        {
                            if (!nullable5.HasValue)
                                nullable118 = new bool?();
                            else if (!nullable5.GetValueOrDefault())
                            {
                                nullable118 = nullable6;
                            }
                            else
                            {
                                nullable3 = new bool?(true);
                                nullable118 = nullable3;
                            }
                        }
                        else
                        {
                            nullable9 = new bool?(true);
                            nullable118 = nullable9;
                        }
                        nullable2 = nullable118;
                        //
                        bool? nullable119;
                        if (!nullable2.HasValue)
                        {
                            nullable119 = new bool?();
                        }
                        else
                        {
                            nullable7 = new bool?(!nullable2.GetValueOrDefault());
                            nullable119 = nullable7;
                        }
                        nullable4 = nullable119;
                        if (nullable4.GetValueOrDefault())
                        {
                            clsLogWriter lcLogWriter = this.lcLogWriter;                            
                            string[] strArray1 = new string[6]
                                                      {
                                                        "Order ",
                                                        ldBackOrder.FOLineSLSS,
                                                        " Data Changed - Actual App Sent Date From; ",
                                                        null,
                                                        null,
                                                        null
                                                      };
                            string[] strArray2 = strArray1;
                            int index = 3;
                            nullable1 = orderLinesExt.OrderLineActAppSentDt;
                            string str2 = nullable1.HasValue ? Conversions.ToString(nullable1.GetValueOrDefault()) : (string)null;
                            strArray2[index] = str2;
                            strArray1[4] = " To: ";                            
                            strArray1[5] = Conversions.ToString(ldBackOrder.OrderLineActAppSentDt);
                            string logMessage = string.Concat(strArray1);
                            lcLogWriter.logData(logMessage);
                        }
                        
                        orderLinesExt.OrderLineActAppSentDt = (DateTime?)ldBackOrder.OrderLineActAppSentDt;                        
                        orderLinesExt.OrderLineCplxA = ldBackOrder.OrderLineCplxA;                        
                        orderLinesExt.OrderLineCplxB = ldBackOrder.OrderLineCplxB;                        
                        orderLinesExt.OrderLineCplxC = ldBackOrder.OrderLineCplxC;                        
                        orderLinesExt.OrderLineAEHrs = (int?)ldBackOrder.OrderLineAEHrs;                        
                        orderLinesExt.OrderLineMDHrs = (int?)ldBackOrder.OrderLineMDHrs;                        
                        orderLinesExt.OrderLineEDHrs = (int?)ldBackOrder.OrderLineEDHrs;                        
                        if (Operators.CompareString(orderLinesExt.OrderLineCOTPP, ldBackOrder.OrderLineCOTPP, false) != 0)
                        {       
                            this.lcLogWriter.logData("Order " + ldBackOrder.FOLineSLSS + " CT01 Status Changed; " + orderLinesExt.OrderLineCOTPP + " To: " + ldBackOrder.OrderLineCOTPP);
                        }                        
                        orderLinesExt.OrderLineCOTPP = ldBackOrder.OrderLineCOTPP;
                        se0085CtEntities1.SaveChanges();
                    }
                    else
                    {                        
                        int num2 = (int)Interaction.MsgBox((object)("Multiple Order numbers found, aborting MES import for Order; " + ldBackOrder.OrderFO), MsgBoxStyle.Information, (object)"ONE QMS MES Import Error - E0012");
                        return;
                    }
                    if (str1.Length == 15)
                    {                        
                        this.lcLogWriter.logData("Updating Schedule for " + ldBackOrder.FOLineSLSS);                        
                        clsEngineMes.UpdateIfRouted(ldBackOrder.FOLineSLSS);
                    }
                    
                    ldBackOrder = (scOrderImportInfo)null;
                    se0085CtEntities1.Database.Connection.Close();
                    //BLOCK 3 ENDS
                }
                else
                {
                    int num3 = (int)Interaction.MsgBox((object)("Multiple AssemblyLine Ids found, aborting MES import for AssemblyLineId; " + Conversions.ToString(ldBackOrder.AssemblyLine.LevelId)), MsgBoxStyle.Information, (object)"ONE QMS MES Import Error - E0001");
                }
            }
        }

    }
}
