Beispiel #1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            if (VariablesGlobales.Idvendedor == 0)
            {
                Intent i = new Intent(this.ApplicationContext, typeof(MainActivity));
                i.SetFlags(ActivityFlags.NewTask | ActivityFlags.ClearTop);
                StartActivity(i);
                this.Finish();
            }
            dbUser = new ConsultasTablas();
            base.OnCreate(savedInstanceState);
            JsonConvert.DefaultSettings = () => new JsonSerializerSettings()
            {
                ContractResolver = new CamelCasePropertyNamesContractResolver(),
                Converters       = { new StringEnumConverter() }
            };

            interfaz = RestService.For <IObtenerListaPrecio>(VariablesGlobales.DireccWebService + VariablesGlobales.NombWebService);
            //interfaz2 = RestService.For<IObtenerPromocionesDescuentos>(VariablesGlobales.DireccWebService + VariablesGlobales.NombWebService);

            SetContentView(Resource.Layout.ListasPrecioServer);
            var btnSincronizar = FindViewById <Button>(Resource.Id.btnListasServerSincronizar);
            var btnVolver      = FindViewById <Button>(Resource.Id.btnListasServerVer);
            var mensaje        = FindViewById <TextView>(Resource.Id.txtListasServerMensaje);

            listaListasPrec       = FindViewById <ListView>(Resource.Id.lstListasServerListas);
            btnSincronizar.Click += btnSincronizar_Click;
            btnVolver.Click      += delegate
            {
                StartActivity(typeof(VerListasPrecio));
            };
        }
Beispiel #2
0
        public string AplicarPromosDescuentos(int idproducto, string cantidad)
        {
            List <PromocionesDescuentos> promocionesDescuentos = new List <PromocionesDescuentos>();
            ConsultasTablas dbuser = new ConsultasTablas();

            promocionesDescuentos = dbuser.VerPromocionesDescuentosCant(idproducto, int.Parse(cantidad));

            double porcdesc = 0, actualVal = 0, maxVal = 0;

            if (promocionesDescuentos.Count() == 0)
            {
                return("1");
            }
            else
            {
                for (int i = 0; i <= promocionesDescuentos.Count() - 1; i++)
                {
                    actualVal = double.Parse(promocionesDescuentos[i].compra_min);
                    if (actualVal > maxVal)
                    {
                        maxVal   = actualVal;
                        porcdesc = (double.Parse(promocionesDescuentos[i].descuento_porc) + 100) / 100;
                    }
                }
                return(porcdesc.ToString());
            }
        }
Beispiel #3
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            dbUser = new ConsultasTablas();
            base.OnCreate(savedInstanceState);
            JsonConvert.DefaultSettings = () => new JsonSerializerSettings()
            {
                ContractResolver = new CamelCasePropertyNamesContractResolver(),
                Converters       = { new StringEnumConverter() }
            };

            interfazClientes = RestService.For <IObtenerClientesServer>(VariablesGlobales.DireccWebService + VariablesGlobales.NombWebService);

            SetContentView(Resource.Layout.ListaClientesServer);

            var btnSincronizar = FindViewById <Button>(Resource.Id.btnClieServerSincro);
            var btnVolver      = FindViewById <Button>(Resource.Id.btnClieServerVolver);
            var Mensaje        = FindViewById <TextView>(Resource.Id.txtClieServerMensaje);

            listaClie             = FindViewById <ListView>(Resource.Id.lstClieServLista);
            btnSincronizar.Click += btnSincronizar_Click;
            Mensaje.Text          = "Vendedor: " + VariablesGlobales.Idvendedor;
            btnVolver.Click      += delegate
            {
                StartActivity(typeof(VerClientes));
            };
        }
Beispiel #4
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            dbUser = new ConsultasTablas();
            base.OnCreate(savedInstanceState);

            JsonConvert.DefaultSettings = () => new JsonSerializerSettings()
            {
                ContractResolver = new CamelCasePropertyNamesContractResolver(),
                Converters       = { new StringEnumConverter() }
            };

            interfaz        = RestService.For <IObtenerProductosServer>("http://66.97.35.86");
            interfazCatprod = RestService.For <IObtenerCategoriaProductos>("http://66.97.35.86");

            SetContentView(Resource.Layout.ListaProductosServer);

            var btnSincronizar = FindViewById <Button>(Resource.Id.btnProductosServerSincronizar);
            var btnVolver      = FindViewById <Button>(Resource.Id.btnProductosServerVer);
            var mensaje        = FindViewById <TextView>(Resource.Id.txtProductosServerMensaje);

            //progreso = FindViewById<ProgressBar>(Resource.Id.pgbProductosProgreso);
            // progreso.Min = 0;

            //listaProd = FindViewById<ListView>(Resource.Id.lstProductosServer);
            btnSincronizar.Click += btnSincronizar_Click;
            btnVolver.Click      += delegate
            {
                StartActivity(typeof(VerProductos));
            };
        }
Beispiel #5
0
        public override View GetView(int position, View convertView, ViewGroup parent)
        {
            FuncionesGlobales funcionesGlobales = new FuncionesGlobales();
            ConsultasTablas   dbUser            = new ConsultasTablas();
            var view        = convertView ?? activity.LayoutInflater.Inflate(Resource.Layout.ListViewProductos_template, parent, false);
            var Descripcion = view.FindViewById <TextView>(Resource.Id.txtProductoDescripcion);

            var Codigo       = view.FindViewById <TextView>(Resource.Id.txtProductoCodigo);
            var Presentacion = view.FindViewById <TextView>(Resource.Id.txtProductoPresentacion);
            var Precio       = view.FindViewById <TextView>(Resource.Id.txtProductoPrecio);
            var Promos       = view.FindViewById <TextView>(Resource.Id.txtProductoPromos);

            Descripcion.Text = lstProductos[position].descripcion;

            Codigo.Text       = "CODIGO: " + lstProductos[position].codigo; //+lstProductos[position].codProdMain+") "+ lstProductos[position].codigo;
            Descripcion.Tag   = lstProductos[position].id;
            Presentacion.Text = "PRESENTACION: X" + lstProductos[position].presentacion;
            Precio.Text       = funcionesGlobales.CalcularPrecioLista(lstProductos[position].precio,
                                                                      lstProductos[position].ganancia, lstProductos[position].utilidad1, lstProductos[position].utilidad2,
                                                                      lstProductos[position].utilidad3, lstProductos[position].utilidad4, lstProductos[position].utilidad5,
                                                                      lstProductos[position].iva, VariablesGlobales.ListaPrecioCliente, lstProductos[position].calcular_precio);
            Promos.Text = funcionesGlobales.CalcularPromosDescuentos(lstProductos[position].codProdMain);
            dbUser      = new ConsultasTablas();
            return(view);
        }
Beispiel #6
0
        public override View GetView(int position, View convertView, ViewGroup parent)
        {
            ConsultasTablas dbUser      = new ConsultasTablas();
            var             view        = convertView ?? activity.LayoutInflater.Inflate(Resource.Layout.ListViewPedidos_template, parent, false);
            var             Descripcion = view.FindViewById <TextView>(Resource.Id.txtPedidosItem);

            lstClientes      = new List <TablaClientes>();
            lstClientes      = dbUser.VerDetalleClienteMain(lstPedidos[position].id_cliente);
            Descripcion.Text = VariablesGlobales.Idvendedor + "-" + lstPedidos[position].id + " - (" + lstPedidos[position].fecha + ") " + lstClientes[0].nomapell_razon;
            Descripcion.Tag  = lstPedidos[position].id;
            return(view);
        }
