Пример #1
0
        public ObservableCollection <mPortaria> LastRows()
        {
            var dataAccess = Sim.Data.Instances.DataM();

            try
            {
                var list = new ObservableCollection <mPortaria>();

                string sqlport = @"SELECT TOP 20 * FROM Portarias ORDER BY Cadastro DESC, Numero DESC";

                List <mClassificacao> tipos = new List <mClassificacao>();

                tipos = ListaGenerica(SqlCollections.Classi_With_Blocked);

                foreach (DataRow dr in dataAccess.Read(sqlport).Rows)
                {
                    var docs = new mPortaria();
                    docs.Indice     = (int)dr["Indice"];
                    docs.IndiceLink = dr["Indice"].ToString();
                    docs.Numero     = (int)dr["Numero"];
                    docs.Data       = (DateTime)dr["Data"];
                    docs.Publicada  = dr["Publicado"].ToString();
                    docs.Resumo     = (string)dr["Resumo"];
                    docs.Pdf        = (string)dr["Link"];
                    docs.Cadastrado = (DateTime)dr["Cadastro"];
                    docs.Atualizado = (DateTime)dr["Atualizado"];
                    docs.Excluido   = (bool)dr["Excluido"];

                    int tipo = (int)dr["Tipo"];

                    docs.Tipo = string.Format("{0}", tipos[tipo].Nome);

                    string[] linha = dr["Servidor"].ToString().Split(';');

                    ObservableCollection <mServidor> func = new ObservableCollection <mServidor>();

                    foreach (string l in linha)
                    {
                        mServidor svnome = new mServidor();
                        svnome.Nome = l.ToString();
                        func.Add(svnome);
                    }

                    docs.Servidor = func;
                    list.Add(docs);
                }

                return(list);
            }
            catch (Exception ex)
            {
                return(null);

                throw new Exception(ex.Message);
            }
            finally
            {
                dataAccess = null;
            }
        }
Пример #2
0
        public List <mPortaria> ListaParaEdicao(int indice)
        {
            var dataAccess = Sim.Data.Instances.DataM();

            try
            {
                dataAccess.ClearParameters();
                dataAccess.AddParameters("@Indice", indice);

                List <mClassificacao> tipos = new List <mClassificacao>();

                tipos = ListaGenerica(SqlCollections.Classi_With_Blocked);

                List <mPortaria> lista = new List <mPortaria>();

                foreach (DataRow dr in dataAccess.Read(SqlCollections.SelectIndice).Rows)
                {
                    var docs = new mPortaria();
                    docs.Indice     = (int)dr["Indice"];
                    docs.IndiceLink = dr["Indice"].ToString();
                    docs.Numero     = (int)dr["Numero"];
                    docs.Data       = (DateTime)dr["Data"];
                    docs.Publicada  = dr["Publicado"].ToString();
                    docs.Resumo     = (string)dr["Resumo"];
                    docs.Pdf        = (string)dr["Link"];
                    docs.Cadastrado = (DateTime)dr["Cadastro"];
                    docs.Atualizado = (DateTime)dr["Atualizado"];
                    docs.Excluido   = (bool)dr["Excluido"];
                    docs.Tipo       = dr["Tipo"].ToString();

                    string[] linha = dr["Servidor"].ToString().Split(';');

                    ObservableCollection <mServidor> func = new ObservableCollection <mServidor>();

                    foreach (string l in linha)
                    {
                        mServidor svnome = new mServidor();
                        svnome.Nome = l.ToString();
                        func.Add(svnome);
                    }

                    docs.Servidor = func;

                    lista.Add(docs);
                }

                return(lista);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
                dataAccess = null;
            }
        }
Пример #3
0
        public ObservableCollection <mPortaria> ConsultaDetelhada(string tipo, string nome, string resumo, DateTime datai, DateTime dataf)
        {
            var list = new ObservableCollection <mPortaria>();

            var dataAccess = Sim.Data.Instances.DataM();

            try
            {
                if (tipo == "0")
                {
                    tipo = "%";
                }

                dataAccess.ClearParameters();
                dataAccess.AddParameters("@Data1", datai.ToShortDateString());
                dataAccess.AddParameters("@Data2", dataf.ToShortDateString());
                dataAccess.AddParameters("@Tipo", tipo);
                dataAccess.AddParameters("@Resumo", "%" + resumo + "%");
                dataAccess.AddParameters("@Nome", "%" + nome + "%");

                List <mClassificacao> tipos = new List <mClassificacao>();

                tipos = ListaGenerica(SqlCollections.Classi_With_Blocked);

                int vreg = dataAccess.Read(SqlCollections.SelectParameters).Rows.Count;

                int cont_reg = 0;

                foreach (DataRow dr in dataAccess.Read(SqlCollections.SelectParameters).Rows)
                {
                    cont_reg += 1;

                    var docs = new mPortaria();
                    docs.Indice     = (int)dr["Indice"];
                    docs.IndiceLink = dr["Indice"].ToString();
                    docs.Numero     = (int)dr["Numero"];
                    docs.Data       = (DateTime)dr["Data"];
                    docs.Publicada  = dr["Publicado"].ToString();
                    docs.Resumo     = (string)dr["Resumo"];
                    docs.Pdf        = (string)dr["Link"];
                    docs.Cadastrado = (DateTime)dr["Cadastro"];
                    docs.Atualizado = (DateTime)dr["Atualizado"];
                    docs.Excluido   = (bool)dr["Excluido"];

                    int rtipo = (int)dr["Tipo"];

                    docs.Tipo = string.Format("{0}", tipos[rtipo].Nome);

                    string[] linha = dr["Servidor"].ToString().Split(';');

                    ObservableCollection <mServidor> func = new ObservableCollection <mServidor>();

                    foreach (string l in linha)
                    {
                        mServidor svnome = new mServidor();
                        svnome.Nome = l.ToString();
                        func.Add(svnome);
                    }

                    docs.Servidor = func;
                    list.Add(docs);
                }

                return(list);
            }
            catch (Exception ex)
            {
                return(null);

                throw new Exception(ex.Message);
            }
            finally
            {
                dataAccess = null;
            }
        }