//-----------------------------------------------------------------------------------------------------
 public void Add_N7(string contPre, string contNum, string contChk, string contType = "")
 {
     if (m310.G_LX[0].G_N7 == null) { m310.G_LX[0].G_N7 = new List<G_N7>(); }
     var N7 = new G_N7
     {
         S_N7 = new S_N7 { D_206_1 = contPre, D_207_2 = contNum, D_761_18 = contChk, D_24_22 = contType }
     };
     SegmentCount++;
 }
        //-----------------------------------------------------------------------------------------------------
        public void Add_LX(XmlDocument doc, XmlNamespaceManager nsmgr)
        {
            if (m310.G_LX == null) { m310.G_LX = new List<G_LX>(); }
            XmlNode root = doc.DocumentElement;
            if (root != null)
            {
                var list = root.SelectNodes(@"//ns:SubShipment/ns:ContainerCollection/ns:Container/ns:ContainerNumber",
                nsmgr);
                if (list.Count > 0)
                {
                    for (var x = 0; x < list.Count; x++)
                    {
                        var LX = new G_LX { S_LX = new S_LX { D_554_1 = (x + 1).ToString() }, G_N7 = new List<G_N7>() };
                        SegmentCount++;
                        var N7 = new G_N7
                        {
                            S_N7 =
                            new S_N7
                            {
                                D_206_1 = list[x].InnerText.Substring(0, 4),
                                D_207_2 = list[x].InnerText.Substring(4, 7),
                                D_24_22 =
                                Func_GetXPathResultString(doc, nsmgr,
                                @"//ns:SubShipment/ns:ContainerCollection/ns:Container[ns:ContainerNumber='" +
                                list[x].InnerText + "']/ContainerType/ISOCode")
                            },
                            S_QTY =
                            new S_QTY
                            {
                                D_673_1 = X12_ID_673.Item39,
                                D_380_2 =
                                Func_GetXPathResultString(doc, nsmgr,
                                @"//ns:PackingLineCollection/ns:PackingLine[ns:ContainerNumber='" +
                                list[x].InnerText + "']/ns:PackQty")
                            }
                        };
                        LX.G_N7.Add(N7);
                        SegmentCount = SegmentCount + 2;
                        LX.G_L0 = new List<G_L0>();
                        var L0 = new G_L0
                        {
                            S_L0 =
                            new S_L0
                            {
                                D_213_1 = (x + 1).ToString(),
                                D_81_4 =
                                Func_GetXPathResultString(doc, nsmgr,
                                @"//ns:PackingLineCollection/ns:PackingLine[ns:ContainerNumber='" +
                                list[x].InnerText + "']/ns:Weight"),
                                D_187_5 = X12_ID_187.G,
                                D_187_5Specified = true,
                                D_80_8 =
                                Func_GetXPathResultString(doc, nsmgr,
                                @"//ns:PackingLineCollection/ns:PackingLine[ns:ContainerNumber='" +
                                list[x].InnerText + "']/ns:PackQty"),
                                D_211_9 = X12_ID_211.PLT, //Create Function For This
                                D_211_9Specified = true,
                                D_188_11 = X12_ID_188.K, //Create Function For This
                                D_188_11Specified = true
                            },
                            S_L5_2 = new List<S_L5_2>(),
                            G_L1_2 = new List<G_L1_2>()
                        };
                        LX.G_L0.Add(L0);
                        SegmentCount++;
                        var L52 = new S_L5_2
                        {
                            D_213_1 = (x + 1).ToString(),
                            D_79_2 =
                            Func_GetXPathResultString(doc, nsmgr,
                            @"//ns:PackingLineCollection/ns:PackingLine[ns:ContainerNumber='" +
                            list[x].InnerText + "']/ns:GoodsDescription"),
                            D_22_3 =
                            Func_GetXPathResultString(doc, nsmgr,
                            @"//ns:PackingLineCollection/ns:PackingLine[ns:ContainerNumber='" +
                            list[x].InnerText + "']/ns:Commodity/ns:Code"),
                            D_23_4 = X12_ID_23.J,
                            D_23_4Specified = true,
                            D_103_5 = "PLT"
                        };

                        if (L52.D_22_3 == string.Empty)
                        {
                            L52.D_23_4Specified = false;
                        }

                        L0.S_L5_2.Add(L52);
                        SegmentCount++;
                        var lines = root.SelectNodes(@"//ns:ChargeLineCollection/ns:ChargeLine", nsmgr);
                        if (lines.Count > 0)
                        {
                            for (var l = 0; l < lines.Count; l++)
                            {
                                var amnt = lines[l]["SellLocalAmount"].InnerText;
                                amnt = amnt.Substring(0, (amnt.IndexOf(".") + 3));
                                amnt = amnt.Replace(".", "");
                                var chgCode =
                                FileProcessor.Func_EDI_ConvertChargeCode(
                                FileProcessor.Func_SQL_GetCWOChargeCodeToX12(
                                lines[l]["ChargeCode"]["Code"].InnerText, "310GLO"));
                                var GL1 = new G_L1_2
                                {
                                    S_L1_2 =
                                    new S_L1_2
                                    {
                                        D_213_1 = (l + 1).ToString(),
                                        D_60_2 = lines[l]["SellLocalAmount"].InnerText,
                                        D_122_3 = X12_ID_122.PU,
                                        D_122_3Specified = true,
                                        D_58_4 = amnt,
                                        D_117_6 = "0",
                                        D_150_8 = chgCode,
                                        D_150_8Specified = true,
                                        D_16_11 = X12_ID_16.P,
                                        D_16_11Specified = true,
                                        D_276_12 = "",
                                        D_220_17 = "1",
                                        D_221_18 = X12_ID_221.NU,
                                        D_221_18Specified = true
                                    }
                                };
                                if ((l + 1) == lines.Count)
                                {
                                    GL1.S_C3_3 = new S_C3_3 { D_100_1 = "USD" };
                                    SegmentCount++;
                                }
                                L0.G_L1_2.Add(GL1);
                                SegmentCount++;
                            }
                        }
                        m310.G_LX.Add(LX);
                    }
                }
            }
        }