private List <Material> PreencheGrid(string sql)
        {
            List <Material> list = new List <Material>();

            using (var bd = FactoryGI_LibBD.GI_LibBD(TipoBDAcessar.bdGI))
            {
                var dr = bd.AbreSQL(sql);

                while (dr.Read())
                {
                    Material mat = new Material().Preenche(dr);
                    list.Add(mat);
                }
            }

            return(list);
        }
        private List <Favorecido> PreencheGrid(string sql)
        {
            List <Favorecido> list = new List <Favorecido>();

            using (var bd = FactoryGI_LibBD.GI_LibBD(TipoBDAcessar.bdGI))
            {
                var dr = bd.AbreSQL(sql);

                while (dr.Read())
                {
                    Favorecido fav = new Favorecido().Preenche(dr);
                    list.Add(fav);
                }
            }

            return(list);
        }
        public static List <CM_CTABM> ReturnCTABMFromTabG(int tabG)
        {
            //Faz select cm_ctabm
            List <CM_CTABM> listaTodosItens = new List <CM_CTABM>();
            string          sql             = "Select CodMae, Codigo, CodInt, Texto, Descr, Ativo FROM cm_ctabm Where Tab = " + tabG + " Order by 1,2";

            using (var bd = FactoryGI_LibBD.GI_LibBD(TipoBDAcessar.bdGI))
            {
                var dr = bd.AbreSQL(sql);

                while (dr.Read())
                {
                    listaTodosItens.Add(new CM_CTABM().Preenche(dr));
                }
            }

            return(listaTodosItens);
        }
        public static List <GIInputCheckbox> Retorna(Tab tab, string checks)
        {
            if (Items.Count > 0)
            {
                Items.Clear();
            }

            if (LastItems.Count > 0)
            {
                LastItems.Clear();
            }

            var itemsCheck = RetornaListaItemsChecados(checks);


            List <GIInputCheckbox> list   = new List <GIInputCheckbox>();
            List <CM_CTABM>        listCM = new List <CM_CTABM>();


            string sql = "SELECT CodMae, Codigo, CodInt, Texto, Descr, Ativo FROM cm_ctabm WHERE Tab = " + TabToString(tab) + " ORDER BY 1,2";

            using (var bd = FactoryGI_LibBD.GI_LibBD(TipoBDAcessar.bdGI))
            {
                var dr = bd.AbreSQL(sql);

                while (dr.Read())
                {
                    var x = new CM_CTABM().Preenche(dr);

                    foreach (string s in itemsCheck)
                    {
                        var teste = s.Trim();
                        if (teste.Equals(x.CodInt))
                        {
                            x.Checked = true;
                        }
                    }

                    listCM.Add(x);
                }
            }


            List <SomeHierarchyViewModel> TodosMae = RetornaListaCodMaeNulo(listCM);

            foreach (var m in TodosMae)
            {
                RetornaListaFilhosRecursivo(listCM, m);
            }


            RetornaUltimoNivel(Items);

            foreach (var x in LastItems)
            {
                GIInputCheckbox check = new GIInputCheckbox();

                check.Content   = x.Title;
                check.Tag       = x.CodInt;
                check.IsChecked = x.IsChecked;

                list.Add(check);
            }



            return(list);
        }