Beispiel #7
0
        public string CalcularPromosDescuentos(int idproducto)
        {
            List <PromocionesDescuentos> promocionesDescuentos = new List <PromocionesDescuentos>();
            ConsultasTablas dbuser = new ConsultasTablas();

            promocionesDescuentos = dbuser.VerPromocionesDescuentosIdProd(idproducto);
            string calculo = "";

            for (int i = 0; i <= promocionesDescuentos.Count() - 1; i++)
            {
                calculo += "x" + promocionesDescuentos[i].compra_min + ": " + promocionesDescuentos[i].descuento_porc + "% -";
            }
            return(calculo);
        }
Beispiel #8
0
        public override View GetView(int position, View convertView, ViewGroup parent)
        {
            ConsultasTablas dbUser;
            var             view        = convertView ?? activity.LayoutInflater.Inflate(Resource.Layout.PedidoActualDetalle_template, parent, false);
            var             Descripcion = view.FindViewById <TextView>(Resource.Id.txtPedidoDetalleProducto);
            var             Codigo      = view.FindViewById <TextView>(Resource.Id.txtPedidoDetalleCodigo);
            var             cantPrecio  = view.FindViewById <TextView>(Resource.Id.txtPedidoCantPrecio);

            Descripcion.Text = lstProductos[position].descripcion;
            Codigo.Text      = "CODIGO: " + lstProductos[position].cod; // lstProductos[position].codProdMain+") "+ lstProductos[position].cod ;
            Descripcion.Tag  = lstProductos[position].id;
            cantPrecio.Text  = "Cant: " + lstProductos[position].cantidad + " | Punit: $" + lstProductos[position].punit + " | Ptotal: $" + lstProductos[position].ptotal;
            dbUser           = new ConsultasTablas();
            return(view);
        }
Beispiel #9
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            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.ListViewPedidos);
            dbUser   = new ConsultasTablas();
            lstDatos = FindViewById <ListView>(Resource.Id.lstPedidosLista);
            RadioGroup  tiposPed  = FindViewById <RadioGroup>(Resource.Id.rdgTiposPedidos);
            RadioButton fin       = FindViewById <RadioButton>(Resource.Id.rd0);
            RadioButton enviar    = FindViewById <RadioButton>(Resource.Id.rd1);
            RadioButton todos     = FindViewById <RadioButton>(Resource.Id.rd2);
            var         btnVolver = FindViewById <Button>(Resource.Id.btnPedidosListaVolver);

            LoadData(1);
            tiposPed.CheckedChange += delegate
            {
                if (fin.Checked == true)
                {
                    LoadData(0);
                }
                ;
                if (enviar.Checked == true)
                {
                    LoadData(1);
                }
                ;
                if (todos.Checked == true)
                {
                    LoadData(2);
                }
                ;
            };
            btnVolver.Click += delegate
            {
                StartActivity(typeof(PaginaPrincipal));
            };
            lstDatos.ItemClick += (s, e) =>
            {
                VariablesGlobales.IdPedidoenCurso = int.Parse(e.Id.ToString());
                StartActivity(typeof(PedidoActual));
            };
        }
Beispiel #10
0
        //Android.Widget.SearchView busquedaCliente;
        protected override void OnCreate(Bundle bundle)
        {
            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.ListViewCliente);
            lstDatosClientes = FindViewById <ListView>(Resource.Id.lstClienteLista);
            dbUser           = new ConsultasTablas();
            BusquedaCliente  = (SearchView)FindViewById(Resource.Id.srchClienteBuscar);
            var btnVolver  = FindViewById <Button>(Resource.Id.btnClienteListaVolver);
            var btnAgregar = FindViewById <Button>(Resource.Id.btnClienteAgregar);

            base.OnCreate(bundle);
            LoadData();

            BusquedaCliente.QueryTextSubmit += BusquedaCliente_QuerySubmit;
            BusquedaCliente.QueryTextChange += BusquedaCliente_TextChange;
            btnAgregar.Click += delegate
            {
                Intent abrirWeb = new Intent(Intent.ActionView);
                abrirWeb.SetData(Android.Net.Uri.Parse("http://authkibit.donweb-remoteip.net/pedidos_test"));

                StartActivity(abrirWeb);
            };

            btnVolver.Click += delegate
            {
                StartActivity(typeof(PaginaPrincipal));
            };
            lstDatosClientes.ItemClick += (s, e) =>
            {
                DetalleCliente.IdCliente = int.Parse(e.Id.ToString());
                StartActivity(typeof(DetalleCliente));
            };
        }
Beispiel #11
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            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.ListViewListasPrecio);
            lstDatosListas = FindViewById <ListView>(Resource.Id.lstListasPrecioLista);
            var btnVolver = FindViewById <Button>(Resource.Id.btnListasPrecioVolver);

            dbUser = new ConsultasTablas();


            btnVolver.Click += delegate
            {
                StartActivity(typeof(PaginaPrincipal));
            };
            LoadData();
        }
Beispiel #12
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            VersionTracking.Track();
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.PaginaPrincipal);
            dbUser = new ConsultasTablas();
            AlertDialog.Builder builder = new AlertDialog.Builder(this);


            var sincroClientes  = FindViewById <Button>(Resource.Id.btnPrincSincroClie);
            var sincroProductos = FindViewById <Button>(Resource.Id.btnPrincSincProd);
            //var sincroPedidos = FindViewById<Button>(Resource.Id.btnPrincSincroPed);
            var    sincroListas       = FindViewById <Button>(Resource.Id.btnPrincSincListasPrecio);
            var    manejoTablas       = FindViewById <Button>(Resource.Id.btnPrincManejoTablas);
            var    actualizarApp      = FindViewById <Button>(Resource.Id.btnPrincActualizarApp);
            var    versionApp         = FindViewById <TextView>(Resource.Id.appInfo);
            var    estadisticasVentas = FindViewById <Button>(Resource.Id.btnPrincVerEstadisticas);
            string folder             = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
            var    versionAPPLICACION = VersionTracking.CurrentVersion;

            versionApp.Text = "Directorio de BD: " + folder + "\n";
            versionApp.Text = versionApp.Text + "Versión de la aplicación: " + versionAPPLICACION;
            var InfoServer = FindViewById <TextView>(Resource.Id.infoVendedor);

            InfoServer.Text = "Vendedor: " + VariablesGlobales.NombWebService;

            sincroClientes.Click += delegate
            {
                StartActivity(typeof(SincronizarClientes));
            };
            sincroProductos.Click += delegate
            {
                StartActivity(typeof(SincronizarProductos));
            };
            sincroListas.Click += delegate
            {
                StartActivity(typeof(SincronizarListasPrecio));
            };
            manejoTablas.Click += delegate
            {
                StartActivity(typeof(Configuracion));
            };
            actualizarApp.Click += delegate
            {
                Intent abrirWeb = new Intent(Intent.ActionView);
                abrirWeb.SetData(Android.Net.Uri.Parse("http://authkibit.donweb-remoteip.net/sistemaPedidosAndroid/kigest.sistemapedidos.apk"));

                StartActivity(abrirWeb);
            };
            estadisticasVentas.Click += delegate
            {
                StartActivity(typeof(verEstadisticas));
            };

            var verClientes  = FindViewById <Button>(Resource.Id.btnPrincVerClientes);
            var verProductos = FindViewById <Button>(Resource.Id.btnPrincVerProductos);
            var verPedidos   = FindViewById <Button>(Resource.Id.btnPrincVerPedidos);

            verClientes.Click += delegate
            {
                StartActivity(typeof(VerClientes));
            };
            verProductos.Click += delegate
            {
                StartActivity(typeof(VerProductos));
            };
            verPedidos.Click += delegate
            {
                StartActivity(typeof(VerPedidos));
            };
        }
