· 5 years ago · Nov 16, 2020, 02:26 PM
1import * as SQLite from "expo-sqlite";
2const db = SQLite.openDatabase("db.GPLOG");
3
4const TAG_TABLENAME_RECEPCION_SER = "LM_RECEPCIONSER1";
5
6export function createTables() {
7 db.transaction((tx) => {
8 tx.executeSql(
9 "CREATE TABLE IF NOT EXISTS " +
10 TAG_TABLENAME_RECEPCION_SER +
11 " (RecepSerId INTEGER PRIMARY KEY AUTOINCREMENT," +
12 "RecepDetId INT," +
13 "RecepcionId INT," +
14 "EmpID INT," +
15 "CodigoArticulo TEXT," +
16 "Serie TEXT," +
17 "Cantidad INT," +
18 "Foto1 TEXT," +
19 "Foto2 TEXT," +
20 "Foto3 TEXT"
21 );
22 });
23}
24
25export function datosTest() {
26 insertRECEPCIONSER(1, 1, 10, "CODE001", "Serie 1", 100, "Foto 1", "Foto 2", "Foto 3");
27}
28
29function insertRECEPCIONSER(RecepDetId, RecepcionId, EmpID, CodigoArticulo, Serie, Cantidad, Foto1, Foto2, Foto3) {
30 const query =
31 "INSERT INTO " + TAG_TABLENAME_RECEPCION_SER +
32 " (RecepDetId, RecepcionId, EmpID, CodigoArticulo, Serie, Cantidad, Foto1, Foto2, Foto3) values (?, ?, ?, ?, ?, ?, ?, ?, ?)";
33 const params = [RecepDetId, RecepcionId, EmpID, CodigoArticulo, Serie, Cantidad, Foto1, Foto2, Foto3];
34 db.transaction((tx) => {
35 tx.executeSql(
36 query,
37 params,
38 (txObj, resultSet) => {
39 console.log(`RECEPCIONSER ${resultSet.insertId} INSERTADO`);
40 },
41 (txObj, error) => console.log("Error", error)
42 );
43 });
44}