private void btnTranslate_Click(object sender, EventArgs e)
        {
            ediDocument oEdiDoc;
            ediSchema oSchema;
            ediSchemas oSchemas;
            ediDataSegment oSegment;
            string sSegmentID = "";
            string sValue = "";
            string sLoopSection = "";
            string sEdiFileName = "";
            string sSefFileName = "";
            int nArea = 0;
            string sQlfr = "";
            string sN1Entity = "";
            string sPath = AppDomain.CurrentDomain.BaseDirectory;

            // Create the top-level application object "ediDocument". 
            oEdiDoc = new ediDocument();

            // This makes certain that Framework EDI only uses the SEF file provided, 
            // and that it does not use its built-in Standard Reference table to translate 
            // the EDI document 
            oSchemas = (ediSchemas) oEdiDoc.GetSchemas();
            oSchemas.EnableStandardReference = false;

            // The FORWARD-ONLY cursor increases the performance of processing the EDI 
            // document (see Technical Note 3 below). 
            oEdiDoc.CursorType = DocumentCursorTypeConstants.Cursor_ForwardOnly;
            sEdiFileName = "940_004010.X12";
            sSefFileName = "940_004010.EVAL0.SEF";//EVALUAION SEF FILES

            // Specify SEF file to load. 
            oSchema = (ediSchema) oEdiDoc.LoadSchema(sPath + sSefFileName, SchemaTypeIDConstants.Schema_Standard_Exchange_Format);


            // Specify EDI document to read. 
            oEdiDoc.LoadEdi(sPath + sEdiFileName);

            // Gets the first data segment in the EDI document. 
            oSegment = (ediDataSegment) oEdiDoc.FirstDataSegment;

            // Loop that will traverse through the EDI document from top to bottom. This 
            // is required for FORWARD-ONLY cursor. 
            while (oSegment != null)
            {

                // Data segments are uniquely identified by their segment Identifier (ID). 
                // The loop section and the area (or table) properties of the data segment 
                // are read for each iteration of the loop.  
                sSegmentID = oSegment.ID;
                sLoopSection = oSegment.LoopSection;
                nArea = oSegment.Area;

                if (nArea == 0)
                {

                    // Data segments that are not designated an area (i.e. area = 0)  
                    // are control segments that are part of the Interchange or  
                    // Functional Group envelopes, and are not part of the Transaction Set. 

                    if (sSegmentID == "ISA")
                    {
                        sValue = oSegment.get_DataElementValue(1, 0);         // Authorization Information Qualifier (I01) 
                        sValue = oSegment.get_DataElementValue(2, 0);         // Authorization Information (I02) 
                        sValue = oSegment.get_DataElementValue(3, 0);         // Security Information Qualifier (I03) 
                        sValue = oSegment.get_DataElementValue(4, 0);         // Security Information (I04) 
                        sValue = oSegment.get_DataElementValue(5, 0);         // Interchange ID Qualifier (I05) 
                        sValue = oSegment.get_DataElementValue(6, 0);         // Interchange Sender ID (I06) 
                        sValue = oSegment.get_DataElementValue(7, 0);         // Interchange ID Qualifier (I05) 
                        sValue = oSegment.get_DataElementValue(8, 0);         // Interchange Receiver ID (I07) 
                        sValue = oSegment.get_DataElementValue(9, 0);         // Interchange Date (I08) 
                        sValue = oSegment.get_DataElementValue(10, 0);         // Interchange Time (I09) 
                        sValue = oSegment.get_DataElementValue(11, 0);         // Interchange Control Standards Identifier (I10) 
                        sValue = oSegment.get_DataElementValue(12, 0);         // Interchange Control Version Number (I11) 
                        listBox1.Items.Add(oSegment.get_DataElementValue(13, 0));         // Interchange Control Number (I12) 
                        sValue = oSegment.get_DataElementValue(14, 0);         // Acknowledgment Requested (I13) 
                        sValue = oSegment.get_DataElementValue(15, 0);         // Usage Indicator (I14) 
                        sValue = oSegment.get_DataElementValue(16, 0);         // Component Element Separator (I15) 

                    }
                    else if (sSegmentID == "IEA")
                    {
                        sValue = oSegment.get_DataElementValue(1, 0);         // Number of Included Functional Groups (I16) 
                        sValue = oSegment.get_DataElementValue(2, 0);         // Interchange Control Number (I12) 

                    }
                    else if (sSegmentID == "GS")
                    {
                        sValue = oSegment.get_DataElementValue(1, 0);         // Functional Identifier Code (479) 
                        sValue = oSegment.get_DataElementValue(2, 0);         // Application Sender's Code (142) 
                        sValue = oSegment.get_DataElementValue(3, 0);         // Application Receiver's Code (124) 
                        sValue = oSegment.get_DataElementValue(4, 0);         // Date (373) 
                        sValue = oSegment.get_DataElementValue(5, 0);         // Time (337) 
                        listBox1.Items.Add(oSegment.get_DataElementValue(6, 0));         // Group Control Number (28) 
                        sValue = oSegment.get_DataElementValue(7, 0);         // Responsible Agency Code (455) 
                        sValue = oSegment.get_DataElementValue(8, 0);         // Version / Release / Industry Identifier Code (480) 

                    }
                    else if (sSegmentID == "GE")
                    {
                        sValue = oSegment.get_DataElementValue(1, 0);         // Number of Transaction Sets Included (97) 
                        sValue = oSegment.get_DataElementValue(2, 0);         // Group Control Number (28) 

                    }         // sSegmentID == "GE" 

                }
                else if (nArea == 1)
                {

                    // Data segments in area 1 are processed here. 

                    if (sLoopSection == "")
                    {

                        if (sSegmentID == "ST")         // Transaction Set Header 
                        {
                            sValue = oSegment.get_DataElementValue(1, 0);         // Transaction Set Identifier Code (143) 
                            listBox1.Items.Add(oSegment.get_DataElementValue(2, 0));         // Transaction Set Control Number (329) 

                        }
                        else if (sSegmentID == "W05")         // Shipping Order Identification 
                        {
                            sValue = oSegment.get_DataElementValue(1, 0);         // Order Status Code (473) 
                            listBox1.Items.Add(oSegment.get_DataElementValue(2, 0));         // Depositor Order Number (285) 
                            sValue = oSegment.get_DataElementValue(3, 0);         // Purchase Order Number (324) 

                        }
                        else if (sSegmentID == "N9")         // Reference Identification 
                        {
                            sQlfr = oSegment.get_DataElementValue(1, 0);         // Reference Identification Qualifier (128) 

                            if (sQlfr == "BM")  //Bill of Lading Number
                            {
                                listBox1.Items.Add(oSegment.get_DataElementValue(2, 0));         // Reference Identification (127) 

                            }
                            else if (sQlfr == "LO")// Load Planning Number
                            {
                                listBox1.Items.Add(oSegment.get_DataElementValue(2, 0));         // Reference Identification (127) 

                            }
                            
                        }
                        else if (sSegmentID == "G61")         // Contact 
                        {
                            sValue = oSegment.get_DataElementValue(1, 0);         // Contact Function Code (366) 
                            listBox1.Items.Add(oSegment.get_DataElementValue(2, 0));         // Name (93) 
                            sValue = oSegment.get_DataElementValue(3, 0);         // Communication Number Qualifier (365) 
                            sValue = oSegment.get_DataElementValue(4, 0);         // Communication Number (364) 

                        }
                        else if (sSegmentID == "G62")         // Date/Time 
                        {
                            sQlfr  = oSegment.get_DataElementValue(1, 0);         // Date Qualifier (432) 

                            if (sQlfr == "04")  //Purchase Date
                            {
                                listBox1.Items.Add("Purchase Date: " + oSegment.get_DataElementValue(2, 0));         // Date (373)
                            }
                            else if (sQlfr == "10") //Requested Ship Date
                            {
                                listBox1.Items.Add("Requested Ship Date: " + oSegment.get_DataElementValue(2, 0));         // Date (373)
                            }
                            else if (sQlfr == "54") //Deliver No Later Date
                            {
                                listBox1.Items.Add("Deliver No Later Date: " + oSegment.get_DataElementValue(2, 0));         // Date (373)
                            }
                            else if (sQlfr == "02") //Delivery Requested Date
                            {
                                listBox1.Items.Add("Delivery Requested Date: " + oSegment.get_DataElementValue(2, 0));         // Date (373)
                            }

                        }
                        else if (sSegmentID == "NTE")         // Note/Special Instruction 
                        {
                            sQlfr  = oSegment.get_DataElementValue(1, 0);         // Note Reference Code (363) 
                            if (sQlfr == "DEL")
                            {
                                listBox1.Items.Add(oSegment.get_DataElementValue(2, 0));         // Description (352) 

                            }
                            else if (sQlfr == "WHI")
                            {
                                listBox1.Items.Add(oSegment.get_DataElementValue(2, 0));         // Description (352) 

                            }
                            
                        }
                        else if (sSegmentID == "W66")         // Warehouse Carrier Information 
                        {
                            sValue = oSegment.get_DataElementValue(1, 0);         // Shipment Method of Payment (146) 
                            sValue = oSegment.get_DataElementValue(2, 0);         // Transportation Method/Type Code (91) 
                            sValue = oSegment.get_DataElementValue(3, 0);         // Pallet Exchange Code (399) 
                            sValue = oSegment.get_DataElementValue(4, 0);         // Unit Load Option Code (400) 
                            listBox1.Items.Add(oSegment.get_DataElementValue(5, 0));         // Routing (387) 
                            sValue = oSegment.get_DataElementValue(6, 0);         // F.O.B. Point Code (433) 
                            sValue = oSegment.get_DataElementValue(7, 0);         // F.O.B. Point (434) 
                            sValue = oSegment.get_DataElementValue(8, 0);         // COD Method of Payment Code (625) 
                            sValue = oSegment.get_DataElementValue(9, 0);         // Amount (610) 
                            sValue = oSegment.get_DataElementValue(10, 0);         // Standard Carrier Alpha Code (140) 

                        }

                    }
                    else if (sLoopSection == "N1")
                    {
                        if (sSegmentID == "N1")
                        {
                            sN1Entity = oSegment.get_DataElementValue(1, 0);         // Entity Identifier Code (98) 
                        }

                        if (sN1Entity == "BT")  //Bill-To
                        {
                            if (sSegmentID == "N1")         // Name 
                            {
                                sValue = oSegment.get_DataElementValue(1, 0);         // Entity Identifier Code (98) 
                                listBox1.Items.Add("Bill-to Name: " + oSegment.get_DataElementValue(2, 0));         // Name (93) 
                                sValue = oSegment.get_DataElementValue(3, 0);         // Identification Code Qualifier (66) 
                                sValue = oSegment.get_DataElementValue(4, 0);         // Identification Code (67) 
                                sValue = oSegment.get_DataElementValue(5, 0);         // Entity Relationship Code (706) 
                                sValue = oSegment.get_DataElementValue(6, 0);         // Entity Identifier Code (98) 

                            }
                            else if (sSegmentID == "N3")         // Address Information 
                            {
                                listBox1.Items.Add("Bill-to Address: " + oSegment.get_DataElementValue(1, 0));         // Address Information (166) 
                                sValue = oSegment.get_DataElementValue(2, 0);         // Address Information (166) 

                            }
                            else if (sSegmentID == "N4")         // Geographic Location 
                            {
                                listBox1.Items.Add("Bill-to City: " + oSegment.get_DataElementValue(1, 0));         // City Name (19) 
                                sValue = oSegment.get_DataElementValue(2, 0);         // State or Province Code (156) 
                                sValue = oSegment.get_DataElementValue(3, 0);         // Postal Code (116) 
                                sValue = oSegment.get_DataElementValue(4, 0);         // Country Code (26) 
                                sValue = oSegment.get_DataElementValue(5, 0);         // Location Qualifier (309) 
                                sValue = oSegment.get_DataElementValue(6, 0);         // Location Identifier (310) 

                            }
                        }
                        else if (sN1Entity == "ST") //Ship-To
                        {
                            if (sSegmentID == "N1")         // Name 
                            {
                                sValue = oSegment.get_DataElementValue(1, 0);         // Entity Identifier Code (98) 
                                listBox1.Items.Add("Ship-To Name: " + oSegment.get_DataElementValue(2, 0));         // Name (93) 
                                sValue = oSegment.get_DataElementValue(3, 0);         // Identification Code Qualifier (66) 
                                sValue = oSegment.get_DataElementValue(4, 0);         // Identification Code (67) 
                                sValue = oSegment.get_DataElementValue(5, 0);         // Entity Relationship Code (706) 
                                sValue = oSegment.get_DataElementValue(6, 0);         // Entity Identifier Code (98) 

                            }
                            else if (sSegmentID == "N3")         // Address Information 
                            {
                                listBox1.Items.Add("Ship-To Address: " + oSegment.get_DataElementValue(1, 0));         // Address Information (166) 
                                sValue = oSegment.get_DataElementValue(2, 0);         // Address Information (166) 

                            }
                            else if (sSegmentID == "N4")         // Geographic Location 
                            {
                                listBox1.Items.Add("Ship-To City: " + oSegment.get_DataElementValue(1, 0));         // City Name (19) 
                                sValue = oSegment.get_DataElementValue(2, 0);         // State or Province Code (156) 
                                sValue = oSegment.get_DataElementValue(3, 0);         // Postal Code (116) 
                                sValue = oSegment.get_DataElementValue(4, 0);         // Country Code (26) 
                                sValue = oSegment.get_DataElementValue(5, 0);         // Location Qualifier (309) 
                                sValue = oSegment.get_DataElementValue(6, 0);         // Location Identifier (310) 

                            }

                        }
                        else if (sN1Entity == "DE") //Depositor
                        {
                            if (sSegmentID == "N1")         // Name 
                            {
                                sValue = oSegment.get_DataElementValue(1, 0);         // Entity Identifier Code (98) 
                                listBox1.Items.Add("Depositor Name: " + oSegment.get_DataElementValue(2, 0));         // Name (93) 
                                sValue = oSegment.get_DataElementValue(3, 0);         // Identification Code Qualifier (66) 
                                sValue = oSegment.get_DataElementValue(4, 0);         // Identification Code (67) 
                                sValue = oSegment.get_DataElementValue(5, 0);         // Entity Relationship Code (706) 
                                sValue = oSegment.get_DataElementValue(6, 0);         // Entity Identifier Code (98) 

                            }
                            else if (sSegmentID == "N3")         // Address Information 
                            {
                                listBox1.Items.Add("Depositor Address: " + oSegment.get_DataElementValue(1, 0));         // Address Information (166) 
                                sValue = oSegment.get_DataElementValue(2, 0);         // Address Information (166) 

                            }
                            else if (sSegmentID == "N4")         // Geographic Location 
                            {
                                listBox1.Items.Add("Depositor City: " + oSegment.get_DataElementValue(1, 0));         // City Name (19) 
                                sValue = oSegment.get_DataElementValue(2, 0);         // State or Province Code (156) 
                                sValue = oSegment.get_DataElementValue(3, 0);         // Postal Code (116) 
                                sValue = oSegment.get_DataElementValue(4, 0);         // Country Code (26) 
                                sValue = oSegment.get_DataElementValue(5, 0);         // Location Qualifier (309) 
                                sValue = oSegment.get_DataElementValue(6, 0);         // Location Identifier (310) 

                            }

                        }   //sN1Entity == "DE"

                    }   //sLoopSection == "N1"
                    
                }
                else if (nArea == 2)
                {

                    // Data segments in area 2 are processed here. 

                    if (sLoopSection == "")
                    {

                        // Nothing to do. 

                    }
                    else if (sLoopSection == "LX")
                    {

                        if (sSegmentID == "LX")         // Assigned Number 
                        {
                            listBox1.Items.Add(oSegment.get_DataElementValue(1, 0));         // Assigned Number (554) 

                        }

                    }
                    else if (sLoopSection == "LX;W01")
                    {

                        if (sSegmentID == "W01")         // Line Item Detail - Warehouse 
                        {
                            listBox1.Items.Add(oSegment.get_DataElementValue(1, 0));         // Quantity Ordered (330) 
                            sValue = oSegment.get_DataElementValue(2, 0);         // Unit or Basis for Measurement Code (355) 
                            sValue = oSegment.get_DataElementValue(3, 0);         // U.P.C. Case Code (438) 
                            sValue = oSegment.get_DataElementValue(4, 0);         // Product/Service ID Qualifier (235) 
                            listBox1.Items.Add(oSegment.get_DataElementValue(5, 0));         // Product/Service ID (234) 
                            sValue = oSegment.get_DataElementValue(6, 0);         // Product/Service ID Qualifier (235) 
                            sValue = oSegment.get_DataElementValue(7, 0);         // Product/Service ID (234) 
                            sValue = oSegment.get_DataElementValue(8, 0);         // Freight Class Code (59) 
                            sValue = oSegment.get_DataElementValue(9, 0);         // Rate Class Code (121) 
                            sValue = oSegment.get_DataElementValue(10, 0);         // Commodity Code Qualifier (23) 
                            sValue = oSegment.get_DataElementValue(11, 0);         // Commodity Code (22) 
                            sValue = oSegment.get_DataElementValue(12, 0);         // Pallet Block and Tiers (416) 
                            sValue = oSegment.get_DataElementValue(13, 0);         // Warehouse Lot Number (451) 
                            sValue = oSegment.get_DataElementValue(14, 0);         // Product/Service Condition Code (286) 
                            sValue = oSegment.get_DataElementValue(15, 0);         // Product/Service ID Qualifier (235) 
                            sValue = oSegment.get_DataElementValue(16, 0);         // Product/Service ID (234) 

                        }
                        else if (sSegmentID == "G69")         // Line Item Detail - Description 
                        {
                            listBox1.Items.Add(oSegment.get_DataElementValue(1, 0));         // Free-form Description (369) 

                        }
                        else if (sSegmentID == "N9")         // Reference Identification 
                        {
                            sValue = oSegment.get_DataElementValue(1, 0);         // Reference Identification Qualifier (128) 
                            listBox1.Items.Add(oSegment.get_DataElementValue(2, 0));         // Reference Identification (127) 
                            sValue = oSegment.get_DataElementValue(3, 0);         // Free-form Description (369) 
                            sValue = oSegment.get_DataElementValue(4, 0);         // Date (373) 
                            sValue = oSegment.get_DataElementValue(5, 0);         // Time (337) 
                            sValue = oSegment.get_DataElementValue(6, 0);         // Time Code (623) 
                            sValue = oSegment.get_DataElementValue(7, 1);         // Reference Identification Qualifier (128) 
                            sValue = oSegment.get_DataElementValue(7, 2);         // Reference Identification (127) 
                            sValue = oSegment.get_DataElementValue(7, 3);         // Reference Identification Qualifier (128) 
                            sValue = oSegment.get_DataElementValue(7, 4);         // Reference Identification (127) 
                            sValue = oSegment.get_DataElementValue(7, 5);         // Reference Identification Qualifier (128) 
                            sValue = oSegment.get_DataElementValue(7, 6);         // Reference Identification (127) 

                        }
                        else if (sSegmentID == "W20")         // Line-Item Detail - Miscellaneous 
                        {
                            sValue = oSegment.get_DataElementValue(1, 0);         // Pack (356) 
                            sValue = oSegment.get_DataElementValue(2, 0);         // Size (357) 
                            sValue = oSegment.get_DataElementValue(3, 0);         // Unit or Basis for Measurement Code (355) 
                            listBox1.Items.Add(oSegment.get_DataElementValue(4, 0));         // Weight (81) 
                            sValue = oSegment.get_DataElementValue(5, 0);         // Weight Qualifier (187) 
                            sValue = oSegment.get_DataElementValue(6, 0);         // Weight Unit Code (188) 
                            sValue = oSegment.get_DataElementValue(7, 0);         // Unit Weight (395) 
                            sValue = oSegment.get_DataElementValue(8, 0);         // Volume (183) 
                            sValue = oSegment.get_DataElementValue(9, 0);         // Unit or Basis for Measurement Code (355) 
                            sValue = oSegment.get_DataElementValue(10, 0);         // Color (397) 

                        }//sSegmentID

                    }//sLoopSection

                }//nArea == 2
                else if (nArea == 3)
                {

                    // Data segments in area 3 are processed here. 

                    if (sLoopSection == "")
                    {

                        if (sSegmentID == "W76")         // Total Shipping Order 
                        {
                            sValue = oSegment.get_DataElementValue(1, 0);         // Quantity Ordered (330) 
                            listBox1.Items.Add(oSegment.get_DataElementValue(2, 0));         // Weight (81) 
                            sValue = oSegment.get_DataElementValue(3, 0);         // Unit or Basis for Measurement Code (355) 
                            sValue = oSegment.get_DataElementValue(4, 0);         // Volume (183) 
                            sValue = oSegment.get_DataElementValue(5, 0);         // Unit or Basis for Measurement Code (355) 
                            sValue = oSegment.get_DataElementValue(6, 0);         // Order Sizing Factor (398) 

                        }

                    }         // sLoopSection == "" 

                }         // nArea == 3 

                // Get the next data segment in the document. 
                ediDataSegment.Set(ref oSegment, oSegment.Next());

            }//oSegment != null

            MessageBox.Show("Done");

        }//btnTranslate_Click
    

    Click here to download a trial version of the Framework EDI