ArticulosDAO.kt
4.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
package com.focasoftware.deboinventariov20.DB.DAO
import androidx.room.Dao
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import com.focasoftware.deboinventariov20.DB.Constans.Constans.Companion.TABLA_ART
import com.focasoftware.deboinventariov20.DB.Constans.Constans.Companion.TABLA_INV_B
import com.focasoftware.deboinventariov20.DB.Constans.Constans.Companion.TABLA_INV_H
import com.focasoftware.deboinventariov20.DB.Constans.Constans.Companion.TABLA_SERV_INV
import com.focasoftware.deboinventariov20.Model.Articles
import com.focasoftware.deboinventariov20.Model.InvBody
import com.focasoftware.deboinventariov20.Model.InvHead
import com.focasoftware.deboinventariov20.Model.ServeInv
@Dao
interface ArticulosDAO {
// TABLA ARTICULOS
@Insert(onConflict = OnConflictStrategy.REPLACE)
suspend fun insertArticulos(articulos: Articles?)
@Query("SELECT * FROM $TABLA_ART ORDER BY DETART DESC")
suspend fun findAllArticulos(): List<Articles>
@Query("SELECT * FROM $TABLA_ART WHERE DEPSN=:dep AND DETART LIKE '%' || :description || '%' GROUP BY DETART ORDER BY DETART")
suspend fun findArticuloByDesc(description: String?, dep: Boolean): List<Articles>
@Query("SELECT * FROM $TABLA_ART WHERE DEPSN=:dep AND TRIM(CODBAR) = :codBarra")
suspend fun findArticuloByCodBar(codBarra: String, dep: Boolean): Articles
@Query("SELECT * FROM $TABLA_ART WHERE DEPSN=:dep AND TRIM(COO) LIKE :CodOrigen")
suspend fun findArticuloByCodOri(CodOrigen: String?, dep: Boolean): List<Articles>
@Query("DELETE FROM $TABLA_ART")
suspend fun deleteAllArticulos()
@Query("SELECT * FROM $TABLA_ART WHERE CODSEC=:sector AND CODART=:codigo")
suspend fun fetchArticuloByCodSec(sector: String?, codigo: String?): Articles?
}
@Dao
interface InvHeadDAO {
@Insert()
suspend fun insertInvHead(invHead: InvHead?)
@Query("SELECT INV_NUM FROM $TABLA_INV_H ORDER BY INV_NUM DESC")
suspend fun findLastInv(): Int
@Query("DELETE FROM $TABLA_INV_H")
suspend fun deleteAllArticulos()
@Query("DELETE FROM $TABLA_INV_H WHERE INV_NUM=:inven")
suspend fun deleteinvHead(inven: Int)
@Query("SELECT * FROM $TABLA_INV_H ORDER BY INV_FEI")
suspend fun fetchAllInvHead(): List<InvHead>
@Query("SELECT INV_LUG FROM $TABLA_INV_H WHERE INV_NUM=:inven")
suspend fun fetchAreaInvH (inven: Int): Boolean
@Query("SELECT INV_PRODCONT FROM $TABLA_INV_H WHERE INV_NUM=:inven")
suspend fun consultaCantidadInvH (inven: Int): Int
@Query("UPDATE $TABLA_INV_H SET INV_PRODCONT=:cant WHERE INV_NUM=:inven")
suspend fun updateInvBody(inven: Int,cant: Int)
}
@Dao
interface InvBodyDAO {
@Insert()
suspend fun insertInvBody(invBody: InvBody?)
@Query("DELETE FROM $TABLA_INV_B")
suspend fun deleteAllInvBody()
@Query("DELETE FROM $TABLA_INV_B WHERE INV_NUM =:inven")
suspend fun deleteInvBody(inven: Int)
@Query("UPDATE $TABLA_INV_B SET CANT=:cant WHERE SEC=:sec AND COD=:cod")
suspend fun UpdateInvBody(cant: Float, sec: String, cod: String)
@Query("SELECT * FROM $TABLA_INV_B WHERE INV_NUM =:inven ORDER BY INV_FEI DESC")
suspend fun fetchAllInvBody(inven: Int): List<InvBody>
@Query("SELECT * FROM $TABLA_INV_B WHERE INV_NUM =:numInventario AND SEC=:sector AND COD=:codigo")
suspend fun fetchArtInInvBody(sector: String, codigo: String, numInventario: String): InvBody
@Query("DELETE FROM $TABLA_INV_B WHERE INV_NUM =:numInventario AND SEC=:sector AND COD=:codigo")
suspend fun deleteItemFromInvBody(sector: String, codigo: String, numInventario: String): Int
}
@Dao
interface ServeInvDao {
@Insert(onConflict = OnConflictStrategy.REPLACE)
fun insertServer(servidor: ServeInv)
@Query("SELECT * FROM $TABLA_SERV_INV ORDER BY SER_NUM")
suspend fun fetchAllServers(): List<ServeInv>
@Query("DELETE FROM $TABLA_SERV_INV WHERE SER_DESC LIKE :description AND SER_DIR LIKE :dir")
suspend fun deleteServer(description: String, dir: String)
@Query("SELECT SER_NUM FROM $TABLA_SERV_INV ORDER BY SER_NUM DESC")
suspend fun findLastServer(): Int
@Query("UPDATE $TABLA_SERV_INV SET SER_PRE=0")
suspend fun UpdateServerPreInZero()
@Query("UPDATE $TABLA_SERV_INV SET SER_PRE=1 WHERE SER_NUM = :numero")
suspend fun UpdateServerPre(numero: Int)
@Query("SELECT * FROM $TABLA_SERV_INV WHERE SER_PRE= 1")
suspend fun fetchServerPreOne(): ServeInv
}