Ejemplo n.º 1
0
        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();
                }
            }
        }
Ejemplo n.º 2
0
        public DTOCategoria PreencheCategoria()
        {
            DTOCategoria categoria = new DTOCategoria();

            categoria.Codigo = "CAT13092";
            categoria.Nome   = "Cozinha";
            return(categoria);
        }
Ejemplo n.º 3
0
 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!"));
            }
        }
Ejemplo n.º 5
0
 public ActionResult Delete(int id)
 {
     try
     {
         DTOCategoria categoria = db.DTOCategorias.Find(id);
         db.DTOCategorias.Remove(categoria);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
Ejemplo n.º 6
0
 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());
     }
 }
Ejemplo n.º 7
0
 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>());
        }
Ejemplo n.º 10
0
 public DTOAlberoCategorie(DTOCategoria dto)
 {
     ID          = dto.Identifier.ID.ToString();
     Descrizione = dto.Nome;
 }
Ejemplo n.º 11
0
 public void consultarCategoria(DTOCategoria categoria)
 {
 }
Ejemplo n.º 12
0
 public void registrarCategoria(DTOCategoria categoria)
 {
     Categoria categoria2 = new Categoria(categoria.Nombre);
 }