// Botão Salvar
        private void btSalvar_Click(object sender, EventArgs e)
        {            
            try
            {
                // Leitura dos dados nos campos
                ModeloSubCategoria modelo = new ModeloSubCategoria();
                modelo.ScatNome = txtNomeSubCategoria.Text;
                modelo.CatCod = Convert.ToInt32(cbCatCod.SelectedValue);

                // Objeto para conexão e gravação no banco
                DALConexao cx = new DALConexao(DadosDaConexao.StringDeConexao);
                BLLSubCategoria bll = new BLLSubCategoria(cx);

                if (this.operacao == "inserir")
                {
                    // Cadastrar uma categoria
                    bll.Incluir(modelo);
                    MessageBox.Show("Cadastro efetuado: Código " + modelo.ScatCod.ToString());
                }
                else
                {
                    // Alterar uma categoria
                    modelo.ScatCod = Convert.ToInt32(txtSubcatcod.Text);
                    bll.Alterar(modelo);
                    MessageBox.Show("Cadastro alterado");
                }
                this.LimpaTela();
                this.alteraBotoes(1);
            }
            catch (Exception erro)
            {
                MessageBox.Show(erro.Message);
            }
        }
        private void btnExcluir_Click(object sender, EventArgs e)
        {
            try
            {
                DialogResult mensagem = MessageBox.Show("Desaja excluir o registro?", "Aviso", MessageBoxButtons.YesNo);

                if (mensagem.ToString().Equals("Yes"))
                {
                    DALConexao con = new DALConexao(DadosConexao.StringConexao);

                    BLLSubCategoria sc = new BLLSubCategoria(con);

                    sc.Excluir(Convert.ToInt32(txtCodigoSubCategoria.Text));

                    this.LimparCampos();

                    this.AlteraBotoes(1);
                }
            }
            catch
            {
                MessageBox.Show("Erro ao excluir registro");

                this.AlteraBotoes(3);
            }
        }
        private void btSalvar_Click(object sender, EventArgs e)
        {
            try
            {

                ModeloSubCategoria modelo = new ModeloSubCategoria();
                modelo.SCatNome = txtSnome.Text;
                modelo.CatCod = Convert.ToInt32(cbCatCod.SelectedValue);
                DALConexao cx = new DALConexao(DadosDaConexao.srtConexao);
                BLLSubCategoria bll = new BLLSubCategoria(cx);

                if (operacao == "inserir")
                {
                    //cadastrar categoria
                    bll.Incluir(modelo);
                    Ferramentas.MessageBoxHelper.PrepToCenterMessageBoxOnForm(this);
                    MessageBox.Show("Cadastro efetuado -  Código " + modelo.SCatCod.ToString(), "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    // alterar categoria
                    modelo.SCatCod= Convert.ToInt32(txtSCatCod.Text);
                    bll.Alterar(modelo);
                    Ferramentas.MessageBoxHelper.PrepToCenterMessageBoxOnForm(this);
                    MessageBox.Show("Cadastro Alterado", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                this.LimpaTela();
                this.AlteraBotoes(1);
            }
            catch (Exception erro)
            {
                Ferramentas.MessageBoxHelper.PrepToCenterMessageBoxOnForm(this);
                MessageBox.Show(erro.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void btPesquisar_Click(object sender, EventArgs e)
        {
            DALConexao cx = new DALConexao(DadosDaConexao.srtConexao);
            BLLSubCategoria bll = new BLLSubCategoria(cx);

            dgvDados.DataSource = bll.Localizar(txtValor.Text);
        }
 private void frmCadastroProduto_Load(object sender, EventArgs e)
 {
     this.alterarBotoes(1);
     //ComboBox da Categoria
     DALConexao cx = new DALConexao(DadosDaConexao.StringDeConexao);
     BLLCategoria bll = new BLLCategoria(cx);
     cbCategoria.DataSource = bll.Localizar("");
     cbCategoria.DisplayMember = "cat_nome";
     cbCategoria.ValueMember = "cat_cod";
     try
     {
         //ComboBox da Subcategoria
         BLLSubCategoria sbll = new BLLSubCategoria(cx);
         cbSubCategoria.DataSource = sbll.LocalizarPorCategoria((int)cbCategoria.SelectedValue);
         cbSubCategoria.DisplayMember = "scat_nome";
         cbSubCategoria.ValueMember = "scat_cod";
     }
     catch
     {
         MessageBox.Show("Cadastre uma Categoria");
     }
     //ComboBox da Unidade de Medidas
     BLLUnidadeDeMedida ubll = new BLLUnidadeDeMedida(cx);
     cbUnd.DataSource = ubll.Localizar("");
     cbUnd.DisplayMember = "umed_nome";
     cbUnd.ValueMember = "umed_cod";
 }
        private void CarregarCategoria(string dados)
        {
            // Objeto conexão
            DALConexao con = new DALConexao(DadosConexao.StringConexao);

            //Objeto categoria regras e manipulação de dados
            BLLSubCategoria sc = new BLLSubCategoria(con);

            dgvDadosSubCategoria.DataSource = sc.Localizar(dados);
        }
        private void btExcluir_Click(object sender, EventArgs e)
        {
            try
            {
                DialogResult d = MessageBox.Show("Deseja excluir o registro?", "Aviso", MessageBoxButtons.YesNo);
                if (d.ToString() == "Yes")
                {
                    DALConexao cx = new DALConexao(DadosConexao.StringDeConexao);
                    BLLSubCategoria bll = new BLLSubCategoria(cx);
                    bll.Excluir(Convert.ToInt32(txtCodigo.Text));
                    this.LimpaTela();
                    this.alteraBotoes(1);
                }
            }
            catch
            {
                MessageBox.Show("Impossível excluir o registro.\n Pois o mesmo está sendo utilizado em outro local.");
                this.alteraBotoes(3);

            }
        }
Esempio n. 8
0
        private void frmCadastroDeProdutos_Load(object sender, EventArgs e)
        {
            Ferramentas.CloseButtonDisabler.FormCloseButtonDisabler.DisableCloseButton(this.Handle.ToInt32());
            AlteraBotoes(1);
            DALConexao cx = new DALConexao(DadosDaConexao.srtConexao);
            BLLCategoria bll = new BLLCategoria(cx);
            cbCategoria.DataSource = bll.Localizar("");
            cbCategoria.DisplayMember = "cat_nome";
            cbCategoria.ValueMember = "cat_cod";
            cbCategoria.AutoCompleteMode = AutoCompleteMode.Suggest;
            cbCategoria.AutoCompleteSource = AutoCompleteSource.ListItems;


            try
            {
                BLLSubCategoria sbll = new BLLSubCategoria(cx);
                cbSubCategoria.DataSource = sbll.LocalizarPorCategoria((int) cbCategoria.SelectedValue);
                cbSubCategoria.DisplayMember = "scat_nome";
                cbSubCategoria.ValueMember = "scat_cod";
                cbSubCategoria.AutoCompleteMode = AutoCompleteMode.Suggest;
                cbSubCategoria.AutoCompleteSource = AutoCompleteSource.ListItems;

            }
            catch
            {
               // MessageBox.Show("Cadastre uma Categoria");

            }


            BLLUnidadeDeMedida ubll = new BLLUnidadeDeMedida(cx);
            cbUnidadeMedida.DataSource = ubll.Localizar("");
            cbUnidadeMedida.DisplayMember = "umed_nome";
            cbUnidadeMedida.ValueMember = "umed_cod";
            cbUnidadeMedida.AutoCompleteMode = AutoCompleteMode.Suggest;
            cbUnidadeMedida.AutoCompleteSource = AutoCompleteSource.ListItems;

            txtNome.Focus();

        }
        private void btLocalizar_Click(object sender, EventArgs e)
        {
            frmConsultaSubcategoria f = new frmConsultaSubcategoria();
            f.ShowDialog();
            f.Dispose();

            if (f.codigo != 0)
            {
                DALConexao cx = new DALConexao(DadosConexao.StringDeConexao);
                BLLSubCategoria bll = new BLLSubCategoria(cx);
                ModeloSubCategoria modelo = bll.CarregaModeloSubCategoria(f.codigo);
                txtCodigo.Text = modelo.ScatCod.ToString();
                txtNome.Text = modelo.ScatNome;
                cbxCategoria.SelectedValue = modelo.CatCod;
                alteraBotoes(3);
            }
            else
            {
                this.LimpaTela();
                this.alteraBotoes(1);
            }
            f.Dispose();
        }
Esempio n. 10
0
 private void btLocalizar_Click(object sender, EventArgs e)
 {
     
     frmConsultaSubCategoria consulta = new frmConsultaSubCategoria();
     consulta.ShowDialog();
     if (consulta.Scodigo != 0)
     {
         DALConexao cx = new DALConexao(DadosDaConexao.srtConexao);
         BLLSubCategoria bll = new BLLSubCategoria(cx);
         ModeloSubCategoria modelo = bll.CarregaModeloSubCategoria(consulta.Scodigo);
         txtSCatCod.Text = modelo.SCatCod.ToString();
         txtSnome.Text = modelo.SCatNome;
         cbCatCod.SelectedValue = modelo.CatCod;
         AlteraBotoes(3);
     }
     else
     {
         this.LimpaTela();
         this.AlteraBotoes(1);
     }
     consulta.Dispose();
 }
        private void btnSalvar_Click(object sender, EventArgs e)
        {
            try
            {
                ModeloSubCategoria m = new ModeloSubCategoria();
                m.SubCategoriaNome = txtNomeSubCategoria.Text;
                m.FKCatCod = Convert.ToInt32(cbCategoria.SelectedValue);

                DALConexao con = new DALConexao(DadosConexao.StringConexao);

                BLLSubCategoria sc = new BLLSubCategoria(con);

                if (this.operacao.Equals("INSERIR"))
                {
                    sc.Incluir(m);

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

                    sc.Alterar(m);

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

                this.LimparCampos();

                this.AlteraBotoes(1);
            }
            catch (Exception erro)
            {
                MessageBox.Show("Erro: " + erro.Message);
            }
        }
 private void cbCategoria_SelectedIndexChanged(object sender, EventArgs e)
 {
     //combo da categoria
     DALConexao cx = new DALConexao(DadosDaConexao.StringDeConexao);
     try
     {
         cbSubCategoria.Text = "";
         //combo da subcategoria
         BLLSubCategoria sbll = new BLLSubCategoria(cx);
         cbSubCategoria.DataSource = sbll.LocalizarPorCategoria((int)cbCategoria.SelectedValue);
         cbSubCategoria.DisplayMember = "scat_nome";
         cbSubCategoria.ValueMember = "scat_cod";
     }
     catch
     {
         //MessageBox.Show("Cadastre uma categoria");
     }
 }
        private void btSalvar_Click(object sender, EventArgs e)
        {
            try
            {
                //leitura dos dados
                ModeloSubCategoria modelo = new ModeloSubCategoria();
                modelo.ScatNome = txtNome.Text;
                modelo.CatCod = Convert.ToInt32(cbxCategoria.SelectedValue);

                //obj para gravar os dados no banco
                DALConexao cx = new DALConexao(DadosConexao.StringDeConexao);
                BLLSubCategoria bll = new BLLSubCategoria(cx);

                if (this.operacao == "inserir")
                {
                    //cadastrar uma categoria
                    bll.Incluir(modelo);
                    MessageBox.Show("Cadastro efetuado: Código: " +modelo.ScatCod.ToString());

                }
                else
                {
                    //alterar uma Subcategoria
                    modelo.ScatCod = Convert.ToInt32(txtCodigo.Text);
                    bll.Alterar(modelo);
                    MessageBox.Show("Cadastro alterado");
                }
                this.LimpaTela();
                this.alteraBotoes(1);
            }
            catch (SqlException)
            {
                MessageBox.Show("A Subcategoria " + txtNome.Text + " já está cadastrada", "Verifique!");
            }
            catch (Exception erro)
            {
                MessageBox.Show(erro.Message);
            }
        }
Esempio n. 14
0
 private void btExcluir_Click(object sender, EventArgs e)
 {
     try
     {
         Ferramentas.MessageBoxHelper.PrepToCenterMessageBoxOnForm(this);
         DialogResult res = MessageBox.Show("Deseja excluir esta Subcategoria ?", "Aviso", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
         if (res.ToString() == "Yes")
         {
             DALConexao cx = new DALConexao(DadosDaConexao.srtConexao);
             BLLSubCategoria bll = new BLLSubCategoria(cx);
             bll.Excluir(Convert.ToInt32(txtSCatCod.Text));
             Ferramentas.MessageBoxHelper.PrepToCenterMessageBoxOnForm(this);
             MessageBox.Show("Registro excluido com sucesso", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);
             this.LimpaTela();
             this.AlteraBotoes(1);
         }
     }
     catch (Exception erro)
     {
         Ferramentas.MessageBoxHelper.PrepToCenterMessageBoxOnForm(this);
         MessageBox.Show("Impossivel excluir este registro \n O Registro está sendo utilizado \n\n" + erro.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
         AlteraBotoes(3);
     }
 }
        private void btnLocalizar_Click(object sender, EventArgs e)
        {
            frmConsultaSubCategoria tela = new frmConsultaSubCategoria();
            tela.ShowDialog();

            if (tela.codigo != 0)
            {
                DALConexao con = new DALConexao(DadosConexao.StringConexao);

                BLLSubCategoria sc = new BLLSubCategoria(con);

                ModeloSubCategoria m = sc.carregaSubCategoria(tela.codigo);

                txtCodigoSubCategoria.Text = m.CodSubCat.ToString();
                txtNomeSubCategoria.Text   = m.SubCategoriaNome;
                cbCategoria.SelectedValue  = m.FKCatCod;

                this.AlteraBotoes(3);
            }
            else
            {
                this.LimparCampos();

                this.AlteraBotoes(1);
            }

            tela.Dispose();
        }
 private void txtValor_TextChanged(object sender, EventArgs e)
 {
     DALConexao cx = new DALConexao(DadosConexao.StringDeConexao);
     BLLSubCategoria bll = new BLLSubCategoria(cx);
     dgvDados.DataSource = bll.Localizar(txtValor.Text);
 }
Esempio n. 17
0
        private void btAssSubCat_Click(object sender, EventArgs e)
        {
            frmCadastroSubCategoria sub = new frmCadastroSubCategoria();
            sub.ShowDialog();
            sub.Dispose();
            DALConexao cx = new DALConexao(DadosDaConexao.srtConexao);


            cbSubCategoria.Text = "";
            BLLSubCategoria sbll = new BLLSubCategoria(cx);
            cbSubCategoria.DataSource = sbll.LocalizarPorCategoria((int)cbCategoria.SelectedValue);
            cbSubCategoria.DisplayMember = "scat_nome";
            cbSubCategoria.ValueMember = "scat_cod";
            cbSubCategoria.AutoCompleteMode = AutoCompleteMode.Suggest;
            cbSubCategoria.AutoCompleteSource = AutoCompleteSource.ListItems;


        }
Esempio n. 18
0
        private void cbCategoria_SelectedIndexChanged(object sender, EventArgs e)
        {
           
            DALConexao cx = new DALConexao(DadosDaConexao.srtConexao);
        
            try
            {
                cbSubCategoria.Text = "";
                BLLSubCategoria sbll = new BLLSubCategoria(cx);
                cbSubCategoria.DataSource = sbll.LocalizarPorCategoria((int)cbCategoria.SelectedValue);
                cbSubCategoria.DisplayMember = "scat_nome";
                cbSubCategoria.ValueMember = "scat_cod";
                cbSubCategoria.AutoCompleteMode = AutoCompleteMode.Suggest;
                cbSubCategoria.AutoCompleteSource = AutoCompleteSource.ListItems;

            }
            catch
            {
                // MessageBox.Show("Cadastre uma Categoria");

            }
        }
 private void LocalizarButton_Click(object sender, EventArgs e)
 {
     DALConexao cx = new DALConexao(DadosDaConexao.StringDeConexao);
     BLLSubCategoria bll = new BLLSubCategoria(cx);
     DadosDataGridView.DataSource = bll.Localizar(ValorTextBox.Text);        
 }
Esempio n. 20
0
 private void btnAddSubCategoria_Click(object sender, EventArgs e)
 {
     frmCadastroSubCategoria f = new frmCadastroSubCategoria();
     f.ShowDialog();
     f.Dispose();
     DALConexao cx = new DALConexao(DadosConexao.StringDeConexao);
     try
     {
         //combo da subcategoria
         BLLSubCategoria sbll = new BLLSubCategoria(cx);
         cbSubCategoria.DataSource = sbll.LocalizarPorCategoria((int)cbCategoria.SelectedValue);
         cbSubCategoria.DisplayMember = "scat_nome";
         cbSubCategoria.ValueMember = "scat_cod";
     }
     catch
     {
         //MessageBox.Show("Cadastre uma categoria");
     }
 }