Ejemplo n.º 1
0
 public bool InsertarNvaConfiguracion(ConfiguracionesVarias nvaConfiguracion)
 {
     try
     {
         using (var connection = new SQLiteConnection(System.IO.Path.Combine(folder, "kigest_sltosAriel.db")))
         {
             connection.Insert(nvaConfiguracion);
             return(true);
         }
     }
     catch (SQLiteException ex)
     {
         Log.Info("SQLiteException", ex.Message);
         return(false);
     }
 }
Ejemplo n.º 2
0
 public bool ActualizarConfiguracion(ConfiguracionesVarias Configuracion)
 {
     try
     {
         using (var connection = new SQLiteConnection(System.IO.Path.Combine(folder, "kigest_sltosAriel.db")))
         {
             connection.Query <TablaClientes>("update ConfiguracionesVarias set valor=? where id=?", Configuracion.valor, Configuracion.id);
             return(true);
         }
     }
     catch (SQLiteException ex)
     {
         Log.Info("SQLiteException", ex.Message);
         return(false);
     }
 }
Ejemplo n.º 3
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            //string cultureName = "es-AR";
            //var locale = new Java.Util.Locale(cultureName);
            //Java.Util.Locale.Default = locale;

            //CultureInfo.DefaultThreadCurrentCulture = CultureInfo.CreateSpecificCulture("es_AR");

            SetContentView(Resource.Layout.Login);
            dbPrinc = new ConsultasTablas();
            dbPrinc.CrearTablasGrales();
            var LoginUsuario    = FindViewById <EditText>(Resource.Id.txtLoginUsuario);
            var LoginContraseña = FindViewById <EditText>(Resource.Id.txtLoginPassword);

            var LoginMensaje = FindViewById <TextView>(Resource.Id.txtLoginMensaje);

            var BotonLogin    = FindViewById <Button>(Resource.Id.btnLoginIngresar);
            var BotonRegistro = FindViewById <Button>(Resource.Id.btnLoginRegistrar);

            BotonLogin.Click += delegate
            {
                try
                {
                    var databasepath = System.IO.Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "kigest_sltosAriel.db");
                    var db           = new SQLiteConnection(databasepath);
                    IEnumerable <ConsultasTablas> resultado = LoguearUsuario(db, LoginUsuario.Text, LoginContraseña.Text);
                    if (resultado.Count() > 0)
                    {
                        Toast.MakeText(this, "Login Correcto!", ToastLength.Long).Show();
                        List <Usuarios> dtosUsuario = new List <Usuarios>();
                        List <ConfiguracionesVarias> configuracionesVarias = new List <ConfiguracionesVarias>();
                        dtosUsuario           = dbPrinc.DatosUsuario(LoginUsuario.Text, LoginContraseña.Text);
                        configuracionesVarias = dbPrinc.VerListaConfiguraciones();

                        if (configuracionesVarias.Count == 0 || configuracionesVarias.Count < 6)
                        {
                            ConfiguracionesVarias monedaPeso = new ConfiguracionesVarias
                            {
                                id     = 1,
                                nombre = "PESO",
                                valor  = "1"
                            };
                            ConfiguracionesVarias monedaDolar = new ConfiguracionesVarias
                            {
                                id     = 2,
                                nombre = "DOLAR",
                                valor  = "1"
                            };
                            ConfiguracionesVarias FormulaCalculo = new ConfiguracionesVarias
                            {
                                id     = 3,
                                nombre = "FormulaCalculo",
                                valor  = "1"
                            };
                            ConfiguracionesVarias ListaDefecto = new ConfiguracionesVarias
                            {
                                id     = 4,
                                nombre = "ListaDefecto",
                                valor  = "0"
                            };
                            ConfiguracionesVarias DireccWebService = new ConfiguracionesVarias
                            {
                                id     = 5,
                                nombre = "DireccWebService",
                                valor  = "http://00.00.00.00/"
                            };
                            ConfiguracionesVarias NombWebService = new ConfiguracionesVarias
                            {
                                id     = 6,
                                nombre = "NombWebService",
                                valor  = "nombreWebService"
                            };

                            dbPrinc.InsertarNvaConfiguracion(monedaPeso);
                            dbPrinc.InsertarNvaConfiguracion(monedaDolar);
                            dbPrinc.InsertarNvaConfiguracion(FormulaCalculo);
                            dbPrinc.InsertarNvaConfiguracion(ListaDefecto);
                            dbPrinc.InsertarNvaConfiguracion(DireccWebService);
                            dbPrinc.InsertarNvaConfiguracion(NombWebService);

                            VariablesGlobales.CotizacionDolar    = 1;
                            VariablesGlobales.MetodoCalculo      = 1;
                            VariablesGlobales.ListaPrecioCliente = 0;
                            VariablesGlobales.DireccWebService   = "http://00.00.00.00/";
                            VariablesGlobales.NombWebService     = "nombreWebService";
                        }
                        else
                        {
                            VariablesGlobales.CotizacionDolar    = double.Parse(configuracionesVarias[1].valor);
                            VariablesGlobales.MetodoCalculo      = int.Parse(configuracionesVarias[2].valor);
                            VariablesGlobales.ListaPrecioCliente = int.Parse(configuracionesVarias[3].valor);
                            VariablesGlobales.DireccWebService   = configuracionesVarias[4].valor;
                            VariablesGlobales.NombWebService     = configuracionesVarias[5].valor;
                        }

                        VariablesGlobales.Idvendedor = dtosUsuario[0].vendedor;

                        if (CrossConnectivity.Current.IsConnected == true)
                        {
                            interfazConfiguraciones = RestService.For <IVerConfiguraciones>(VariablesGlobales.DireccWebService + VariablesGlobales.NombWebService);
                            ObtenerConfiguraciones();

                            Toast.MakeText(this, "ESTA CONECTADO A INTERNET!", ToastLength.Long).Show();
                        }
                        else
                        {
                            Toast.MakeText(this, "NO ESTA CONECTADO A INTERNET!", ToastLength.Long).Show();
                        }
                        StartActivity(typeof(PaginaPrincipal));
                        Finish();
                    }
                    else
                    {
                        //LoginMensaje.Text = "Nombre de usuario o contraseña incorrectos, asegúrese que su usuario este activado!";
                        Toast.MakeText(this, "Nombre de usuario o contraseña incorrectos, asegúrese que su usuario este activado!", ToastLength.Long).Show();
                    }
                }
                catch (SQLiteException ex)
                {
                    LoginMensaje.Text = ex.Message;
                }
            };

            BotonRegistro.Click += delegate
            {
                StartActivity(typeof(Registro));
            };
        }
