-
Notifications
You must be signed in to change notification settings - Fork 2
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 #61 from AliMatias/combine-molecule
Combine molecule
- Loading branch information
Showing
12 changed files
with
245 additions
and
24 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 |
---|---|---|
@@ -1,20 +1,20 @@ | ||
INSERT INTO materiales_mapping_element (id_material,id_elemento,id_molecula,cantidad) VALUES ( | ||
1,NULL,1,1); | ||
1,0,1,2); | ||
INSERT INTO materiales_mapping_element (id_material,id_elemento,id_molecula,cantidad) VALUES ( | ||
2,NULL,31,1); | ||
2,0,31,2); | ||
INSERT INTO materiales_mapping_element (id_material,id_elemento,id_molecula,cantidad) VALUES ( | ||
3,NULL,22,1); | ||
3,0,22,2); | ||
INSERT INTO materiales_mapping_element (id_material,id_elemento,id_molecula,cantidad) VALUES ( | ||
4,NULL,44,1); | ||
4,0,44,2); | ||
INSERT INTO materiales_mapping_element (id_material,id_elemento,id_molecula,cantidad) VALUES ( | ||
5,NULL,27,1); | ||
5,0,27,2); | ||
INSERT INTO materiales_mapping_element (id_material,id_elemento,id_molecula,cantidad) VALUES ( | ||
6,NULL,30,1); | ||
6,0,30,2); | ||
INSERT INTO materiales_mapping_element (id_material,id_elemento,id_molecula,cantidad) VALUES ( | ||
7,NULL,2,1); | ||
7,0,2,2); | ||
INSERT INTO materiales_mapping_element (id_material,id_elemento,id_molecula,cantidad) VALUES ( | ||
8,6,NULL,1); | ||
8,6,0,2); | ||
INSERT INTO materiales_mapping_element (id_material,id_elemento,id_molecula,cantidad) VALUES ( | ||
9,6,NULL,1); | ||
9,6,0,2); | ||
INSERT INTO materiales_mapping_element (id_material,id_elemento,id_molecula,cantidad) VALUES ( | ||
10,NULL,7,1); | ||
10,0,7,2); |
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
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,14 @@ | ||
public class MaterialData{ | ||
|
||
private int id; | ||
private string name; | ||
|
||
public int Id { get => id; set => id = value; } | ||
public string Name { get => name; set => name = value; } | ||
|
||
public MaterialData(int id, string name) | ||
{ | ||
this.id = id; | ||
this.name = name; | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
New Unity Project/Assets/Scripts/Model/MaterialData.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
20 changes: 20 additions & 0 deletions
20
New Unity Project/Assets/Scripts/Model/MaterialMappingData.cs
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,20 @@ | ||
public class MaterialMappingData{ | ||
|
||
private int idMaterial; | ||
private int idElement; | ||
private int idMolecule; | ||
private int amount; | ||
|
||
public int IdMaterial { get => idMaterial; set => idMaterial = value; } | ||
public int IdElement { get => idElement; set => idElement = value; } | ||
public int IdMolecule { get => idMolecule; set => idMolecule = value; } | ||
public int Amount { get => amount; set => amount = value; } | ||
|
||
public MaterialMappingData(int idMaterial, int idElement, int idMolecule, int amount) | ||
{ | ||
this.idMaterial = idMaterial; | ||
this.idElement = idElement; | ||
this.idMolecule = idMolecule; | ||
this.amount = amount; | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
New Unity Project/Assets/Scripts/Model/MaterialMappingData.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
using Mono.Data.Sqlite; | ||
using System; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
|
||
public class QryMaterials : MonoBehaviour | ||
{ | ||
private DBManager dBManager = null; | ||
|
||
private void Awake() | ||
{ | ||
dBManager = FindObjectOfType<DBManager>(); | ||
} | ||
|
||
#region Metodos Exec Querys & Management | ||
|
||
public MaterialMappingData GetMaterialByMoleculeId(int moleculeId){ | ||
MaterialMappingData result = null; | ||
//dejo un reader local para cada query, no siendo global | ||
SqliteDataReader reader = null; | ||
SqliteConnection dbConnection = null; | ||
|
||
try{ | ||
string sqlQuery = "SELECT * FROM materiales_mapping_element WHERE id_molecula=" + moleculeId; | ||
//LLAMADA AL METODO DE LA DBMANAGER | ||
dbConnection = dBManager.openCon(); | ||
reader = dBManager.ManageExec(dbConnection, sqlQuery); | ||
while (reader.Read()) | ||
{ | ||
int idMat = reader.GetInt32(0); | ||
int idElem = reader.GetInt32(1); | ||
int idMol = reader.GetInt32(2); | ||
int amount = reader.GetInt32(3); | ||
|
||
result = new MaterialMappingData(idMat, idElem, idMol, amount); | ||
} | ||
} | ||
catch (Exception e) | ||
{ | ||
throw e; | ||
} | ||
finally | ||
{ | ||
dBManager.ManageClosing(dbConnection, reader); | ||
} | ||
return result; | ||
} | ||
|
||
public MaterialData GetMaterialById(int materialId){ | ||
MaterialData data = null; | ||
//dejo un reader local para cada query, no siendo global | ||
SqliteDataReader reader = null; | ||
SqliteConnection dbConnection = null; | ||
try{ | ||
string sqlQuery = "SELECT * FROM materiales_lista WHERE id=" + materialId; | ||
//LLAMADA AL METODO DE LA DBMANAGER | ||
dbConnection = dBManager.openCon(); | ||
reader = dBManager.ManageExec(dbConnection, sqlQuery); | ||
while (reader.Read()) | ||
{ | ||
int idMat = reader.GetInt32(0); | ||
string name = reader.GetString(1); | ||
|
||
data = new MaterialData(idMat, name); | ||
} | ||
} | ||
catch (Exception e) | ||
{ | ||
throw e; | ||
} | ||
finally | ||
{ | ||
dBManager.ManageClosing(dbConnection, reader); | ||
} | ||
return data; | ||
} | ||
|
||
#endregion | ||
} |
11 changes: 11 additions & 0 deletions
11
New Unity Project/Assets/Scripts/Querys/QryMaterials.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.