public void Alterar(ModeloCategoria modelo)
        {
            if (modelo.Categoria < 0)
            {
                throw new Exception("O código da categoria é obrigatório!");
            }

            if (modelo.Descricao.Trim().Length == 0)
            {
                throw new Exception("A descrição da categoria é obrigatória!");
            }

            DALCategoria DALobj = new DALCategoria(conexao);

            DALobj.Alterar(modelo);
        }
        public void Alterar(ModeloCategoria modelo)
        {
            if (modelo.CatCod <= 0)
            {
                throw new Exception("O código da categoria é obrigatório");
            }
            if (modelo.CatNome.Trim().Length == 0)
            {
                throw new Exception("O nome da categoria é obrigatório");
            }
            //modelo.CatNome = modelo.CatNome.ToUpper();

            DALCategoria DALobj = new DALCategoria(conexao);

            DALobj.Alterar(modelo);
        }
Example #3
0
        //==============================================================================================================================
        //Metodo para incluir uma categoria =================================================================== aula 05
        public void Incluir(ModeloCategoria modelo)//modelo = coleta as informações da tela
        {
            //Validação se o nome esta preenchido, campo nome nao pode ser vazio, a propriedade nome nao pode ser vazia
            if (modelo.CatNome.Trim().Length == 0)                        //se o tamanho do texto for igual a zero ...
            {
                throw new Exception("O nome da categoria é obrigatório"); // cria uma exceção, e retornar a mensagem obrigando
            }

            //formatar o texto para maiusculo:
            modelo.CatNome = modelo.CatNome.ToUpper();

            //cria um objeto, e informa a conexão
            DALCategoria DALobj = new DALCategoria(conexao);

            //manda gravar no banco as informações coletadas na tela
            DALobj.Incluir(modelo);//usa o metodo incluir
        }
Example #4
0
        public void Alterar(ModeloCategoria modelo)
        {
            if (modelo.Cat_cod <= 0)
            {
                throw new Exception("O código da Categoria é Obrigatório!");
            }
            if (modelo.Cat_nome.Trim().Length == 0)
            {
                throw new Exception("O nomde da Categoria é Obrigatório!");
            }

            modelo.Cat_nome = modelo.Cat_nome.ToUpper();

            DALCategoria DAOObj = new DALCategoria(conexao);

            DAOObj.Alterar(modelo);
        }
        public void Alterar(ModeloCategoria categoria)
        {
            if (categoria.CatCod <= 0)
            {
                throw new Exception("Um codigo deve ser informado");
            }

            if (categoria.CatNome.Trim().Length == 0)
            {
                throw new Exception("O nome da categoria deve ser preenchido.");
            }

            categoria.CatNome = categoria.CatNome.ToUpper();

            DALCategoria DALobj = new DALCategoria(conexao);

            DALobj.Alterar(categoria);
        }
Example #6
0
        public void Alterar(ModeloCategoria modelo)
        {
            //Verifica se o código foi alterado
            if (modelo.CatCod <= 0)
            {
                throw new Exception("O código da categoria é obrigatório para alterar o registro!");
            }
            //verificando se o nome da categoria foi digitado
            if (modelo.CatNome.Trim().Length == 0)
            {
                throw new Exception("O nome da categoria é obrigatório!");
            }
            //Comando coloca o nome sempre em maiúsculo
            modelo.CatNome = modelo.CatNome.ToUpper();

            DALCategoria DALobj = new DALCategoria(conexao);

            DALobj.Alterar(modelo);
        }
Example #7
0
        public List <Fila> AtendenteDisponivel()
        {
            StringBuilder strSQL = new StringBuilder();
            List <Fila>   ListaAtendenteDisponivel = new List <Fila>();

            strSQL.Append("select top 1");
            strSQL.Append(" id_atendente");
            strSQL.Append(", nome ");
            strSQL.Append(", status_atendente ");
            strSQL.Append("from tb_atendente ");
            strSQL.Append("where status_atendente = 2 ");

            DALConexao   cx  = new DALConexao(Conexao.StringDeConexao);
            DALCategoria bll = new DALCategoria(cx);

            ListaAtendenteDisponivel = bll.AtendenteDisponivel(strSQL.ToString());

            return(ListaAtendenteDisponivel);
        }
Example #8
0
 public string ExcluirCategoria(ModCatergoria md, int tam, string valida)
 {
     if (tam == 0)
     {
         return("Registro deve ser diferente de vazio !");
     }
     else
     {
         if (md.Categoria == valida)
         {
             DALCategoria cat = new DALCategoria(conexao);
             return(cat.Excluir(md));
         }
         else
         {
             return("O nome do Registro não pode ser alterado !");
         }
     }
 }
