Exemplo n.º 1
0
        public bool CreateEstabelecimento(EstabelecimentosDTO DTO)
        {
            bool sucess = false;

            try
            {
                var data  = DateTime.Now.ToString();
                var query = "INSERT INTO estabelecimento (USUARIO_id, cnpj, endereco, inscricao, telefone, data, ESTADOS_id, CIDADES_id, CLIENTE_id, descricao) VALUES('" + Logindto.Id + "','" + DTO.Cnpj + "','" + DTO.Endereco + "','" + DTO.Ie + "','" + DTO.Telefone + "','" + data + "','" + DTO.UF_Id + "','" + DTO.Cidade_Id + "', '" + DTO.Cliente_Id + "', '" + DTO.Descricao + "')";
                bd.Conectar();
                bd.ExecutarComandoSQL(query);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
                sucess = true;
                bd.CloseConection();
            }
            if (sucess)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        public ActionResult Inserir(UsuarioModel _usuarioModel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    string nome = _usuarioModel.Nome.Replace("'", "''");

                    bd.Conectar();
                    string comando = "INSERT INTO usuario(nome, email, telefone, senha) VALUES ('" + nome + "','" + _usuarioModel.Email + "','" + _usuarioModel.Telefone + "','" + _usuarioModel.Senha + "')";
                    bd.ExecutarComandoSQL(comando);

                    return(RedirectToAction("Index"));
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Erro ao tentar inserir: " + ex.Message);
            }
            finally
            {
                bd = null;
            }

            return(View());
        }
Exemplo n.º 3
0
 public void CadastrarAtividade(CadastroAtividadesDTO DTO, AtividadeCadastradaDTO atividadeCadastradaDTO)
 {
     try
     {
         var query = "INSERT INTO atividade (descricao, NEGOCIO_id, DESC_ATIVIDADES_id, VERSAO_ATIVIDADE_id, USUARIO_id) VALUES ('" + atividadeCadastradaDTO.Descricao + "', '" + DTO.Id + "' , '" + atividadeCadastradaDTO.Atividade_id + "', '" + DTO.Versao_Atividade_Id + "', '" + loginDTO.Id + "' )";
         bd.Conectar();
         bd.ExecutarComandoSQL(query);
     }
     catch (Exception ex)
     {
         throw new Exception(ex.ToString());
     }
 }
Exemplo n.º 4
0
 public void Insert(CopiarItensOrcamentoDTO dTO)
 {
     try
     {
         var query = "INSERT INTO lista_orcamento (NEGOCIO_id, PRODUTO_id, ATIVIDADES_id, preco_orc, descricao_orc) VALUES ('" + dTO.Negocio_Id + "','" + dTO.Id + "','" + dTO.Atividade_Id + "', (SELECT CASE WHEN icms = '0' AND ipi = '0' THEN custounitario+(custounitario*(1+ipi)-(custounitario*(1+ipi)*icms))/(1)*((0))-(custounitario*(1+ipi)*icms)+custounitario*ipi ELSE custounitario+(custounitario*(1+ipi)-(custounitario*(1+ipi)*icms))/(1-0.18)*((0.18))-(custounitario*(1+ipi)*icms)+custounitario*ipi END FROM produto WHERE id='" + dTO.Id + "'), (SELECT descricao from produto WHERE id='" + dTO.Id + "'))";
         bd.Conectar();
         bd.ExecutarComandoSQL(query);
     }
     catch (Exception ex)
     {
         throw new Exception(ex.ToString());
     }
 }
Exemplo n.º 5
0
 public void AtualizarQuantidade(ListaProjetosDTO DTO)
 {
     try
     {
         var query = "UPDATE lista_vendas SET quantidade='" + DTO.Quantidade + "' WHERE id='" + DTO.Id + "'";
         bd.Conectar();
         bd.ExecutarComandoSQL(query);
     }
     catch (Exception ex)
     {
         throw new Exception(ex.ToString());
     }
 }
