Skip to content

Commit

Permalink
Merge pull request #5 from cvchris/database
Browse files Browse the repository at this point in the history
Database
  • Loading branch information
cvchris committed Aug 30, 2019
2 parents 8d18a45 + d1f68c0 commit 34540b2
Show file tree
Hide file tree
Showing 39 changed files with 6,179 additions and 3,844 deletions.
Binary file added Data/Excel/2018/vaseis1.txt
Binary file not shown.
Binary file added Data/Excel/2018/vaseis1.xlsx
Binary file not shown.
Binary file added Data/Excel/2018/vaseis2.txt
Binary file not shown.
Binary file added Data/Excel/2018/vaseis2.xlsx
Binary file not shown.
Binary file added Data/Excel/2018/vaseis3.txt
Binary file not shown.
Binary file added Data/Excel/2018/vaseis3.xlsx
Binary file not shown.
Binary file added Data/Excel/2018/vaseis4.txt
Binary file not shown.
Binary file added Data/Excel/2018/vaseis4.xlsx
Binary file not shown.
Binary file added Data/Excel/vaseis1.xlsx
Binary file not shown.
Binary file added Data/Excel/vaseis2.xlsx
Binary file not shown.
Binary file added Data/Excel/vaseis3.xlsx
Binary file not shown.
Binary file added Data/Excel/vaseis4.xlsx
Binary file not shown.
Binary file added Data/txt/2019/vaseis1.txt
Binary file not shown.
Binary file added Data/txt/2019/vaseis2.txt
Binary file not shown.
Binary file added Data/txt/2019/vaseis3.txt
Binary file not shown.
Binary file added Data/txt/2019/vaseis4.txt
Binary file not shown.
Binary file added Data/vaseis.db
Binary file not shown.
Binary file added ypologismosMorion.Android/Assets/vaseis.db
Binary file not shown.
58 changes: 58 additions & 0 deletions ypologismosMorion.Android/DatabaseService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
using System;
using System.IO;
using Xamarin.Forms;
using ypologismosMorion.Droid;
using ypologismosMorion.Interfaces;

[assembly: Dependency(typeof(DatabaseService))]
namespace ypologismosMorion.Droid
{
public class DatabaseService : IDBInterface
{
public DatabaseService()
{
}

public SQLite.SQLiteConnection CreateConnection()
{
var sqliteFilename = "vaseis.db";
string documentsDirectoryPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
var path = Path.Combine(documentsDirectoryPath, sqliteFilename);

// This is where we copy in our pre-created database
if (!File.Exists(path))
{
using (var binaryReader = new BinaryReader(Android.App.Application.Context.Assets.Open(sqliteFilename)))
{
using (var binaryWriter = new BinaryWriter(new FileStream(path, FileMode.Create)))
{
byte[] buffer = new byte[2048];
int length = 0;
while ((length = binaryReader.Read(buffer, 0, buffer.Length)) > 0)
{
binaryWriter.Write(buffer, 0, length);
}
}
}
}
//var plat = new SQLite.Platform.XamarinAndroid.SQLitePlatformAndroid();
var conn = new SQLite.SQLiteConnection(path);

return conn;
}

void ReadWriteStream(Stream readStream, Stream writeStream)
{
int Length = 256;
Byte[] buffer = new Byte[Length];
int bytesRead = readStream.Read(buffer, 0, Length);
while (bytesRead >= 0)
{
writeStream.Write(buffer, 0, bytesRead);
bytesRead = readStream.Read(buffer, 0, Length);
}
readStream.Close();
writeStream.Close();
}
}
}
4 changes: 2 additions & 2 deletions ypologismosMorion.Android/Properties/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="1.5" package="com.chrisvamvalis.ypologismosMorion" android:installLocation="preferExternal" android:versionCode="6">
<uses-sdk android:minSdkVersion="19" android:targetSdkVersion="27" />
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="2.0" package="com.chrisvamvalis.ypologismosMorion" android:installLocation="preferExternal" android:versionCode="8">
<uses-sdk android:minSdkVersion="19" android:targetSdkVersion="28" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<application android:label="Υπολογισμός Μορίων" android:icon="@drawable/icon">
Expand Down
8,726 changes: 5,667 additions & 3,059 deletions ypologismosMorion.Android/Resources/Resource.designer.cs

Large diffs are not rendered by default.