Beispiel #13
0
        //string PrecioProdSel;

        protected override void OnCreate(Bundle savedInstanceState)
        {
            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.DetalleCliente);

            dbUser      = new ConsultasTablas();
            dtosCliente = dbUser.VerDetalleCliente(IdCliente);

            var txtnomapell_razon   = FindViewById <TextView>(Resource.Id.txtDetalleClieNomRazon);
            var txtdireccion        = FindViewById <TextView>(Resource.Id.txtDetalleClieDireccion);
            var txttelefono_celular = FindViewById <TextView>(Resource.Id.txtDetalleClieTelefonoCelular);
            var txtcontacto         = FindViewById <TextView>(Resource.Id.txtDetalleClieContacto);
            var txtobservaciones    = FindViewById <TextView>(Resource.Id.txtDetalleClieObservaciones);
            var btnnvopedido        = FindViewById <Button>(Resource.Id.btnDetalleClieNvoPedido);
            var btnvolver           = FindViewById <Button>(Resource.Id.btnDetalleClieVolver);
            var btnModificar        = FindViewById <Button>(Resource.Id.btnDetalleClieModificar);

            txtnomapell_razon.Text   = dtosCliente[0].codclieMain + " - " + dtosCliente[0].nomapell_razon;
            txtdireccion.Text        = "DIRECCION: " + dtosCliente[0].domicilio;
            txttelefono_celular.Text = "TELEFONO/CELULAR:" + dtosCliente[0].telefono + "/" + dtosCliente[0].celular;
            txtcontacto.Text         = "PERSONA DE CONTACTO:" + dtosCliente[0].contacto;
            txtobservaciones.Text    = "OBSERVACIONES:" + dtosCliente[0].observaciones + "\n" + "E-Mail: " + dtosCliente[0].email;
            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
            string           fecha            = simpleDateFormat.Format(new Date());

            btnnvopedido.Click += delegate
            {
                PedidosMaster pedidosMaster = new PedidosMaster()
                {
                    id_cliente = dtosCliente[0].codclieMain,
                    fecha      = fecha,
                    vendedor   = VariablesGlobales.Idvendedor.ToString(),
                    finalizado = 0,
                    enviado    = 0
                };
                dbUser.InsertarPedido(pedidosMaster);
                nuevoPedido = dbUser.ObtenerUltimoIdPedido();
                int idpedido = int.Parse(nuevoPedido[0].id.ToString());
                VariablesGlobales.IdPedidoenCurso    = int.Parse(idpedido.ToString());
                VariablesGlobales.IdCliente          = dtosCliente[0].codclieMain;
                VariablesGlobales.ListaPrecioCliente = dtosCliente[0].lista_precios;
                VariablesGlobales.PedidoEnCurso      = true;
                StartActivity(typeof(PedidoActual));
            };
            btnvolver.Click += delegate
            {
                StartActivity(typeof(VerClientes));
            };
            btnModificar.Click += (s, e) =>
            {
                LayoutInflater layoutInflater = LayoutInflater.From(Application.Context);

                View dialogo = layoutInflater.Inflate(Resource.Layout.inputBoxModificaClie, null);

                AlertDialog.Builder builder       = new AlertDialog.Builder(this);
                EditText            NomApellRazon = dialogo.FindViewById <EditText>(Resource.Id.txtModClieNomaApelRazon);
                EditText            Domicilio     = dialogo.FindViewById <EditText>(Resource.Id.txtModClieDomicilio);
                EditText            Celular       = dialogo.FindViewById <EditText>(Resource.Id.txtModClieCelular);
                EditText            Email         = dialogo.FindViewById <EditText>(Resource.Id.txtModClieEMail);
                EditText            Observaciones = dialogo.FindViewById <EditText>(Resource.Id.txtModClieObservaciones);

                builder.SetView(dialogo);
                AlertDialog alertDialog = builder.Create();

                alertDialog.SetCanceledOnTouchOutside(true);
                alertDialog.SetTitle("Operaciones sobre Cliente");
                alertDialog.SetButton("Modificar", (ss, ee) =>

                {
                    List <TablaClientes> clienteDatos = new List <TablaClientes>();
                    clienteDatos = dbUser.VerDetalleCliente(IdClienteSel);

                    string ClieNombreApellido = NomApellRazon.Text;
                    string ClieDomicilio      = Domicilio.Text;
                    string ClieCelular        = Celular.Text;
                    string ClieEmail          = Email.Text;
                    string ClieObservaciones  = Observaciones.Text;

                    if (ClieNombreApellido == "")
                    {
                        ClieNombreApellido = clienteDatos[0].nomapell_razon;
                    }
                    if (ClieDomicilio == "")
                    {
                        ClieDomicilio = clienteDatos[0].domicilio;
                    }
                    if (ClieCelular == "")
                    {
                        ClieCelular = clienteDatos[0].celular;
                    }
                    if (ClieEmail == "")
                    {
                        ClieEmail = clienteDatos[0].email;
                    }
                    if (ClieObservaciones == "")
                    {
                        ClieObservaciones = clienteDatos[0].observaciones;
                    }

                    TablaClientes clienteModifica = new TablaClientes()
                    {
                        idclientes     = IdClienteSel,
                        nomapell_razon = ClieNombreApellido,
                        domicilio      = ClieDomicilio,
                        celular        = ClieCelular,
                        email          = ClieEmail,
                        observaciones  = ClieObservaciones
                    };

                    txtnomapell_razon.Text   = ClieNombreApellido;
                    txtdireccion.Text        = "DIRECCION: " + ClieDomicilio;
                    txttelefono_celular.Text = "TELEFONO/CELULAR: " + ClieCelular;
                    //txtcontacto.Text = "PERSONA DE CONTACTO:" +;
                    txtobservaciones.Text = "OBSERVACIONES: " + ClieObservaciones + "\n" + "E-Mail: " + ClieEmail;
                    dbUser.ActualizarClienteLocal(clienteModifica);
                    ModificarClienteServer();
                    Toast.MakeText(this, "Cliente modificado y actualizado en el servidor remoto!", ToastLength.Short).Show();
                });
                alertDialog.SetButton2("Cancelar", (sss, eee) =>
                {
                });
                alertDialog.SetButton3("Eliminar", (sssss, eeeee) =>
                {
                    EliminarClienteServer();
                    dbUser.EliminarCliente(IdClienteSel);
                    Toast.MakeText(this, "Cliente eliminado del la base local y remota", ToastLength.Short).Show();
                    StartActivity(typeof(VerClientes));
                });

                List <TablaClientes> clienteDetalle = new List <TablaClientes>();
                clienteDetalle = dbUser.VerDetalleCliente(IdClienteSel);

                NomApellRazon.Hint = "Nombre y Apellido / Razon: \n" + clienteDetalle[0].nomapell_razon;
                Domicilio.Hint     = "Domicilio: \n" + clienteDetalle[0].domicilio;
                Celular.Hint       = "Celular: \n" + clienteDetalle[0].celular;
                Email.Hint         = "E-Mail: \n" + clienteDetalle[0].email;
                Observaciones.Hint = "Observaciones: \n" + clienteDetalle[0].observaciones;

                alertDialog.Show();
            };
        }