Ejemplo n.º 4
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            try
            {
                base.OnCreate(savedInstanceState);
                if (VariablesGlobales.Idvendedor == 0)
                {
                    Intent i = new Intent(this.ApplicationContext, typeof(MainActivity));
                    i.SetFlags(ActivityFlags.NewTask | ActivityFlags.ClearTop);
                    StartActivity(i);
                    this.Finish();
                }
                SetContentView(Resource.Layout.PaginaConfiguracion);

                var btnVaciarProductos = FindViewById <Button>(Resource.Id.btnVaciarProductos);
                //var btnVaciarCategoriasProductos = FindViewById<Button>(Resource.Id.btnVaciarCategorias);
                var btnVaciarListasPrecio = FindViewById <Button>(Resource.Id.btnVaciarListasPrecio);
                var btnVaciarClientes     = FindViewById <Button>(Resource.Id.btnVaciarClientes);
                var btnVaciarPedidos      = FindViewById <Button>(Resource.Id.btnVaciarPedidos);
                //var btnVaciarPedidosDetalle = FindViewById<Button>(Resource.Id.btnVariarDetallePed);
                var btnGuardarCotizacionMoneda = FindViewById <Button>(Resource.Id.btnCotizacionDolar);
                var btnVolver              = FindViewById <Button>(Resource.Id.btnConfVolverInicio);
                var txtCotizacion          = FindViewById <EditText>(Resource.Id.txtCotizacionDolar);
                var txtMetodoCalculo       = FindViewById <EditText>(Resource.Id.txtMetodoCalculo);
                var txtDireccionWebService = FindViewById <EditText>(Resource.Id.txtDireccionWebService);
                var txtNomWebService       = FindViewById <EditText>(Resource.Id.txtNombWebService);
                SeleccListaPrecios = (Spinner)FindViewById(Resource.Id.spnListaPrecios);
                //dbUser = new ConsultasTablas();

                ListasPrecio  = db.VerListaPrecio();
                ListaVendedor = db.VerListaPreciosVendedor(VariablesGlobales.Idvendedor);
                adapter       = new ArrayAdapter(this, Android.Resource.Layout.SimpleSpinnerDropDownItem, ListasPrecio);
                SeleccListaPrecios.Adapter = adapter;

                int posicion = 0;
                for (int i = 0; i < SeleccListaPrecios.Count; i++)
                {
                    if (SeleccListaPrecios.GetItemAtPosition(i).ToString() == ListaVendedor[0].nombre)
                    {
                        posicion = i;
                    }
                }
                //Toast.MakeText(this, "posicion " + posicion, ToastLength.Long).Show();
                SeleccListaPrecios.ItemSelected += new EventHandler <AdapterView.ItemSelectedEventArgs>(ListasPrecios_ItemSelected);
                MonedaYConfig = db.VerListaConfiguraciones();

                txtCotizacion.Text          = MonedaYConfig[1].valor;
                txtMetodoCalculo.Text       = MonedaYConfig[2].valor;
                txtDireccionWebService.Text = MonedaYConfig[4].valor;
                txtNomWebService.Text       = MonedaYConfig[5].valor;

                SeleccListaPrecios.SetSelection(posicion);
                if (int.Parse(MonedaYConfig[3].valor) != 0)
                {
                    ListasPrecio = new List <ListasPrecio>();
                    ListasPrecio = db.VerListaPrecioId(int.Parse(MonedaYConfig[3].valor));
                    int itemSel = adapter.GetPosition(ListasPrecio[0].nombre);
                }

                btnVaciarProductos.Click += delegate
                {
                    AlertDialog.Builder alert = new AlertDialog.Builder(this);
                    alert.SetTitle("Specify Action");
                    alert.SetMessage("Esta seguro que desea vaciar la tabla de productos?");
                    alert.SetPositiveButton("Aceptar", (senderAlert, args) =>
                    {
                        if (db.VaciarTablaProductos())
                        {
                            Toast.MakeText(this, "Se vacio la tabla de PRODUCTOS", ToastLength.Long).Show();
                        }
                        if (db.VaciarTablaCategoriasProd())
                        {
                            Toast.MakeText(this, "Se vacio la tabla de categorias", ToastLength.Long).Show();
                        }
                    });
                    alert.SetNegativeButton("Cancelar", (senderAlert, args) =>
                    {
                        Toast.MakeText(this, "Proceso cancelado", ToastLength.Long).Show();
                    });
                    Dialog dialog = alert.Create();
                    dialog.Show();
                };
                btnVaciarListasPrecio.Click += delegate
                {
                    AlertDialog.Builder alert = new AlertDialog.Builder(this);
                    alert.SetTitle("Specify Action");
                    alert.SetMessage("Esta seguro que desea vaciar la tabla de productos?");
                    alert.SetPositiveButton("Aceptar", (senderAlert, args) =>
                    {
                        if (db.VaciarTablaListasPrecio())
                        {
                            Toast.MakeText(this, "Se vacio la tabla de LISTAS DE PRECIO", ToastLength.Long).Show();
                        }
                    });
                    alert.SetNegativeButton("Cancelar", (senderAlert, args) =>
                    {
                        Toast.MakeText(this, "Proceso cancelado", ToastLength.Long).Show();
                    });
                    Dialog dialog = alert.Create();
                    dialog.Show();
                };
                btnVaciarClientes.Click += delegate
                {
                    AlertDialog.Builder alert = new AlertDialog.Builder(this);
                    alert.SetTitle("Specify Action");
                    alert.SetMessage("Esta seguro que desea vaciar la tabla de CLIENTES?");
                    alert.SetPositiveButton("Aceptar", (senderAlert, args) =>
                    {
                        if (db.VaciarTablaClientes())
                        {
                            Toast.MakeText(this, "Se vacio la tabla de Clientes", ToastLength.Long).Show();
                        }
                    });
                    alert.SetNegativeButton("Cancelar", (senderAlert, args) =>
                    {
                        Toast.MakeText(this, "Proceso cancelado", ToastLength.Long).Show();
                    });
                    Dialog dialog = alert.Create();
                    dialog.Show();
                };
                btnVaciarPedidos.Click += delegate
                {
                    AlertDialog.Builder alert = new AlertDialog.Builder(this);
                    alert.SetTitle("Specify Action");
                    alert.SetMessage("Esta seguro que desea vaciar la tabla de PEDIDOS?");
                    alert.SetPositiveButton("Aceptar", (senderAlert, args) =>
                    {
                        if (db.VaciarTablaPedidosMaster())
                        {
                            Toast.MakeText(this, "Se vacio la tabla de Pedidos", ToastLength.Long).Show();
                        }
                        if (db.VaciarTablaDetallePedidos())
                        {
                            Toast.MakeText(this, "Se vacio la tabla de Detalle de pedidos", ToastLength.Long).Show();
                        }
                    });
                    alert.SetNegativeButton("Cancelar", (senderAlert, args) =>
                    {
                        Toast.MakeText(this, "Proceso cancelado", ToastLength.Long).Show();
                    });
                    Dialog dialog = alert.Create();
                    dialog.Show();
                };
                btnGuardarCotizacionMoneda.Click += delegate
                {
                    if (listaOK == true)
                    {
                        string ItemLIstaPrecios = SeleccListaPrecios.SelectedItem.ToString();
                        ListasPrecio = new List <ListasPrecio>();
                        ListasPrecio = db.ObtenerIDListaPrecios(ItemLIstaPrecios);
                    }
                    double tempCotiza = 0;
                    if (txtCotizacion.Text != "" & double.TryParse(txtCotizacion.Text, out tempCotiza))

                    {
                        string valLista = "0";
                        if (listaOK == true)
                        {
                            valLista = ListasPrecio[0].id.ToString();
                        }
                        else
                        {
                            valLista = "0";
                        }

                        ConfiguracionesVarias moneda = new ConfiguracionesVarias()
                        {
                            id    = 2,
                            valor = txtCotizacion.Text
                        };
                        ConfiguracionesVarias FormulaCalculo = new ConfiguracionesVarias
                        {
                            id    = 3,
                            valor = txtMetodoCalculo.Text
                        };

                        ConfiguracionesVarias listaDefecto = new ConfiguracionesVarias
                        {
                            id    = 4,
                            valor = valLista
                        };
                        db.ActualizarConfiguracion(moneda);
                        db.ActualizarConfiguracion(FormulaCalculo);
                        db.ActualizarConfiguracion(listaDefecto);

                        VariablesGlobales.CotizacionDolar    = double.Parse(txtCotizacion.Text);
                        VariablesGlobales.MetodoCalculo      = int.Parse(txtMetodoCalculo.Text);
                        VariablesGlobales.ListaPrecioCliente = int.Parse(valLista); // ListasPrecio[0].id;

                        Toast.MakeText(this, "Se actualizo configuraciones varias", ToastLength.Long).Show();
                    }
                    else
                    {
                        Toast.MakeText(this, "NO SE PUEDEN GUARDAR LAS CONFIGURACIONES VARIAS", ToastLength.Long).Show();
                    }
                    if (txtDireccionWebService.Text != "" & txtDireccionWebService.Text.Contains("http://") == true & txtNomWebService.Text != "" & txtNomWebService.Text.Contains("/") == false)
                    {
                        ConfiguracionesVarias DireccWebService = new ConfiguracionesVarias
                        {
                            id     = 5,
                            nombre = "DireccWebService",
                            valor  = txtDireccionWebService.Text
                        };
                        ConfiguracionesVarias NombWebService = new ConfiguracionesVarias
                        {
                            id     = 6,
                            nombre = "NombWebService",
                            valor  = txtNomWebService.Text
                        };

                        db.ActualizarConfiguracion(DireccWebService);
                        db.ActualizarConfiguracion(NombWebService);

                        VariablesGlobales.DireccWebService = txtDireccionWebService.Text;
                        VariablesGlobales.NombWebService   = txtNomWebService.Text;

                        Toast.MakeText(this, "Se actualizo la configuracion de web service", ToastLength.Long).Show();
                    }
                    else
                    {
                        Toast.MakeText(this, "NO SE PUEDEN GUARDAR LAS CONFIGURACIONES DE WEB SERVICE", ToastLength.Long).Show();
                    }
                };
                btnVolver.Click += delegate
                {
                    StartActivity(typeof(PaginaPrincipal));
                };
            }
            catch (Exception ex)
            {
                Toast.MakeText(Application.Context, ex.Message, ToastLength.Short).Show();
            }
        }