Example #1
0
        public void V600_GetPartsInfo(int Sequence, List<string> SWCP, DataTable BOM,string FileEBOM, string FileEBOMExtra)
        {
            IVSStructure EBOM = new IVSStructure(FileEBOM);
            if (FileEBOMExtra != "")
                EBOM.LoadEBOMExtra(FileEBOMExtra);

            for (int i = 0; i < SWCP.Count; i++)
            {
                var q = from DataRow p in BOM.AsEnumerable()
                        where
                            p[0].ToString() == new PartNumber(SWCP[i]).ToString() || p[0].ToString() == new PartNumber(SWCP[i]).ToStringNo()
                        select p;
                foreach (DataRow BOMTarget in q)
                    if (BOMTarget[Sequence + 1].ToString() != "")
                    {
                        PartLineage Target = EBOM.GetModuleByAssyPN(SWCP[i]);
                        if (Target != null)
                            PARTS += Target.ToBroadcast();
                    }

            }
        }
Example #2
0
        public void OBOM_GetPartsFromEBOM(string FileOBOM, string FileEBOM, string FileEBOMExtra, string FileSWCP, string SWCPSheet, int ColumnBoughtIn, int ColumnAssy)
        {
            IVSStructure EBOM = new IVSStructure(FileEBOM);
            if (FileEBOMExtra != "")
                EBOM.LoadEBOMExtra(FileEBOMExtra);

            if (SWCPSheet != "")
                this.SYMBLE_SWCP = SWCPSheet;

            //OBOM
            string strCon = " Provider = Microsoft.Jet.OLEDB.4.0 ; Data Source = " + FileOBOM + ";Extended Properties=Excel 8.0";
            OleDbConnection myConn = new OleDbConnection(strCon);
            myConn.Open();
            string strCom = " SELECT * FROM [" + OBOM_SYMBLE_BOM + "$]";
            OleDbDataAdapter myCommand = new OleDbDataAdapter(strCom, myConn);
            myDataSet = new DataSet();

            //Read Feature Codes
            myCommand.Fill(myDataSet, "[" + OBOM_SYMBLE_BOM + "$]");
            DataTable OBOM = myDataSet.Tables[0];
            myConn.Close();


            //SWCP
            strCon = " Provider = Microsoft.Jet.OLEDB.4.0 ; Data Source = " + FileSWCP + ";Extended Properties=Excel 8.0";
            myConn = new OleDbConnection(strCon);
            myConn.Open();
            strCom = " SELECT * FROM [" + SYMBLE_SWCP + "$] ";
            myCommand = new OleDbDataAdapter(strCom, myConn);
            myDataSet = new DataSet();

            //Read Feature Codes
            myCommand.Fill(myDataSet, SYMBLE_SWCP);
            DataTable SWCP = myDataSet.Tables[0];
            myConn.Close();

            foreach (DataRow t in SWCP.Rows)
            {
                PartNumber theBoughtIn = new PartNumber(t[ColumnAssy].ToString());
                var p = from DataRow q in OBOM.AsEnumerable()
                        where q[2].ToString() == (theBoughtIn.Prefix + theBoughtIn.Infix + theBoughtIn.Suffix)
                        select q;
                int count = 0;
                foreach (var l in p)
                    count++;
                if (count != 0)
                {
                    PartLineage theModule = EBOM.GetModuleByAssyPN(t[ColumnAssy].ToString());
                    this.PARTS += theModule.ToBroadcast();
                }
            } 
        }