Beispiel #14
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.Registro);
            dbPrinc = new ConsultasTablas();
            //dbPrinc.CrearTablasGrales();
            JsonConvert.DefaultSettings = () => new JsonSerializerSettings()
            {
                ContractResolver = new CamelCasePropertyNamesContractResolver(),
                Converters       = { new StringEnumConverter() }
            };
            var RegistroNombre      = FindViewById <EditText>(Resource.Id.txtRegistroNombre);
            var RegistroApellido    = FindViewById <EditText>(Resource.Id.txtRegistroApellido);
            var RegistroUsuario     = FindViewById <EditText>(Resource.Id.txtRegistroUsuario);
            var RegistroContraseña1 = FindViewById <EditText>(Resource.Id.txtRegistroContraseña1);
            var RegistroContraseña2 = FindViewById <EditText>(Resource.Id.txtRegistroContraseña2);
            var RegistroActivo      = FindViewById <EditText>(Resource.Id.txtRegistroActivo);
            var RegistroVendedor    = FindViewById <EditText>(Resource.Id.txtRegistroVendedor);

            var RegistroMensaje = FindViewById <TextView>(Resource.Id.txtRegistroMensaje);

            var BtnAceptar  = FindViewById <Button>(Resource.Id.btnRegistroAceptar);
            var BtnCancelar = FindViewById <Button>(Resource.Id.btnRegistroCancelar);



            BtnAceptar.Click += delegate
            {
                if (RegistroContraseña1.Text == RegistroContraseña2.Text)
                {
                    try
                    {
                        Usuarios nvoUsuario = new Usuarios()
                        {
                            nombre     = RegistroNombre.Text,
                            apellido   = RegistroApellido.Text,
                            usuario    = RegistroUsuario.Text,
                            contraseña = RegistroContraseña1.Text,
                            //activo = int.Parse(RegistroActivo.Text),
                            vendedor = int.Parse(RegistroVendedor.Text)
                        };



                        dbPrinc.InstertarNuevoUsuario(nvoUsuario);
                        Toast.MakeText(this, "Se ingreso nuevo usuario!", ToastLength.Long).Show();
                        StartActivity(typeof(MainActivity));
                    }
                    catch (SQLiteException ex)
                    {
                        RegistroMensaje.Text = ex.Message;
                    }
                }
                else
                {
                    Toast.MakeText(this, "Error de login, coroobore sus datos y que su usario este activo!", ToastLength.Long).Show();
                }
            };


            BtnCancelar.Click += delegate
            {
                StartActivity(typeof(MainActivity));
            };
        }
Beispiel #15
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));
            };
        }
Beispiel #16
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            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.ListViewProductos);
            lstDatosProductos = FindViewById <ListView>(Resource.Id.lstProductosLista);
            dbUser            = new ConsultasTablas();

            LoadData();
            var btnVolverAlPedido = FindViewById <Button>(Resource.Id.btnProductosPedidoActual);

            SeleccCategoria = (Spinner)FindViewById(Resource.Id.spnProductosCategoria);
            string folder = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);

            CategoriasProd          = dbUser.verCategoriaProductos();
            adapter                 = new ArrayAdapter(this, Android.Resource.Layout.SimpleSpinnerDropDownItem, CategoriasProd);
            SeleccCategoria.Adapter = adapter;
            //SeleccCategoria.SetSelection(adapter.GetPosition("PRODUCTOS REVENDEDORES"));
            SeleccCategoria.ItemSelected += new EventHandler <AdapterView.ItemSelectedEventArgs>(ListaCategorias_ItemSelected);


            var btnVolver = FindViewById <Button>(Resource.Id.btnProductosVolver);

            BusquedaProducto = (SearchView)FindViewById(Resource.Id.srcProductosBusqueda);
            BusquedaProducto.QueryTextSubmit += BusquedaProducto_QuerySubmit;
            BusquedaProducto.QueryTextChange += BusquedaProducto_TextChange;

            btnVolver.Click += delegate
            {
                StartActivity(typeof(PaginaPrincipal));
            };
            if (VariablesGlobales.PedidoEnCurso == true)
            {
                lstDatosProductos.ItemClick += (s, e) =>
                {
                    LayoutInflater layoutInflater = LayoutInflater.From(Application.Context);

                    View dialogo = layoutInflater.Inflate(Resource.Layout.inputBoxCantProd, null);

                    AlertDialog.Builder builder      = new AlertDialog.Builder(this);
                    EditText            cantProd     = dialogo.FindViewById <EditText>(Resource.Id.txtInputCantProd);
                    EditText            PrecioProd   = dialogo.FindViewById <EditText>(Resource.Id.txtInputPrecioProd);
                    TextView            mensajeInput = dialogo.FindViewById <TextView>(Resource.Id.txtInputCantMensaje);

                    builder.SetView(dialogo);
                    AlertDialog alertDialog = builder.Create();

                    alertDialog.SetCanceledOnTouchOutside(true);
                    alertDialog.SetTitle("Agregar producto");

                    alertDialog.SetButton("Agregar", (ss, ee) =>

                    {
                        if (cantProd.Text == "" || cantProd.Text == "0")
                        {
                            mensajeInput.Text = "La cantidad debes ser un numero mayor que 0";
                        }
                        else
                        {
                            //agregamos el producto
                            List <Productos> agregaProd = new List <Productos>();
                            agregaProd = dbUser.VerListaProductosBusquedaID(IdPoductoSel);

                            string cant  = cantProd.Text;
                            string pUnit = funcionesGlobales.CalcularPrecioLista(agregaProd[0].precio, agregaProd[0].ganancia, agregaProd[0].utilidad1,
                                                                                 agregaProd[0].utilidad2, agregaProd[0].utilidad3, agregaProd[0].utilidad4, agregaProd[0].utilidad5, agregaProd[0].iva,
                                                                                 VariablesGlobales.ListaPrecioCliente, agregaProd[0].calcular_precio);

                            if (PrecioProd.Text != "" & PrecioProd.Text != "0")
                            {
                                string bonificacion   = agregaProd[0].bonif;
                                string PrecioSugerido = pUnit;
                                double PrecioMinimo   = Math.Round(double.Parse(pUnit) / ((double.Parse(bonificacion) + 100) / 100), 2);
                                if (bonificacion != "0")
                                {
                                    if (double.Parse(PrecioProd.Text) < PrecioMinimo)
                                    {
                                        Toast.MakeText(this, "El precio ingresado es inferior al minimo permitido, " +
                                                       "se modificara el precio al valor correspondiente ", ToastLength.Short).Show();
                                        pUnit = PrecioMinimo.ToString();
                                    }

                                    else
                                    {
                                        pUnit = PrecioProd.Text;
                                    }
                                }
                                else
                                {
                                    pUnit = PrecioProd.Text;
                                }
                            }
                            string pTotal = (double.Parse(pUnit) * double.Parse(cantProd.Text)).ToString();
                            PedidosDetalle productoDetalle = new PedidosDetalle()
                            {
                                id_master   = VariablesGlobales.IdPedidoenCurso,
                                cod         = agregaProd[0].codigo,
                                plu         = agregaProd[0].codigo,
                                codProdMain = agregaProd[0].codProdMain,
                                descripcion = agregaProd[0].descripcion,
                                iva         = agregaProd[0].iva,
                                cantidad    = cantProd.Text,
                                punit       = pUnit,
                                ptotal      = pTotal
                            };
                            dbUser.InsertarProductoPedido(productoDetalle);
                            Toast.MakeText(this, "Producto agregado!", ToastLength.Short).Show();
                        }
                    });
                    alertDialog.SetButton2("Cancelar", (sss, eee) =>
                    {
                        Toast.MakeText(this, "No se agrego el producto!", ToastLength.Short).Show();
                    });

                    IdPoductoSel = int.Parse(e.Id.ToString());
                    List <Productos> selectPrecio = new List <Productos>();
                    selectPrecio  = dbUser.VerListaProductosBusquedaID(IdPoductoSel);
                    PrecioProdSel = funcionesGlobales.CalcularPrecioLista(selectPrecio[0].precio, selectPrecio[0].ganancia, selectPrecio[0].utilidad1,
                                                                          selectPrecio[0].utilidad2, selectPrecio[0].utilidad3, selectPrecio[0].utilidad4, selectPrecio[0].utilidad5, selectPrecio[0].iva,
                                                                          VariablesGlobales.ListaPrecioCliente, selectPrecio[0].calcular_precio);

                    PrecioProd.Hint = "Precio: $" + PrecioProdSel;
                    alertDialog.Show();
                };
            }
            if (VariablesGlobales.PedidoEnCurso == false)
            {
                btnVolverAlPedido.Enabled = false;
            }
            else
            {
                btnVolverAlPedido.Enabled = true;
            }

            btnVolverAlPedido.Click += delegate
            {
                StartActivity(typeof(PedidoActual));
            };
        }
