Ejemplo n.º 1
0
 public ColecoesEditPage(Colecao colecao)
 {
     InitializeComponent();
     PopularFormulario(colecao);
     RegistraClickBotaoCamera(idcolecao.Text.Trim());
     RegistraClickBotaoAlbum();
 }
Ejemplo n.º 2
0
    public static void Main(string[] args)
    {
        Aluno x = new Aluno("Marina", 1001);
        Aluno y = new Aluno("Ana", 1002);
        Aluno z = new Aluno("Nanda", 1003);

        Colecao <Aluno> turma = new Colecao <Aluno>();

        turma.Add(x);
        turma.Add(y);
        turma.Add(z);

        foreach (Aluno i in turma)
        {
            Console.WriteLine(i.ToString());
        }

        Console.WriteLine("x");
        turma.Sort();

        foreach (Aluno i in turma)
        {
            Console.WriteLine(i.ToString());
        }
    }
Ejemplo n.º 3
0
        public ActionResult Cadastrar(Colecao model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            model.nome       = model.nome.ToUpper();
            model.id_usuario = Convert.ToInt64(UsuarioLogado.IdUsuario);
            model.id_conta   = Convert.ToInt64(UsuarioLogado.IdConta);
            try
            {
                var existe = DAL.GetObjeto <Colecao>(string.Format("id_conta={0} and nome='{1}'", UsuarioLogado.IdConta, model.nome)) ?? new Colecao();
                if (existe.id > 0 && model.id == 0)
                {
                    this.AddNotification("Coleção já existe!", "Alerta");
                    return(View());
                }
                long id = DAL.Gravar(model);

                if (model.id > 0 && id == 0)
                {
                    this.AddNotification("Coleção alterada!", "Sucesso");
                }
                else
                {
                    this.AddNotification("Coleção cadastrada!", "Sucesso");
                }
            }
            catch (Exception e)
            {
                this.AddNotification("Erro:" + e.Message, "Erro");
            }
            return(View(model));
        }
Ejemplo n.º 4
0
    public static void Main(string[] args)
    {
        Colecao <int> c = new Colecao <int>();

        c.Add(5);
        c.Add(3);
        c.Add(1);
        c.Sort();
        Console.WriteLine();
        foreach (int i in c)
        {
            Console.WriteLine(i);
        }
        c.Remove(5);
        Console.WriteLine();
        foreach (int i in c)
        {
            Console.WriteLine(i);
        }
        c.Add(55);
        c.Add(33);
        c.Add(11);
        Console.WriteLine();
        foreach (int i in c)
        {
            Console.WriteLine(i);
        }
        c.Sort();
        Console.WriteLine();
        foreach (int i in c)
        {
            Console.WriteLine(i);
        }
    }
Ejemplo n.º 5
0
 private void PopularFormulario(Colecao colecao)
 {
     this.colecao   = colecao;
     idcolecao.Text = colecao.ColecaoId.ToString();
     nome.Text      = colecao.Nome;
     //caminhoArquivo = produto.CaminhoArquivoFoto;
     //fotoproduto.Source = ImageSource.FromFile(produto.CaminhoArquivoFoto);
 }
Ejemplo n.º 6
0
 public BD(string diretorio)
 {
     Produtos = new Colecao<Produto>();
     Vendedores = new Colecao<Vendedor>();
     Clientes = new Colecao<Cliente>();
     this.diretorio = diretorio;
     Recuperar();
 }
Ejemplo n.º 7
0
        public MainPage()
        {
            this.InitializeComponent();

            _vm               = new Colecao();
            _vm.Items         = new ObservableCollection <Item>();
            _vm.IsEasyChecked = true;
            this.DataContext  = _vm; // setando o contexto dos dados.
        }
Ejemplo n.º 8
0
        public async Task <Colecao> LoadColecaoAsync()
        {
            var res = await LoadTextAsync("colecao.xml");

            var colecao = res.DeserializarColecao();

            _ultimaColecaoCarregada = colecao;
            return(colecao);
        }