Example #9
0
        public void ListarStatusAtendente()
        {
            StringBuilder strSQL = new StringBuilder();

            strSQL.Append("SELECT  a.id_atendente ");
            strSQL.Append(",a.nome ");
            strSQL.Append(",a.status_atendente ");
            strSQL.Append(",b.descricao ");
            strSQL.Append("FROM tb_atendente as a ");
            strSQL.Append("INNER JOIN tb_status_atendente as b ");
            strSQL.Append("on a.status_atendente = b.id_status;");

            DALConexao       cx             = new DALConexao(Conexao.StringDeConexao);
            DALCategoria     bll            = new DALCategoria(cx);
            List <Atendente> ListaAtendente = new List <Atendente>();

            ListaAtendente = bll.ListarStatusAtendente(strSQL.ToString());
            StatusDoAtende(ListaAtendente);
        }
Example #10
0
 protected void gvDadosCat_SelectedIndexChanged(object sender, EventArgs e)
 {
     try
     {
         int          i   = gvDadosCat.SelectedIndex;
         int          cod = Convert.ToInt32(gvDadosCat.Rows[i].Cells[0].Text);
         DALCategoria cat = new DALCategoria();
         Categoria    c   = cat.GetRegistro(cod);
         if (c.Id != 0)
         {
             txtCateg.Text  = c.Nome;
             txtId.Text     = c.Id.ToString();
             btnSalvar.Text = "Alterar";
         }
     }
     catch (Exception error)
     {
         throw new Exception(error.Message);
     }
 }
 public void Excluir(int codigo)
 {
     if (codigo <= 0)
     {
         aviso("Não há categoria selecionada"); return;
     }
     else
     {
         try
         {
             DALCategoria dalCategoria = new DALCategoria(conexao);
             dalCategoria.Excluir(codigo);
             aviso("Operação realizada com sucesso!!!");
         }
         catch (Exception)
         {
             throw;
         }
     }
 }
Example #12
0
 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(DadosDaConexao.StringDeConexao);
             DALCategoria bll = new DALCategoria(cx);
             bll.Excluir(Convert.ToInt32(txtCodigo.Text));
             this.LimpaTela();
             this.alteraBotoes(1);
         }
     }
     catch
     {
         MessageBox.Show("Impossível excluir o registro. \n O registro esta sendo utilizado em outro local.");
         this.alteraBotoes(3);
     }
 }
 public void Incluir(ModeloCategoria modelo)
 {
     if (String.IsNullOrEmpty(modelo.cat_nome))
     {
         aviso("O nome da categoria é obrigatório"); return;
     }
     else
     {
         try
         {
             DALCategoria dalCategoria = new DALCategoria(conexao);
             dalCategoria.Incluir(modelo);
             aviso("Operação realizada com sucesso!!!");
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message.ToString(), "Ops. Parece que algo deu errado"); return;
         }
     }
 }