Beispiel #17
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            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.PedidoActual);
            dbUser = new ConsultasTablas();

            lstDatosProductos = FindViewById <ListView>(Resource.Id.lstPedidoActProductos);

            var pedCliente         = FindViewById <TextView>(Resource.Id.txtPedidoCliente);
            var btnAddProducto     = FindViewById <Button>(Resource.Id.btnPedidoActAgregar);
            var btnFinalizarPedido = FindViewById <Button>(Resource.Id.btnPedidoActFinalizar);
            var btnAddProductoNvo  = FindViewById <Button>(Resource.Id.btnPedidoActAddProd);

            if (IdPedido != 0 && VariablesGlobales.PedidoEnCurso == false)
            {
                pedidosMaster = dbUser.VerPedidoMaster(IdPedido);
                IdCliente     = pedidosMaster[0].id_cliente;

                datosCliente     = dbUser.VerDetalleClienteMain(IdCliente);
                IdVendedor       = datosCliente[0].vendedor;
                IdListaPrecio    = datosCliente[0].lista_precios;
                PedidoFinalizado = pedidosMaster[0].finalizado;

                VariablesGlobales.Idvendedor         = IdVendedor;
                VariablesGlobales.ListaPrecioCliente = IdListaPrecio;
                VariablesGlobales.IdCliente          = IdCliente;
            }
            else
            {
                pedidosMaster = dbUser.VerPedidoMaster(IdPedido);
                datosCliente  = dbUser.VerDetalleClienteMain(pedidosMaster[0].id_cliente);

                IdCliente        = pedidosMaster[0].id_cliente;
                IdVendedor       = datosCliente[0].vendedor;
                IdListaPrecio    = datosCliente[0].lista_precios;
                PedidoFinalizado = pedidosMaster[0].finalizado;

                VariablesGlobales.Idvendedor         = IdVendedor;
                VariablesGlobales.ListaPrecioCliente = IdListaPrecio;
                VariablesGlobales.IdCliente          = IdCliente;
            }

            if (pedidosMaster[0].finalizado == 1 && pedidosMaster[0].enviado == 0)
            {
                VariablesGlobales.PedidoEnCurso = false;
                btnAddProducto.Enabled          = false;
                btnFinalizarPedido.Enabled      = true;
                btnFinalizarPedido.Text         = "Modificar pedido";
            }
            else if (pedidosMaster[0].finalizado == 0 && pedidosMaster[0].enviado == 0)
            {
                VariablesGlobales.PedidoEnCurso = true;
                //btnEnviarPedido.Enabled = false;
                btnAddProducto.Enabled     = true;
                btnFinalizarPedido.Enabled = true;
            }
            else if (pedidosMaster[0].finalizado == 1 && pedidosMaster[0].enviado == 1)
            {
                VariablesGlobales.PedidoEnCurso = false;
                //btnEnviarPedido.Enabled = false;
                btnAddProducto.Enabled     = false;
                btnFinalizarPedido.Enabled = false;
            }
            LoadDataPedido(IdPedido);
            LoadDataProductos(IdPedido);
            lstDatosProductos.ItemClick += (s, e) =>
            {
                LayoutInflater inputModificar = LayoutInflater.From(Application.Context);
                View           viewModificar  = inputModificar.Inflate(Resource.Layout.inputBoxCantProd, null);

                AlertDialog.Builder constrModifica = new AlertDialog.Builder(this);
                EditText            cantProd       = viewModificar.FindViewById <EditText>(Resource.Id.txtInputCantProd);
                EditText            PrecioProd     = viewModificar.FindViewById <EditText>(Resource.Id.txtInputPrecioProd);

                TextView mensajeInput = viewModificar.FindViewById <TextView>(Resource.Id.txtInputCantMensaje);
                constrModifica.SetView(viewModificar);

                string cantidad    = "";
                string precioUnit  = "";
                double precioTotal = 0;

                AlertDialog alertModificar = constrModifica.Create();
                alertModificar.SetCanceledOnTouchOutside(true);
                alertModificar.SetTitle("Modificar producto");


                alertModificar.SetButton("Modificar", (ss, ee) =>
                {
                    List <PedidosDetalle> consProdPedido = new List <PedidosDetalle>();
                    consProdPedido = dbUser.VerPedidoDetalleID(IdPoductoSel);

                    List <Productos> consultaPrecioPod = new List <Productos>();
                    consultaPrecioPod = dbUser.VerListaProductosBusquedaCod(IdProductoCod);
                    //



                    if (cantProd.Text != "" & cantProd.Text != "0")
                    {
                        cantidad = cantProd.Text;
                    }
                    else
                    {
                        cantidad = consProdPedido[0].cantidad;
                    }

                    if (PrecioProd.Text != "" & PrecioProd.Text != "0")
                    {
                        precioUnit            = consProdPedido[0].punit;
                        string bonificacion   = consultaPrecioPod[0].bonif;
                        string PrecioSugerido = funcionesGlobales.CalcularPrecioLista(consultaPrecioPod[0].precio, consultaPrecioPod[0].ganancia,
                                                                                      consultaPrecioPod[0].utilidad1, consultaPrecioPod[0].utilidad2, consultaPrecioPod[0].utilidad3, consultaPrecioPod[0].utilidad4,
                                                                                      consultaPrecioPod[0].utilidad5,
                                                                                      consultaPrecioPod[0].iva, VariablesGlobales.ListaPrecioCliente, consultaPrecioPod[0].calcular_precio);

                        double PrecioMinimo = Math.Round(double.Parse(PrecioSugerido) / ((double.Parse(bonificacion) + 100) / 100), 2);

                        if (bonificacion != "0")
                        {
                            if (double.Parse(PrecioProd.Text) < PrecioMinimo)
                            {
                                Toast.MakeText(this, "El precio ingresado es inferior al minimo permitido, " +
                                               "se modificara el precio al valor correspondiente ", ToastLength.Short).Show();
                                precioUnit = PrecioMinimo.ToString();
                            }

                            else
                            {
                                precioUnit = PrecioProd.Text;
                            }
                        }
                        else
                        {
                            precioUnit = PrecioProd.Text;
                        }
                    }
                    else
                    {
                        precioUnit = consProdPedido[0].punit;
                    }

                    precioTotal = double.Parse(precioUnit) * double.Parse(cantidad);

                    PedidosDetalle productoDetalle = new PedidosDetalle()
                    {
                        id       = IdPoductoSel,
                        cantidad = cantidad,
                        punit    = precioUnit,
                        ptotal   = precioTotal.ToString()
                    };

                    dbUser.ModificarProductoPedido(productoDetalle);
                    Toast.MakeText(this, "Producto modificado!", ToastLength.Short).Show();
                    LoadDataPedido(IdPedido);
                    LoadDataProductos(IdPedido);
                });

                alertModificar.SetButton2("Eliminar producto", (sss, eee) =>
                {
                    PedidosDetalle productoDetalle = new PedidosDetalle()
                    {
                        id = int.Parse(e.Id.ToString()),
                    };
                    if (dbUser.EliminarProductoPedido(productoDetalle))
                    {
                        Toast.MakeText(this, "Producto Eliminado!", ToastLength.Short).Show();
                    }
                    else
                    {
                        Toast.MakeText(this, "No se pudo eliminar el producto!", ToastLength.Short).Show();
                    }
                    LoadDataPedido(IdPedido);
                    LoadDataProductos(IdPedido);
                });
                IdPoductoSel = int.Parse(e.Id.ToString());

                List <PedidosDetalle> consProdPedido = new List <PedidosDetalle>();
                consProdPedido = dbUser.VerPedidoDetalleID(IdPoductoSel);
                IdProductoCod  = consProdPedido[0].codProdMain;

                PrecioProd.Hint = "Precio: $" + consProdPedido[0].punit;
                precioUnit      = consProdPedido[0].punit;

                cantProd.Hint = "Cantidad:" + consProdPedido[0].cantidad;
                cantidad      = consProdPedido[0].cantidad;
                if (PedidoFinalizado == 0)
                {
                    alertModificar.Show();
                }
            };

            Toast.MakeText(this, "Pedido cliente:" + VariablesGlobales.IdCliente + " | Pedido N°:" + VariablesGlobales.IdPedidoenCurso + " | Lista de precios:" +
                           +VariablesGlobales.ListaPrecioCliente, ToastLength.Long).Show();

            pedCliente.Text = datosCliente[0].nomapell_razon;

            btnAddProducto.Click += delegate
            {
                StartActivity(typeof(VerProductos));
            };

            btnFinalizarPedido.Click += delegate
            {
                if (btnFinalizarPedido.Text == "Modificar pedido")
                {
                    List <PedidosMaster> datosPedido = new List <PedidosMaster>();

                    datosPedido = dbUser.VerPedidoMaster(IdPedido);

                    string fecha         = datosPedido[0].fecha.ToString();
                    string subtotal      = datosPedido[0].subtotal.ToString();
                    string iva21         = datosPedido[0].iva21.ToString();
                    string total         = datosPedido[0].total.ToString();
                    string vendedor      = datosPedido[0].vendedor.ToString();
                    string observaciones = datosPedido[0].observaciones.ToString();

                    PedidosMaster pedidosMaster = new PedidosMaster()
                    {
                        id            = IdPedido,
                        id_cliente    = IdCliente,
                        fecha         = fecha,
                        finalizado    = 0,
                        subtotal      = subtotal.ToString(),
                        iva105        = "0",
                        iva21         = iva.ToString(),
                        total         = TotalFinal.ToString(),
                        vendedor      = IdVendedor.ToString(),
                        observaciones = observaciones
                    };
                    if (dbUser.ActualizaPedido(pedidosMaster))
                    {
                        btnFinalizarPedido.Text = "Finalizar pedido";
                        btnAddProducto.Enabled  = true;
                        //btnEnviarPedido.Enabled = false;
                        VariablesGlobales.PedidoEnCurso = true;
                        PedidoFinalizado = 0;
                        //LoadDataPedido(IdPedido);
                    }
                }
                else
                {
                    LayoutInflater layoutInflater   = LayoutInflater.From(Application.Context);
                    View           dialogo          = layoutInflater.Inflate(Resource.Layout.inputBoxFinalizarPedido, null);
                    TextView       txtsubtotal      = dialogo.FindViewById <TextView>(Resource.Id.txtFinalizarPedSubtotal);
                    TextView       txtiva           = dialogo.FindViewById <TextView>(Resource.Id.txtFinalizarPedIVA);
                    TextView       txtptotal        = dialogo.FindViewById <TextView>(Resource.Id.txtFinalizarPedPtotal);
                    EditText       txtObservaciones = dialogo.FindViewById <EditText>(Resource.Id.txtFinalizarPedObservaciones);

                    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
                    string           fecha            = simpleDateFormat.Format(new Date());

                    AlertDialog.Builder constrFinaliza = new AlertDialog.Builder(this);

                    constrFinaliza.SetView(dialogo);
                    AlertDialog alertFinalizar = constrFinaliza.Create();
                    alertFinalizar.SetCanceledOnTouchOutside(true);
                    alertFinalizar.SetTitle("Finalizar pedido");
                    alertFinalizar.SetButton("Finalizar", (ss, ee) =>
                    {
                        PedidosMaster pedidosMaster = new PedidosMaster()
                        {
                            id            = IdPedido,
                            id_cliente    = IdCliente,
                            fecha         = fecha,
                            finalizado    = 1,
                            subtotal      = subtotal.ToString(),
                            iva105        = "0",
                            iva21         = iva.ToString(),
                            total         = TotalFinal.ToString(),
                            vendedor      = IdVendedor.ToString(),
                            observaciones = txtObservaciones.Text
                        };
                        if (dbUser.ActualizaPedido(pedidosMaster))
                        {
                            Toast.MakeText(this, "Pedido finalizado!", ToastLength.Short).Show();
                            StartActivity(typeof(VerPedidos));
                            VariablesGlobales.IdCliente          = 0;
                            VariablesGlobales.IdPedidoenCurso    = 0;
                            VariablesGlobales.ListaPrecioCliente = 0;
                        }
                    });
                    alertFinalizar.SetButton2("Cancelar", (ss, ee) =>
                    {
                        Toast.MakeText(this, "Finalizacion cancelada!", ToastLength.Short).Show();
                    });

                    txtsubtotal.Text = "Subtotal: " + subtotal.ToString();       // Math.Round(subtotal,2).ToString();
                    txtiva.Text      = "IVA: " + iva.ToString();                 //Math.Round(iva,2).ToString();
                    txtptotal.Text   = "Total pedido: " + TotalFinal.ToString(); // Math.Round(TotalFinal,2).ToString();
                    alertFinalizar.Show();
                }
            };

            //btnAddProductoNvo.Click += delegate
            // {
            //     LayoutInflater layoutInflater = LayoutInflater.From(Application.Context);

            //     View dialogo = layoutInflater.Inflate(Resource.Layout.inputBoxNvoProd, null);

            //     AlertDialog.Builder builder = new AlertDialog.Builder(this);

            //     EditText cantProd = dialogo.FindViewById<EditText>(Resource.Id.txtNvoProdCantidad);
            //     EditText PrecioProd = dialogo.FindViewById<EditText>(Resource.Id.txtNvoProdPrecio);
            //     EditText DescripcionProd = dialogo.FindViewById<EditText>(Resource.Id.txtNvoProdDescripcion);
            //     EditText ivaProd = dialogo.FindViewById<EditText>(Resource.Id.txtNvoProdIVA);

            //     builder.SetView(dialogo);
            //     AlertDialog alertDialog = builder.Create();

            //     alertDialog.SetCanceledOnTouchOutside(true);
            //     alertDialog.SetTitle("Agregar producto fuera de lista");
            //     alertDialog.SetButton("Agregar", (ss, ee) =>
            //     {
            //         if (cantProd.Text == "" || cantProd.Text == "0")
            //         {
            //             Toast.MakeText(this, "La cantidad debe ser mayor que Cero!", ToastLength.Short).Show();
            //         }
            //         else
            //         {

            //             string cant = cantProd.Text;
            //             string pUnit = "0";
            //             if (PrecioProd.Text != "" & PrecioProd.Text != "0")
            //             {
            //                 pUnit = PrecioProd.Text;
            //             }
            //             string pTotal = (double.Parse(pUnit) * double.Parse(cantProd.Text)).ToString();
            //             PedidosDetalle productoDetalle = new PedidosDetalle()
            //             {
            //                 id_master = VariablesGlobales.IdPedidoenCurso,
            //                 cod = "0",
            //                 plu = "0",
            //                 codProdMain = 0,
            //                 descripcion = DescripcionProd.Text,
            //                 iva = "21,00",
            //                 cantidad = cantProd.Text,
            //                 punit = pUnit,
            //                 ptotal = pTotal
            //             };
            //             dbUser.InsertarProductoPedido(productoDetalle);
            //             Toast.MakeText(this, "Producto agregado!", ToastLength.Short).Show();
            //             LoadDataProductos(VariablesGlobales.IdPedidoenCurso);
            //         }
            //     });
            //     alertDialog.SetButton2("Cancelar", (sss, eee) =>
            //     {
            //         Toast.MakeText(this, "No se agrego el producto!", ToastLength.Short).Show();
            //     });
            //     alertDialog.Show();
            // };
        }