Exemplo n.º 6
0
        public bool CreateCliente(ClientesDTO DTO)
        {
            bool sucess = false;

            try
            {
                var data  = DateTime.Now.ToString();
                var query = "INSERT INTO cliente (rsocial, fantasia, data, USUARIO_id, CATEGORIA_CLIENTE_id) VALUES('" + DTO.Razao_Social + "', '" + DTO.Nome_Fantasia + "', '" + data + "', '" + Logindto.Id + "' , '" + DTO.Categoria_Id + "')";
                bd.Conectar();
                bd.ExecutarComandoSQL(query);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
                sucess = true;
                bd.CloseConection();
            }
            if (sucess)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 7
0
        public string GerarRM(InformacoesGerarRequisicaoMaterialDTO DTO, ObservableCollection <GerarRequisicaoMaterialDTO> listaMateriais)
        {
            string rm;
            var    dtRM = new DataTable();

            try
            {
                string substringMateriais = "";
                foreach (var item in listaMateriais)
                {
                    substringMateriais = substringMateriais + "((select id from requisicao_material where vendas_id = '" + DTO.Id + "' ORDER BY id desc LIMIT 1), '" + item.Produto_Id + "', '" + item.Quantidade + "'),";
                }
                string queryMateriais = "INSERT INTO materiais_requeridos (requisicao_material_id, produto_id, quantidade) VALUES " + substringMateriais.TrimEnd(',');

                var queryRM = "INSERT INTO requisicao_material (vendas_id, usuario_id) VALUES ('" + DTO.Id + "', '" + loginDTO.Id + "');" + queryMateriais;
                bd.Conectar();
                bd.ExecutarComandoSQL(queryRM);

                var querySelectRM = "select id from requisicao_material where vendas_id = '" + DTO.Id + "' ORDER BY id desc LIMIT 1";
                bd.Conectar();
                dtRM = bd.RetDataTable(querySelectRM);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.ToString());
            }
            finally
            {
                rm = dtRM.Rows[0]["id"].ToString();
            }
            return(rm);
        }
Exemplo n.º 8
0
        public void inserir(turmaDTO dto)
        {
            bd.Conectar();
            string comando = "INSERT INTO tb_turma(sigla_turma, periodo, modulo) VALUES ('" + dto.Sigla_turma + "','" + dto.Periodo + "','" + dto.Modulo + "')";

            bd.ExecutarComandoSQL(comando);
        }
Exemplo n.º 9
0
 public void Inserir(CadastroFilmeDTO dto)
 {
     try
     {
         bd.Conectar();
         string comando = "INSERT INTO Filmes (titulo, genero) VALUES ('" + dto.Titulo + "' , '" + dto.Genero + "')";
         bd.ExecutarComandoSQL(comando);
     }
     catch (Exception ex)
     {
         throw new Exception("Erro ao Cadastrar Filme" + ex.Message);
     }
     finally
     {
     }
 }
Exemplo n.º 10
0
        AcessoBancoDados bd;    //Variável global de acesso ao banco de dados

        // Metodo de cadastro de equipamentos
        public void cadEquip(dto_Equip dto)
        {                        //ini cadEquip
            AcessoBancoDados bd; // Declaração de variável para acesso ao banco de dados

            try
            {   //ini try
                string tipo       = dto.Tipo.Replace("'", "''");
                string fabricante = dto.Fabricante.Replace("'", "''");
                string modelo     = dto.Modelo.Replace("'", "'");
                string sn         = dto.SN.Replace("'", "'");
                string contagem   = dto.Contagem.Replace("'", "'");
                string potencia   = dto.Potencia.Replace("'", "'");
                string polegada   = dto.Polegadas.Replace("'", "'");
                string local      = "RCA Interno";
                string tecent     = "";
                string tecret     = "";
                string tecsaid    = "";
                string tecinstal  = "";
                int    status     = dto.Status;

                bd = AcessoBancoDados.GetInstance;
                bd.conectar();
                string comando = "INSERT INTO equipamentos(tipo, fabricante, modelo, sn, contagem, potencia, polegada, status, local, tecent, tecret, tecsaid, tecinstal) VALUES('" + tipo + "','" + fabricante + "','" + modelo + "','" + sn + "','" + contagem + "','" + potencia + "','" + polegada + "','" + status + "','" + local + "','" + tecent + "','" + tecret + "','" + tecsaid + "','" + tecinstal + "')";
                bd.ExecutarComandoSQL(comando);
            }   //fim try
            catch (Exception ex)
            {
                throw new Exception("Erro ao acadastrar o novo equipamento!" + ex.Message);
            }
            finally
            {
                bd = null;
            }
        }   //fim cadEquip
        //Metodo Para Efectuar Uma Nova Venda

        public int GerarCodigoVenda()
        {
            bd = new AcessoBancoDados();
            bd.Conectar();
            string comando = "select MAX(id_venda) from tb_venda";

            return(Convert.ToInt32(bd.ExecutarComandoSQL(comando)));
        }
        public void Excluir(ClienteDTO dto)
        {
            bd = new AcessoBancoDados();
            bd.Conectar();
            string comando = "DELETE FROM CLIENTE where id_cliente = '" + dto.IdCliente + "'";

            bd.ExecutarComandoSQL(comando);
        }