Ejemplo n.º 9
0
    public static void Main(string[] args)
    {
        Colecao c = new Colecao(3);

        c.Inserir("item1");
        c.Inserir("item2");
        c.Inserir("item3");
        Console.WriteLine("aaaa");
        Console.WriteLine(c.Listar());
    }
Ejemplo n.º 10
0
        public async Task <Colecao> LoadColecaoAsync()
        {
            var res = await LoadTextAsync("colecao.xml");

            /* DESERIALIZAR OBJETO */
            var colecao = DeserializeObject(res);

            _ultimaColecaoCarregada = colecao;
            return(colecao);
        }
Ejemplo n.º 11
0
        public string SerializeObject(Colecao toSerialize)
        {
            XmlSerializer xmlSerializer = new XmlSerializer(toSerialize.GetType());

            using (StringWriter textWriter = new StringWriter())
            {
                xmlSerializer.Serialize(textWriter, toSerialize);
                return(textWriter.ToString());
            }
        }
Ejemplo n.º 12
0
 public async Task SaveColecaoAsync(Colecao colecao)
 {
     await Task.Run(() =>
     {
         var localStorage     = Environment.GetFolderPath(_diretorioLocalPath);
         var filePath         = Path.Combine(localStorage, "colecao.xml");
         var colecaoStringXml = colecao.SerializarColecao();
         File.WriteAllText(filePath, colecaoStringXml);
     });
 }
Ejemplo n.º 13
0
 public ActionResult Edit([Bind(Include = "Id,Nome,Quantidade,AnoLancamento,Descricao, Editora")] ColecaoViewModel viewModel)
 {
     if (ModelState.IsValid)
     {
         Colecao colecao = Mapper.Map <ColecaoViewModel, Colecao>(viewModel);
         repositorioColecoes.Alterar(colecao);
         return(RedirectToAction("Index"));
     }
     return(View(viewModel));
 }
Ejemplo n.º 14
0
 /// <summary>
 /// Insere uma lista.
 /// </summary>
 /// <param name="lstRegistro">Lista de registros.</param>
 public virtual void Inserir(IEnumerable <T> lstRegistro)
 {
     try
     {
         Colecao.InsertMany(sessao, lstRegistro);
     }
     catch (Exception)
     {
         throw;
     }
 }
Ejemplo n.º 15
0
 /// <summary>
 /// Recupera a lista de todos os registros da tabela.
 /// </summary>
 /// <returns>Lista do tipo IMongoQueryable com dados da tabelaa.</returns>
 public virtual IMongoQueryable <T> Listar()
 {
     try
     {
         return(Colecao.AsQueryable());
     }
     catch (Exception)
     {
         throw;
     }
 }
Ejemplo n.º 16
0
        public ActionResult Deletar(int id = 0)
        {
            var model = new Colecao();

            if (id > 0)
            {
                model = DAL.GetObjeto <Colecao>(string.Format("id_conta={0} and id={1}", UsuarioLogado.IdConta, id));
                DAL.Excluir(model);
            }
            return(RedirectToAction("Consultar"));
        }
Ejemplo n.º 17
0
 /// <summary>
 /// Insere uma lista assíncrona.
 /// </summary>
 /// <param name="lstRegistro">Lista de registros.</param>
 public virtual async void InserirAsync(IEnumerable <T> lstRegistro)
 {
     try
     {
         await Colecao.InsertManyAsync(sessao, lstRegistro);
     }
     catch (Exception)
     {
         throw;
     }
 }
Ejemplo n.º 18
0
 /// <summary>
 /// Lista assíncrono todos os registros da tabela assincronos.
 /// </summary>
 /// <returns>Lista os dados da coleção.</returns>
 public virtual async Task <List <T> > ListarAsync()
 {
     try
     {
         return(await Colecao.AsQueryable().ToListAsync());
     }
     catch (Exception)
     {
         throw;
     }
 }
Ejemplo n.º 19
0
 /// <summary>
 /// Busca o registro assincrono identico ao objeto informado.
 /// </summary>
 /// <param name="filtro">Expressão LAMBDA.</param>
 /// <returns>Retorna o primeiro registro encontrado.</returns>
 public virtual T Buscar(Expression <Func <T, bool> > filtro)
 {
     try
     {
         return(Colecao.Find(sessao, filtro).FirstOrDefault());
     }
     catch (Exception)
     {
         throw;
     }
 }