Example #14
0
        private void btLocalizar_Click(object sender, EventArgs e)
        {
            frmConsultaCategoria f = new frmConsultaCategoria();

            f.ShowDialog();
            if (f.codigo != 0)
            {
                DALConexao      cx     = new DALConexao(DadosDaConexao.StringDeConexao);
                DALCategoria    bll    = new DALCategoria(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();
        }
Example #15
0
        //==============================================================================================================================
        //Metodo para alterar uma categoria =================================================================== aula 05
        public void Alterar(ModeloCategoria modelo)
        {
            //Validação: verificar se o codigo informado é menor ou igual a zero,
            if (modelo.CatCod <= 0)//verifica se o usuário informou o codigo
            {
                throw new Exception("O código da categoria é obrigatório");
            }
            //Validação: verifica se foi informado um nome para a catagoria
            if (modelo.CatNome.Trim().Length == 0)
            {
                throw new Exception("O nome da categoria é obrigatório");
            }

            //formatar o texto para maiusculo:
            modelo.CatNome = modelo.CatNome.ToUpper();

            //cria um objeto, e informa a conexão
            DALCategoria DALobj = new DALCategoria(conexao);

            //manda Alterar no banco conforme as informações coletadas na tela
            DALobj.Alterar(modelo);
        }
Example #16
0
        private void btnSalvarMarca_Click(object sender, EventArgs e)
        {
            Marcas     m          = new Marcas();
            BLLProduto objProduto = new BLLProduto();
            var        BLLCat     = new BLLCategoria();

            if (txtNomeMarca.Text != "" && DALCategoria.SelecionarCodMarca(txtNomeMarca.Text) == 0)
            {
                m.nome = txtNomeMarca.Text;
                objProduto.IncluirMarca(m);
                txtNomeMarca.Text     = "";
                cbMarca.DataSource    = BLLProduto.ListarMarca();
                cbMarca.ValueMember   = "id";
                cbMarca.DisplayMember = "nome";
                MessageBox.Show("Salvo com sucesso !");
                txtNomeMarca.Focus();
            }
            else
            {
                MessageBox.Show("Informe algum nome ! Lembre-se, não pode ser um que já existe!");
            }
        }
Example #17
0
        private void FrmProduto_Load(object sender, EventArgs e)
        {
            marc = new DALMarca(cn);
            tBoxProduto.Focus();
            cBoxMarca.DataSource    = marc.GetMarca();
            cBoxMarca.ValueMember   = "ID_Marca";
            cBoxMarca.DisplayMember = "Marca";
            //cBoxMarca.SelectedIndex = 1;
            cBoxMarca.Update();

            cat = new DALCategoria(cn);
            cBoxCategoria.DataSource    = cat.GetCategoria();
            cBoxCategoria.ValueMember   = "ID_Categoria";
            cBoxCategoria.DisplayMember = "Categoria";
            //cBoxCategoria.SelectedIndex = 1;
            cBoxCategoria.Update();

            umed = new DALUnMedida(cn);
            cBoxUnMed.DataSource    = umed.GetUnMedida();
            cBoxUnMed.ValueMember   = "ID_UMedida";
            cBoxUnMed.DisplayMember = "Medida";
            //cBoxUnMed.SelectedIndex = 1;
            cBoxUnMed.Update();
        }
 public void Alterar(ModeloCategoria modelo)
 {
     if (modelo.cat_cod <= 0)
     {
         aviso("O código da categoria é obrigatório"); return;
     }
     if (modelo.cat_nome.Trim().Length == 0)
     {
         aviso("O nome da categoria é obrigatório"); return;
     }
     else
     {
         try
         {
             DALCategoria dalCategoria = new DALCategoria(conexao);
             dalCategoria.Alterar(modelo);
             aviso("Operação realizada com sucesso!!!");
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message.ToString(), "Ops. Parece que algo deu errado"); return;
         }
     }
 }
Example #19
0
        //-------------------------------------------------------------------------------------------------------------------
        public int VerificaCategoria(String valor)//0 - não existe valor || > 0 existe
        {
            DALCategoria DALobj = new DALCategoria(new DALConexao(DALDadosDoBanco.stringDeConexao));

            return(DALobj.VerificaCategoria(valor));
        }
Example #20
0
        //-------------------------------------------------------------------------------------------------------------------
        public DataTable ListagemComFiltro(String valor)
        {
            DALCategoria DALobj = new DALCategoria(new DALConexao(DALDadosDoBanco.stringDeConexao));

            return(DALobj.ListagemComFiltro(valor));
        }
Example #21
0
        //-------------------------------------------------------------------------------------------------------------------
        public DataTable Listagem()
        {
            DALCategoria DALobj = new DALCategoria(new DALConexao(DALDadosDoBanco.stringDeConexao));

            return(DALobj.Listagem());
        }
Example #22
0
        //-------------------------------------------------------------------------------------------------------------------
        public void Excluir(int codigo)
        {
            DALCategoria DALobj = new DALCategoria(new DALConexao(DALDadosDoBanco.stringDeConexao));

            DALobj.Excluir(codigo);
        }
Example #23
0
        public DataTable LocalizarCategoria(String valor, bool IdOuCat)
        {
            DALCategoria categoria = new DALCategoria(conexao);

            return(categoria.Localizar(valor, IdOuCat));
        }
Example #24
0
 public ModelCategoria CarregarModeloCategoria(int codigo)
 {
     dALCategoria = new DALCategoria(conexao);
     return(dALCategoria.CarregarModeloCategoria(codigo));
 }
        public DataTable Localizar(String valor)
        {
            DALCategoria DALobj = new DALCategoria(conexao);

            return(DALobj.Localizar(valor));
        }
Example #26
0
        //-------------------------------------------------------------------------------------------------------------------
        public ModeloCategoria carregaModelo(int codigo)
        {
            DALCategoria DALobj = new DALCategoria(new DALConexao(DALDadosDoBanco.stringDeConexao));

            return(DALobj.carregaModelo(codigo));
        }
        public void Excluir(int codigo)
        {
            DALCategoria DALobj = new DALCategoria(conexao);

            DALobj.Excluir(codigo);
        }
Example #28
0
 public void Excluir(int codigo)
 {
     dALCategoria = new DALCategoria(conexao);
     dALCategoria.Excluir(codigo);
 }
        public ModeloCategoria CarregarModeloCategoria(int codigo)
        {
            DALCategoria DALobj = new DALCategoria(conexao);

            return(DALobj.CarregaModeloCategoria(codigo));
        }
Example #30
0
 public DataTable Localizar(string valor)
 {
     dALCategoria = new DALCategoria(conexao);
     return(dALCategoria.Localizar(valor));
 }