Example #1
0
        private void btSalvar_Click(object sender, EventArgs e)
        {
            try
            {
                //leitura de dados
                ModeloCategoria modelo = new ModeloCategoria();
                modelo.CatNome = txtNome.Text;
                // obj para gravar os dados no banco
                DALConexao   cx  = new DALConexao(DadosDaConexao.StringDeConexao);
                BLLCategoria bll = new BLLCategoria(cx);

                if (this.operacao == "inserir")
                {
                    //cadastrar uma categoria
                    bll.Incluir(modelo);
                    MessageBox.Show("Cadastro efetuado com sucesso! O código da categoria é: " + modelo.CatCod.ToString());
                }
                else
                {
                    //alterar uma categoria
                    modelo.CatCod = Convert.ToInt32(txtCodigo.Text);
                    bll.Alterar(modelo);
                    MessageBox.Show("Cadastro atualizado com sucesso!");
                }
                this.limpaTela();
                this.alteraBotoes(1);
            }
            catch (Exception erro)
            {
                MessageBox.Show(erro.Message);
            }
        }
        private void btSalvar_Click(object sender, EventArgs e)
        {
            try {
                ModeloCategoria categoria = new ModeloCategoria();
                categoria.CatNome = txtNome.Text;
                DALConexao   cx  = new DALConexao(DadosDaConexao.StringDaConexao);
                BLLCategoria bll = new BLLCategoria(cx);

                if (this.operacao.Equals("inserir"))
                {
                    bll.Incluir(categoria);
                    MessageBox.Show("Cadastro efetuado com sucesso. Codigo: " + categoria.CatCod.ToString());
                }
                else
                {
                    categoria.CatCod = Convert.ToInt32(txtCodigo.Text);
                    bll.Alterar(categoria);
                    MessageBox.Show("Alteração efetuada com sucesso.");
                }
                this.LimpaTela();
                this.alteraBotoes(1);
            } catch (Exception erro)
            {
                MessageBox.Show(erro.Message);
            }
        }
Example #3
0
        //Método do botão salvar (Método criado na camada DAL)
        private void btnSalvar_Click(object sender, EventArgs e)
        {
            try
            {
                /*Aqui eu chamei a classe MCategoria que está na camada Modelo. Caso eu não chamasse ela aqui, eu não iria conseguir acessar
                 * os atributos da classe. A classe está sendo instanciada pela varíavel modelo, que está guardando todos os atributos da
                 * classe.*/
                MCategoria modelo = new MCategoria(txtNome.Text);

                //Analisando se o usuário deseja atualizar ou salvar um novo registro
                if (btnSalvar.Text != "Atualizar")
                {
                    BLLCategoria.Incluir(modelo);
                    MessageBox.Show("Cadastro realizado com sucesso!");
                }
                else
                {
                    modelo.categoriaCod = Convert.ToInt32(txtCodigo.Text); //Pegando o ID
                    BLLCategoria.Alterar(modelo);
                    MessageBox.Show("Cadastro alterado com sucesso!");
                }
                LimpaTela();
            }

            /* A mensagem de erro já está perfeita. Com esse método ele já idenifica o tipo de erro que está causando e retorna
             * para o usuário. Só precisa apenas aprimorar. Colocar um ícone e etc.*/
            catch (Exception erro)
            {
                MessageBox.Show(erro.Message);
            }
        }