Ejemplo n.º 20
0
 /// <summary>
 /// Recupera a lista dos registros da tabela de acordo com filtro.
 /// </summary>
 /// <param name="filtro">Expressão LAMBDA.</param>
 /// <returns>Lista do tipo IMongoQueryable com dados da tabela de acordo com filtro informado.</returns>
 public virtual IMongoQueryable <T> Listar(Expression <Func <T, bool> > filtro)
 {
     try
     {
         return(Colecao.AsQueryable().Where(filtro));
     }
     catch (Exception)
     {
         throw;
     }
 }
Ejemplo n.º 21
0
 /// <summary>
 /// Busca assíncrono o registro identico ao objeto informado.
 /// </summary>
 /// <param name="filtro">Expressão LAMBDA.</param>
 /// <returns>Retorna o primeiro registro encontrado.</returns>
 public virtual async Task <T> BuscarAsync(Expression <Func <T, bool> > filtro)
 {
     try
     {
         return(await Colecao.Find(sessao, filtro).FirstOrDefaultAsync());
     }
     catch (Exception)
     {
         throw;
     }
 }
Ejemplo n.º 22
0
 /// <summary>
 /// Lista assíncrono todos os registros da tabela assincronos.
 /// </summary>
 /// <param name="filtro">Expressão LAMBDA.</param>
 /// <returns>Lista os dados da coleção de acordo com filtro informado.</returns>
 public virtual async Task <List <T> > ListarAsync(Expression <Func <T, bool> > filtro)
 {
     try
     {
         return(await Colecao.Find(sessao, filtro).ToListAsync());
     }
     catch (Exception)
     {
         throw;
     }
 }
Ejemplo n.º 23
0
 /// <summary>
 /// Busca o registro assíncrono identico ao objeto informado.
 /// </summary>
 /// <param name="registro">Informe o objeto.</param>
 /// <returns>Retorna o primeiro registro encontrado.</returns>
 public virtual async Task <T> BuscarAsync(T registro)
 {
     try
     {
         return(await Colecao.Find(sessao, CriarFiltro(registro)).FirstOrDefaultAsync());
     }
     catch (Exception)
     {
         throw;
     }
 }
Ejemplo n.º 24
0
 /// <summary>
 /// Altera assíncrono o registro na base de dados.
 /// </summary>
 /// <param name="filtro">Expressão LAMBDA.</param>
 /// <param name="registro">Informe o objeto.</param>
 /// <param name="opcao">Opções para um comando findAndModify para atualizar um objeto.</param>
 /// <returns>Retorna o registro atualizado.</returns>
 public virtual async Task <T> AlterarAsync(Expression <Func <T, bool> > filtro, UpdateDefinition <T> registro, FindOneAndUpdateOptions <T> opcao = null)
 {
     try
     {
         Buscar(filtro);
         return(await Colecao.FindOneAndUpdateAsync(filtro, registro, opcao));
     }
     catch (Exception)
     {
         throw;
     }
 }
Ejemplo n.º 25
0
 /// <summary>
 /// Busca o registro identico ao objeto informado.
 /// </summary>
 /// <param name="registro">Informe o objeto.</param>
 /// <returns>Retorna o primeiro registro encontrado.</returns>
 public virtual T Buscar(T registro)
 {
     try
     {
         return(Colecao.Find(sessao, CriarFiltro(registro)).FirstOrDefault());
     }
     catch (Exception)
     {
         sessao.AbortTransaction();
         throw;
     }
 }
Ejemplo n.º 26
0
 /// <summary>
 /// Altera o registro na base de dados.
 /// </summary>
 /// <param name="filtro">Expressão LAMBDA.</param>
 /// <param name="registro">Informe o objeto.</param>
 /// <returns>Retorna o registro atualizado.</returns>
 public virtual T Alterar(Expression <Func <T, bool> > filtro, UpdateDefinition <T> registro)
 {
     try
     {
         Buscar(filtro);
         return(Colecao.FindOneAndUpdate(sessao, filtro, registro, opcaoPadrao));
     }
     catch (Exception)
     {
         throw;
     }
 }
