Exemplo n.º 1
0
 private void ctaOferta_Clicked(object sender, EventArgs e)
 {
     try
     {
         EntregaItemVendido iv = ((Button)sender).BindingContext as EntregaItemVendido;
         if (iv.Oferta)
         {
             iv.Oferta             = false;
             ((Button)sender).Text = "NO";
         }
         else
         {
             iv.Oferta             = true;
             ((Button)sender).Text = "OF";
         }
         this.viewModel.TotalRefresh();
         this.TotalAmount.Text    = viewModel.Item.Total.ToString("#.##");
         this.SubTotalAmount.Text = viewModel.Item.SubTotal.ToString("#.##");
     }
     catch (Exception ex)
     {
         string    messag = "";
         Exception er     = ex;
         while (er != null)
         {
             messag += er.Message + "!!!";
             er      = er.InnerException;
         }
         ((Entry)sender).TextColor = Const.TextInvalidColor;
         DisplayAlert("Error", messag, "OK");
     }
 }
Exemplo n.º 2
0
        private async void lstItemVendidos_ItemSelected(object sender, SelectedItemChangedEventArgs e)
        {
            EntregaItemVendido param = e.SelectedItem as EntregaItemVendido;

            viewModel.EditingPosition = viewModel.iVendidos.IndexOf(param);
            await Navigation.PushModalAsync(new EntregaAddProducto(viewModel, viewModel.Item.EsMayorista, param));
        }
