Commit d60eae7d0b1c4be1ca69d245878efacb0249cc9d
1 parent
c8fab9ae77
Exists in
master
21052020 0205
Showing
7 changed files
with
90 additions
and
76 deletions
Show diff stats
.idea/vcs.xml
app/src/main/java/com/focasoftware/deboinventariov20/DB/DAO/ArticulosDAO.kt
| ... | ... | @@ -16,7 +16,7 @@ interface ArticulosDAO { |
| 16 | 16 | @Query("SELECT * FROM $TABLA_ART ORDER BY DES DESC") |
| 17 | 17 | suspend fun findAllArticulos(): List<Articles> |
| 18 | 18 | |
| 19 | - @Query("SELECT * FROM $TABLA_ART WHERE DEPSN=:dep AND DES LIKE '%' || :description || '%'") | |
| 19 | + @Query("SELECT * FROM $TABLA_ART WHERE DEPSN=:dep AND DES LIKE '%' || :description || '%' GROUP BY DES ORDER BY SEC, COD") | |
| 20 | 20 | suspend fun findArticuloByDesc(description: String?, dep: Int): List<Articles> |
| 21 | 21 | |
| 22 | 22 | @Query("SELECT * FROM $TABLA_ART WHERE DEPSN=:dep AND CB LIKE :codBarra") |
app/src/main/java/com/focasoftware/deboinventariov20/ui/inventario/DescripcionFragment.kt
| ... | ... | @@ -62,7 +62,7 @@ class DescripcionFragment : Fragment() { |
| 62 | 62 | IngresarRecicler(artAcargar2) |
| 63 | 63 | |
| 64 | 64 | btnSalir.setOnClickListener { |
| 65 | - requireActivity().onBackPressed() | |
| 65 | + VolverAinventario() | |
| 66 | 66 | } |
| 67 | 67 | return v |
| 68 | 68 | } |
| ... | ... | @@ -110,11 +110,7 @@ class DescripcionFragment : Fragment() { |
| 110 | 110 | InventarioFragment().ObtenerFechaActual(), |
| 111 | 111 | InventarioFragment().ObtenerFechaActual()) |
| 112 | 112 | InsertarArtEnDB(body)// TODO: MANDO A CARGAR A LA BASE DE DATOS |
| 113 | - val editor = sharedPreferences.edit() | |
| 114 | - editor?.putString("Inventario", numeroInventario.toString()) | |
| 115 | - editor?.apply() | |
| 116 | - editor.commit() | |
| 117 | - navController.navigate(R.id.action_descripcionFragment_to_inventarioFragment) | |
| 113 | + VolverAinventario() | |
| 118 | 114 | } |
| 119 | 115 | }.cancelOnTouchOutside(false).cornerRadius(10F) |
| 120 | 116 | } |
| ... | ... | @@ -148,5 +144,13 @@ class DescripcionFragment : Fragment() { |
| 148 | 144 | } |
| 149 | 145 | } |
| 150 | 146 | } |
| 147 | + fun VolverAinventario(){ | |
| 148 | + | |
| 149 | + val editor = sharedPreferences.edit() | |
| 150 | + editor?.putString("Inventario", numeroInventario.toString()) | |
| 151 | + editor?.apply() | |
| 152 | + editor.commit() | |
| 153 | + navController.navigate(R.id.action_descripcionFragment_to_inventarioFragment) | |
| 154 | + } | |
| 151 | 155 | } |
| 152 | 156 |
app/src/main/java/com/focasoftware/deboinventariov20/ui/inventario/InventarioFragment.kt
| ... | ... | @@ -10,7 +10,10 @@ import android.view.KeyEvent |
| 10 | 10 | import android.view.LayoutInflater |
| 11 | 11 | import android.view.View |
| 12 | 12 | import android.view.ViewGroup |
| 13 | -import android.widget.* | |
| 13 | +import android.widget.EditText | |
| 14 | +import android.widget.TextView | |
| 15 | +import android.widget.Toast | |
| 16 | +import android.widget.ToggleButton | |
| 14 | 17 | import androidx.core.content.ContextCompat |
| 15 | 18 | import androidx.core.os.bundleOf |
| 16 | 19 | import androidx.fragment.app.Fragment |
| ... | ... | @@ -76,9 +79,9 @@ class InventarioFragment : Fragment() { |
| 76 | 79 | if (InventarioNuevo == 0) {// TODO: SI INVETNARIO NUEVO |
| 77 | 80 | GlobalScope.launch(Dispatchers.Main) { |
| 78 | 81 | //TODO: BUSCO EL ULTIMO INVENTARIO EN LA BD PARA PODER CREAR EL PROXIMO |
| 79 | - InventarioNuevo = AppDb.getAppDb(requireActivity())!!.InvHeadDAO()!!.findLastInv() + 1 | |
| 82 | + InventarioNuevo = AppDb.getAppDb(requireActivity())?.InvHeadDAO()?.findLastInv()?.plus(1) ?: 1 | |
| 80 | 83 | SerchArea() |
| 81 | - val descripInv: String = if (iArea == 0) "Inventario Ventas" else "Inventario Deposito" | |
| 84 | + val descripInv: String = if (iArea == 0) "Ventas" else "Deposito" | |
| 82 | 85 | //TODO: CREAMOS EL INVENTARIO EN LA CABECERA DEL INVENTARIO |
| 83 | 86 | invHead = InvHead(InventarioNuevo, descripInv, 1, ObtenerFechaActual(), ObtenerFechaActual(), 0L, iArea, AjusteProductos(), ProdNoCont()) |
| 84 | 87 | AppDb.getAppDb(requireActivity())!!.InvHeadDAO()!!.insertInvHead(invHead) |
| ... | ... | @@ -159,40 +162,41 @@ class InventarioFragment : Fragment() { |
| 159 | 162 | return@setOnKeyListener true |
| 160 | 163 | |
| 161 | 164 | |
| 162 | - } else {//TODO BUSQUEDA POR DESCRIPCION************************************************************************** | |
| 163 | - | |
| 164 | - indiceDelArtEncontrado = buscoArtEnRv(sChangeUpper.toUpperCase(Locale.ROOT), 1) //TODO :Si encuentra el articulo en el RV devuelve el indice | |
| 165 | - //TODO Si no lo encuentra devuelve -1 | |
| 166 | - if (indiceDelArtEncontrado != -1) { | |
| 167 | -// if (swSumaUno!!.isChecked) { | |
| 168 | -// fCant = 0F | |
| 169 | -// fCant = listArticulos[indiceDelArtEncontrado].cantTomada | |
| 170 | -// fCant += 1F | |
| 171 | -// listArticulos[indiceDelArtEncontrado].cantTomada = fCant | |
| 172 | -// viewAdapter.notifyDataSetChanged() | |
| 173 | -// } else { | |
| 174 | - fCant = listArticulos[indiceDelArtEncontrado].cantTomada | |
| 175 | - MaterialDialog(requireContext()).show { | |
| 176 | - title(R.string.sTituloNueva) | |
| 177 | - message(R.string.sCantidadNueva) | |
| 178 | - input { materialDialog, charSequence -> | |
| 179 | - fCant = 0F | |
| 180 | - fCant = charSequence.toString().toFloat() | |
| 181 | - } | |
| 182 | - positiveButton(R.string.btnOk) { | |
| 183 | - listArticulos[indiceDelArtEncontrado].cantTomada = fCant | |
| 184 | - viewAdapter.notifyDataSetChanged() | |
| 185 | - dismiss() | |
| 186 | - } | |
| 187 | - }.cancelOnTouchOutside(false).cornerRadius(10F) | |
| 188 | -// } | |
| 189 | - | |
| 190 | - } else if (indiceDelArtEncontrado == -1) {// TODO: no lo encontro en el RV, lo va a buscar en al BD | |
| 165 | + } else {//TODO: BUSQUEDA POR DESCRIPCION************************************************************************** | |
| 166 | +// | |
| 167 | +// indiceDelArtEncontrado = buscoArtEnRv(sChangeUpper.toUpperCase(Locale.ROOT), 1) //TODO :Si encuentra el articulo en el RV devuelve el indice | |
| 168 | +// //TODO Si no lo encuentra devuelve -1 | |
| 169 | +// if (indiceDelArtEncontrado != -1) { | |
| 170 | +//// if (swSumaUno!!.isChecked) { | |
| 171 | +//// fCant = 0F | |
| 172 | +//// fCant = listArticulos[indiceDelArtEncontrado].cantTomada | |
| 173 | +//// fCant += 1F | |
| 174 | +//// listArticulos[indiceDelArtEncontrado].cantTomada = fCant | |
| 175 | +//// viewAdapter.notifyDataSetChanged() | |
| 176 | +//// } else { | |
| 177 | +// fCant = listArticulos[indiceDelArtEncontrado].cantTomada | |
| 178 | +// MaterialDialog(requireContext()).show { | |
| 179 | +// title(R.string.sTituloNueva) | |
| 180 | +// message(R.string.sCantidadNueva) | |
| 181 | +// input { materialDialog, charSequence -> | |
| 182 | +// fCant = 0F | |
| 183 | +// fCant = charSequence.toString().toFloat() | |
| 184 | +// } | |
| 185 | +// positiveButton(R.string.btnOk) { | |
| 186 | +// listArticulos[indiceDelArtEncontrado].cantTomada = fCant | |
| 187 | +// viewAdapter.notifyDataSetChanged() | |
| 188 | +// dismiss() | |
| 189 | +// } | |
| 190 | +// }.cancelOnTouchOutside(false).cornerRadius(10F) | |
| 191 | +//// } | |
| 192 | +// | |
| 193 | +// } else if | |
| 194 | +// (indiceDelArtEncontrado == -1) {// TODO: no lo encontro en el RV, lo va a buscar en al BD | |
| 191 | 195 | GlobalScope.launch(Dispatchers.Main) { |
| 192 | 196 | val artEncontrado = buscarDescEnBD(sChangeUpper.toUpperCase(Locale.ROOT)) |
| 193 | 197 | ContinuarCargaDesc(artEncontrado as ArrayList<Articles>) |
| 194 | 198 | } |
| 195 | - } | |
| 199 | +// } | |
| 196 | 200 | tCodigoBarras.focusable = View.FOCUSABLE |
| 197 | 201 | tCodigoBarras.setText("") |
| 198 | 202 | tCodigoBarras.selectAll() |
| ... | ... | @@ -226,22 +230,22 @@ class InventarioFragment : Fragment() { |
| 226 | 230 | }.cancelOnTouchOutside(false).cornerRadius(10F) |
| 227 | 231 | } |
| 228 | 232 | |
| 229 | - btnExportarInv.setOnClickListener { | |
| 230 | - MaterialDialog(requireContext()).show { | |
| 231 | - title(R.string.sTituloExportar) | |
| 232 | - message(R.string.sMensajeExportar) | |
| 233 | - positiveButton(R.string.btnOk) { | |
| 234 | - BorrarInvActual() | |
| 235 | - Toast.makeText(requireContext(), "El inventario $InventarioNuevo fue Exportado al Servidor", Toast.LENGTH_LONG).show() | |
| 236 | - navController.navigate(R.id.action_inventarioFragment_to_mainFragment2) | |
| 237 | - InventarioNuevo = 0 | |
| 238 | - dismiss() | |
| 239 | - } | |
| 240 | - negativeButton { | |
| 241 | - dismiss() | |
| 242 | - } | |
| 243 | - }.cancelOnTouchOutside(false).cornerRadius(10F) | |
| 244 | - } | |
| 233 | + btnExportarInv.setOnClickListener { | |
| 234 | + MaterialDialog(requireContext()).show { | |
| 235 | + title(R.string.sTituloExportar) | |
| 236 | + message(R.string.sMensajeExportar) | |
| 237 | + positiveButton(R.string.btnOk) { | |
| 238 | + BorrarInvActual() | |
| 239 | + Toast.makeText(requireContext(), "El inventario $InventarioNuevo fue Exportado al Servidor", Toast.LENGTH_LONG).show() | |
| 240 | + navController.navigate(R.id.action_inventarioFragment_to_mainFragment2) | |
| 241 | + InventarioNuevo = 0 | |
| 242 | + dismiss() | |
| 243 | + } | |
| 244 | + negativeButton { | |
| 245 | + dismiss() | |
| 246 | + } | |
| 247 | + }.cancelOnTouchOutside(false).cornerRadius(10F) | |
| 248 | + } | |
| 245 | 249 | } |
| 246 | 250 | |
| 247 | 251 | private fun BorrarInvActual() { |
| ... | ... | @@ -346,7 +350,7 @@ class InventarioFragment : Fragment() { |
| 346 | 350 | positiveButton(R.string.btnOk) { |
| 347 | 351 | dismiss() |
| 348 | 352 | } |
| 349 | - }.cancelOnTouchOutside(false).cornerRadius(10F) | |
| 353 | + }.cornerRadius(10F) | |
| 350 | 354 | } |
| 351 | 355 | |
| 352 | 356 | } |
| ... | ... | @@ -387,7 +391,7 @@ class InventarioFragment : Fragment() { |
| 387 | 391 | // } |
| 388 | 392 | dismiss() |
| 389 | 393 | } |
| 390 | - }.cancelOnTouchOutside(false).cornerRadius(10F) | |
| 394 | + }.cornerRadius(10F) | |
| 391 | 395 | } |
| 392 | 396 | } |
| 393 | 397 | |
| ... | ... | @@ -457,7 +461,7 @@ class InventarioFragment : Fragment() { |
| 457 | 461 | listArticulos.add(item) |
| 458 | 462 | |
| 459 | 463 | viewAdapter = ProductosListAdapter(listArticulos) |
| 460 | - viewManager =LinearLayoutManager(requireContext()) | |
| 464 | + viewManager = LinearLayoutManager(requireContext()) | |
| 461 | 465 | deleteIcon = ContextCompat.getDrawable(requireContext(), R.drawable.borrar)!! |
| 462 | 466 | rcInventarios.apply { |
| 463 | 467 | adapter = viewAdapter |
| ... | ... | @@ -482,7 +486,7 @@ class InventarioFragment : Fragment() { |
| 482 | 486 | |
| 483 | 487 | if (dX < c.width / 2) c.drawColor(Color.GREEN) |
| 484 | 488 | else c.drawColor(Color.RED) |
| 485 | - deleteIcon.setBounds(itemView.left + iconMargin, itemView.top + iconMargin, itemView.left + iconMargin + deleteIcon.intrinsicWidth, itemView.bottom-iconMargin) | |
| 489 | + deleteIcon.setBounds(itemView.left + iconMargin, itemView.top + iconMargin, itemView.left + iconMargin + deleteIcon.intrinsicWidth, itemView.bottom - iconMargin) | |
| 486 | 490 | } else { |
| 487 | 491 | |
| 488 | 492 | } |
| ... | ... | @@ -519,7 +523,7 @@ class InventarioFragment : Fragment() { |
| 519 | 523 | fun ObtenerFechaActual(): String? { |
| 520 | 524 | //TODO OBTENGO FECHA Y HORA ACTUAL PARA LA CABECERA DEL INVENTARIO Y PARA CADA ITEM QUE SE INSERTA EN LA BD |
| 521 | 525 | val current = LocalDateTime.now() |
| 522 | - val formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss") | |
| 526 | + val formatter = DateTimeFormatter.ofPattern("dd/MM/yyyy hh:mm:ss") | |
| 523 | 527 | val dFechaHora = current.format(formatter) |
| 524 | 528 | return dFechaHora.toString() |
| 525 | 529 | } |
app/src/main/java/com/focasoftware/deboinventariov20/ui/main/MainFragment.kt
| ... | ... | @@ -6,7 +6,6 @@ import android.os.Bundle |
| 6 | 6 | import android.view.LayoutInflater |
| 7 | 7 | import android.view.View |
| 8 | 8 | import android.view.ViewGroup |
| 9 | -import androidx.core.view.get | |
| 10 | 9 | import androidx.fragment.app.Fragment |
| 11 | 10 | import androidx.navigation.NavController |
| 12 | 11 | import androidx.navigation.Navigation |
| ... | ... | @@ -68,10 +67,10 @@ class MainFragment : Fragment(), InventarioListAdapter.OnItemClickListener { |
| 68 | 67 | } |
| 69 | 68 | |
| 70 | 69 | fun cargarRecicler(inv: InvHead) { |
| 71 | - var numero="" | |
| 72 | 70 | //TODO CARGO EN LE RV |
| 73 | - if (inv.invNum.toLong()<10) numero="0${inv.invNum.toLong()}" else numero=inv.invNum.toString() | |
| 74 | - val item = ItemInventario("Inventeario: ${numero} ${inv.descripcion} Fecha:${inv.fechaFinal} ") | |
| 71 | + | |
| 72 | + val number = if (inv.invNum.toLong()<10) "0${inv.invNum.toLong()}" else inv.invNum.toString() | |
| 73 | + val item = ItemInventario("Nยฐ $number ${inv.descripcion}. Fecha: ${inv.fechaFinal}") | |
| 75 | 74 | //(articulos.sector, articulos.codigo, articulos.descripcion, cant, articulos.codBar) |
| 76 | 75 | listIvn.add(item) |
| 77 | 76 |
app/src/main/res/layout/fragment_servidores.xml
| ... | ... | @@ -76,7 +76,7 @@ |
| 76 | 76 | android:focusable="true" |
| 77 | 77 | android:inputType="text" |
| 78 | 78 | android:lines="1" |
| 79 | - android:text="" | |
| 79 | + android:hint="Servidor Local" | |
| 80 | 80 | android:textSize="15sp" |
| 81 | 81 | app:layout_constraintBottom_toTopOf="@id/guideline3" |
| 82 | 82 | app:layout_constraintEnd_toEndOf="parent" |
| ... | ... | @@ -95,7 +95,8 @@ |
| 95 | 95 | android:focusable="true" |
| 96 | 96 | android:inputType="text" |
| 97 | 97 | android:lines="1" |
| 98 | - android:text="" | |
| 98 | + | |
| 99 | + android:hint="192.168.10.1:9090" | |
| 99 | 100 | android:textSize="15sp" |
| 100 | 101 | app:layout_constraintBottom_toTopOf="@id/guideline4" |
| 101 | 102 | app:layout_constraintEnd_toEndOf="parent" |
app/src/main/res/layout/login_dialog.xml
| ... | ... | @@ -56,6 +56,7 @@ |
| 56 | 56 | android:layout_width="wrap_content" |
| 57 | 57 | android:layout_height="wrap_content" |
| 58 | 58 | android:layout_margin="5dp" |
| 59 | + android:visibility="gone" | |
| 59 | 60 | android:gravity="center" |
| 60 | 61 | android:text="@string/tvSeleccion" |
| 61 | 62 | android:textSize="20sp" |
| ... | ... | @@ -68,41 +69,40 @@ |
| 68 | 69 | android:layout_height="wrap_content" |
| 69 | 70 | android:layout_margin="5dp" |
| 70 | 71 | android:gravity="start" |
| 71 | - android:orientation="vertical" | |
| 72 | + android:orientation="horizontal" | |
| 72 | 73 | app:layout_constraintEnd_toEndOf="parent" |
| 73 | 74 | app:layout_constraintHorizontal_bias="0.0" |
| 74 | 75 | app:layout_constraintStart_toStartOf="parent" |
| 75 | 76 | app:layout_constraintTop_toBottomOf="@+id/tvgenerico2"> |
| 76 | 77 | |
| 77 | - | |
| 78 | 78 | <RadioButton |
| 79 | - android:id="@+id/rbMdodificar" | |
| 79 | + android:id="@+id/rbSumar" | |
| 80 | 80 | android:layout_width="wrap_content" |
| 81 | 81 | android:layout_height="wrap_content" |
| 82 | 82 | android:layout_margin="5dp" |
| 83 | - android:checked="false" | |
| 83 | + android:checked="true" | |
| 84 | 84 | android:padding="5dp" |
| 85 | - android:text="@string/rbModificar" | |
| 85 | + android:text="@string/rbSumar" | |
| 86 | 86 | android:textSize="@dimen/text_size2" /> |
| 87 | 87 | |
| 88 | 88 | <RadioButton |
| 89 | - android:id="@+id/rbSumar" | |
| 89 | + android:id="@+id/rbRestar" | |
| 90 | 90 | android:layout_width="wrap_content" |
| 91 | 91 | android:layout_height="wrap_content" |
| 92 | 92 | android:layout_margin="5dp" |
| 93 | 93 | android:checked="false" |
| 94 | 94 | android:padding="5dp" |
| 95 | - android:text="@string/rbSumar" | |
| 95 | + android:text="@string/rbRestar" | |
| 96 | 96 | android:textSize="@dimen/text_size2" /> |
| 97 | 97 | |
| 98 | 98 | <RadioButton |
| 99 | - android:id="@+id/rbRestar" | |
| 99 | + android:id="@+id/rbMdodificar" | |
| 100 | 100 | android:layout_width="wrap_content" |
| 101 | 101 | android:layout_height="wrap_content" |
| 102 | 102 | android:layout_margin="5dp" |
| 103 | 103 | android:checked="false" |
| 104 | 104 | android:padding="5dp" |
| 105 | - android:text="@string/rbRestar" | |
| 105 | + android:text="@string/rbModificar" | |
| 106 | 106 | android:textSize="@dimen/text_size2" /> |
| 107 | 107 | </RadioGroup> |
| 108 | 108 |