Ejemplo n.º 27
0
 /// <summary>
 /// Exclui o primeiro registro encontrado igual ao registro informado da base de dados.
 /// </summary>
 /// <param name="registro">Informe o objeto.</param>
 public virtual void Excluir(T registro)
 {
     try
     {
         Buscar(registro);
         Colecao.DeleteOne(sessao, CriarFiltro(registro));
     }
     catch (Exception)
     {
         throw;
     }
 }
Ejemplo n.º 28
0
 /// <summary>
 /// Exclui registro da base de dados.
 /// </summary>
 /// <param name="filtro">Expressão LAMBDA.</param>
 public virtual void Excluir(Expression <Func <T, bool> > filtro)
 {
     try
     {
         Buscar(filtro);
         Colecao.DeleteOne(sessao, filtro);
     }
     catch (Exception)
     {
         throw;
     }
 }
Ejemplo n.º 29
0
 /// <summary>
 /// Altera o registro na base de dados.
 /// </summary>
 /// <param name="filtro">Expressão LAMBDA.</param>
 /// <param name="registro">Informe o objeto.</param>
 /// <returns>Retorna o registro atualizado.</returns>
 public virtual T Alterar(Expression <Func <T, bool> > filtro, T registro)
 {
     try
     {
         Buscar(filtro);
         var novo = registro.ToJson();
         return(Colecao.FindOneAndUpdate(sessao, filtro, novo, opcaoPadrao));
     }
     catch (Exception)
     {
         throw;
     }
 }
Ejemplo n.º 30
0
        public async Task SaveColecaoAsync(Colecao colecao)
        {
            var local = ApplicationData.Current.LocalFolder;
            var file  = await local.CreateFileAsync("colecao.xml", CreationCollisionOption.ReplaceExisting);

            // Serializa objeto
            var colecaoStringXml = SerializeObject(colecao);

            using (StreamWriter writer = new StreamWriter(await file.OpenStreamForWriteAsync()))
            {
                writer.Write(colecaoStringXml);
            }
        }
Ejemplo n.º 31
0
        /// <summary>
        /// Exclui registro assíncrono da base de dados.
        /// </summary>
        /// <param name="filtro">Expressão LAMBDA.</param>
        public virtual async void ExcluirAsync(Expression <Func <T, bool> > filtro)
        {
            try
            {
                await BuscarAsync(filtro);

                await Colecao.DeleteOneAsync(sessao, filtro);
            }
            catch (Exception)
            {
                throw;
            }
        }
Ejemplo n.º 32
0
        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.button1 = new System.Windows.Forms.Button();
            this.textBox1 = new System.Windows.Forms.TextBox();
            this.listBox2 = new System.Windows.Forms.ListBox();
            this.SuspendLayout();
            // 
            // button1
            // 
            this.button1.Location = new System.Drawing.Point(187, 42);
            this.button1.Name = "button1";
            this.button1.Size = new System.Drawing.Size(75, 23);
            this.button1.TabIndex = 0;
            this.button1.Text = "Add";
            this.button1.UseVisualStyleBackColor = true;
            // 
            // textBox1
            // 
            this.textBox1.Location = new System.Drawing.Point(30, 42);
            this.textBox1.Name = "textBox1";
            this.textBox1.Size = new System.Drawing.Size(151, 20);
            this.textBox1.TabIndex = 1;
            // 
            // listBox2
            // 
            Colecao c = new Colecao();
            listBox2.DataSource = c.getVet();
            this.listBox2.FormattingEnabled = true;
            this.listBox2.Location = new System.Drawing.Point(30, 68);
            this.listBox2.Name = "listBox2";
            this.listBox2.Size = new System.Drawing.Size(151, 147);
            this.listBox2.TabIndex = 2;

            // 
            // Form1
            // 
            this.ClientSize = new System.Drawing.Size(284, 261);
            this.Controls.Add(this.listBox2);
            this.Controls.Add(this.textBox1);
            this.Controls.Add(this.button1);
            this.Name = "Form1";
            this.ResumeLayout(false);
            this.PerformLayout();

        }