15 changes: 12 additions & 3 deletions ypologismosMorion.Android/ypologismosMorion.Android.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix>
<MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix>
<AndroidUseLatestPlatformSdk>false</AndroidUseLatestPlatformSdk>
<TargetFrameworkVersion>v8.1</TargetFrameworkVersion>
<TargetFrameworkVersion>v9.0</TargetFrameworkVersion>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
Expand All @@ -33,6 +33,7 @@
<EnableLLVM>false</EnableLLVM>
<BundleAssemblies>false</BundleAssemblies>
<EnableProguard>false</EnableProguard>
<AndroidDexTool>d8</AndroidDexTool>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugSymbols>false</DebugSymbols>
Expand All @@ -48,8 +49,9 @@
<BundleAssemblies>false</BundleAssemblies>
<EmbedAssembliesIntoApk>true</EmbedAssembliesIntoApk>
<EnableProguard>false</EnableProguard>
<AndroidSupportedAbis>armeabi;armeabi-v7a;arm64-v8a</AndroidSupportedAbis>
<AndroidLinkMode>Full</AndroidLinkMode>
<AndroidSupportedAbis>arm64-v8a</AndroidSupportedAbis>
<AndroidLinkMode>None</AndroidLinkMode>
<MandroidI18n />
</PropertyGroup>
<ItemGroup>
<Reference Include="Mono.Android" />
Expand All @@ -62,6 +64,9 @@
<PackageReference Include="Plugin.StoreReview">
<Version>2.0.0.5</Version>
</PackageReference>
<PackageReference Include="sqlite-net-pcl">
<Version>1.5.231</Version>
</PackageReference>
<PackageReference Include="Xamarin.Build.Download">
<Version>0.4.11</Version>
</PackageReference>
Expand All @@ -78,13 +83,17 @@
<ItemGroup>
<Compile Include="AdBanner_Droid.cs" />
<Compile Include="AdInterstitial_Droid.cs" />
<Compile Include="DatabaseService.cs" />
<Compile Include="MainActivity.cs" />
<Compile Include="Resources\Resource.Designer.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SplashActivity.cs" />
<Compile Include="ypolEntryRenderer.cs" />
</ItemGroup>
<ItemGroup>
<AndroidAsset Include="Assets\vaseis.db">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</AndroidAsset>
<None Include="Resources\AboutResources.txt" />
<None Include="Assets\AboutAssets.txt" />
<None Include="Properties\AndroidManifest.xml">
Expand Down
3 changes: 3 additions & 0 deletions ypologismosMorion.iOS/ypologismosMorion.iOS.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,9 @@
<PackageReference Include="Plugin.StoreReview">
<Version>2.0.0.5</Version>
</PackageReference>
<PackageReference Include="sqlite-net-pcl">
<Version>1.5.231</Version>
</PackageReference>
<PackageReference Include="Xamarin.Build.Download">
<Version>0.4.11</Version>
</PackageReference>
Expand Down
5 changes: 3 additions & 2 deletions ypologismosMorion.sln
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27703.2035
# Visual Studio Version 16
VisualStudioVersion = 16.0.29209.62
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ypologismosMorion.Android", "ypologismosMorion.Android\ypologismosMorion.Android.csproj", "{9D057B70-E671-4F18-877C-C1A256A5F684}"
EndProject
Expand Down Expand Up @@ -47,6 +47,7 @@ Global
{9D057B70-E671-4F18-877C-C1A256A5F684}.Debug|iPhone.Build.0 = Debug|Any CPU
{9D057B70-E671-4F18-877C-C1A256A5F684}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{9D057B70-E671-4F18-877C-C1A256A5F684}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
{9D057B70-E671-4F18-877C-C1A256A5F684}.Debug|iPhoneSimulator.Deploy.0 = Debug|Any CPU
{9D057B70-E671-4F18-877C-C1A256A5F684}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9D057B70-E671-4F18-877C-C1A256A5F684}.Release|Any CPU.Build.0 = Release|Any CPU
{9D057B70-E671-4F18-877C-C1A256A5F684}.Release|Any CPU.Deploy.0 = Release|Any CPU
Expand Down
6 changes: 3 additions & 3 deletions ypologismosMorion/AboutPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
<StackLayout Orientation="Horizontal" Grid.Row="0" Margin="10,20">
<Image Source="icon.png" VerticalOptions="Center" HeightRequest="100" />

<Label Text="Πανελλήνιες 2019 - Υπολογισμός Μορίων" FontSize="Large" HorizontalOptions="Center" HorizontalTextAlignment="Center" VerticalOptions="Center" />
<Label Text="Πανελλήνιες 2020 - Υπολογισμός Μορίων" FontSize="Large" HorizontalOptions="Center" HorizontalTextAlignment="Center" VerticalOptions="Center" />


