private void Salvar() { DALConexao cx = new DALConexao(DadosDaConexao.StringDaConexao); if (txtNome.Text.Trim() != "") { if (tipo == "Setor") { BLLBuffet blls = new BLLBuffet(cx); DTOBuffet dtob = new DTOBuffet(); dtob.NomeBuffet = txtNome.Text.Trim().ToUpper(); dtob.DescBuffet = txtDesc.Text.Trim().ToUpper(); blls.Incluir(dtob); this.categoria = dtob.NomeBuffet; txtNome.Clear(); txtDesc.Clear(); CarregarDgv(); } if (tipo == "Categoria") { BLLCategoria bllc = new BLLCategoria(cx); DTOCategoria dtoc = new DTOCategoria(); dtoc.NomeCat = txtNome.Text.Trim().ToUpper(); dtoc.DescCat = txtDesc.Text.Trim().ToUpper(); bllc.Incluir(dtoc); this.categoria = dtoc.NomeCat; txtNome.Clear(); txtDesc.Clear(); CarregarDgv(); } if (tipo == "Subcategoria") { BLLSubCategoria bllsc = new BLLSubCategoria(cx); DTOSubCategoria dtosc = new DTOSubCategoria(); dtosc.NomeSCat = txtNome.Text.Trim().ToUpper(); dtosc.DescSCat = txtDesc.Text.Trim().ToUpper(); bllsc.Incluir(dtosc); this.categoria = dtosc.NomeSCat; txtNome.Clear(); txtDesc.Clear(); CarregarDgv(); } } }
public DTOCategoria PreencheCategoria() { DTOCategoria categoria = new DTOCategoria(); categoria.Codigo = "CAT13092"; categoria.Nome = "Cozinha"; return(categoria); }
public ActionResult Edit([Bind(Include = "Descricao,Codigo")] DTOCategoria dtoCategoria) { if (ModelState.IsValid) { db.Entry(dtoCategoria).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(dtoCategoria)); }
public ActionResult Salvar(DTOCategoria item) { if (ModelState.IsValid) { item = GetCadastroService().SalvarCategoria(item); return(InformationMessage("Informação", "O registro foi gravado com sucesso.", Url.Action("Index"))); } else { return(ErrorMessage("Erro", "Registro Inválido!")); } }
public ActionResult Delete(int id) { try { DTOCategoria categoria = db.DTOCategorias.Find(id); db.DTOCategorias.Remove(categoria); db.SaveChanges(); return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Create([Bind(Include = "Descricao,Codigo")] DTOCategoria dtoCategoria) { try { // TODO: Add insert logic here db.DTOCategorias.Add(dtoCategoria); db.SaveChanges(); return(RedirectToAction("Index")); } catch { return(View()); } }
public void registrarCategoria(DTOCategoria categoria) { try { conectarBD(); conectado.Open(); comandoCategoria = new MySqlCommand(); comandoCategoria.Connection = conectado; comandoCategoria.CommandText = "INSERT INTO categoria(Nombre) VALUES(@Nombre)"; comandoCategoria.Parameters.AddWithValue("@Nombre", categoria.Nombre); comandoCategoria.ExecuteNonQuery(); conectado.Close(); } catch (Exception) { } }
public ActionResult Detalhar(int?id) { DTOCategoria result = null; if (id.HasValue) { result = GetCadastroService().ObterCategoria(id.Value); if (result == null) { throw new Exception("Registro não encontrado!"); } } else { result = new DTOCategoria(); } return(View(result)); }
public DTOCategoria SalvarCategoria(DTOCategoria dto) { Categoria categoria = null; if (dto.Id > 0) { categoria = Categoria.GetRepository().Get(dto.Id); if (categoria == null) { throw new Exception("Categoria não encontrado(a)!"); } dto.Transform <Categoria>(categoria); } else { categoria = dto.Transform <Categoria>(); } categoria.Save(); return(categoria.Transform <DTOCategoria>()); }
public DTOAlberoCategorie(DTOCategoria dto) { ID = dto.Identifier.ID.ToString(); Descrizione = dto.Nome; }
public void consultarCategoria(DTOCategoria categoria) { }
public void registrarCategoria(DTOCategoria categoria) { Categoria categoria2 = new Categoria(categoria.Nombre); }