Skip to content

Commit a98d358

Browse files
committed
C# app first commit
1 parent 62a3eb4 commit a98d358

File tree

95 files changed

+151751
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+151751
-0
lines changed

Escapade.sln

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 2012
4+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Escapade", "Escapade\Escapade.csproj", "{E81F3590-8EBD-48CE-A9EE-6E1F94FF9915}"
5+
EndProject
6+
Global
7+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
8+
Debug|x86 = Debug|x86
9+
Release|x86 = Release|x86
10+
EndGlobalSection
11+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
12+
{E81F3590-8EBD-48CE-A9EE-6E1F94FF9915}.Debug|x86.ActiveCfg = Debug|x86
13+
{E81F3590-8EBD-48CE-A9EE-6E1F94FF9915}.Debug|x86.Build.0 = Debug|x86
14+
{E81F3590-8EBD-48CE-A9EE-6E1F94FF9915}.Release|x86.ActiveCfg = Release|x86
15+
{E81F3590-8EBD-48CE-A9EE-6E1F94FF9915}.Release|x86.Build.0 = Release|x86
16+
EndGlobalSection
17+
EndGlobal

Escapade/Client.cs

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
using System;
2+
namespace Escapade
3+
{
4+
public class Client
5+
{
6+
string firstname;
7+
string lastname;
8+
string adress;
9+
string stay;
10+
int year;
11+
int week;
12+
13+
public Client(string firstname, string lastname, string adress, string stay, int year, int week)
14+
{
15+
this.firstname = firstname;
16+
this.lastname = lastname;
17+
this.adress = adress;
18+
this.stay = stay;
19+
this.year = year;
20+
this.week = week;
21+
}
22+
23+
public string Firstname
24+
{
25+
get { return firstname; }
26+
}
27+
public string Lastname
28+
{
29+
get { return lastname; }
30+
}
31+
public string Adress
32+
{
33+
get { return adress; }
34+
}
35+
public string Stay
36+
{
37+
get { return stay; }
38+
}
39+
public int Year
40+
{
41+
get { return year; }
42+
}
43+
public int Week
44+
{
45+
get { return week; }
46+
}
47+
}
48+
}

Escapade/Escapade.csproj

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5+
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
6+
<ProjectGuid>{E81F3590-8EBD-48CE-A9EE-6E1F94FF9915}</ProjectGuid>
7+
<OutputType>Exe</OutputType>
8+
<RootNamespace>Escapade</RootNamespace>
9+
<AssemblyName>Escapade</AssemblyName>
10+
<TargetFrameworkVersion>v4.7</TargetFrameworkVersion>
11+
</PropertyGroup>
12+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
13+
<DebugSymbols>true</DebugSymbols>
14+
<DebugType>full</DebugType>
15+
<Optimize>false</Optimize>
16+
<OutputPath>bin\Debug</OutputPath>
17+
<DefineConstants>DEBUG;</DefineConstants>
18+
<ErrorReport>prompt</ErrorReport>
19+
<WarningLevel>4</WarningLevel>
20+
<ExternalConsole>true</ExternalConsole>
21+
<PlatformTarget>x86</PlatformTarget>
22+
</PropertyGroup>
23+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
24+
<Optimize>true</Optimize>
25+
<OutputPath>bin\Release</OutputPath>
26+
<ErrorReport>prompt</ErrorReport>
27+
<WarningLevel>4</WarningLevel>
28+
<ExternalConsole>true</ExternalConsole>
29+
<PlatformTarget>x86</PlatformTarget>
30+
</PropertyGroup>
31+
<ItemGroup>
32+
<Reference Include="System" />
33+
<Reference Include="Google.Protobuf">
34+
<HintPath>..\packages\Google.Protobuf.3.5.1\lib\net45\Google.Protobuf.dll</HintPath>
35+
</Reference>
36+
<Reference Include="MySql.Data">
37+
<HintPath>..\packages\MySql.Data.8.0.11\lib\net452\MySql.Data.dll</HintPath>
38+
</Reference>
39+
<Reference Include="Microsoft.CSharp" />
40+
<Reference Include="System.ComponentModel" />
41+
<Reference Include="System.ComponentModel.DataAnnotations" />
42+
<Reference Include="System.Configuration" />
43+
<Reference Include="System.Configuration.Install" />
44+
<Reference Include="System.Data" />
45+
<Reference Include="System.Drawing" />
46+
<Reference Include="System.Drawing.Design" />
47+
<Reference Include="System.Management" />
48+
<Reference Include="System.Transactions" />
49+
<Reference Include="System.Xml" />
50+
<Reference Include="System.Linq">
51+
<HintPath>..\packages\System.Linq.4.3.0\lib\net463\System.Linq.dll</HintPath>
52+
</Reference>
53+
<Reference Include="mscorlib" />
54+
<Reference Include="System.Core" />
55+
</ItemGroup>
56+
<ItemGroup>
57+
<Compile Include="Program.cs" />
58+
<Compile Include="Properties\AssemblyInfo.cs" />
59+
<Compile Include="Client.cs" />
60+
</ItemGroup>
61+
<ItemGroup>
62+
<None Include="packages.config" />
63+
</ItemGroup>
64+
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
65+
</Project>

Escapade/Program.cs