</StackLayout>
<Label Text="Version 1.5" FontSize="Small" HorizontalOptions="EndAndExpand" Margin="0,0,10,0"/>
<Label Text="Version 2.0" FontSize="Small" HorizontalOptions="EndAndExpand" Margin="0,0,10,0"/>
<ScrollView Grid.Row="1" Margin="0,0,5,0">
<StackLayout>
<StackLayout Margin="3,0">
<Label Text="Προγραμματιστής : Χρήστος Βάμβαλης"/>
<Label Text="Email επικοινωνίας για βελτιώσεις, bug report etc. "/>
<Label x:Name="mail" Text="cv.chris580@gmail.com" TextColor="Blue" HorizontalOptions="Center" Margin="0,10,0,0">
Expand Down
101 changes: 101 additions & 0 deletions ypologismosMorion/DatabaseManager.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
using System;
using ypologismosMorion.Models;
using SQLite;
using System.Collections.Generic;
using Xamarin.Forms;
using System.Linq;
using ypologismosMorion.Interfaces;

namespace ypologismosMorion
{
public class DatabaseManager
{
SQLiteConnection dbConnection;
public DatabaseManager()
{
dbConnection = DependencyService.Get<IDBInterface>().CreateConnection();
}

public List<VaseisDBnewWithPedio> GetAllVaseis(int etos)
{
var protopedio = dbConnection.Query<VaseisDBnewWithPedio>("Select * From [1opedio" + etos.ToString() + "]");
var deuteropedio = dbConnection.Query<VaseisDBnewWithPedio>("Select * From [2opedio" + etos.ToString() + "]");
var tritopedio = dbConnection.Query<VaseisDBnewWithPedio>("Select * From [3opedio" + etos.ToString() + "]");
var tetartopedio = dbConnection.Query<VaseisDBnewWithPedio>("Select * From [4opedio" + etos.ToString() + "]");

foreach(var item in protopedio)
{
item.Pedio = 1;
}
foreach (var item in deuteropedio)
{
item.Pedio = 2;
}
foreach (var item in tritopedio)
{
item.Pedio = 3;
}
foreach (var item in tetartopedio)
{
item.Pedio = 4;
}

var vaseis = new List<VaseisDBnewWithPedio>();
vaseis.AddRange(protopedio);
vaseis.AddRange(deuteropedio);
vaseis.AddRange(tritopedio);
vaseis.AddRange(tetartopedio);

var yy = vaseis.GroupBy(elem => elem.Mixanografiko).Select(group => group.First()).ToList();

var z = yy.OrderByDescending(x=> x.vasi).ToList();

return z;
}

public List<VaseisDBnewWithPedio> GetVaseis(int pedio, int etos = 2019)
{
var data = dbConnection.Query<VaseisDBnewWithPedio>("Select * From [" + pedio + "opedio" + etos.ToString() + "]");
foreach(var item in data)
{
item.Pedio = pedio;
}
return data;

}

public VaseisDBnew GetVasi(int kodikosMixanografikou, int pedio, int etos)
{

var query = "SELECT * FROM [" + pedio + "oPedio" + etos.ToString() + "] WHERE Mixanografiko =" + kodikosMixanografikou.ToString();
var aa = dbConnection.Query<VaseisDBnew>(query);
if(aa.Count > 0)
{
return aa[0];
}
else
{
return null;
}
}

public List<int> SePoiaPediaAnikei(int kodikosMixanografikou, int etos)
{
List<int> exists = new List<int>();
for(int i=1;i<5;i++)
{
var query = "SELECT * FROM [" + i.ToString() + "oPedio" + etos.ToString() + "] WHERE Mixanografiko =" + kodikosMixanografikou.ToString();
var e = dbConnection.Query<VaseisDBnew>(query);
if (e.Count > 0)
{
exists.Add(i);
}
}
return exists;
}


}
}


12 changes: 12 additions & 0 deletions ypologismosMorion/Interfaces/IDBInterface.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using SQLite;
using System;
using System.Collections.Generic;
using System.Text;

namespace ypologismosMorion.Interfaces
{
public interface IDBInterface
{
SQLiteConnection CreateConnection();
}
}
4 changes: 4 additions & 0 deletions ypologismosMorion/MainPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ void Result_Clicked(object sender, System.EventArgs e)
}

}
else
{
exeieidiko = false;
}

}
else
Expand Down
Loading

0 comments on commit 34540b2

Please sign in to comment.