Example #1
0
        public bool insertdises(dises_Description_tbl obj)
        {
            try
            {
                if (!string.IsNullOrEmpty(obj.code_dec))
                {
                    db.dises_Description_tbl.Add(obj);
                    db.SaveChanges();
                }
                return(true);
            }
            catch (Exception ex)
            {
                return(false);

                throw;
            }
        }
Example #2
0
        private dises_Description_tbl GetData3(string Link, int FK)
        {
            try
            {
                Link            = "https://icd.codes" + Link;
                webBrowser1.Url = new Uri(Link);

                WebClient client = new WebClient();

                string content = client.DownloadString(Link);

                HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
                doc.LoadHtml(content);

                var n2 = doc.DocumentNode.SelectNodes(xpath: "//div[@id='content']/div[@class='well']/div[@class='row']/div[@class='col-md-8']/p");
                dises_Description_tbl thirdobj = new dises_Description_tbl();
                if (n2 != null)
                {
                    //DataTable dt = new DataTable();
                    //dt.Columns.Add("Descraption");
                    //dt.Columns.Add("code_dec");
                    //dt.Columns.Add("Specialty");
                    //dt.Columns.Add("MeSH_Codes");
                    //dt.Columns.Add("ICD9Codes");
                    //dt.Columns.Add("img");

                    //HtmlNode Descraption = n2.FirstOrDefault().SelectSingleNode("//p");
                    HtmlNode Descraption = doc.DocumentNode.SelectNodes(xpath: "//div[@id='content']/div[@class='well']/div[@class='row']/div[@class='col-md-8']/p")[0];
                    HtmlNode code_dec    = doc.DocumentNode.SelectNodes(xpath: "//div[@id='content']/div[@class='well']/h3")[0];
                    HtmlNode img         = doc.DocumentNode.
                                           SelectNodes(xpath: "//div[@id='content']/div[@class='well']/div[@class='row']/div[@class='col-md-4 text-right']/img")[0];

                    HtmlNodeCollection table = doc.DocumentNode.
                                               SelectNodes(xpath: "//div[@id='content']/div[@class='well']/div[@class='row']/div[@class='col-md-8']/table/tr");
                    string Specialty = "", MeSH_Codes = "", ICD9Codes = "";

                    if (table != null)
                    {
                        HtmlNodeCollection tr1 = table[0].SelectNodes("//td");
                        Specialty  = tr1 != null && tr1.Count >= 5 ? tr1[1].InnerText : "";
                        MeSH_Codes = tr1 != null && tr1.Count >= 5 ? tr1[3].InnerText : "";
                        ICD9Codes  = tr1 != null && tr1.Count >= 5 ? tr1[5].InnerText : "";
                    }

                    thirdobj = new dises_Description_tbl()
                    {
                        Descraption = Descraption == null ? "" : Descraption.InnerText,
                        code_dec    = code_dec == null ? "" : code_dec.InnerText,
                        Specialty   = Specialty,
                        ICD9Codes   = ICD9Codes,
                        MeSH_Codes  = MeSH_Codes,
                        img         = img.Attributes["src"] == null ? "" : img.Attributes["src"].Value.ToString(),
                        details_fk  = FK
                    };
                }
                return(thirdobj);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Example #3
0
        private void BtnSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (webBrowser1.Url != null)
                {
                    using (MedicalDBEntities db = new MedicalDBEntities())
                    {
                        List <Chabter1_Tbl> List = GetData();
                        bool result = new Home().insertChabter(List);
                        if (result)
                        {
                            foreach (var item in List)
                            {
                                List <Section_Tbl> obj = GetData(item.link_data, item.ID);
                                bool result2           = new Home().insertSection(obj);
                                foreach (var item2 in obj)
                                {
                                    List <Notes_Tbl> notes1 = GetData6(item2.link_data, item2.ID, 2);
                                    new Home().insertnotse1(notes1);
                                    List <Diseases_Tbl> dises = GetData4(item2.link_data, item2.ID);
                                    bool result3 = new Home().insertDiseases(dises);
                                    if (result3)
                                    {
                                        foreach (var item3 in dises)
                                        {
                                            foreach (var item4 in item3.Diseases_destails_tbl)
                                            {
                                                dises_Description_tbl _dises_Description = GetData3(item4.Link_data, item4.ID);
                                                new Home().insertdises(_dises_Description);
                                            }
                                        }
                                    }
                                }

                                List <Notes_Tbl> note = GetData6(item.link_data, item.ID, 1);

                                new Home().insertnotse(note);
                            }
                        }

                        //foreach (var item4 in item6)
                        //{
                        //    Notes_Tbl _dises_Description = GetData6();
                        //    new Home().insertnotse();
                        //}
                        //List<Section_Tbl> obj = GetData();
                        //bool list1 = new Home().insertSection(obj);

                        //for (int i = 0; i < List.Count; i++)
                        //{
                        //    Chabter1_Tbl obj = new Chabter1_Tbl()
                        //    {
                        //        CodeRange_from = List.Rows[i][0].ToString(),
                        //        CodeRange_To = List.Rows[i][1].ToString(),
                        //        SectionDescription = List.Rows[i][2].ToString(),
                        //        link_data = List.Rows[i][3].ToString()
                        //    };
                        //    int result = new Home().insertChabter(obj);
                        //    if (result > 0)
                        //    {
                        //        DataTable notestbl1 = GetData6(obj.link_data);
                        //        foreach (DataRow detailsitem in notestbl1.Rows)
                        //        {
                        //            // insert chapter notes
                        //            Notes_Tbl notes5 = new Notes_Tbl()
                        //            {
                        //                Notes = detailsitem[0].ToString(),
                        //                Table_FK = result,
                        //                Fk_type = 1
                        //            };
                        //            int notes1 = new Home().insertnotse(notes5);
                        //        }
                        //        DataTable secoundtable = GetData(obj.link_data);
                        //        foreach (DataRow item in secoundtable.Rows)
                        //        {
                        //            Section_Tbl secoundobj = new Section_Tbl()
                        //            {
                        //                Code_from = item[0].ToString(),
                        //                Code_to = item[1].ToString(),
                        //                Name = item[2].ToString(),
                        //                link_data = item[3].ToString(),
                        //                Chabter1_fk = result
                        //            };
                        //            int secondresult = new Home().insertSection(secoundobj);

                        //            DataTable notestbl12 = GetData6(secoundobj.link_data);
                        //            foreach (DataRow detailsitem in notestbl1.Rows)
                        //            {
                        //                // insert chapter notes
                        //                Notes_Tbl notes5 = new Notes_Tbl()
                        //                {
                        //                    Notes = detailsitem[1].ToString(),
                        //                    Table_FK = secondresult,
                        //                    Fk_type = 2
                        //                };
                        //                int notes1 = new Home().insertnotse(notes5);
                        //            }

                        //            DataTable desis = GetData4(item[3].ToString());
                        //            foreach (DataRow desisitem in desis.Rows)
                        //            {
                        //                Diseases_Tbl thirdTable = new Diseases_Tbl()
                        //                {
                        //                    Code = desisitem[0].ToString(),
                        //                    Name = desisitem[1].ToString(),
                        //                    Section_Fk = secondresult
                        //                };
                        //                int thirdResult = new Home().insertDiseases(thirdTable);
                        //                DataTable details = GetData5(desisitem[2].ToString());
                        //                foreach (DataRow detailsitem in details.Rows)
                        //                {
                        //                    Diseases_destails_tbl fourthtable = new Diseases_destails_tbl()
                        //                    {
                        //                        Name = detailsitem[0].ToString(),
                        //                        Code = detailsitem[1].ToString(),
                        //                        Link_data = detailsitem[2].ToString(),
                        //                        Diseases_fk = thirdResult
                        //                    };
                        //                    int fourthResult = new Home().insertDiseases_destails(fourthtable);
                        //                    if (fourthResult > 0)
                        //                    {
                        //                        dises_Description_tbl thirdobj = GetData3(fourthtable.Link_data);
                        //                        thirdobj.details_fk = fourthResult;
                        //                        int descrnote = new Home().insertdises(thirdobj);
                        //                        DataTable notestbl7 = GetData7(fourthtable.Link_data);
                        //                        foreach (DataRow decrip in notestbl1.Rows)
                        //                        {
                        //                            // insert chapter notes
                        //                            Notes_Tbl notes5 = new Notes_Tbl()
                        //                            {
                        //                                Notes = detailsitem[1].ToString(),
                        //                                Table_FK = secondresult,
                        //                                Fk_type = 3
                        //                            };
                        //                            int notes1 = new Home().insertnotse(notes5);
                        //                        }
                        //                    }
                        //                }
                        //            }

                        //        };
                        //    }
                        MessageBox.Show("saved", "info", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
                        //}
                    }
                }
                else
                {
                    MessageBox.Show("Please load the web Page first!");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);

                throw;
            }
        }