protected void OnEditActionActivated (object sender, EventArgs e) { TreeIter treeIter; articuloTreeView.Selection.GetSelected (out treeIter); object id = listStore.GetValue (treeIter, 0); CategoriaView categoriaView = new CategoriaView (id); }
public ADSResposta Excluir(CategoriaView c) { try { using (var db = DBCore.NovaInstanciaDoBanco()) { var id = int.Parse(c.Codigo); var conta = db.Categorias.Where(w => w.Codigo.Equals(id)).FirstOrDefault(); if (conta == null) { return(new ADSResposta(sucesso: false, mensagem: "Categoria não encontrada.", objeto: c)); } db.Categorias.Remove(conta); db.SaveChanges(); return(new ADSResposta(sucesso: true, objeto: conta)); } } catch (Exception ex) { return(new ADSResposta(false, ex.Message, c)); } }
public ADSResposta Salvar(CategoriaView c) { var db = DBCore.InstanciaDoBanco(); Categoria novo = null; if (!c.Codigo.Equals("0")) { var id = int.Parse(c.Codigo); novo = db.Categorias.Where(w => w.Codigo.Equals(id)).FirstOrDefault(); novo.Descricao = c.Descricao; } else { novo = db.Categorias.Create(); novo.Descricao = c.Descricao; db.Categorias.Add(novo); } try { db.SaveChanges(); c.Codigo = novo.Codigo.ToString(); return(new ADSResposta(true, objeto: c)); } catch (Exception ex) { return(new ADSResposta(false, ex.Message, c)); } }
public ActionResult Edit(CategoriaView categoria) { try { if (ModelState.IsValid) { Categoria eCategoria = new Categoria() { Id = categoria.Id, Nome = categoria.Nome, Status = categoria.Status }; cb.SaveCategoria(eCategoria); return(RedirectToAction("Index")); } else { return(View(categoria)); } } catch { return(View(categoria)); } }
public ActionResult Create(CategoriaView categoria) { try { if (ModelState.IsValid) { Categoria nCategoria = new Categoria { Nome = categoria.Nome, Status = categoria.Status, Create = DateTime.Now, }; cb.SaveCategoria(nCategoria); ViewBag.Message = "Categoria " + categoria.Nome + " salva com sucesso"; ViewBag.TypeMsg = "success"; return(RedirectToAction("Index")); } else { return(View(categoria)); } } catch (Exception ex) { return(View(categoria)); } }
public ActionResult Edit(int?id) { try { if (id == null) { return(RedirectToAction("Index")); } else { var ret = cb.GetCategoriaById((int)id); CategoriaView categoria = new CategoriaView() { Id = ret.Id, Nome = ret.Nome, Status = ret.Status }; ConfigureList(); return(View(categoria)); } } catch { return(View()); } }
private async void category() { var pagina = new CategoriaView(); pagina.BindingContext = new CategoriaViewModel(Category); await App.Current.MainPage.Navigation.PushAsync(pagina); }
public CategoriaViewModel(CategoriaView categoriaView) { this.Instancia = this; borrarCampos(); Mensajes = categoriaView; IsvisibleAdd = "Hidden"; }
public void Execute(object parameter) { if (parameter.Equals("Categoria")) { CategoriaView categoria = new CategoriaView(); categoria.Show(); } else if (parameter.Equals("TipoEmpaque")) { TipoEmpaqueView tipoEmpaque = new TipoEmpaqueView(); tipoEmpaque.Show(); } else if (parameter.Equals("Clientes")) { ClientesView clientes = new ClientesView(); clientes.Show(); } else if (parameter.Equals("Proveedores")) { ProveedoresView proveedores = new ProveedoresView(); proveedores.Show(); } else if (parameter.Equals("Productos")) { ProductosView productos = new ProductosView(); productos.Show(); } }
public CategoriaViewModel(CategoriaView categoriaView, ProductoView productoView) { this.Instancia = this; borrarCampos(); Mensajes = categoriaView; this.AgregandoCodigo = productoView; IsvisibleAdd = "Visible"; }
public ActionResult Create(CategoriaView model) { if (ModelState.IsValid) { var categoria = Mapper.Map<CategoriaView, Categoria>(model); ctrl.Insert(categoria); return RedirectToAction("Index"); } return View(model); }
public ActionResult Edit(int id, CategoriaView model) { if (ModelState.IsValid) { var c = ctrl.Retrieve(new Categoria() { CategoriaId = id }).FirstOrDefault(); Mapper.DynamicMap<CategoriaView, Categoria>(model,c); ctrl.Update(c); return RedirectToAction("Index"); } return View(model); }
private void atualizarCategoria(CategoriaInfo categoria, int left, int top) { var seguimentoView = new CategoriaView { Categoria = categoria }; seguimentoView.AoClicar += async(sender, e) => { //AoClicar?.Invoke(sender, e); await abrirCategoria(e); }; _categoriaGrid.Children.Add(seguimentoView, left, top); }
public void AdicionarTeste() { CategoriaView input = new CategoriaView(); input.IdMarca = 1; input.Descricao = "Pijamas"; input.Ativo = true; input.UsuarioCriacao = "ebenedicto"; input.DataCriacao = DateTime.Now; input.UsuarioAtualizacao = null; input.DataAtualizacao = null; _categoriaApplication.Inserir(input); }
public CategoriaView PegaPorCodigo(int id) { var categoria = DBCore.InstanciaDoBanco().Categorias .Where(w => w.Codigo.Equals(id)) .FirstOrDefault(); CategoriaView resposta = null; if (categoria != null) { resposta = ConverteParaView(categoria); } return(resposta); }
public async Task <ActionResult <CategoriaView> > Incluir([FromBody] CategoriaView categoria) { try { var resultado = this.mapper.Map <Categoria>(categoria); if (resultado.Valid) { return(this.Ok(this.mapper.Map <CategoriaView>(await this.serviceCategoria.Adicionar(resultado)))); } else { return(this.Ok(resultado.Lista)); } } catch { return(StatusCode(500)); } }
public ADSResposta Salvar(CategoriaView c) { var resposta = new ADSResposta(); using (var db = DBCore.NovaInstanciaDoBanco()) { using (var transacao = db.Database.BeginTransaction()) { try { Categoria novo = null; if (!c.Codigo.Equals("0")) { var id = int.Parse(c.Codigo); novo = db.Categorias.Where(w => w.Codigo.Equals(id)).FirstOrDefault(); novo.Descricao = c.Descricao; } else { novo = db.Categorias.Create(); novo.Descricao = c.Descricao; db.Categorias.Add(novo); } db.SaveChanges(); c.Codigo = novo.Codigo.ToString(); resposta.Sucesso = true; resposta.Objeto = c; transacao.Commit(); } catch (Exception ex) { transacao.Rollback(); resposta.Sucesso = false; resposta.Mensagem = ex.Message; } } } return(resposta); }
public async Task <bool> Add(CategoriaView mensaje) { var resultado = await mensaje.ShowMessageAsync("Agregando", "Desea Agregar una nueva categoria", MessageDialogStyle.AffirmativeAndNegative, new MetroDialogSettings { AffirmativeButtonText = "Si", NegativeButtonText = "No", AnimateShow = true, AnimateHide = false }); if (resultado == MessageDialogResult.Affirmative) { return(true); } else { return(false); } }
public async Task <ActionResult> Create(CategoriaView categoriaView) { try { if (ModelState.IsValid) { var categoria = this.mapper.Map <Categoria>(categoriaView); await this.serviceCategoria.Adicionar(categoria); return(RedirectToAction(nameof(Listar))); } else { return(View(categoriaView)); } } catch (Exception ex) { throw new ArgumentException(ex.Message); } }
public async Task <ActionResult> Edit(CategoriaView categoriaView) { try { if (ModelState.IsValid) { var categoria = this.mapper.Map <Categoria>(categoriaView); await this.serviceCategoria.Alterar(categoria); return(RedirectToAction(nameof(Listar))); } else { return(RedirectToAction(nameof(Index))); } } catch { return(View()); } }
public ADSResposta Excluir(CategoriaView c) { var resposta = new ADSResposta(); using (var db = DBCore.NovaInstanciaDoBanco()) { using (var transacao = db.Database.BeginTransaction()) { try { var id = int.Parse(c.Codigo); var categoria = db.Categorias.Where(w => w.Codigo.Equals(id)).FirstOrDefault(); if (categoria == null) { resposta.Sucesso = false; resposta.Objeto = c; resposta.Mensagem = "Categoria não encontrada."; } else { db.Categorias.Remove(categoria); db.SaveChanges(); resposta.Sucesso = true; resposta.Objeto = c; transacao.Commit(); } } catch (Exception ex) { transacao.Rollback(); resposta.Sucesso = false; resposta.Mensagem = ex.Message; } } } return(resposta); }
public MainWindow() : base(Gtk.WindowType.Toplevel) { Build(); treeView.AppendColumn("id", new CellRendererText(), "text", 0); treeView.AppendColumn("nombre", new CellRendererText(), "text", 1); ListStore liststore = new ListStore(typeof(long), typeof(string)); treeView.Model = liststore; //liststore.AppendValues (33L, "Treinta y tres"); App.Instance.DbConnection = new MySqlConnection("Database=dbprueba;user=root;password=sistemas"); App.Instance.DbConnection.Open(); fillListStore(liststore); newAction.Activated += delegate { CategoriaView categoriaView = new CategoriaView(); }; //dbConnection.Close (); deleteAction.Activated += delegate { //confirmar /* MessageDialog messageDialog = new MessageDialog( * this, * DialogFlags.Modal, * MessageType.Question, * ButtonsType.YesNo, * " ¿ Deseas eliminar el registro ? " * ); * messageDialog.Title = Title; * ResponseType response = (ResponseType)messageDialog.Run(); * messageDialog.Destroy(); * if (response != ResponseType.Yes) * return; * */ if (!WindowHelper.Confirm(this, "¿quieres Eliminar el registro?")) { return; } TreeIter treeIter; treeView.Selection.GetSelected(out treeIter); object id = liststore.GetValue(treeIter, 0); Console.WriteLine("deletedAction Activated id = {0}", id); IDbCommand deleteDbCommand = App.Instance.DbConnection.CreateCommand(); deleteDbCommand.CommandText = "delete from categoria where id = @id"; DbHelper.DbCommandAddParameter(deleteDbCommand, "id", id); deleteDbCommand.ExecuteNonQuery(); }; treeView.Selection.Changed += delegate { Console.WriteLine("treeView Selection Changed Count Selected Rows()={0}"); treeView.Selection.CountSelectedRows(); refreshActions(); }; refreshActions(); }
public void Alterar(CategoriaView input) { var obj = _mapper.Map <Categoria>(input); _categoriaRepository.Alterar(obj); }
public async Task <IHttpActionResult> Excluir([FromBody] JObject jsonData) { CategoriaView categoria = jsonData.SelectToken("Categoria").ToObject <CategoriaView>(); return(Ok((new CategoriaNegocio().Excluir(categoria)))); }
private void btnCategoria_Click(object sender, EventArgs e) { CategoriaView categoriaView = new CategoriaView(); categoriaView.Show(); }
public void Inserir(CategoriaView input) { var obj = _mapper.Map <Categoria>(input); _categoriaRepository.Inserir(obj); }
public MainWindow() : base(Gtk.WindowType.Toplevel) { Build(); //Crear treeview categorias treeView.AppendColumn("Id", new CellRendererText(), "text", 0); treeView.AppendColumn("Nombre", new CellRendererText(), "text", 1); ListStore listStore = new ListStore(typeof(long), typeof(string)); treeView.Model = listStore; //mysql App.Instance.DbConnection = new MySqlConnection( "Database=dbprueba;User=root;Password=sistemas"); App.Instance.DbConnection.Open(); //operaciones // IDbCommand insertdbCommand = dbConnection.CreateCommand (); // insertdbCommand.CommandText = // "insert into categoria (nombre) values ('categoria 4')"; // insertdbCommand.ExecuteNonQuery (); //App.Instance.DbConnection.Close (); CategoriaView categoriaView = new CategoriaView(); deleteAction.Activated += delegate { // Confirmar el borrado // MessageDialog messageDialog= new MessageDialog( // this, // DialogFlags.Modal, // MessageType.Question, // ButtonsType.YesNo, // "¿Deseas eliminar el registro?" // ); // messageDialog.Title=Title; // ResponseType response=(ResponseType)messageDialog.Run(); // messageDialog.Destroy(); // if(response!=ResponseType.Yes) // return; if (!WindowHelper.Confirm(this, "¿Deseas eliminar el registro?")) { return; } Console.WriteLine("delete activated"); TreeIter treeIter; treeView.Selection.GetSelected(out treeIter); object id = listStore.GetValue(treeIter, 0); Console.WriteLine("deleteAction Activated id={0}", id); IDbCommand deleteDbCommand = App.Instance.DbConnection.CreateCommand(); deleteDbCommand.CommandText = "delete from categoria where id= " + id; }; treeView.Selection.Changed += delegate { Console.WriteLine("Selection changed CountSelectedRows()={0}", treeView.Selection.CountSelectedRows()); updateActions(); }; refreshAction.Activated += delegate { fillListstore(listStore); }; updateActions(); }