Skip to content

Commit

Permalink
Adicionar arquivos de projeto.
Browse files Browse the repository at this point in the history
  • Loading branch information
iagocolodetti committed Apr 7, 2019
1 parent f13eb4e commit bdc3bd7
Show file tree
Hide file tree
Showing 12 changed files with 893 additions and 0 deletions.
25 changes: 25 additions & 0 deletions CSharpDBExemplo.sln
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
6 changes: 6 additions & 0 deletions CSharpDBExemplo/App.config
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>
65 changes: 65 additions & 0 deletions CSharpDBExemplo/CSharpDBExemplo.csproj
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>
57 changes: 57 additions & 0 deletions CSharpDBExemplo/ConnectionFactory.cs
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
}
}
}
}
54 changes: 54 additions & 0 deletions CSharpDBExemplo/Contato.cs
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;
}
}
}
25 changes: 25 additions & 0 deletions CSharpDBExemplo/ContatoDAO.cs
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);
}
}
Loading

0 comments on commit bdc3bd7

Please sign in to comment.