public ColecoesEditPage(Colecao colecao) { InitializeComponent(); PopularFormulario(colecao); RegistraClickBotaoCamera(idcolecao.Text.Trim()); RegistraClickBotaoAlbum(); }
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()); } }
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)); }
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); } }
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); }
public BD(string diretorio) { Produtos = new Colecao<Produto>(); Vendedores = new Colecao<Vendedor>(); Clientes = new Colecao<Cliente>(); this.diretorio = diretorio; Recuperar(); }
public MainPage() { this.InitializeComponent(); _vm = new Colecao(); _vm.Items = new ObservableCollection <Item>(); _vm.IsEasyChecked = true; this.DataContext = _vm; // setando o contexto dos dados. }
public async Task <Colecao> LoadColecaoAsync() { var res = await LoadTextAsync("colecao.xml"); var colecao = res.DeserializarColecao(); _ultimaColecaoCarregada = colecao; return(colecao); }
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()); }
public async Task <Colecao> LoadColecaoAsync() { var res = await LoadTextAsync("colecao.xml"); /* DESERIALIZAR OBJETO */ var colecao = DeserializeObject(res); _ultimaColecaoCarregada = colecao; return(colecao); }
public string SerializeObject(Colecao toSerialize) { XmlSerializer xmlSerializer = new XmlSerializer(toSerialize.GetType()); using (StringWriter textWriter = new StringWriter()) { xmlSerializer.Serialize(textWriter, toSerialize); return(textWriter.ToString()); } }
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); }); }
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)); }
/// <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; } }
/// <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; } }
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")); }
/// <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; } }
/// <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; } }
/// <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; } }
/// <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; } }
/// <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; } }
/// <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; } }
/// <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; } }
/// <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; } }
/// <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; } }
/// <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; } }
/// <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; } }
/// <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; } }
/// <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; } }
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); } }
/// <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; } }
/// <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(); }