Exemplo n.º 13
0
        public void inseir(responsavelDTO dto)
        {
            bd.Conectar();
            string comando = "INSERT INTO tb_responsavel(nome_responsavel," +
                             "tel_residencial, tel_celular, tel_opcional, nome_opcional)" +
                             " VALUES ('" + dto.Nome_responsavel + "','" + dto.Tel_residencial + "','" + dto.Tel_celular + "','" + dto.Tel_opcional + "','" + dto.Nome_opcional + "')";

            bd.ExecutarComandoSQL(comando);
        }
        public void Excluir(CategoriaClienteDTO dto)
        {
            bd = new AcessoBancoDados();
            bd.Conectar();
            string comando = "DELETE FROM CATEGORIA_CLIENTE " +
                             "where id_categoria_cliente = '" + dto.IdCategoriaCliente + "'";

            bd.ExecutarComandoSQL(comando);
        }
Exemplo n.º 15
0
 public void UpdateProduto(ProdutosDTO DTO)
 {
     try
     {
         var query = "UPDATE produto SET status_id='" + DTO.Status_Id + "', ncm='" + DTO.Ncm + "', custounitario='" + DTO.Custo.ToString().Replace(",", ".") + "', descricao='" + DTO.Anotacoes + "', ipi='" + DTO.Ipi.ToString().Replace(",", ".") + "', partnumber='" + DTO.Partnumber + "', icms='" + DTO.Icms.ToString().Replace(",", ".") + "' WHERE id='" + DTO.Id + "'";
         bd.Conectar();
         bd.ExecutarComandoSQL(query);
     }
     catch (Exception ex)
     {
         throw new Exception(ex.ToString());
     }
 }
Exemplo n.º 16
0
        public bool CreateUser(CadastroUsuarioDTO dTO)
        {
            var success           = false;
            var query_funcionario = "INSERT INTO funcionario (nome) VALUES ('" + dTO.Name + "')";

            try
            {
                bd.Conectar();
                bd.ExecutarComandoSQL(query_funcionario);
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                try
                {
                    var select_funcionario = "SELECT id FROM funcionario WHERE nome = '" + dTO.Name + "' ORDER BY id DESC LIMIT 1;";
                    bd.Conectar();
                    var dr = bd.RetDataReader(select_funcionario);
                    dTO.Id = dr[0].ToString();
                    try
                    {
                        var query_usuario = "INSERT INTO usuario (login, senha, funcionario_id) VALUES ('" + dTO.Login + "', '" + dTO.Password + "', '" + dTO.Id + "'); CREATE TABLE `mensagem_" + dTO.Login.ToLower() + "` (`id` int(11) NOT NULL AUTO_INCREMENT,`USUARIO_id` int(11) NOT NULL,`USUARIO_FROM_id` int(11) DEFAULT NULL, `mensagem` longtext NOT NULL, `lida` tinyint(1) NOT NULL DEFAULT '0', `data` datetime NOT NULL, `NEGOCIO_id` int(11) DEFAULT NULL, `descricao` varchar(200) NOT NULL, PRIMARY KEY(`id`,`USUARIO_id`)); ";
                        bd.Conectar();
                        bd.ExecutarComandoSQL(query_usuario);
                        success = true;
                    }
                    catch (Exception)
                    {
                        throw;
                    }
                }
                catch (Exception)
                {
                    throw;
                }
            }
            return(success);
        }
Exemplo n.º 17
0
        //metodo para inserir
        public void inserir(alunoDTO dto)
        {
            bd.Conectar();
            string comando = "INSERT INTO tb_aluno" +
                             "(nome_aluno,cep,logradouro,numero,complemento," +
                             "bairro,cidade,estado,rg,cpf,tel_residencial,tel_celular" +
                             "data_nascimento,responsavel_id,email,situacao) VALUES ('" + dto.Nome_aluno +
                             "','" + dto.Cep + "','" + dto.Logradouro + "','" + dto.Numero + "','" + dto.Complemento + "','" + dto.Bairro +
                             "','" + dto.Cidade + "','" + dto.Estado + "','" + dto.Rg + "','" + dto.Cpf + "','" + dto.Tel_residencial + "','" +
                             dto.Tel_celular + "','" + dto.Data_nascimento + "'," + dto.Responsavel_id + ",'" + dto.Email + "','" + dto.Situacao + "')";

            bd.ExecutarComandoSQL(comando);
        }
