-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f13eb4e
commit bdc3bd7
Showing
12 changed files
with
893 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio 15 | ||
VisualStudioVersion = 15.0.27130.2010 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CSharpDBExemplo", "CSharpDBExemplo\CSharpDBExemplo.csproj", "{8E4ADD72-4FD6-44A8-BEAA-5DE031F5DD99}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{8E4ADD72-4FD6-44A8-BEAA-5DE031F5DD99}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{8E4ADD72-4FD6-44A8-BEAA-5DE031F5DD99}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{8E4ADD72-4FD6-44A8-BEAA-5DE031F5DD99}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{8E4ADD72-4FD6-44A8-BEAA-5DE031F5DD99}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {BF81CFC1-4182-465B-9378-375277C0DE4C} | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<configuration> | ||
<startup> | ||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/> | ||
</startup> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{8E4ADD72-4FD6-44A8-BEAA-5DE031F5DD99}</ProjectGuid> | ||
<OutputType>Exe</OutputType> | ||
<RootNamespace>CSharpDBExemplo</RootNamespace> | ||
<AssemblyName>CSharpDBExemplo</AssemblyName> | ||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> | ||
<TargetFrameworkProfile /> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
<Prefer32Bit>false</Prefer32Bit> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
<Prefer32Bit>false</Prefer32Bit> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="MySql.Data, Version=8.0.14.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d, processorArchitecture=MSIL" /> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="Microsoft.CSharp" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Net.Http" /> | ||
<Reference Include="System.Xml" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="ConnectionFactory.cs" /> | ||
<Compile Include="Contato.cs" /> | ||
<Compile Include="ContatoDAO.cs" /> | ||
<Compile Include="ContatoDAOImpl.cs" /> | ||
<Compile Include="ContatoException.cs" /> | ||
<Compile Include="ContatoNaoExisteException.cs" /> | ||
<Compile Include="Program.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="App.config" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<WCFMetadata Include="Connected Services\" /> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
using System; | ||
using MySql.Data.MySqlClient; | ||
using System.Data; | ||
|
||
/* iagocolodetti */ | ||
|
||
namespace CSharpDBExemplo | ||
{ | ||
class ConnectionFactory | ||
{ | ||
private const string SERVER = "localhost", | ||
PORT = "3306", | ||
DATABASE = "contatodb", | ||
UID = "root", | ||
PWD = "root"; | ||
|
||
public MySqlConnection GetConnection() | ||
{ | ||
MySqlConnection con = null; | ||
try | ||
{ | ||
con = new MySqlConnection("SERVER=" + SERVER + ";PORT=" + PORT + ";DATABASE=" + DATABASE + ";UID=" + UID + ";PWD=" + PWD + ";"); | ||
con.Open(); | ||
} | ||
catch (MySqlException e) | ||
{ | ||
#if DEBUG | ||
Console.WriteLine(e.ToString()); | ||
#else | ||
Console.WriteLine("Não foi possível realizar a conexão."); | ||
#endif | ||
} | ||
return con; | ||
} | ||
|
||
public bool IsConnectionOpen(MySqlConnection con) | ||
{ | ||
return (con.State == ConnectionState.Open); | ||
} | ||
|
||
public void CloseConnection(MySqlConnection con) | ||
{ | ||
try | ||
{ | ||
con.Close(); | ||
} | ||
catch (MySqlException e) | ||
{ | ||
#if DEBUG | ||
Console.WriteLine(e.ToString()); | ||
#else | ||
Console.WriteLine("Não foi possível encerrar a conexão."); | ||
#endif | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
| ||
/* iagocolodetti */ | ||
|
||
namespace CSharpDBExemplo | ||
{ | ||
class Contato | ||
{ | ||
private int id; | ||
private string nome, | ||
telefone, | ||
email; | ||
|
||
public Contato() { } | ||
|
||
public Contato(string nome, string telefone, string email) | ||
{ | ||
this.nome = nome; | ||
this.telefone = telefone; | ||
this.email = email; | ||
} | ||
|
||
public Contato(int id, string nome, string telefone, string email) | ||
{ | ||
this.id = id; | ||
this.nome = nome; | ||
this.telefone = telefone; | ||
this.email = email; | ||
} | ||
|
||
public int Id | ||
{ | ||
get => id; | ||
set => id = value; | ||
} | ||
|
||
public string Nome | ||
{ | ||
get => nome; | ||
set => nome = value; | ||
} | ||
|
||
public string Telefone | ||
{ | ||
get => telefone; | ||
set => telefone = value; | ||
} | ||
|
||
public string Email | ||
{ | ||
get => email; | ||
set => email = value; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using System.Collections.Generic; | ||
|
||
/* iagocolodetti */ | ||
|
||
namespace CSharpDBExemplo | ||
{ | ||
interface ContatoDAO | ||
{ | ||
void Add(Contato contato); | ||
|
||
Contato GetContato(int id); | ||
|
||
List<Contato> GetContatosPorNome(string nome); | ||
|
||
List<Contato> GetContatosPorTelefone(string telefone); | ||
|
||
List<Contato> GetContatosPorEmail(string email); | ||
|
||
List<Contato> GetContatos(); | ||
|
||
void Update(Contato contato); | ||
|
||
void Delete(int id); | ||
} | ||
} |
Oops, something went wrong.