コード例 #1
0
        public bool Excluir(int codigo)
        {
            try
            {
                banco.AbrirConexao();


                string SQL_empresa = "DELETE FROM PRODUTO WHERE EMP_ID = " + codigo;


                if (banco.AtualizarComandoSQL(SQL_empresa) != true)
                {
                    Debug.WriteLine("Erro -  Excluir Empresa no BD -> String : " + SQL_empresa);
                }
                else
                {
                    Debug.WriteLine("OK - Excluir Empresa no BD");
                }
            }
            catch (SqlException)
            {
                return(false);
            }
            return(true);
        }
コード例 #2
0
        public bool Inativar(int codigo)
        {
            try
            {
                banco.AbrirConexao();

                bool status = false;

                //TODO: Add a tabela VEICULO status
                string SQL_empresa = string.Format("UPDATE TB_Veiculo SET Status = '{0}' WHERE ID_Veiculo = '{1}'", status, codigo);


                if (banco.AtualizarComandoSQL(SQL_empresa) != true)
                {
                    Debug.WriteLine("Erro - Inativar Empresa no BD -> String : " + SQL_empresa);
                }
                else
                {
                    Debug.WriteLine("OK - Inativar Empresa no BD");
                }
            }
            catch (SqlException e)
            {
                return(false);
            }
            return(true);
        }
コード例 #3
0
        public bool Atualizar(Empresa e)
        {
            try
            {
                banco.AbrirConexao();


                string SQL_empresa = string.Format(
                    "UPDATE TB_Empresa SET" +
                    "EMP_CNPJ = '{0}'" +
                    "EMP_RazaoSocial = '{1}'" +
                    "EMP_Email = '{2}'" +
                    "WHERE EMP_ID = '{4}'",
                    e.cnpj,
                    e.razaoSocial,
                    e.email,
                    e.ID);


                if (banco.AtualizarComandoSQL(SQL_empresa) != true)
                {
                    Debug.WriteLine("Erro - Atualizar Inserir Empresa no BD -> String : " + SQL_empresa);
                }
                else
                {
                    Debug.WriteLine("OK - Atualizar Inserir Empresa no BD");
                }


                // Comprimento ? trocar para complemento
                string SQL_endereco = string.Format(
                    "UPDATE TB_Endereco SET" +
                    "ENDE_Rua = '{0}'," +
                    "ENDE_Numero = '{1}'," +
                    "ENDE_Comprimento = '{2}'," +
                    "ENDE_Bairro = '{3}'," +
                    "ENDE_Municipio = '{4}'," +
                    "ENDE_Estado = '{5}'," +
                    "ENDE_CEP = '{6}'," +
                    "ENDE_Cidade = '{7}'," +
                    "WHERE ID_Empresa = '{8}'",
                    e.endereco.rua,
                    e.endereco.numero,
                    e.endereco.complemento,
                    e.endereco.bairro,
                    e.endereco.municipio,
                    e.endereco.estado,
                    e.endereco.cep,
                    e.endereco.cidade,
                    e.ID);


                if (banco.AtualizarComandoSQL(SQL_endereco))
                {
                    Debug.WriteLine("Erro - Atualizar Endereço de Empresa -> String : " + SQL_endereco);
                }
                else
                {
                    Debug.WriteLine("OK - Atualizar Endereço de Empresa");
                }


                foreach (var telefone in e.telefone)
                {
                    string SQL_telefone = string.Format(
                        "UPDATE TB_Telefone SET" +
                        "Tel_DDI = '{0}'," +
                        "Tel_DDD = '{1}'," +
                        "Tel_Telefone = '{2}'," +
                        "WHERE ID_EmpresaTel = '{3}'",
                        telefone.DDI,
                        telefone.DDD,
                        telefone.telefone,
                        e.ID);


                    if (banco.AtualizarComandoSQL(SQL_telefone))
                    {
                        Debug.WriteLine("Erro - Atualizar Telefone de Empresa-> String : " + SQL_telefone);
                    }
                    else
                    {
                        Debug.WriteLine("OK - Atualizar Telefone de Empresa");
                    }
                }


                Debug.WriteLine("OK - Atualizar Empresa");
                return(true);
            }
            catch (SqlException ex)
            {
                Debug.Write("Erro - Atualizar Empresa" + ex);
                return(false);
            }
            finally
            {
                banco.FecharConexao();
            }
        }