Exemplo n.º 18
0
 public void UpdateCodigoBarra(LinkarProdutoNotaFiscalDTO DTO)
 {
     try
     {
         var query = "UPDATE produto SET codigo_barra = '' WHERE codigo_barra = '" + DTO.Codigo_Barra + "'; UPDATE produto SET codigo_barra = '" + DTO.Codigo_Barra + "' WHERE id = '" + DTO.Id + "'";
         bd.Conectar();
         bd.ExecutarComandoSQL(query);
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
Exemplo n.º 19
0
 public void Add(InformacoesListaOrcamentosDTO DTO, AdicionarItemOrcamentoDTO listaDTO)
 {
     try
     {
         var query = "INSERT INTO lista_orcamento (NEGOCIO_id, PRODUTO_id, ATIVIDADES_id, preco_orc, descricao_orc) VALUES ('" + DTO.Negocio_Id + "','" + listaDTO.Id + "','" + DTO.Atividade_Id + "', (SELECT CASE WHEN icms = '0' AND ipi = '0' THEN custounitario+(custounitario*(1+ipi)-(custounitario*(1+ipi)*icms))/(1)*((0))-(custounitario*(1+ipi)*icms)+custounitario*ipi ELSE custounitario+(custounitario*(1+ipi)-(custounitario*(1+ipi)*icms))/(1-0.18)*((0.18))-(custounitario*(1+ipi)*icms)+custounitario*ipi END FROM produto WHERE id='" + listaDTO.Id + "'), '" + listaDTO.Descricao_Produto + "' )";
         bd.Conectar();
         bd.ExecutarComandoSQL(query);
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
Exemplo n.º 20
0
 public void Inserir(AdicionarItemProjetoDTO DTO)
 {
     try
     {
         var query = "INSERT INTO lista_vendas (VENDAS_id, PRODUTO_id, ATIVIDADE_id, preco, anotacoes, USUARIO_id) VALUES ('" + DTO.Negocio_Id + "','" + DTO.Id + "','" + DTO.Atividade_Id + "', (SELECT CASE WHEN icms = '0' AND ipi = '0' THEN custounitario+(custounitario*(1+ipi)-(custounitario*(1+ipi)*icms))/(1)*((0))-(custounitario*(1+ipi)*icms)+custounitario*ipi ELSE custounitario+(custounitario*(1+ipi)-(custounitario*(1+ipi)*icms))/(1-0.18)*((0.18))-(custounitario*(1+ipi)*icms)+custounitario*ipi END FROM produto WHERE id='" + DTO.Id + "'), '" + DTO.Anotacoes + "', '" + loginDTO.Id + "' )";
         bd.Conectar();
         bd.ExecutarComandoSQL(query);
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
Exemplo n.º 21
0
 public bool SavePassword(LoginDTO dto)
 {
     try
     {
         var query = "UPDATE usuario SET senha='" + dto.Senha + "' WHERE id = '" + dto.Id + "'";
         bd.Conectar();
         bd.ExecutarComandoSQL(query);
         return(true);
     }
     catch (Exception ex)
     {
         throw new Exception(ex.ToString());
     }
 }
Exemplo n.º 22
0
        public void ExcluirProduto(string IdProduto)
        {
            try {
                bd = new AcessoBancoDados();

                bd.Conectar();
                string comando = "DELETE FROM Produtos WHERE Id_Produto =" + IdProduto;
                bd.ExecutarComandoSQL(comando);
            } catch (Exception ex) {
                throw new Exception("Erro ao tentar excluir o produto: " + ex.Message);
            } finally {
                bd = null;
            }
        }
Exemplo n.º 23
0
 public void AtenderProdutos(InformacoesAtendimentoDTO informacoesDTO, ObservableCollection <AtendimentoDTO> listaDTO)
 {
     foreach (var dto in listaDTO)
     {
         try
         {
             var query = "call gegetdb.SP_SaidaProdutos('" + dto.Produto_Id + "', '" + dto.Quantidade + "', '" + loginDTO.Id + "', '" + informacoesDTO.Id + "');";
             bd.Conectar();
             bd.ExecutarComandoSQL(query);
         }
         catch (Exception ex)
         {
             throw new Exception(ex.ToString());
         }
     }
 }
Exemplo n.º 24
0
        public void InserirGrupo(GrupoDTO dto)
        {
            try {
                string nomeGrupo = dto.NomeGrupo.Replace("'", "''");
                bd = new AcessoBancoDados();

                bd.Conectar();

                string comando = "INSERT INTO Grupos(NomeGrupo) VALUES('" + nomeGrupo + "')";
                bd.ExecutarComandoSQL(comando);
            } catch (Exception ex) {
                throw new Exception("Erro ao cadastrar o grupo" + ex.Message);
            } finally {
                bd = null;
            }
        }
Exemplo n.º 25
0
        public void EditarGrupo(GrupoDTO dto)
        {
            try {
                string nomeGrupo = dto.NomeGrupo.Replace("'", "''");
                bd = new AcessoBancoDados();

                bd.Conectar();

                string comando = "UPDATE grupos set NomeGrupo = '" + nomeGrupo + "' Where ID =" + dto.Id;
                bd.ExecutarComandoSQL(comando);
            } catch (Exception ex) {
                throw new Exception("Erro ao editar o produto: " + ex.Message);
            } finally {
                bd = null;
            }
        }
Exemplo n.º 26
0
 public void EstornarProdutos(ObservableCollection <EstornoEstoqueDTO> listaEstorno)
 {
     foreach (var dto in listaEstorno)
     {
         try
         {
             var query = "DELETE FROM materiais_requeridos WHERE id = '" + dto.Id + "'";
             bd.Conectar();
             bd.ExecutarComandoSQL(query);
         }
         catch (Exception ex)
         {
             throw new Exception(ex.ToString());
         }
     }
 }
Exemplo n.º 27
0
 public void Excluir(string Id_Filme)
 {
     try
     {
         bd = new AcessoBancoDados();
         bd.Conectar();
         string comando = "DELETE FROM Filmes where id_filme =" + Id_Filme;
         bd.ExecutarComandoSQL(comando);
     }
     catch (Exception ex)
     {
         throw new Exception("Erro ao excluir Filme" + ex.Message);
     }
     finally
     {
     }
 }
Exemplo n.º 28
0
 public bool CadastroLote(DataTable dt)
 {
     try
     {
         foreach (DataRow dr in dt.Rows)
         {
             var query = "INSERT INTO item (descricao, usuario_id, grupo_item_id, mobra, unidade_id) VALUES ('" + dr["descricao"] + "', '" + loginDTO.Id + "', '" + dr["grupo_item"].ToString() + "', '" + dr["mao_obra"].ToString() + "', '" + dr["un"].ToString() + "') ";
             bd.Conectar();
             bd.ExecutarComandoSQL(query);
         }
     }
     catch (Exception)
     {
         throw;
     }
     return(true);
 }
Exemplo n.º 29
0
        }   //fim atualiza entrada

        // Metodo para atualizar valor de saída - status = 1 (equipamento externo)
        public void saiEquip(dto_Equip dto)
        {                        //ini atualiza entrada
            AcessoBancoDados bd; // Declaração de variável para acesso ao banco de dados

            try
            {   //ini try
                string local     = dto.Local.Replace("'", "''");
                string tecSaid   = dto.TecSaid.Replace("'", "''");
                string tecInstal = dto.TecInstal.Replace("'", "''");
                string tecEnt    = "";
                string tecRet    = "";
                int    status    = 1; // Variável de atualização de status 0 para 1, ou entrada para saída

                bd = AcessoBancoDados.GetInstance;
                bd.conectar();
                string comando = "UPDATE equipamentos set status = '" + status + "', local = '" + local + "', tecsaid = '" + tecSaid + "', tecinstal = '" + tecInstal + "', tecent = '" + tecEnt + "', tecret = '" + tecRet + "' where id =" + dto.ID;
                bd.ExecutarComandoSQL(comando);
            }   //fim try
            catch (Exception ex)
            {
                throw new Exception("Erro ao dar saída no equipamento!" + ex.Message);
            }
            try
            {
                //sendMailSaid(dto);  //envia email de saída de equipamento
                sendMail(dto);  //envia email de saída de equipamento
            }
            catch (Exception ex)
            {
                throw new Exception("Erro ao enviar o email de saída de equipamento!" + ex.Message);
            }
            try
            {
                atualCont(dto); // atualiza a contagem de paginas na entrada de equipamentos
            }
            catch (Exception ex)
            {
                throw new Exception("Erro ao atualizar a contagem de paginas do equipamento!" + ex.Message);
            }
            finally
            {
                bd  = null;
                dto = null;
            }
        }   //fim atualiza entrada
 public void ExcluirUsuarioBLL(UsuariosDTO dto)
 {
     try
     {
         bd = new AcessoBancoDados();
         bd.Conectar();
         string comando = "DELETE FROM tb_usuarios WHERE cod_usuario=" + dto.cod_usuario + " ";
         bd.ExecutarComandoSQL(comando);
     }
     catch (Exception ex)
     {
         throw new Exception("Erro ao Excluir o Usuário. Detalhes: " + ex.Message);
     }
     finally
     {
         bd = null;
     }
 }