-
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.
Merge pull request #5 from cvchris/database
Database
- Loading branch information
Showing
39 changed files
with
6,179 additions
and
3,844 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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,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(); | ||
} | ||
} | ||
} |
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
8,726 changes: 5,667 additions & 3,059 deletions
8,726
ypologismosMorion.Android/Resources/Resource.designer.cs
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
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
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,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; | ||
} | ||
|
||
|
||
} | ||
} | ||
|
||
|
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,12 @@ | ||
using SQLite; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace ypologismosMorion.Interfaces | ||
{ | ||
public interface IDBInterface | ||
{ | ||
SQLiteConnection CreateConnection(); | ||
} | ||
} |
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 |
---|---|---|
|
@@ -126,6 +126,10 @@ void Result_Clicked(object sender, System.EventArgs e) | |
} | ||
|
||
} | ||
else | ||
{ | ||
exeieidiko = false; | ||
} | ||
|
||
} | ||
else | ||
|
Oops, something went wrong.