Beispiel #18
0
        public string CalcularPrecioLista(string precio, string utilidad, string utilidad1, string utilidad2, string utilidad3, string utilidad4, string utilidad5, string iva, int idLista, int moneda)
        {
            List <ListasPrecio> listasPrecios = new List <ListasPrecio>();
            ConsultasTablas     dbuser        = new ConsultasTablas();
            double cotizacion = 0;

            if (moneda == 1)
            {
                cotizacion = 1;
            }
            else if (moneda == 2)
            {
                cotizacion = VariablesGlobales.CotizacionDolar;
            }
            string Precios = "";

            if (iva == "")
            {
                iva = "0";
            }
            if (precio == "")
            {
                precio = "0";
            }
            if (utilidad == "")
            {
                utilidad = "0";
            }
            if (utilidad1 == "")
            {
                utilidad1 = "0";
            }
            if (utilidad2 == "")
            {
                utilidad2 = "0";
            }
            if (utilidad3 == "")
            {
                utilidad3 = "0";
            }
            if (utilidad4 == "")
            {
                utilidad4 = "0";
            }
            if (utilidad5 == "")
            {
                utilidad5 = "0";
            }

            precio    = CambiarPuntoDecimalEU(precio);
            iva       = CambiarPuntoDecimalEU(iva);
            utilidad  = CambiarPuntoDecimalEU(utilidad);
            utilidad1 = CambiarPuntoDecimalEU(utilidad1);
            utilidad2 = CambiarPuntoDecimalEU(utilidad2);
            utilidad3 = CambiarPuntoDecimalEU(utilidad3);
            utilidad4 = CambiarPuntoDecimalEU(utilidad4);
            utilidad5 = CambiarPuntoDecimalEU(utilidad5);

            double LISTA       = 0;
            double precioFinal = 0;

            double IVA       = Convert.ToDouble(iva);
            double PRECIO    = Convert.ToDouble(precio);
            double GANANCIA  = Convert.ToDouble(utilidad);
            double GANANCIA1 = Convert.ToDouble(utilidad1);
            double GANANCIA2 = Convert.ToDouble(utilidad2);
            double GANANCIA3 = Convert.ToDouble(utilidad3);
            double GANANCIA4 = Convert.ToDouble(utilidad4);
            double GANANCIA5 = Convert.ToDouble(utilidad5);
            double utilSum   = GANANCIA2;

            IVA       = (IVA + 100) / 100;
            GANANCIA  = (GANANCIA + 100) / 100;
            GANANCIA1 = (GANANCIA1 + 100) / 100;
            GANANCIA2 = (GANANCIA2 + 100) / 100;
            GANANCIA3 = (GANANCIA3 + 100) / 100;
            GANANCIA4 = (GANANCIA4 + 100) / 100;
            GANANCIA5 = (GANANCIA5 + 100) / 100;


            if (idLista == 0)
            {
                listasPrecios = dbuser.VerListaPrecio();

                for (int i = 0; i <= listasPrecios.Count() - 1; i++)
                {
                    string modo   = listasPrecios[i].utilidad;
                    int    auxcol = listasPrecios[i].auxcol;
                    if (modo.Contains("%"))
                    {
                        LISTA = Convert.ToDouble(listasPrecios[i].utilidad.Replace(",", ".").Replace("%", ""));
                        //utilSum = (utilSum + LISTA + 100) / 100;
                        LISTA = (LISTA + 100) / 100;

                        precioFinal = Math.Round(PRECIO * IVA * LISTA * cotizacion, 2);
                        Precios     = Precios + listasPrecios[i].nombre + " : $" + precioFinal + "\n";
                    }
                    else
                    {
                        LISTA   = Convert.ToDouble(listasPrecios[i].utilidad.Replace(",", "."));
                        utilSum = (utilSum + LISTA + 100) / 100;
                        LISTA   = (LISTA + 100) / 100;
                        if (VariablesGlobales.MetodoCalculo == 1)
                        {
                            switch (auxcol)
                            {
                            case 0:
                                precioFinal = Math.Round(PRECIO * IVA * GANANCIA * LISTA * cotizacion, 2);
                                Precios     = Precios + listasPrecios[i].nombre + " : $" + precioFinal + "\n";
                                break;

                            case 1:
                                precioFinal = Math.Round(PRECIO * IVA * GANANCIA1 * LISTA * cotizacion, 2);
                                Precios     = Precios + listasPrecios[i].nombre + " : $" + precioFinal + "\n";
                                break;

                            case 2:
                                precioFinal = Math.Round(PRECIO * IVA * GANANCIA2 * LISTA * cotizacion, 2);
                                Precios     = Precios + listasPrecios[i].nombre + " : $" + precioFinal + "\n";
                                break;

                            case 3:
                                precioFinal = Math.Round(PRECIO * IVA * GANANCIA3 * LISTA * cotizacion, 2);
                                Precios     = Precios + listasPrecios[i].nombre + " : $" + precioFinal + "\n";
                                break;

                            case 4:
                                precioFinal = Math.Round(PRECIO * IVA * GANANCIA4 * LISTA * cotizacion, 2);
                                Precios     = Precios + listasPrecios[i].nombre + " : $" + precioFinal + "\n";
                                break;

                            case 5:
                                precioFinal = Math.Round(PRECIO * IVA * GANANCIA5 * LISTA * cotizacion, 2);
                                Precios     = Precios + listasPrecios[i].nombre + " : $" + precioFinal + "\n";
                                break;
                            }
                        }
                        else if (VariablesGlobales.MetodoCalculo == 0)
                        {
                            switch (auxcol)
                            {
                            case 0:
                                precioFinal = Math.Round(PRECIO * IVA * ((GANANCIA + LISTA) - 1) * cotizacion, 2);
                                Precios     = Precios + listasPrecios[i].nombre + " : $" + precioFinal + "\n";
                                break;

                            case 1:
                                precioFinal = Math.Round(PRECIO * IVA * ((GANANCIA1 + LISTA) - 1) * cotizacion, 2);
                                Precios     = Precios + listasPrecios[i].nombre + " : $" + precioFinal + "\n";
                                break;

                            case 2:
                                precioFinal = Math.Round(PRECIO * IVA * ((GANANCIA2 + LISTA) - 1) * cotizacion, 2);
                                Precios     = Precios + listasPrecios[i].nombre + " : $" + precioFinal + "\n";
                                break;

                            case 3:
                                precioFinal = Math.Round(PRECIO * IVA * ((GANANCIA3 + LISTA) - 1) * cotizacion, 2);
                                Precios     = Precios + listasPrecios[i].nombre + " : $" + precioFinal + "\n";
                                break;

                            case 4:
                                precioFinal = Math.Round(PRECIO * IVA * ((GANANCIA4 + LISTA) - 1) * cotizacion, 2);
                                Precios     = Precios + listasPrecios[i].nombre + " : $" + precioFinal + "\n";
                                break;

                            case 5:
                                precioFinal = Math.Round(PRECIO * IVA * ((GANANCIA5 + LISTA) - 1) * cotizacion, 2);
                                Precios     = Precios + listasPrecios[i].nombre + " : $" + precioFinal + "\n";
                                break;
                            }
                        }
                    }
                }
                Precios = "Seleccione un cliente para poder ver los precios";
                return(Precios);
            }
            else
            {
                listasPrecios = dbuser.VerListaPrecioId(idLista);
                string modo   = listasPrecios[0].utilidad;
                int    auxcol = listasPrecios[0].auxcol;
                if (modo.Contains("%"))
                {
                    LISTA = Convert.ToDouble(listasPrecios[0].utilidad.Replace(",", ".").Replace("%", ""));
                    LISTA = (LISTA + 100) / 100;

                    precioFinal = Math.Round(PRECIO * IVA * LISTA * cotizacion, 2);
                    Precios     = precioFinal.ToString();
                    return(Precios);
                }
                else
                {
                    LISTA = Convert.ToDouble(listasPrecios[0].utilidad.Replace(",", "."));
                    LISTA = (LISTA + 100) / 100;

                    if (VariablesGlobales.MetodoCalculo == 1)
                    {
                        switch (auxcol)
                        {
                        case 0:
                            precioFinal = Math.Round(PRECIO * IVA * GANANCIA * LISTA * cotizacion, 2);
                            Precios     = precioFinal.ToString();
                            break;

                        case 1:
                            precioFinal = Math.Round(PRECIO * IVA * GANANCIA1 * LISTA * cotizacion, 2);
                            Precios     = precioFinal.ToString();
                            break;

                        case 2:
                            precioFinal = Math.Round(PRECIO * IVA * GANANCIA2 * LISTA * cotizacion, 2);
                            Precios     = precioFinal.ToString();
                            break;

                        case 3:
                            precioFinal = Math.Round(PRECIO * IVA * GANANCIA3 * LISTA * cotizacion, 2);
                            Precios     = precioFinal.ToString();
                            break;

                        case 4:
                            precioFinal = Math.Round(PRECIO * IVA * GANANCIA4 * LISTA * cotizacion, 2);
                            Precios     = precioFinal.ToString();
                            break;

                        case 5:
                            precioFinal = Math.Round(PRECIO * IVA * GANANCIA5 * LISTA * cotizacion, 2);
                            Precios     = precioFinal.ToString();
                            break;
                        }
                    }
                    else if (VariablesGlobales.MetodoCalculo == 0)
                    {
                        switch (auxcol)
                        {
                        case 0:
                            precioFinal = Math.Round(PRECIO * IVA * ((GANANCIA + LISTA) - 1) * cotizacion, 2);
                            Precios     = precioFinal.ToString();
                            break;

                        case 1:
                            precioFinal = Math.Round(PRECIO * IVA * ((GANANCIA1 + LISTA) - 1) * cotizacion, 2);
                            Precios     = precioFinal.ToString();
                            break;

                        case 2:
                            precioFinal = Math.Round(PRECIO * IVA * ((GANANCIA2 + LISTA) - 1) * cotizacion, 2);
                            Precios     = precioFinal.ToString();
                            break;

                        case 3:
                            precioFinal = Math.Round(PRECIO * IVA * ((GANANCIA3 + LISTA) - 1) * cotizacion, 2);
                            Precios     = precioFinal.ToString();
                            break;

                        case 4:
                            precioFinal = Math.Round(PRECIO * IVA * ((GANANCIA4 + LISTA) - 1) * cotizacion, 2);
                            Precios     = precioFinal.ToString();
                            break;

                        case 5:
                            precioFinal = Math.Round(PRECIO * IVA * ((GANANCIA5 + LISTA) - 1) * cotizacion, 2);
                            Precios     = precioFinal.ToString();
                            break;
                        }
                    }
                    return(Precios);
                }
            }
        }