Example #1
0
 public List <DheyaDocuments> GetParentDocList()
 {
     try
     {
         using (SqlConnection con = new SqlConnection(connectionString))
         {
             List <DheyaDocuments> li = new List <DheyaDocuments>();
             string     strQuery      = "SELECT id, doc_name,tooltip,preview_path FROM tblDocDirectory where status='ACTIVE' and p_id=0";
             SqlCommand cmd           = new SqlCommand(strQuery, con);
             con.Open();
             SqlDataReader sdr = cmd.ExecuteReader();
             if (sdr.HasRows)
             {
                 while (sdr.Read())
                 {
                     DheyaDocuments DD = new DheyaDocuments();
                     // DD.Child_Id = Convert.ToInt32(sdr["id"]);
                     DD.Doc_name = sdr["doc_name"].ToString();
                     //DD.Tooltip = sdr["tooltip"].ToString();
                     li.Add(DD);
                 }
                 return(li);
             }
             return(null);
         }
     }
     catch (Exception ex)
     {
         Log.Error("" + ex);
         return(null);
     }
 }
Example #2
0
        public List <DheyaDocuments> GetParentDocList1()
        {
            try
            {
                using (SqlConnection con = new SqlConnection(connectionString))
                {
                    List <DheyaDocuments> li    = new List <DheyaDocuments>();
                    List <DheyaDocuments> Child = new List <DheyaDocuments>();
                    // List<DheyaDocuments> li = new List<DheyaDocuments>();
                    // allList li = new allList();
                    string     strQuery = "SELECT id, doc_name,tooltip,preview_path FROM tblDocDirectory where status='ACTIVE' and p_id=0";
                    SqlCommand cmd      = new SqlCommand(strQuery, con);
                    con.Open();
                    SqlDataReader sdr = cmd.ExecuteReader();
                    if (sdr.HasRows)
                    {
                        while (sdr.Read())
                        {
                            DheyaDocuments DD = new DheyaDocuments();
                            DD.Parent_Id = Convert.ToInt32(sdr["id"]);
                            DD.Doc_name  = sdr["doc_name"].ToString();
                            //  DD.Tooltip = sdr["tooltip"].ToString();
                            li.Add(DD);
                            // ------------------New code For child details end

                            SqlConnection con1      = new SqlConnection(connectionString);
                            string        strQuery1 = "SELECT id, doc_name,tooltip,preview_path,p_id FROM tblDocDirectory where status='ACTIVE' and p_id=" + DD.Parent_Id;
                            SqlCommand    cmd1      = new SqlCommand(strQuery1, con1);
                            con1.Open();
                            SqlDataAdapter sda = new SqlDataAdapter(cmd1);
                            DataSet        ds  = new DataSet();
                            sda.Fill(ds);
                            //  SqlDataReader sdr1 = cmd.ExecuteReader();
                            if (ds.Tables[0].Rows.Count > 0)
                            {
                                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                                {
                                    DheyaDocuments DD1 = new DheyaDocuments();
                                    //ChildDoc DD1 = new ChildDoc();
                                    DD1.Parent_ChildId1 = new int[] { Convert.ToInt32(ds.Tables[0].Rows[i]["p_id"]) };
                                    DD1.Child_Id1       = new int[] { Convert.ToInt32(ds.Tables[0].Rows[i]["id"]) };
                                    DD1.Child_Doc_name  = new string[] { ds.Tables[0].Rows[i]["doc_name"].ToString() };
                                    DD1.Child_Tooltip   = new string[] { ds.Tables[0].Rows[i]["tooltip"].ToString() };
                                    string path = ds.Tables[0].Rows[i]["preview_path"].ToString();
                                    DD1.Child_Preview_path = new string[] { "https://dheya.com/cdf-dashboard/doc/cdf-doc/" + path };
                                    // li.ChildDheya.Add(DD1);
                                    li.Add(DD1);
                                }
                                //  li.AddRange(Child);
                            }


                            //-------------------New code for child details end
                        }
                        return(li);
                    }
                    return(null);
                }
            }
            catch (Exception ex)
            {
                Log.Error("" + ex);
                return(null);
            }
        }