Example #3
0
        private void btn_Check_Click_Click(object sender, EventArgs e)
        {
            try
            {
                this.tbx_Check_Result.Text = "";
                List<string> BOM = new List<string>();
                List<string> SWCPTop = new List<string>();
                List<string> SWCPBoughtIn = new List<string>();


                object missing = Missing.Value;
                Microsoft.Office.Interop.Excel.Application xlApp = null;
                Microsoft.Office.Interop.Excel.Workbook BOM_xlBook = null;
                Microsoft.Office.Interop.Excel.Worksheet BOM_xlSheet = null;
                Microsoft.Office.Interop.Excel.Workbook SWCP_xlBook = null;
                Microsoft.Office.Interop.Excel.Worksheet SWCP_xlSheet = null;

                xlApp = new Microsoft.Office.Interop.Excel.Application();
                xlApp.DisplayAlerts = false;


                tbx_Check_Result.AppendText("Reading SWCP" + "\r\n");
                SWCP_xlBook = xlApp.Workbooks.Add(tbx_Setting_SWCP.Text);
                SWCP_xlSheet = SWCP_xlBook.Sheets[tbx_Setting_SWCPSheetName.Text];

                int Rows = 2;
                string SWCPAssy = SWCP_xlSheet.Cells[nud_Setting_SWCPTopAssyCol.Value][Rows].Value;
                while (SWCPAssy != null && SWCPAssy != "")
                {
                    SWCPTop.Add(SWCPAssy);

                    if (Convert.ToInt32(nud_Setting_SWCPBoughtin_Column.Value) != 0)
                    {
                        object TargetBoughtIn = SWCP_xlSheet.Cells[nud_Setting_SWCPBoughtin_Column.Value][Rows].Value;
                        if (TargetBoughtIn != null && TargetBoughtIn.ToString() !="")
                            SWCPBoughtIn.Add(TargetBoughtIn.ToString());
                    }

                    Rows++;
                    SWCPAssy = SWCP_xlSheet.Cells[nud_Setting_SWCPTopAssyCol.Value][Rows].Value;
                    if (Rows % 10 == 0)
                        tbx_Check_Result.AppendText((Rows / 10).ToString("00") + "\r\n");
                }




                SWCP_xlBook.Close();


                tbx_Check_Result.AppendText("Reading BOM" + "\r\n");
                BOM_xlBook = xlApp.Workbooks.Add(tbx_Setting_BOM.Text);
                BOM_xlSheet = BOM_xlBook.Sheets[tbx_Setting_BOMSheetName.Text];

                Rows = 0;
                string BOMAssy = BOM_xlSheet.Cells[Convert.ToInt32(nud_Setting_BOMTopCol.Value)][Convert.ToInt32(nud_Setting_BOMStartRow.Value) + Rows].Value;
                while (BOMAssy != null && BOMAssy != "")
                {
                    BOM.Add(BOMAssy);
                    Rows++;
                    BOMAssy = BOM_xlSheet.Cells[Convert.ToInt32(nud_Setting_BOMTopCol.Value)][Convert.ToInt32(nud_Setting_BOMStartRow.Value) + Rows].Value;

                    if (Rows % 100 == 0)
                        tbx_Check_Result.AppendText((Rows / 100).ToString("0000") + "\r\n");

                }

                tbx_Check_Result.AppendText("Reading Complete");
                BOM_xlBook.Close();
                xlApp.Quit();
                this.tbx_Check_Result.Text = "";


                IVSStructure EBOM = new IVSStructure(this.tbx_Setting_EBOM.Text);
                if (tbx_Setting_EBOMExtra.Text != "")
                    EBOM.LoadEBOMExtra(tbx_Setting_EBOMExtra.Text);
                //Check if Top Assembly Parts in BOM
                tbx_Check_Result.AppendText("-----Top Assembly BOM PN Check------\r\n");
                foreach (string target in SWCPTop)
                {
                    if (!BOM.Exists(s=>s==new PartNumber(target).ToStringNo()))
                        tbx_Check_Result.AppendText(target + " NOT in BOM\r\n");
                }

                /*
                AddResult("-----Bought In BOM PN Check------\r\n", tbx_Check_Result);
                foreach (string target in SWCPBoughtIn)
                {
                    if (!BOM.Exists(s => s == new PartNumber(target).ToStringNo()))
                        AddResult(target + " NOT in BOM\r\n", tbx_Check_Result);
                }
                */
                tbx_Check_Result.AppendText("-----EBOM PN Check------\r\n");
                foreach (string target in SWCPTop)
                {
                    PartLineage Part = EBOM.GetModuleByAssyPN(target);
                    if (Part == null)
                        tbx_Check_Result.AppendText(target + " NOT in EBOM\r\n");
                }
                tbx_Check_Result.AppendText("Test Complete");

                MessageBox.Show("Test Complete");
            }
            catch
            {
                MessageBox.Show("Please Check Settings!");
            }

        }
