From f5924704060599070135a849b1bf7e45d3a7142c Mon Sep 17 00:00:00 2001 From: Giuliano Paschoalino Date: Thu, 31 Jul 2025 17:11:05 -0300 Subject: [PATCH] =?UTF-8?q?feat:=20Migra=C3=A7=C3=A3o=20de=20app=20console?= =?UTF-8?q?=20para=20WPF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitattributes | 63 ------------------------ .gitignore | 2 +- App.xaml | 9 ++++ App.xaml.cs | 14 ++++++ AssemblyInfo.cs | 10 ++++ BD_empresa.csproj | 14 ++---- BD_empresa.sln | 15 +++--- MainWindow.xaml | 12 +++++ MainWindow.xaml.cs | 24 +++++++++ Program.cs | 119 --------------------------------------------- 10 files changed, 81 insertions(+), 201 deletions(-) delete mode 100644 .gitattributes create mode 100644 App.xaml create mode 100644 App.xaml.cs create mode 100644 AssemblyInfo.cs create mode 100644 MainWindow.xaml create mode 100644 MainWindow.xaml.cs delete mode 100644 Program.cs diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1ff0c42..0000000 --- a/.gitattributes +++ /dev/null @@ -1,63 +0,0 @@ -############################################################################### -# Set default behavior to automatically normalize line endings. -############################################################################### -* text=auto - -############################################################################### -# Set default behavior for command prompt diff. -# -# This is need for earlier builds of msysgit that does not have it on by -# default for csharp files. -# Note: This is only used by command line -############################################################################### -#*.cs diff=csharp - -############################################################################### -# Set the merge driver for project and solution files -# -# Merging from the command prompt will add diff markers to the files if there -# are conflicts (Merging from VS is not affected by the settings below, in VS -# the diff markers are never inserted). Diff markers may cause the following -# file extensions to fail to load in VS. An alternative would be to treat -# these files as binary and thus will always conflict and require user -# intervention with every merge. To do so, just uncomment the entries below -############################################################################### -#*.sln merge=binary -#*.csproj merge=binary -#*.vbproj merge=binary -#*.vcxproj merge=binary -#*.vcproj merge=binary -#*.dbproj merge=binary -#*.fsproj merge=binary -#*.lsproj merge=binary -#*.wixproj merge=binary -#*.modelproj merge=binary -#*.sqlproj merge=binary -#*.wwaproj merge=binary - -############################################################################### -# behavior for image files -# -# image files are treated as binary by default. -############################################################################### -#*.jpg binary -#*.png binary -#*.gif binary - -############################################################################### -# diff behavior for common document formats -# -# Convert binary document formats to text before diffing them. This feature -# is only available from the command line. Turn it on by uncommenting the -# entries below. -############################################################################### -#*.doc diff=astextplain -#*.DOC diff=astextplain -#*.docx diff=astextplain -#*.DOCX diff=astextplain -#*.dot diff=astextplain -#*.DOT diff=astextplain -#*.pdf diff=astextplain -#*.PDF diff=astextplain -#*.rtf diff=astextplain -#*.RTF diff=astextplain diff --git a/.gitignore b/.gitignore index 9491a2f..7a39ba9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -## Ignore Visual Studio temporary files, build results, and +## Ignore Visual Studio temporary files, build results, and ## files generated by popular Visual Studio add-ons. ## ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore diff --git a/App.xaml b/App.xaml new file mode 100644 index 0000000..fc1f6f4 --- /dev/null +++ b/App.xaml @@ -0,0 +1,9 @@ + + + + + diff --git a/App.xaml.cs b/App.xaml.cs new file mode 100644 index 0000000..8a03987 --- /dev/null +++ b/App.xaml.cs @@ -0,0 +1,14 @@ +using System.Configuration; +using System.Data; +using System.Windows; + +namespace BD_empresa +{ + /// + /// Interaction logic for App.xaml + /// + public partial class App : Application + { + } + +} diff --git a/AssemblyInfo.cs b/AssemblyInfo.cs new file mode 100644 index 0000000..b0ec827 --- /dev/null +++ b/AssemblyInfo.cs @@ -0,0 +1,10 @@ +using System.Windows; + +[assembly: ThemeInfo( + ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located + //(used if a resource is not found in the page, + // or application resource dictionaries) + ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located + //(used if a resource is not found in the page, + // app, or any theme specific resource dictionaries) +)] diff --git a/BD_empresa.csproj b/BD_empresa.csproj index d0d136f..defb4d1 100644 --- a/BD_empresa.csproj +++ b/BD_empresa.csproj @@ -1,15 +1,11 @@ - + - Exe - net9.0-windows7.0 - enable + WinExe + net9.0-windows enable - x64 + enable + true - - - - diff --git a/BD_empresa.sln b/BD_empresa.sln index 04ae9b4..1ea3376 100644 --- a/BD_empresa.sln +++ b/BD_empresa.sln @@ -1,9 +1,9 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 -VisualStudioVersion = 17.0.32014.148 +VisualStudioVersion = 17.12.35527.113 d17.12 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BD_empresa", "BD_empresa.csproj", "{AF7C4BDC-57FB-4277-8D9D-4F863B11538E}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BD_empresa", "BD_empresa.csproj", "{8A5C3F7B-3694-45AA-BAF0-5A3A7C2F23D4}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -11,15 +11,12 @@ Global Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {AF7C4BDC-57FB-4277-8D9D-4F863B11538E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {AF7C4BDC-57FB-4277-8D9D-4F863B11538E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {AF7C4BDC-57FB-4277-8D9D-4F863B11538E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {AF7C4BDC-57FB-4277-8D9D-4F863B11538E}.Release|Any CPU.Build.0 = Release|Any CPU + {8A5C3F7B-3694-45AA-BAF0-5A3A7C2F23D4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8A5C3F7B-3694-45AA-BAF0-5A3A7C2F23D4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8A5C3F7B-3694-45AA-BAF0-5A3A7C2F23D4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8A5C3F7B-3694-45AA-BAF0-5A3A7C2F23D4}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {142A299C-80F0-4D68-B366-3891F4D5C9BB} - EndGlobalSection EndGlobal diff --git a/MainWindow.xaml b/MainWindow.xaml new file mode 100644 index 0000000..ed01b74 --- /dev/null +++ b/MainWindow.xaml @@ -0,0 +1,12 @@ + + + + + diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs new file mode 100644 index 0000000..61c9e62 --- /dev/null +++ b/MainWindow.xaml.cs @@ -0,0 +1,24 @@ +using System.Text; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace BD_empresa +{ + /// + /// Interaction logic for MainWindow.xaml + /// + public partial class MainWindow : Window + { + public MainWindow() + { + InitializeComponent(); + } + } +} \ No newline at end of file diff --git a/Program.cs b/Program.cs deleted file mode 100644 index a6215e3..0000000 --- a/Program.cs +++ /dev/null @@ -1,119 +0,0 @@ -using System.Data.OleDb; -using System.Diagnostics; - -class Download_BD -{ - static void Main() - { - string nome_entrada; - string strQRY; - string[] charsToRemove = new string[] { "@", ",", ".", ";", "'", "-", "/" }; - - nome_entrada = "aaa"; - while (nome_entrada.Length != 0) - { - Console.WriteLine("Digite 'c' - caso que queira pesquisar por CNPJ ou 'u' - caso que queira pesquisar por UC e pressione Enter"); - Console.WriteLine("Para pesquisar por Razao Social/Nome, escreva o nome da empresa a ser procurada (min: 4 digitos) e pressione Enter - deixe em branco para sair:"); - nome_entrada = Console.ReadLine(); - switch (nome_entrada.ToUpper()) - { - case "U": - Console.WriteLine("Digite a UC a ser procurada (completa) e pressione Enter:"); - nome_entrada = Console.ReadLine(); - - if (nome_entrada.Length >= 4) - { - strQRY = "SELECT DISTINCT Gestao, Cliente, razao_social, Caminho_NFs FROM Dados_cadastrais WHERE Codigo_Instalacao = " + "\"" + nome_entrada + "\""; - strQRY += " ORDER BY gestao, cliente, razao_social"; - Acessar_BD(strQRY); - } - break; - - case "C": - Console.WriteLine("Digite o CNPJ a ser procurado (14 dig) e pressione Enter:"); - nome_entrada = Console.ReadLine(); - - foreach (var c in charsToRemove) - { - nome_entrada = nome_entrada.Replace(c, string.Empty); - } - - while (nome_entrada.Length < 14) - { - nome_entrada = "0" + nome_entrada; - } - - strQRY = "SELECT DISTINCT Gestao, Cliente, razao_social, Caminho_NFs FROM Dados_cadastrais WHERE CNPJ_CPF = " + "\"" + nome_entrada + "\""; - strQRY += " ORDER BY gestao, cliente, razao_social"; - //Console.WriteLine(strQRY); - Acessar_BD(strQRY); - break; - - default: - if (nome_entrada.Length >= 4) - { - strQRY = "SELECT DISTINCT Gestao, Cliente, razao_social, Caminho_NFs FROM Dados_cadastrais WHERE Cliente ALike " + "\"" + "%" + nome_entrada + "%" + "\""; - strQRY += " UNION " + " SELECT DISTINCT Gestao, Cliente, razao_social, Caminho_NFs FROM Dados_cadastrais WHERE Razao_social ALike " + "\"" + "%" + nome_entrada + "%" + "\""; - strQRY += " ORDER BY gestao, cliente, razao_social"; - Acessar_BD(strQRY); - } - break; - } - } - Console.WriteLine("Programa encerrado."); - return; - } - static void Acessar_BD(string strSQL) - { - int cont_result; - string prt_str; - int n_pasta; - bool teste_par; - string teste_cli = ""; - - List caminhos = new List(); - - OleDbConnection conn = new("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=X:/Middle/Informativo Setorial/Modelo Word/BD1_dados cadastrais e faturas.accdb;Jet OLEDB:Database Password=gds21"); - conn.Open(); - OleDbCommand tbEmpresas = new(strSQL, conn); - OleDbDataReader reader = tbEmpresas.ExecuteReader(); - - prt_str = "\n" + String.Format("{0,-4} | {1,-8} | {2,-25}| {3,-30}", "N", "Gestao", "Nome cliente", "Razao social"); - cont_result = 0; - while (reader.Read() && cont_result < 11) - { - if (reader["Cliente"].ToString() != teste_cli) - { - teste_cli = reader["Cliente"].ToString(); - cont_result++; - prt_str += "\n" + String.Format("{0,-4} | {1,-8} | {2,-25}| {3,-30}", cont_result, reader["gestao"].ToString(), reader["Cliente"].ToString(), reader["Razao_Social"].ToString()); - caminhos.Add(reader["Caminho_NFs"].ToString()); - } - } - prt_str += "\n\n"; - conn.Close(); - - if (cont_result >= 10) - { - Console.WriteLine("\nForam encontrados mais de {0} resultados para o nome pesquisado, buscou-se por razao social e nome do cliente.\n", cont_result - 1); - Console.WriteLine("Especificar melhor o nome pesquisado para que os resultados possam sem exibidos.\n"); - } - else if (cont_result > 0) - { - Console.WriteLine("\nForam encontrados {0} resultados para os parametros procurados.\n", cont_result); - Console.WriteLine(prt_str); - Console.WriteLine("Digite um numero da lista para acessar a pasta do cliente (só funcionará se possuir acesso):"); - teste_par = Int32.TryParse(Console.ReadLine(), out n_pasta); - if (teste_par && n_pasta <= cont_result) - { - //Console.WriteLine(caminhos[n_pasta - 1]); - Process.Start("explorer.exe", caminhos[n_pasta - 1]); - } - else - { - Console.WriteLine("Numero invalido"); - } - } - return; - } -}