+103
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Data;
5+
using MySql.Data.MySqlClient;
6+
using System.Text;
7+
using System.Threading.Tasks;
8+
using System.Xml;
9+
using System.Xml.XPath;
10+
using System.IO;
11+
using System.Xml.Serialization;
12+
13+
namespace Escapade
14+
{
15+
class MainClass
16+
{
17+
18+
public static void Main(string[] args)
19+
{
20+
try
21+
{
22+
Client demonstration = new Client("Goku", "Son", "ESILV, La defense", "visite de la défense", 2018, 14);
23+
string connexionString = "SERVER=localhost;PORT=3306;DATABASE= escapade;UID=escapade;PASSWORD=esilv;SslMode=none";
24+
MySqlConnection connexion = new MySqlConnection(connexionString);
25+
Demo1(demonstration);
26+
connexion.Open();
27+
string [] queryResult = Query_mysql_server(connexion, "select count(id) from client where firstname ='" + demonstration.Firstname + "' and lastname ='" + demonstration.Lastname + "';");
28+
int result = int.Parse(queryResult[0]);
29+
connexion.Close();
30+
if(result == 0)
31+
{
32+
connexion.Open();
33+
queryResult = Query_mysql_server(connexion, "");
34+
connexion.Close();
35+
}
36+
else if(result == 1)
37+
{
38+
connexion.Open();
39+
queryResult = Query_mysql_server(connexion, "select id from client where firstname ='" + demonstration.Firstname + "' and lastname ='" + demonstration.Lastname + "';");
40+
int id_client = int.Parse(queryResult[0]);
41+
connexion.Close();
42+
Console.WriteLine("Succès, votre identifiant client est : " + id_client);
43+
}
44+
}
45+
catch(MySqlException ex)
46+
{
47+
Console.WriteLine("Error :" + ex.ToString());
48+
}
49+
}
50+
public static void Demo1(Client c)
51+
{
52+
Console.WriteLine("Bienvenue à l'agence de voyage Escapade !\n");
53+
Console.WriteLine("\nVeuillez indiquer votre nom :\n");
54+
TypeLine(c.Firstname + ' ' + c.Lastname);
55+
Console.WriteLine("\n\nExcellent, maintenant votre adresse :\n");
56+
TypeLine(c.Adress);
57+
Console.WriteLine("\n\nParfait, veuillez à présent préciser le thème de votre séjour :\n");
58+
TypeLine(c.Stay);
59+
Console.WriteLine("\n\nPresque fini, quelles sont vos dates ?\n");
60+
TypeLine("Semaine " + c.Week + ", Année " + c.Year);
61+
Console.WriteLine("\nNous interrogeons notre base de donnée...");
62+
System.Threading.Thread.Sleep(1500);
63+
}
64+
public static string[] Query_mysql_server(MySqlConnection connexion, string query)
65+
{
66+
MySqlCommand command = connexion.CreateCommand();
67+
command.CommandText = query; // exemple de requete bien-sur !
68+
69+
MySqlDataReader reader;
70+
reader = command.ExecuteReader();
71+
string[] toReturn = new string[reader.FieldCount];
72+
int individu = 0;
73+
while (reader.Read()) // parcours ligne par ligne
74+
{
75+
string currentRowAsString = "";
76+
for (int i = 0; i < reader.FieldCount; i++) // parcours cellule par cellule
77+
{
78+
string valueAsString = reader.GetValue(i).ToString(); // recuperation de la valeur de chaque cellule sous forme d'une string (voir cependant les differentes methodes disponibles !!)
79+
if (i < reader.FieldCount - 1)
80+
{
81+
currentRowAsString += valueAsString + ", ";
82+
}
83+
else
84+
{
85+
currentRowAsString += valueAsString;
86+
}
87+
}
88+
toReturn[individu] = currentRowAsString;
89+
individu++;
90+
}
91+
return toReturn;
92+
}
93+
public static void TypeLine(string line)
94+
{
95+
System.Threading.Thread.Sleep(1500);
96+
for (int i = 0; i < line.Length; i++)
97+
{
98+
Console.Write(line[i]);
99+
System.Threading.Thread.Sleep(150); // Sleep for 150 milliseconds
100+
}
101+
}
102+
}
103+
}

Escapade/Properties/AssemblyInfo.cs

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
4+
// Information about this assembly is defined by the following attributes.
5+
// Change them to the values specific to your project.
6+
7+
[assembly: AssemblyTitle("Escapade")]
8+
[assembly: AssemblyDescription("")]
9+
[assembly: AssemblyConfiguration("")]
10+
[assembly: AssemblyCompany("")]
11+
[assembly: AssemblyProduct("")]
12+
[assembly: AssemblyCopyright("${AuthorCopyright}")]
13+
[assembly: AssemblyTrademark("")]
14+
[assembly: AssemblyCulture("")]
15+
16+
// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
17+
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
18+
// and "{Major}.{Minor}.{Build}.*" will update just the revision.
19+
20+
[assembly: AssemblyVersion("1.0.*")]
21+
22+
// The following attributes are used to specify the signing key for the assembly,
23+
// if desired. See the Mono documentation for more information about signing.
24+
25+
//[assembly: AssemblyDelaySign(false)]
26+
//[assembly: AssemblyKeyFile("")]

Escapade/bin/Debug/Escapade.exe

8 KB
Binary file not shown.

Escapade/bin/Debug/Escapade.pdb

1.92 KB
Binary file not shown.
288 KB
Binary file not shown.

0 commit comments

Comments
 (0)