Example #4
0
        private void ES_btndosearch_Click(object sender, EventArgs e)
        {
            string targetPN = ("*" + tbx_ES_Partnumber.Text.Trim() + "*").ToUpper();
            bool HasExtra = false;
            IVSStructure EBOM = new IVSStructure();
            if (!EBOM.LoadEBOM(tbx_Setting_EBOM.Text))
                MessageBox.Show("Can NOT Open EBOM, Please Check Setting Page", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            else
            {
                if (EBOM.LoadEBOMExtra(tbx_Setting_EBOMExtra.Text))
                    HasExtra = true;





                List<XmlNode> SearchResult = new List<XmlNode>();
                string CBXSelected = (string)cbx_ES_SearchOption.SelectedItem;
                //Do Search Here

                if (CBXSelected == "Top-Assemble" || CBXSelected == "Any")
                {
                    IEnumerable<XmlNode> theList = from XmlNode t in EBOM.EBOM.GetElementsByTagName("PartLineage")
                                                   where IsMatch(t.SelectNodes("AssyPN")[0].InnerText, targetPN) == true
                                                   select t;
                    SearchResult.AddRange(theList);
                    if (HasExtra)
                    {
                        theList = from XmlNode t in EBOM.EBOMExtra.GetElementsByTagName("PartLineage")
                                  where IsMatch(t.SelectNodes("AssyPN")[0].InnerText, targetPN) == true
                                  select t;
                        SearchResult.AddRange(theList);
                    }
                }
                if (CBXSelected == "Hardware" || CBXSelected == "Any")
                {
                    IEnumerable<XmlNode> theList = from XmlNode t in EBOM.EBOM.GetElementsByTagName("PartLineage")
                                                   where IsMatch(t.SelectNodes("HardwareComponentPart/HardwareType")[0].InnerText, targetPN) == true
                                                   select t;
                    SearchResult.AddRange(theList);
                    if (HasExtra)
                    {
                        theList = from XmlNode t in EBOM.EBOMExtra.GetElementsByTagName("PartLineage")
                                  where IsMatch(t.SelectNodes("HardwareComponentPart/HardwareType")[0].InnerText, targetPN) == true
                                  select t;
                        SearchResult.AddRange(theList);
                    }
                }
                if (CBXSelected == "Software" || CBXSelected == "Any")
                {
                    IEnumerable<XmlNode> theList = from XmlNode t in EBOM.EBOM.GetElementsByTagName("FilePN")
                                                   where IsMatch(t.InnerText, targetPN) == true
                                                   select t;
                    foreach (XmlNode t in theList)
                        if (t.ParentNode.Name != "SupportingSoftwarePart")
                            SearchResult.Add(t.ParentNode.ParentNode.ParentNode);
                    if (HasExtra)
                    {
                        theList = from XmlNode t in EBOM.EBOMExtra.GetElementsByTagName("FilePN")
                                  where IsMatch(t.InnerText, targetPN) == true
                                  select t;
                        foreach (XmlNode t in theList)
                            if (t.ParentNode.Name != "SupportingSoftwarePart")
                                SearchResult.Add(t.ParentNode.ParentNode.ParentNode);
                    }
                }

                if (cbx_ES_SearchOption.Text == "SBL" || CBXSelected == "Any")
                {
                    IEnumerable<XmlNode> theList = from XmlNode t in EBOM.EBOM.GetElementsByTagName("FilePN")
                                                   where IsMatch(t.InnerText, targetPN) == true
                                                   select t;
                    foreach (XmlNode t in theList)
                        if (t.ParentNode.Name == "SupportingSoftwarePart")
                            SearchResult.Add(t.ParentNode.ParentNode.ParentNode);
                    if (HasExtra)
                    {
                        theList = from XmlNode t in EBOM.EBOMExtra.GetElementsByTagName("FilePN")
                                  where IsMatch(t.InnerText, targetPN) == true
                                  select t;
                        foreach (XmlNode t in theList)
                            if (t.ParentNode.Name != "SupportingSoftwarePart")
                                SearchResult.Add(t.ParentNode.ParentNode.ParentNode);


                    }
                }

                if (SearchResult.Count == 0)
                {
                    MessageBox.Show("Part Number Not Found", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    XmlDocument Root = new XmlDocument();
                    Root.AppendChild(Root.CreateXmlDeclaration("1.0", "utf-8", null));
                    XmlElement RootElement = Root.CreateElement("Parts");


                    foreach (XmlNode t in SearchResult)
                        RootElement.AppendChild(Root.ImportNode(t, true));
                    Root.AppendChild(RootElement);
                    Root.Save("Display");
                    wb_ES_Browser.Url = new System.Uri(Application.StartupPath + "\\Display");
                    MessageBox.Show("Totally " + SearchResult.Count.ToString() + " records found");
                }
            }

                
        }
Example #5
0
        private void btn_SDS_GetInfo_Click(object sender, EventArgs e)
        {
            string targetPN = (tbx_SDS_PartNumber.Text.Trim()).ToUpper();
            lb_SDS_Software.Items.Clear();
            tbx_SDS_BroadcastString.Text = "";
            IVSStructure EBOM = new IVSStructure();
            if (!EBOM.LoadEBOM(tbx_Setting_EBOM.Text))
                MessageBox.Show("Can NOT Open EBOM, Please Check Setting Page", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            else
            {
                lb_SDS_Software.Items.Clear();
                EBOM.LoadEBOMExtra(tbx_Setting_EBOMExtra.Text);
                PartLineage PN = EBOM.GetModuleByAssyPN(targetPN);
                
                if (PN != null)
                {
                    this.tbx_SDS_Title.Text = PN.ECUAcronym + "_" + PN.AssyPN.Part.ToString();
                    tbx_SDS_PartNumber.Enabled = true;
                    tbx_SDS_Security.Enabled = true;
                    tbx_SDS_Title.Enabled = true;
                    btn_SDS_GenSDS.Enabled = true;
                    lb_SDS_SWDLMethod.Enabled = true;
                    lb_SDS_Software.Enabled = true;
                  
                    foreach (SoftPart t in PN.Softwares)
                    {
                        lb_SDS_Software.Items.Add(t.ToString());
                        if (t.IsFlash)
                            lb_SDS_Software.SelectedItems.Add(t.ToString());
                    }
                    lb_SDS_SWDLMethod.SelectedItem = "SWDL005";

                    //Broadcast String
                    this.tbx_SDS_BroadcastString.Text = PN.ToBroadcast();
                }
                else
                    MessageBox.Show("Part Number not Found", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);


                   

            }
            
        }
Example #6
0
        private void btn_SDS_GenSDS_Click(object sender, EventArgs e)
        {
            IVSStructure EBOM = new IVSStructure();
            if (!EBOM.LoadEBOM(tbx_Setting_EBOM.Text))
                MessageBox.Show("Can NOT Open EBOM, Please Check Setting Page");
            else
            {
                if (!IVSStructure.isValidPN(tbx_SDS_PartNumber.Text))
                    MessageBox.Show("Wrong Part Number Format");
                else
                {
                    if (tbx_Setting_EBOMExtra.Text != "")
                        EBOM.LoadEBOMExtra(tbx_Setting_EBOMExtra.Text);
                    PartLineage PN = EBOM.GetModuleByAssyPN(tbx_SDS_PartNumber.Text.ToUpper());
                    if (PN == null)
                        MessageBox.Show("Part Number NOT Found in EBOM");
                    else
                    {
                        

                        try
                        {
                            string GenerateMessage = "";

                            if (sfg_SDS_File.ShowDialog() == DialogResult.OK)
                            {
                                string OutputFolder = new FileInfo(sfg_SDS_File.FileName).DirectoryName;
                                

                                    
                                 


                                String Output = "";
                                Output += "title\t\t\t\t\t\t= \"" + tbx_SDS_Title.Text + "\";" + "\r\n";
                                Output += "protocol\t\t\t\t\t= \"Jaguar 11-bit\";" + "\r\n";
                                Output += "\r\n";
                                Output += "inhibit_tester_present\t\t\t\t= TRUE;" + "\r\n";
                                Output += "broadcast_keep_alive_net\t\t\t= TRUE;" + "\r\n";
                                Output += "check_for_updates_only\t\t\t\t= FALSE;" + "\r\n";
                                Output += "force_all_updates\t\t\t\t= TRUE;" + "\r\n";
                                Output += "rig_update_mode\t\t\t\t\t= TRUE;" + "\r\n";
                                Output += "\r\n";
                                Output += "node" + "\r\n";
                                Output += "{";
                                if (PN.NodeAddr == "MOST")
                                {
                                    Output += "\tname\t\t\t\t\t= \"HLDF\";" + "\r\n";
                                    Output += "\tecu_address\t\t\t\t= 0x7A5;" + "\r\n";
                                }
                                else
                                {
                                    Output += "\tname\t\t\t\t\t= \"" + PN.ECUAcronym + "\";" + "\r\n";
                                    Output += "\tecu_address\t\t\t\t= " + "0x" + PN.NodeAddr + ";" + "\r\n";
                                }
                                Output += "};" + "\r\n";
                                Output += "\r\n";

                                Output += "node" + "\r\n";
                                Output += "{" + "\r\n";

                                Output += "\tid\t\t\t\t\t= \"" + PN.ECUAcronym + "\";" + "\r\n";
                                Output += "\r\n";
                                Output += "\tswdl_method\t\t\t\t= \"" + lb_SDS_SWDLMethod.SelectedItem + "\";" + "\r\n";
                                Output += "\tname\t\t\t\t\t= \"" + PN.ECUAcronym + "\";" + "\r\n";
                                Output += "\tecu_address\t\t\t\t= " + "0x" + PN.NodeAddr + ";" + "\r\n";
                                Output += "\tnd_security_interface\t\t\t= \"" + tbx_SDS_Security.Text + "\";" + "\r\n";
                                if (PN.SBL != null)
                                {
                                    Output += "\tnd_sbl_vbf_file\t\t\t\t= \"" + PN.SBL.Part.ToString() + ".VBF\";" + "\r\n";
                                    if (cbx_SDS_VBF.Checked)
                                    {
                                        try
                                        {
                                            string TargetPN = OutputFolder + "\\" + PN.SBL.Part.ToString() + ".VBF";
                                            string SourcePN = tbx_Setting_VBFFolder.Text + "\\" + PN.SBL.Part.ToString() + ".VBF";
                                            if (File.Exists(TargetPN))
                                                File.Delete(TargetPN);
                                            File.Copy(SourcePN, TargetPN);                                           
                                        }
                                        catch
                                        {
                                            GenerateMessage += PN.SBL.Part.ToString() + " not found\r\n";
                                        }
                  
                                    }
                                }
                                    
                                else
                                    Output += "\tnd_sbl_vbf_file\t\t\t\t= \"(none)\";" + "\r\n";

                                //Software
                                int j = 1;
                                for (int i = 0; i < PN.Softwares.Count; i++)
                                {
                                    if (lb_SDS_Software.SelectedItems.Contains(PN.Softwares[i].ToString()))
                                    {
                                        Output += "\r\n";
                                        Output += "\tdata" + j.ToString() + "_vbf_file\t\t\t\t= \"" + PN.Softwares[i].Part.ToString() + ".vbf" + "\"" + ";\r\n";
                                        Output += "\tdata" + j.ToString() + "_part_did\t\t\t\t= " + "0x" + PN.Softwares[i].PID + ";\r\n";
                                        Output += "\tdata" + j.ToString() + "_part_ref\t\t\t\t= \"" + PN.Softwares[i].Part.ToString() + "\"" + ";\r\n";
                                        Output += "\tdata" + j.ToString() + "_part_inf\t\t\t\t= \"" + PN.Softwares[i].Type.ToString() + "\"" + ";\r\n";

                                        if (cbx_SDS_VBF.Checked)
                                        {
                                            try
                                            {
                                                string TargetPN = OutputFolder + "\\" + PN.Softwares[i].Part.ToString() + ".VBF";
                                                string SourcePN = tbx_Setting_VBFFolder.Text + "\\" + PN.Softwares[i].Part.ToString() + ".VBF";
                                                if (File.Exists(TargetPN))
                                                    File.Delete(TargetPN);
                                                File.Copy(SourcePN, TargetPN);
                                            }
                                            catch
                                            {
                                                GenerateMessage += PN.Softwares[i].Part.ToString() + " not found\r\n";
                                            }

                                        }

                                        j++;
                                    }
                                }
                                Output += "};" + "\r\n";
                                Output += "\r\n";
                                Output += "node" + "\r\n";
                                Output += "{" + "\r\n";
                                Output += "\tid\t\t\t\t\t= \"Exit and DTC Clear\";" + "\r\n";
                                Output += "\r\n";
                                Output += "\tswdl_method\t\t\t\t= \"DTCCLEAR2\";" + "\r\n";
                                Output += "\tname\t\t\t\t\t= \"EXIT\";" + "\r\n";
                                Output += "\tecu_address\t\t\t\t= 0x7DF;" + "\r\n";
                                Output += "};";


                                if (File.Exists(sfg_SDS_File.FileName))
                                    File.Delete(sfg_SDS_File.FileName);
                                FileStream fs = new FileStream(this.sfg_SDS_File.FileName,FileMode.OpenOrCreate);
                                byte[] data = System.Text.Encoding.Default.GetBytes(Output);
                                fs.Write(data, 0, data.Length);
                                fs.Flush();
                                fs.Close();

                                //Copy Security File
                                string SourceSecu = tbx_setting_SecurityFolder.Text + "\\" + CurrentSecurityFile;
                                string TargetSecu = OutputFolder + "\\" + CurrentSecurityFile;
                                if (File.Exists(SourceSecu))
                                {
                                    if (File.Exists(TargetSecu))
                                    {
                                        File.Delete(TargetSecu);
                                    }
                                    File.Copy(SourceSecu, TargetSecu);
                                }

                                MessageBox.Show("Generate Finished\r\n" + GenerateMessage, "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);


                            }
                        }
                        catch
                        {
                            MessageBox.Show("Generate Failed", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                }
            }
        }
Example #7
0
        private void btn_Setting_Fill_SWCP_Click(object sender, EventArgs e)
        {


            //Test Codes
            /*
            Snapshot a = new Snapshot();
            a.Load(this.tbx_Setting_Snapshot.Text);
            test = a.CompareData("ABS", "F190", "L2CVA2BG6FG000518");
            */
            //End of Test Codes


            tbx_SWCP_Result.Text = "";
            try
            {
                tbc_Main.SelectTab(tbp_SWCPGen.Name);
                IVSStructure EBOM = new IVSStructure(tbx_Setting_EBOM.Text);
                Snapshot theSS = new Snapshot();
                DirectoryInfo theVBFDir;
                DirectoryInfo ExportVBFDir;
                string[] VBFFileNameList = new string[1];


                if (cbx_SWCP_ifCompare.Checked == true)
                {
                    if (theSS.Load(this.tbx_Setting_Snapshot.Text))
                    {

                    }
                    else
                    {
                        throw new Exception("SnapShot File Error, Please choose again");
                    }
                }

                if (cbx_SWCP_CompareVBF.Checked)
                {
                    theVBFDir = new DirectoryInfo(this.tbx_Setting_VBFFolder.Text);
                    FileInfo[] VBFList = theVBFDir.GetFiles();
                    VBFFileNameList = new string[VBFList.Length];
                    for (int j = 0; j < VBFList.Length; j++)
                    {
                        VBFFileNameList[j] = VBFList[j].Name.ToUpper();
                    }
                }

                if (cbx_SWCP_ExportVBF.Checked)
                {
                    theVBFDir = new DirectoryInfo(this.tbx_Setting_VBFFolder.Text);
                    FileInfo[] VBFList = theVBFDir.GetFiles();
                    VBFFileNameList = new string[VBFList.Length];
                    for (int j = 0; j < VBFList.Length; j++)
                    {
                        VBFFileNameList[j] = VBFList[j].Name.ToUpper();
                    }
                    if (fbd_SWCP_ExportVBF.ShowDialog() == DialogResult.OK)
                    {
                        ExportVBFDir = new DirectoryInfo(fbd_SWCP_ExportVBF.SelectedPath);
                    }
                    else
                    {
                        throw new Exception("Please select VBF Export Folder");
                    }
                }
                


                if (tbx_Setting_EBOMExtra.Text != "")
                    EBOM.LoadEBOMExtra(tbx_Setting_EBOMExtra.Text);
                if (tbx_Setting_EBOMExtra.Text != "")
                    EBOM.LoadEBOMExtra(tbx_Setting_EBOMExtra.Text);
                Microsoft.Office.Interop.Excel.Application xlApp = null;
                Microsoft.Office.Interop.Excel.Workbook xlBook = null;
                Microsoft.Office.Interop.Excel.Worksheet xlSheet = null;
                object missing = Missing.Value;

                xlApp = new Microsoft.Office.Interop.Excel.Application();
                xlBook = xlApp.Workbooks.Add(tbx_Setting_SWCP.Text);
                xlSheet = xlBook.Sheets[tbx_Setting_SWCPSheetName.Text];

                int i = 2;
                while (IVSStructure.isValidPN(xlSheet.Cells[Convert.ToInt32(nud_Setting_SWCPTopAssyCol.Value)][i].Value))
                {


                    PartLineage PN = EBOM.GetModuleByAssyPN(xlSheet.Cells[nud_Setting_SWCPTopAssyCol.Value][i].Value);
                    if (PN == null)
                    {
                        tbx_SWCP_Result.AppendText("Warning:" + xlSheet.Cells[nud_Setting_SWCPTopAssyCol.Value][i].Value + " Data NOT Found in EBOM\r\n");
                        xlSheet.Cells[nud_Setting_Comment_Column.Value][i].Value = "Part Number NOT Found in EBOM";
                    }
                    else
                    {
                        tbx_SWCP_Result.AppendText("Working on " + xlSheet.Cells[nud_Setting_SWCPTopAssyCol.Value][i].Value);
                        //ECU Address
                        if (PN.NodeAddr != null)
                        {
                            xlSheet.Cells[(Convert.ToInt32(nud_Setting_EDUAddress_Column.Value))][i].Value = ("0x" + PN.NodeAddr);
                        }

                        tbx_SWCP_Result.AppendText(".");
                        //Network
                        if (PN.Protocol != null)
                            xlSheet.Cells[Convert.ToInt32(nud_Setting_Network_Column.Value)][i].Value = PN.Protocol;
                        tbx_SWCP_Result.AppendText(".");
                        //SBL
                        if (PN.SBL != null)
                        {
                            xlSheet.Cells[Convert.ToInt32(nud_Setting_SBL_Column.Value)][i].Value = PN.SBL.Part.ToString();
                            if (cbx_SWCP_CompareVBF.Checked)
                            {
                                string target = PN.SBL.Part.ToString().ToUpper();
                                if (!target.EndsWith(".VBF"))
                                    target = target + ".VBF";
                                if (VBFFileNameList.Contains<string>(target))
                                    xlSheet.Cells[Convert.ToInt32(nud_Setting_SBL_Column.Value)][i].Interior.Colorindex = 4;
                                else
                                {
                                    if (PN.CheckFlash())
                                        xlSheet.Cells[Convert.ToInt32(nud_Setting_SBL_Column.Value)][i].Interior.Colorindex = 3;
                                    else
                                        xlSheet.Cells[Convert.ToInt32(nud_Setting_SBL_Column.Value)][i].Interior.Colorindex = 27;
                                }
                            }
                        }
                        tbx_SWCP_Result.AppendText(".");
                        //Hardware
                        if (PN.Hardware != null)
                        {
                            xlSheet.Cells[Convert.ToInt32(nud_Setting_Hardware_Column.Value)][i].Value = PN.Hardware.Part.ToString();
                            xlSheet.Cells[Convert.ToInt32(nud_Setting_Hardware_Column.Value + 1)][i].Value = PN.Hardware.PID;
                            if (cbx_SWCP_ifCompare.Checked == true)
                            {
                                int result = theSS.CompareData(PN.ECUAcronym, PN.Hardware.PID, PN.Hardware.Part.ToString());
                                if (result == 1)
                                {
                                    xlSheet.Cells[Convert.ToInt32(nud_Setting_Hardware_Column.Value)][i].Interior.Colorindex = 4;
                                    if (xlSheet.Cells[Convert.ToInt32(nud_Setting_Hardware_Column.Value)][i].Comment != null)
                                        xlSheet.Cells[Convert.ToInt32(nud_Setting_Hardware_Column.Value)][i].Comment.Delete();
                                }
                                else if (result == 2)
                                {
                                    xlSheet.Cells[Convert.ToInt32(nud_Setting_Hardware_Column.Value)][i].Interior.Colorindex = 3;
                                    xlSheet.Cells[Convert.ToInt32(nud_Setting_Hardware_Column.Value)][i].AddComment(theSS.GetData(PN.ECUAcronym, PN.Hardware.PID));
                                }

                            }
                        }
                        tbx_SWCP_Result.AppendText(".");
                        //Application

                        if (PN.Softwares != null)
                        {
                            for (int j = 0; j < PN.Softwares.Count; j++)
                            {
                                xlSheet.Cells[(nud_Setting_APP_Column.Value) + (j * 4)][i].Value = PN.Softwares[j].Part.ToString();
                       
                                if (cbx_SWCP_ifCompare.Checked == true)
                                {
                                    int result = theSS.CompareData(PN.ECUAcronym.ToString(), PN.Softwares[j].PID, PN.Softwares[j].Part.ToString());
                                    if (result == 1)
                                    {
                                        xlSheet.Cells[(nud_Setting_APP_Column.Value) + (j * 4)][i].Interior.Colorindex = 4;
                                        if (xlSheet.Cells[(nud_Setting_APP_Column.Value) + (j * 4)][i].Comment != null)
                                            xlSheet.Cells[(nud_Setting_APP_Column.Value) + (j * 4)][i].Comment.Delete();
                                    }                                        
                                    else if (result == 2)
                                    {
                                        if (!PN.Softwares[j].IsFlash)
                                            xlSheet.Cells[(nud_Setting_APP_Column.Value) + (j * 4)][i].Interior.Colorindex = 3;
                                        else
                                            xlSheet.Cells[(nud_Setting_APP_Column.Value) + (j * 4)][i].Interior.Colorindex = 27;
                                        xlSheet.Cells[(nud_Setting_APP_Column.Value) + (j * 4)][i].AddComment(theSS.GetData(PN.ECUAcronym, PN.Softwares[j].PID));
                                    }                                      
                                }
                                else if (cbx_SWCP_CompareVBF.Checked == true)
                                {
                                    string target = PN.Softwares[j].Part.ToString().ToUpper();
                                    if (!target.EndsWith(".VBF"))
                                        target = target + ".VBF";
                                    if (VBFFileNameList.Contains<string>(target))
                                        xlSheet.Cells[(nud_Setting_APP_Column.Value) + (j * 4)][i].Interior.Colorindex = 4;
                                    else
                                    {
                                        if (!PN.Softwares[j].IsFlash)
                                            xlSheet.Cells[(nud_Setting_APP_Column.Value) + (j * 4)][i].Interior.Colorindex = 27;
                                        else
                                            xlSheet.Cells[(nud_Setting_APP_Column.Value) + (j * 4)][i].Interior.Colorindex = 3;
                                    }
                                       

                                }
                                xlSheet.Cells[(nud_Setting_APP_Column.Value) + (j * 4) + 1][i].Value = PN.Softwares[j].PID;
                                xlSheet.Cells[(nud_Setting_APP_Column.Value) + (j * 4) + 2][i].Value = PN.Softwares[j].Type.ToString();
                                if (PN.Softwares[j].IsFlash)
                                    xlSheet.Cells[(nud_Setting_APP_Column.Value) + (j * 4) + 3][i].Value = "Y";
                                else
                                    xlSheet.Cells[(nud_Setting_APP_Column.Value) + (j * 4) + 3][i].Value = "N";

                                tbx_SWCP_Result.AppendText(".");
                            }
                        }
                        tbx_SWCP_Result.AppendText(".");

                        //Comment
                        if (PN.Latest == false)
                            xlSheet.Cells[Convert.ToInt32(nud_Setting_Comment_Column.Value)][i].Value = "Not Latest Version";




                        tbx_SWCP_Result.AppendText("Done!\r\n");
                    }

                    i++;
                }

                xlApp.Visible = true;
                //xlBook.Save();
                //xlApp.Quit();

            }
            catch (Exception Error)
            {
                MessageBox.Show(Error.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }


        }