private void btBusca_Click(object sender, EventArgs e)
        {
            DALConexao     cx  = new DALConexao(DadosDaConexao.StringDeConexao);
            DLLFerramentas dll = new DLLFerramentas(cx);

            dgvDados.DataSource = dll.Localizar(txtNome.Text);
            label2.Visible      = true;
        }
Exemple #2
0
        private void btSalvar_Click(object sender, EventArgs e)
        {
            //Alterna imagens dos botões
            btSalvar.ImageIndex = 9;

            //o try é para tratamento de erros ao inserir objeto
            try
            {
                ModeloFerramentas modelo = new ModeloFerramentas();
                modelo.FerrNome   = txtferrnome.Text;
                modelo.FerrValor  = Convert.ToDouble(txtferrvalor.Text);
                modelo.FerrData   = DateTime.Now.ToShortDateString();
                modelo.FerrTime   = DateTime.Now.ToShortTimeString();
                modelo.FerrStatus = "local";

                //Obj para gravar os dados da conexão
                DALConexao     cx  = new DALConexao(DadosDaConexao.StringDeConexao);
                DLLFerramentas dll = new DLLFerramentas(cx);

                if (this.operacao == "inserir")
                {
                    //Cadastrar nova categoria
                    dll.Incluir(modelo);
                    MessageBox.Show("Cadastro realizado: Código " + modelo.FerrCod.ToString());
                    //toolStripBarStatus.Text = "Procedimento OK! Item " + modelo.FerrCod.ToString() + " cadastrado!";
                }
                else
                {
                    //Alterar Categoria
                    modelo.FerrCod = Convert.ToInt32(txtferrcod.Text);
                    dll.Alterar(modelo);
                    MessageBox.Show("Cadastro Alterado!");
                    //toolStripBarStatus.Text = "Procedimento OK! Item " + txtcodigo.Text + " alterado!";
                    label1.Visible = false;
                }
                //Limpa os campos do formulário
                this.LimpaTela();
                //Habilita botões
                this.alteraBotoes(1);
                //Habilita o fechamento da janela
                closeCadFerramentas = 0;
            }
            catch (Exception erro)
            {
                MessageBox.Show(erro.Message);
                //toolStripBarStatus.Text = "Erro! Cadastro não realizado!";
            }
            //Altera imagens dos botões
            btSalvar.ImageIndex    = 8;
            btInserir.ImageIndex   = 0;
            btLocalizar.ImageIndex = 2;
        }
Exemple #3
0
        private void btExcluir_Click(object sender, EventArgs e)
        {
            //Alterna imagens dos botões
            btExcluir.ImageIndex = 7;


            //o try é para tratamento de erros ao inserir objeto
            try
            {
                DialogResult d = MessageBox.Show("Tem certeza que deseja excluir o registro?", "Excluir?", MessageBoxButtons.YesNo);
                if (d.ToString() == "Yes")
                {
                    //MessageBox.Show("Excluindo o registro!");
                    //Exclui o registro
                    DALConexao     cx  = new DALConexao(DadosDaConexao.StringDeConexao);
                    DLLFerramentas dll = new DLLFerramentas(cx);
                    dll.Excluir(Convert.ToInt32(txtferrcod.Text));
                    //Limpa os campos
                    this.LimpaTela();
                    //Habilita os botões
                    this.alteraBotoes(1);
                    //Habilita o fechamento do User Control
                    closeCadFerramentas = 1;
                }
                else
                {
                    MessageBox.Show("Erro no valor passado!" + d.ToString());
                }
            }
            catch
            {
                MessageBox.Show("Impossível excluir o registro. \n O registro está sendo utilizado em outro local.");
                //Habilita botões
                this.alteraBotoes(3);
                //Habilita o fechamento do User Control
                closeCadFerramentas = 3;

                //FormPrincipal.toolStripBarStatus.Text = "ERRO! Impossível excluir o registro.";
            }
            //Altera imagens dos botões
            btExcluir.ImageIndex   = 6;
            btLocalizar.ImageIndex = 2;
        }
Exemple #4
0
        private void btLocalizar_Click(object sender, EventArgs e)
        {
            //Alterna imagens dos botões
            btLocalizar.ImageIndex = 3;

            //Abre o cadastro do item retornado nos campos
            frmConsultaFerramentas frmCFerr = new frmConsultaFerramentas();

            frmCFerr.ShowDialog();
            if (frmCFerr.codigo != 0)
            {
                DALConexao        cx     = new DALConexao(DadosDaConexao.StringDeConexao);
                DLLFerramentas    dll    = new DLLFerramentas(cx);
                ModeloFerramentas modelo = dll.CarregaModeloFerramentas(frmCFerr.codigo);
                txtferrcod.Text   = modelo.FerrCod.ToString();
                txtferrnome.Text  = modelo.FerrNome;
                txtferrvalor.Text = Convert.ToString(modelo.FerrValor);
                txtferrdata.Text  = modelo.FerrData;
                txtferrcod.Text   = Convert.ToString(modelo.FerrCod);
                label1.Visible    = true;
                this.alteraBotoes(3);
                if (txtferrvalor.Text.Contains(","))
                {
                    txtferrvalor.Text = txtferrvalor.Text.Replace(',', '.');
                }
            }
            else
            {
                //Limpa os campos
                this.LimpaTela();
                //Altera os botões
                this.alteraBotoes(1);
                //Altera se o controle pode ser fechado
                closeCadFerramentas = 1;
                //Altera Imagem do botão
                btLocalizar.ImageIndex = 2;
            }
            frmCFerr.Dispose();
        }