Exemplo n.º 3
0
 public List <EntregaItemVendido> ReadEntrega(int id)
 {
     try
     {
         List <EntregaItemVendido> rt = new List <EntregaItemVendido>();
         string   path  = System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments);
         string   f     = System.IO.Path.Combine(path, id.ToString() + ".txt");
         string[] lines = System.IO.File.ReadAllLines(f);
         foreach (string e in lines)
         {
             string[]           values = e.Split("||".ToCharArray());
             EntregaItemVendido t      = new EntregaItemVendido();
             t.Producto        = new Producto();
             t.EntregaId       = int.Parse(values[0]);
             t.Producto.Codigo = values[1];
             t.Producto.Nombre = values[2];
             t.PrecioUnitario  = double.Parse("0" + values[3]);
             t.PrecioOferta    = double.Parse("0" + values[4]);
             t.CantidadNor     = int.Parse("0" + values[5]);
             t.CantidadDev     = int.Parse("0" + values[6]);
             //t.Devolucion = t.CantidadDev > 0;
             t.Oferta     = bool.Parse(values[7]);
             t.Devolucion = bool.Parse(values[8]);
             rt.Add(t);
             //IDentrega||ProductoID||ProductoDescripcion||PrecioUnitario||PrecioOferta||cantidadNormal||CantidadDevolucion
         }
         return(rt);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        public EntregaAddProducto(EntregaCreacionViewModel viewModel, bool EsMayorista, EntregaItemVendido _item)
        {
            try
            {
                vmParent = viewModel;

                item           = _item;
                BindingContext = this;
                InitializeComponent();
                this.cta_eliminar.IsEnabled = true;
                this.cta_agregar.Text       = "Guardar";
                esMayorista                = EsMayorista;
                this.SC_Devolucion.On      = item.Devolucion;
                this.SC_Oferta.On          = item.Oferta;
                this.ProdCtaSrc.Text       = item.Cantidad.ToString();
                this.SubTotal.Text         = item.SubTotal.ToString();
                this.ProdcutoSrc.Text      = item.Producto.Codigo;
                this.ProdcutoSrc.IsEnabled = false;
                vmParent.ProductoIncrementarStockPorEdicion(item.Producto.Codigo, item.Cantidad);
                ProductoSelected.Text = string.Concat(item.Producto.Codigo, " - ", item.Producto.Nombre, " - $ ", item.PrecioUnitario);
            }
            catch (Exception ex)
            {
                string    messag = "";
                Exception er     = ex;
                while (er != null)
                {
                    messag += er.Message + "!!!";
                    er      = er.InnerException;
                }

                DisplayAlert("Error", messag, "OK");
            }
        }
Exemplo n.º 5
0
            public static bool IsStockValid(EntregaItemVendido iv)
            {
                bool IsValid = true;

                if (iv != null)
                {
                    if (!(iv.Producto.Stock >= iv.CantidadDev + iv.CantidadNor))
                    {
                        IsValid = false;
                    }
                }
                else
                {
                    IsValid = false;
                }
                return(IsValid);
            }
        public EntregaCreacionViewModel(bool isSavana)
        {
            _isSavana  = isSavana;
            ItemMaster = new EntregaMock();
            Item       = new Entrega();
            iVendidos  = new ObservableRangeCollection <EntregaItemVendido>();
            var list = App.ProductoDB.GetItems();
            EntregaItemVendido tmp;

            _stock = new Dictionary <string, int>();
            foreach (Producto iv in list)
            {
                this._stock.Add(iv.Codigo, iv.Stock);
                tmp               = new EntregaItemVendido();
                tmp.Producto      = iv;
                tmp.CostoUnitario = iv.CostoUnitario;
                iVendidos.Add(tmp);
            }
        }
Exemplo n.º 7
0
        void HandleTextChanged(object sender, TextChangedEventArgs e)
        {
            bool  IsValid         = true;
            Entry ety             = sender as Entry;
            EntregaItemVendido iv = ety.BindingContext as EntregaItemVendido;

            if (iv != null)
            {
                if (!(iv.Producto.Stock >= iv.CantidadDev + iv.CantidadNor))
                {
                    IsValid = false;
                }
            }
            else
            {
                IsValid = false;
            }
            ((EntregaItemVendido)ety.BindingContext).IsValid = IsValid;
            ((Entry)sender).TextColor = IsValid ? PanLoco.Helpers.Const.TextValidColor : PanLoco.Helpers.Const.TextInvalidColor;
        }
Exemplo n.º 8
0
        private async void lstItemVendidos_ItemSelected(object sender, SelectedItemChangedEventArgs e)
        {
            try
            {
                EntregaItemVendido param = e.SelectedItem as EntregaItemVendido;
                viewModel.EditingPosition = viewModel.iVendidos.IndexOf(param);
                await Navigation.PushModalAsync(new EntregaAddProducto(viewModel, viewModel.Item.EsMayorista, param));
            }
            catch (Exception ex)
            {
                string    messag = "";
                Exception er     = ex;
                while (er != null)
                {
                    messag += er.Message + "!!!";
                    er      = er.InnerException;
                }

                await DisplayAlert("Error", messag, "OK");
            }
        }
Exemplo n.º 9
0
        private bool Validate(Entry ety)
        {
            EntregaItemVendido iv = ety.BindingContext as EntregaItemVendido;

            if (iv != null)
            {
                if (!(iv.Producto.Stock > iv.CantidadDev + iv.CantidadNor))
                {
                    DisplayAlert("Stock Faltante", "Tenes " + iv.Producto.Stock + " de " + iv.Producto.Nombre, "OK");
                    ety.BackgroundColor = Color.Red;
                    return(false);
                }
            }
            else
            {
                DisplayAlert("Erro", "algo salió mal. Cerra la aplicación y volve a abrirla", "OK");
                ety.BackgroundColor = Color.Red;
                return(false);
            }
            ety.BackgroundColor = Color.Transparent;
            return(true);
        }
        private void ProccessItemsVendidos()
        {
            EntregaItemVendido iTemp = null;

            Item.Total = 0;
            foreach (EntregaItemVendido eiv in iVendidos)
            {
                if (eiv.CantidadNor > 0)
                {
                    iTemp = new EntregaItemVendido
                    {
                        Producto        = eiv.Producto,
                        CantidadNor     = eiv.CantidadNor,
                        CantidadDev     = 0,
                        Devolucion      = false,
                        Oferta          = eiv.Oferta,
                        PrecioMayorista = eiv.Producto.PrecioMayorista,
                        PrecioOferta    = eiv.Producto.PrecioOferta,
                        PrecioUnitario  = eiv.Producto.PrecioUnitario,
                        ProductoID      = eiv.Producto.Id
                    };
                    if (iTemp.Oferta)
                    {
                        iTemp.SubTotal = iTemp.CantidadNor * iTemp.PrecioOferta;
                    }
                    else
                    {
                        iTemp.SubTotal = iTemp.CantidadNor * iTemp.PrecioUnitario;
                        if (this.Item.ClienteDescuento > 0)
                        {
                            iTemp.SubTotal -= iTemp.SubTotal * (this.Item.ClienteDescuento / 100);
                        }
                    }
                    Item.ItemVendidos.Add(iTemp);
                    Item.Total += iTemp.SubTotal;
                }
                if (eiv.CantidadDev > 0)
                {
                    iTemp = new EntregaItemVendido
                    {
                        Producto        = eiv.Producto,
                        CantidadNor     = 0,
                        CantidadDev     = eiv.CantidadDev,
                        Devolucion      = true,
                        Oferta          = eiv.Oferta,
                        PrecioMayorista = eiv.Producto.PrecioMayorista,
                        PrecioOferta    = eiv.Producto.PrecioOferta,
                        PrecioUnitario  = eiv.Producto.PrecioUnitario,
                        ProductoID      = eiv.Producto.Id
                    };
                    Item.ItemVendidos.Add(iTemp);
                }
                //if (eiv.Oferta && eiv.CantidadNor > 0)
                //{
                //    eiv.PrecioOferta = eiv.Producto.PrecioOferta;
                //    eiv.SubTotal = eiv.PrecioOferta * eiv.CantidadNor;
                //}
                //else if (!eiv.Oferta && eiv.CantidadNor > 0)
                //{
                //    eiv.PrecioUnitario = eiv.Producto.PrecioUnitario;
                //    eiv.SubTotal = eiv.PrecioUnitario * eiv.CantidadNor;
                //}
                if (eiv.CantidadNor > 0 || eiv.CantidadDev > 0)
                {
                    //Item.ItemVendidos.Add(eiv);
                    //Item.Total += eiv.SubTotal;
                    SetStock(eiv.Producto.Codigo, eiv.CantidadDev + eiv.CantidadNor, false);
                }
            }
        }