Example #4
0
        private void btSalvar_Click(object sender, EventArgs e)
        {
            try
            {
                //criar uma conexao
                ModeloCategoria modelo = new ModeloCategoria();
                modelo.CatNome = txtNome.Text;
                //objeto para gravar os dados do banco
                DALConexao   cx  = new DALConexao(DadosDaConexao.StringDeConexao);
                BLLCategoria BLL = new BLLCategoria(cx);

                if (Operacao == "inserir")
                {
                    BLL.Incluir(modelo);                        //CADASTRA NOVA CATEGORIA
                    MessageBox.Show("Cadastro efetuado : codigo " + modelo.CatCod.ToString());
                }
                else
                {
                    modelo.CatCod = Convert.ToInt32(txtCodigo.Text);    //ALTERA UMA CATEGORIA
                    BLL.Alterar(modelo);
                    MessageBox.Show("Cadastro alterado");
                }
                LimpaTela();
                AlterarBotoes(1);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Example #5
0
 private void btnSalvar_Click(object sender, EventArgs e)
 {
     try
     {
         //Leitura dos dados;
         ModeloCategoria modelo = new ModeloCategoria();
         modelo.catnome = txtNome.Text;
         //Objeto para gravar os dados no banco
         DALConexao   cx  = new DALConexao(DadosDaConexao.StringDeConexão);
         BLLCategoria bll = new BLLCategoria(cx);
         if (txtCodigo.Text == "")
         {
             //Cadastrar uma categoria
             bll.Incluir(modelo);
             Mensagem("CATEGORIA INSERIDA, CÓDIGO: " + modelo.cat_cod.ToString(), Color.Blue);
         }
         else
         {
             //Alterar uma categoria
             modelo.cat_cod = Convert.ToInt32(txtCodigo.Text);
             bll.Alterar(modelo);
             Mensagem("CATEGORIA ALTERADA ", Color.Blue);
         }
         LimpaTela();
         alteraBotoes();
     }
     catch (Exception erro)
     {
         Erro(erro.Message);
     }
 }
Example #6
0
        private void btnSalvar_Click(object sender, EventArgs e)
        {
            try
            {
                ModeloCategoria modelo = new ModeloCategoria();
                modelo.Cat_nome = txtNome.Text;
                DALConexao   cx  = new DALConexao(DadosDaConexao.StringDeConexao);
                BLLCategoria bll = new BLLCategoria(cx);

                if (this.operacao == "inserir")
                {
                    bll.Incluir(modelo);
                    MessageBox.Show("Cadastro Realizado. Código: " + modelo.Cat_cod.ToString());
                }
                else
                {
                    modelo.Cat_cod = Convert.ToInt32(txtCodigo.Text);
                    bll.Alterar(modelo);
                    MessageBox.Show("Cadastro Alterado.");
                }
                this.LimpaTela();
                this.alteraBotoes(1);
            }
            catch (Exception erro)
            {
                MessageBox.Show(erro.Message);
            }
        }
        private void btnSalvar_Click(object sender, EventArgs e)
        {
            try
            {
                ModeloCategoria m = new ModeloCategoria();
                m.NomeCategoria = txtDescricao.Text;

                DALConexao con = new DALConexao(DadosConexao.StringConexao);

                BLLCategoria c = new BLLCategoria(con);

                if (this.operacao == "INSERIR") //Cadastro
                {
                    c.Incluir(m);

                    MessageBox.Show("Cadastro efetuado com sucesso: Código " + m.CodCategoria.ToString());
                }
                else //Alterar
                {
                    m.CodCategoria = Convert.ToInt32(txtCodigo.Text);

                    c.Alterar(m);

                    MessageBox.Show("Cadastro alterado com sucesso.");
                }

                this.LimparCampos();

                this.AlteraBotoes(1);
            }
            catch (Exception erro)
            {
                MessageBox.Show("Erro: " + erro.Message);
            }
        }
        private void btnSalvar_Click(object sender, EventArgs e)
        {
            try
            {
                //leitura dos dados da tela
                ModeloCategoria modeloCategoria = new ModeloCategoria();
                modeloCategoria.CatNome = txtNome.Text;

                //obj para gravar os dados no banco
                DALConexao   cnx          = new DALConexao(DadosDaConexao.StringDeConexao);
                BLLCategoria bllCategoria = new BLLCategoria(cnx);

                if (this.operacao == "Inserir")
                {
                    //cadastrar uma categoria
                    bllCategoria.Incluir(modeloCategoria);
                    MessageBox.Show("Cadastro efetuado, Codigo" + modeloCategoria.CatCod.ToString());
                }
                else
                {
                    //Alterar uma categoria
                    modeloCategoria.CatCod = Convert.ToInt32(txtCodigo.Text);
                    bllCategoria.Alterar(modeloCategoria);
                    MessageBox.Show("Cadastro alterado");
                }
                this.LimpaTela();
                this.alteraBotoes(1);
            }
            catch (Exception erro)
            {
                MessageBox.Show(erro.Message);
            }
        }
Example #9
0
        private void btSalvar_Click(object sender, EventArgs e)
        {
            try
            {
                //Leitura dos  na tela
                ModeloCategoria modelo = new ModeloCategoria();
                modelo.CatNome = txtNome.Text;

                //Objeto para grvar os dado no banco de dados
                DALConexao   cx  = new DALConexao(DadosDaConexao.StringDeConexao);
                BLLCategoria bll = new BLLCategoria(cx);

                if (this.operacao == "inserir")
                {
                    //Cadastrar uma categoria
                    bll.Incluir(modelo);
                    MessageBox.Show("Cadastro efetuado: Codigo " + modelo.CatCod.ToString());
                }
                else
                {
                    //Alterar uma categoria
                    modelo.CatCod = Convert.ToInt32(txtCodigo);
                    bll.Alterar(modelo);
                    MessageBox.Show("Cadastro alterado");
                }
                this.LimpaTela();
                this.alteraBotes(1);
            }

            catch (Exception erro)
            {
                MessageBox.Show(erro.Message);
            }
        }
 private void btnSalvar_Click(object sender, EventArgs e)
 {
     try
     {
         ModeloCategoria modelo = new ModeloCategoria();
         modelo.Cat_nome = txtCategoria.Text;
         DALConexao   dao       = new DALConexao(DadosDaConexao.StringDeConexao);
         BLLCategoria categoria = new BLLCategoria(dao);
         if (this.operacao == "inserir")
         {
             //cadastrar
             categoria.Incluir(modelo);
             MetroFramework.MetroMessageBox.Show(this, "Cadastrado com sucesso! ", "OK", MessageBoxButtons.OK, MessageBoxIcon.Information);
             this.limparTela();
             this.alterarBotoes(1);
         }
         else
         {
             //alterar
             modelo.Cat_cod = Convert.ToInt32(txtCodigo.Text);
             categoria.Alterar(modelo);
             MetroFramework.MetroMessageBox.Show(this, "Editado com sucesso! ", "OK", MessageBoxButtons.OK, MessageBoxIcon.Information);
             this.limparTela();
             this.alterarBotoes(1);
         }
     }
     catch (Exception ex)
     {
         MetroFramework.MetroMessageBox.Show(this, "Ops Ocorreu algum erro! " + ex.Message, "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Example #11
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();
                }
            }
        }
 private void btnInserirCategoria_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("Confirma inclusão de categoria?", "Incluir Categoria", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
     {
         ModeloCategoria modelo = new ModeloCategoria();
         modelo.CatNome = inputInserirCategoria.Text;
         DALConexao   cx  = new DALConexao(DadosdaConexao.StringDeConexao);
         BLLCategoria bll = new BLLCategoria(cx);
         bll.Incluir(modelo);
         inputInserirCategoria.Text   = String.Empty;
         gridViewCategoria.DataSource = bll.Localizar(inputInserirCategoria.Text);
         MessageBox.Show("Cadastro efetuado!");
     }
     else
     {
         MessageBox.Show("Categoria não incluida!", "Incluir Categoria", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Example #13
0
        private void btnSalvar_Click(object sender, EventArgs e)
        {
            var cat    = new Categoria();
            var BLLCat = new BLLCategoria();

            if (txtDescricao.Text != "" && BLLCat.selecionarIDCategoria(txtDescricao.Text) == 0)
            {
                cat.descricao = txtDescricao.Text;

                BLLCat.Incluir(cat);
                txtDescricao.Text         = "";
                cbCategoria.DataSource    = BLLProduto.selecionarcategoria("");
                cbCategoria.ValueMember   = "id";
                cbCategoria.DisplayMember = "descricao";
                MessageBox.Show("Salvo com sucesso !");
            }
            else
            {
                MessageBox.Show("Informe algum nome ! Lembre-se, não pode ser um que já existe!");
            }
        }
        private void btnSalvar_Click(object sender, EventArgs e)
        {
            try
            {
                ModeloCategoria modelo = new ModeloCategoria();
                modelo.Descricao = txtDescricao.Text;
                modelo.Data      = dtpData.Value;

                if (chkAtiva.Checked)
                {
                    modelo.Ativa = "S";
                }
                else
                {
                    modelo.Ativa = "N";
                }

                DALConexao   cx  = new DALConexao(DadosConexao.StringConexao);
                BLLCategoria bll = new BLLCategoria(cx);

                if (this.operacao == "Inserir")
                {
                    bll.Incluir(modelo);
                    MessageBox.Show("Categoria '" + txtDescricao.Text + "' cadastrada com sucesso! Código: " + modelo.Categoria.ToString());
                }
                else
                {
                    modelo.Categoria = Convert.ToInt32(txtSequencia.Text);
                    bll.Alterar(modelo);
                    MessageBox.Show("Categoria '" + txtDescricao.Text + "' alterada com sucesso!");
                }
                this.LimpaTela();
                this.alteraBotoes(1);
                this.alteraCampos("False");
            }
            catch (Exception erro)
            {
                MessageBox.Show(erro.Message);
            }
        }
        //===============================================================================================================================
        private void btSalvar_Click(object sender, EventArgs e) //vai servir tanto para alterar quanto para gravar uma alteração
        {
            try                                                 //tratamento de erro
            {
                //leitura dos dados
                ModeloCategoria modelo = new ModeloCategoria(); //cria uma objeto que representa os dados da tabela catagoria

                modelo.CatNome = txtNome.Text;                  // passar o valor do campo nome para a proriedade CatNome

                //obj para gravar os dados no banco
                DALConexao cx = new DALConexao(DadosDaConexao.StringDeConexao);//Recebe a string da conexão da classe DadosDaConexão

                //bll possui os metodos para incluir e alterar
                BLLCategoria bll = new BLLCategoria(cx);//passa a string de conexao

                //verificar qual o tipo de operação que vai executar ao gravar
                if (this.operacao == "inserir")//valida se é um inserção, verificar o valro da variavel operação
                {
                    //cadastrar uma categoria
                    bll.Incluir(modelo);                                                      //passa o nome para o metodo incluir
                    MessageBox.Show("Cadastro efetuado: Código " + modelo.CatCod.ToString()); //retorna a mensagem como o codigo do item que foi gerado
                }
                else
                {
                    //alterar uma categoria
                    modelo.CatCod = Convert.ToInt32(txtCodigo.Text); //alterar a categoria correspondente ao codigo exixtente na tela
                    bll.Alterar(modelo);                             //alterar conforme codigo da tela
                    MessageBox.Show("Cadastro alterado");            //mostrar mensagem de confirmação
                }

                //em ambos os casos:
                this.LimpaTela();              // limpar a tela
                this.alteraBotoes(1);          //volta os botoes para o estado padrão
            }
            catch (Exception erro)             // caos der algum erro...(não limpa a tela)
            {
                MessageBox.Show(erro.Message); //retorna mensagem do sistema, melhorar mensagem para o usuario
            }
        }
Example #16
0
 //-------------------------------------------------------------------------------------------------------------------
 private void btSalvar_Click(object sender, EventArgs e)
 {
     try
     {
         BLLCategoria    bll    = new BLLCategoria();
         ModeloCategoria modelo = new ModeloCategoria();
         modelo.cat_nome = txtCategoria.Text;
         if (this.operacao == "inserir")
         {
             bll.Incluir(modelo);
             MessageBox.Show("Cadastro inserido com código: " + modelo.cat_cod, "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         else
         {
             modelo.cat_cod = Convert.ToInt32(txtCodigo.Text);
             bll.Alterar(modelo);
             MessageBox.Show("Cadastro alterado", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         this.limpaTela();
         this.alteraBotoes(1);
     }
     catch (Exception error) { MessageBox.Show(error.Message); }
 }