// Botão Salvar
        private void btSalvar_Click(object sender, EventArgs e)
        {
           try
           {            
              // Leitura dos dados nos campos
              ModeloCategoria modelo = new ModeloCategoria();
              modelo.CatNome = txtNome.Text;

              // Objeto para conexão e gravação 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: Código " + modelo.CatCod.ToString());
              }
              else
              {
                // Alterar uma categoria
                modelo.CatCod = 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 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 btSalvar_Click(object sender, EventArgs e)
        {
            try {

                ModeloCategoria modelo = new ModeloCategoria();
                txtNome.Text = txtNome.Text.ToUpper();
                modelo.CatNome = txtNome.Text;
                DALConexao cx = new DALConexao(DadosDaConexao.srtConexao);
                BLLCategoria bll = new BLLCategoria(cx);

                if (operacao == "inserir")
                {
                    //cadastrar categoria
                    bll.Incluir(modelo);
                    Ferramentas.MessageBoxHelper.PrepToCenterMessageBoxOnForm(this);
                    MessageBox.Show("Cadastro efetuado -  Código " + modelo.CatCod.ToString(),"Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    // alterar categoria
                    modelo.CatCod = Convert.ToInt32(txtCodigo.Text);
                    bll.Alterar(modelo);
                    Ferramentas.MessageBoxHelper.PrepToCenterMessageBoxOnForm(this);
                    MessageBox.Show("Cadastro Alterado", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                this.LimpaCampos();
                this.AlteraBotoes(1);
            }
            catch(Exception erro)
            {
                Ferramentas.MessageBoxHelper.PrepToCenterMessageBoxOnForm(this);
                MessageBox.Show(erro.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
 public void frmListaCategoria_Load(object sender, EventArgs e)
 {
     DALConexao cx = new DALConexao(DadosConexao.StringDeConexao);
     BLLCategoria bll = new BLLCategoria(cx);
     cboCategoria.DataSource = bll.Localizar("");//trás todos os dados
     cboCategoria.DisplayMember = "cat_nome";// valor que aparece
     cboCategoria.ValueMember = "cat_cod";//valor que vai ser passado
 }
 private void frmCadastroSubCategoria_Load(object sender, EventArgs e)
 {
     this.alteraBotoes(1);
     DALConexao cx = new DALConexao(DadosDaConexao.StringDeConexao);
     BLLCategoria bll = new BLLCategoria(cx);
     cbCatCod.DataSource = bll.Localizar(""); // Carrega no ComboBox os valores da Categoria
     cbCatCod.DisplayMember = "cat_nome"; 
     cbCatCod.ValueMember = "cat_cod";
 }
        private void btPesquisar_Click(object sender, EventArgs e)
        {
            DALConexao cx = new DALConexao(DadosDaConexao.srtConexao);
            BLLCategoria bll = new BLLCategoria(cx);

            dgvDados.DataSource = bll.Localizar(txtValor.Text);


        }
        private void CarregarCategoria(string dados)
        {
            // Objeto conexão
            DALConexao con = new DALConexao(DadosConexao.StringConexao);

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

            dgvDadosCategoria.DataSource = c.Localizar(dados);
        }
Exemple #8
0
        public void Incluir(ModeloCategoria modelo)
        {
            if (modelo.CatNome.Trim().Length == 0)
            {
                throw new Exception("O nome da categoria é obrigatorio!");
                //modelo.CatNome = modelo.CatNome.ToUpper();
            }
            BLLCategoria DALobj = new BLLCategoria(conexao);

            DALobj.Incluir(modelo);
        }
 private void frmCadastroSubCategoria_Load(object sender, EventArgs e)
 {
     Ferramentas.CloseButtonDisabler.FormCloseButtonDisabler.DisableCloseButton(this.Handle.ToInt32());
     this.AlteraBotoes(1);
     DALConexao cx = new DALConexao(DadosDaConexao.srtConexao);
     BLLCategoria bll = new BLLCategoria(cx);
     cbCatCod.DataSource = bll.Localizar("");
     cbCatCod.DisplayMember = "cat_nome";
     cbCatCod.ValueMember = "cat_cod";
     txtSnome.Focus();
 }
Exemple #10
0
        public void Alterar(ModeloCategoria modelo)
        {
            if (modelo.CatCod <= 0)
            {
                throw new Exception("O código da categoria é obrigatorio!");
            }
            if (modelo.CatNome.Trim().Length == 0)
            {
                throw new Exception("O nome da categoria é obrigatorio!");
            }
            BLLCategoria DALobj = new BLLCategoria(conexao);

            DALobj.Alterar(modelo);
        }
Exemple #11
0
        private void preencherCategoria()
        {
            try
            {
                var b = new BLL.BLLCategoria();

                ddlCategoria.DataSource     = b.ListarPais(IdCategoria);
                ddlCategoria.DataTextField  = "Categoria1";
                ddlCategoria.DataValueField = "IdCategoria";
                ddlCategoria.DataBind();


                ddlCategoria.Items.Insert(0, "Selecione");
            }
            catch (Exception)
            {
                throw;
            }
        }
 private void btnExcluir_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(DadosDaConexao.StringDeConexao);
             BLLCategoria bll = new BLLCategoria(cx);
             bll.Excluir(Convert.ToInt32(txtCodigo.Text));
             this.LimpaTela();
             this.alterarBotoes(1);
         }
     }catch
     {
         MessageBox.Show("Impossível excluir o registro. \n O Registro Está sendo Utilizado em outro Local.");
         this.alterarBotoes(3);
     }
 }
 private void btLocalizar_Click(object sender, EventArgs e)
 {
     frmConsultaCategoria f = new frmConsultaCategoria();
     f.ShowDialog();
     if (f.codigo != 0)
     {
         DALConexao cx = new DALConexao(DadosDaConexao.StringDeConexao);
         BLLCategoria bll = new BLLCategoria(cx);
         ModeloCategoria modelo = bll.CarregaModeloCategoria(f.codigo);
         txtCodigo.Text = modelo.CatCod.ToString();
         txtNome.Text = modelo.CatNome;
         alteraBotoes(3);
     }
     else
     {
         this.LimpaTela();
         this.alteraBotoes(1);
     }
     f.Dispose();
 }
        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();

        }
        public void btSalvar_Click(object sender, EventArgs e)
        {
            try
            {
                //leitura dos dados
                ModeloCategoria modelo = new ModeloCategoria();
                modelo.CatNome = txtNome.Text;

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

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

                }
                else
                {
                    //alterar uma categoria
                    modelo.CatCod = Convert.ToInt32(txtCodigo.Text);
                    bll.Alterar(modelo);
                    MessageBox.Show("Cadastro alterado");
                }
                this.LimpaTela();
                this.alteraBotoes(1);
            }
               catch (SqlException)
            {
                MessageBox.Show("A categoria " + txtNome.Text + " já está cadastrada", "Verifique!");
            }
               catch (Exception erro)
               {
               MessageBox.Show(erro.Message);
               }
        }
 // Botão Localizar
 private void LocalizarButton_Click(object sender, EventArgs e)
 {
     DALConexao cx = new DALConexao(DadosDaConexao.StringDeConexao);
     BLLCategoria bll = new BLLCategoria(cx);
     DadosDataGridView.DataSource = bll.Localizar(ValorTextBox.Text);
 }
Exemple #17
0
        public DataTable Localizar(String valor)
        {
            BLLCategoria DALobj = new BLLCategoria(conexao);

            return(DALobj.Localizar(valor));
        }
Exemple #18
0
        public ModeloCategoria CarregaModeloCategoria(int codigo)
        {
            BLLCategoria DALobj = new BLLCategoria(conexao);

            return(DALobj.CarregaModeloCategoria(codigo));
        }
        private void frmCadastroSubCategoria_Load(object sender, EventArgs e)
        {
            this.AlteraBotoes(1);

            DALConexao con = new DALConexao(DadosConexao.StringConexao);
            BLLCategoria c = new BLLCategoria(con);

            cbCategoria.DataSource = c.Localizar("");
            cbCategoria.DisplayMember = "Nome";
            cbCategoria.ValueMember = "Categoria";
        }
 private void txtValor_TextChanged(object sender, EventArgs e)
 {
     DALConexao cx = new DALConexao(DadosConexao.StringDeConexao);
     BLLCategoria bll = new BLLCategoria(cx);
     dgvDados.DataSource = bll.Localizar(txtValor.Text);
 }
        private void frmCadastroSubCategoria_Load(object sender, EventArgs e)
        {
            this.alteraBotoes(1);

            DALConexao cx = new DALConexao(DadosConexao.StringDeConexao);
            BLLCategoria bll = new BLLCategoria(cx);
            cbxCategoria.DataSource = bll.Localizar("");//trás todos os dados
            cbxCategoria.DisplayMember = "cat_nome";// valor que aparece
            cbxCategoria.ValueMember = "cat_cod";//valor que vai ser passado
        }
        private void btnAddCat_Click(object sender, EventArgs e)
        {
            frmCadastroCategoria f = new frmCadastroCategoria();
            f.ShowDialog();
            f.Dispose();

            DALConexao cx = new DALConexao(DadosConexao.StringDeConexao);
            BLLCategoria bll = new BLLCategoria(cx);
            cbCategoria.DataSource = bll.Localizar("");
            cbCategoria.DisplayMember = "cat_nome";
            cbCategoria.ValueMember = "cat_cod";
            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");
            }
        }
        private void btAdd_Click(object sender, EventArgs e)
        {
            frmCadastroCategoria cat = new frmCadastroCategoria();
            cat.ShowDialog();
            cat.Dispose();
            DALConexao cx = new DALConexao(DadosDaConexao.srtConexao);
            BLLCategoria bll = new BLLCategoria(cx);
            cbCatCod.DataSource = bll.Localizar("");
            cbCatCod.DisplayMember = "cat_nome";
            cbCatCod.ValueMember = "cat_cod";

        }
Exemple #24
0
        private Anuncio LimparDadosNaoValidos(Anuncio entity)
        {
            var       bllCat = new BLLCategoria(_context);
            Categoria cat    = bllCat.SelectByKey(entity.Categoria_ID);
            Categoria catAux = cat;

            while (catAux != null)
            {
                catAux.QuantidadeAnuncios += 1;

                catAux = catAux.Categoria2;
            }


            if (!cat.usaCor)
            {
                entity.C_Cor = null;
            }

            if (!cat.usaDisponibilidade)
            {
                entity.C_Disponibilidade = null;
            }

            if (!cat.usaGarantia)
            {
                entity.C_Garantia = null;
            }


            if (!cat.usaVeiculo)
            {
                entity.C_Veiculo_Acessorios     = null;
                entity.C_Veiculo_Ano_Fabricacao = null;
                entity.C_Veiculo_Ano_Modelo     = null;
                entity.C_Veiculo_Combustivel_ID = null;
                entity.C_Veiculo_Cor_ID         = null;
            }

            if (!cat.usaImovel)
            {
                entity.C_Imovel_Area_Terreno = null;
                entity.C_Imovel_Area_Util    = null;
                entity.C_Imovel_IPTU         = null;
            }
            if (!cat.usaImovel || entity.C_Imovel_Idade == 0)
            {
                entity.C_Imovel_Idade = null;
            }


            if (!cat.usaImovel_Condominio)
            {
                entity.C_Imovel_Condominio_Administradora     = null;
                entity.C_Imovel_Condominio_Andar              = null;
                entity.C_Imovel_Condominio_Andares            = null;
                entity.C_Imovel_Condominio_Infraestrutura     = null;
                entity.C_Imovel_Condominio_Nome               = null;
                entity.C_Imovel_Condominio_Unidades_Por_Andar = null;
                entity.C_Imovel_Condominio_Valor              = null;
            }

            if (!cat.usaImovel_Garagem)
            {
                entity.C_Imovel_Vagas_Garagem = null;
            }

            if (!cat.usaImovel_Lazer)
            {
                entity.C_Imovel_Lazer = null;
            }

            if (!cat.usaImovel_Instalacoes)
            {
                entity.C_Imovel_Instalacoes = null;
            }

            if (!cat.usaImovel_Residencial)
            {
                entity.C_Imovel_Quartos = null;
                entity.C_Imovel_Suites  = null;
            }

            return(entity);
        }
Exemple #25
0
        public void Excluir(int codigo)
        {
            BLLCategoria DALobj = new BLLCategoria(conexao);

            DALobj.Excluir(codigo);
        }
        private void btnAdd_Click(object sender, EventArgs e)
        {
            frmCadastroCategoria f = new frmCadastroCategoria();
            f.ShowDialog();
            f.Dispose();

            DALConexao cx = new DALConexao(DadosConexao.StringDeConexao);
            BLLCategoria bll = new BLLCategoria(cx);
            cbxCategoria.DataSource = bll.Localizar("");//trás todos os dados
            cbxCategoria.DisplayMember = "cat_nome";// valor que aparece
            cbxCategoria.ValueMember = "cat_cod";//valor que vai ser passado
        }
 private void btExcluir_Click(object sender, EventArgs e)
 {
     try
     {
         Ferramentas.MessageBoxHelper.PrepToCenterMessageBoxOnForm(this);
         DialogResult res = MessageBox.Show("Deseja excluir esta categoria ?", "Aviso", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
         if (res.ToString() == "Yes")
         {
             DALConexao cx = new DALConexao(DadosDaConexao.srtConexao);
             BLLCategoria bll = new BLLCategoria(cx);
             bll.Excluir(Convert.ToInt32(txtCodigo.Text));
             Ferramentas.MessageBoxHelper.PrepToCenterMessageBoxOnForm(this);
             MessageBox.Show("Registro excluido com sucesso", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);
             this.LimpaCampos();
             this.AlteraBotoes(1);
         }
     }
     catch(Exception erro)
     {
         Ferramentas.MessageBoxHelper.PrepToCenterMessageBoxOnForm(this);
         MessageBox.Show("Impossivel excluir este registro \n O Registro está sendo utilizado \n" + erro.Message,"Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
         AlteraBotoes(3);
     }
 }
        private void btAddCat_Click(object sender, EventArgs e)
        {
            frmCadastroCategoria cat = new frmCadastroCategoria();
            cat.ShowDialog();
            cat.Dispose();
            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;

        }