コード例 #1
0
        public async Task <bool> RemoveStockLigneMIAsync(StockLigne obj)
        {
            if (obj == null)
            {
                return(false);
            }
            IList <StockLigne> stocks = new List <StockLigne>();

            try
            {
                stocks = await getStockLigneObjectsMIAsync();

                if (stocks == null)
                {
                    return(false);
                }

                for (int i = 0; i < stocks.Count; i++)
                {
                    if (obj.code.Equals(stocks[i].code) && obj.prix.Equals(stocks[i].prix) && (obj.sense == 1) && obj.depin.DEPID == stocks[i].depin.DEPID)
                    {
                        stocks.RemoveAt(i);
                    }
                }
                return(addStockLigneListMIAsync(stocks));
            }
            catch (Exception e)
            {
                Console.WriteLine("Data service ==== error deleting to stock element list" + e.StackTrace);
                return(false);
            }
        }
コード例 #2
0
        public async Task <bool> addStockLigneMTAsync(StockLigne obj)
        {
            if (obj == null)
            {
                return(false);
            }
            try
            {
                var stocks = await getStockLigneObjectsMTAsync();

                if (stocks == null)
                {
                    stocks = new List <StockLigne>();
                }
                //for (int i = 0; i < stocks.Count; i++)
                //{

                //    if (obj.code.Equals(stocks[i].code) && obj.prix.Equals(stocks[i].prix) && (obj.sense == 0) && obj.depin.DEPID == stocks[i].depin.DEPID && obj.depout.DEPID == stocks[i].depout.DEPID && (int.Parse(obj.quantite) > 0))
                //    {
                //        obj.quantite = (int.Parse(stocks[i].quantite) + int.Parse(obj.quantite)).ToString();
                //        if (await RemoveStockLigneMTAsync(stocks[i]))
                //        {
                //            stocks.RemoveAt(i);
                //            stocks.Add(obj);
                //            return addStockLigneListMTAsync(stocks);
                //        }
                //    }
                //}
                if (int.Parse(obj.quantite) > 0)
                {
                    stocks.Add(obj);
                    return(addStockLigneListMTAsync(stocks));
                }
                return(false);
            }
            catch (Exception e)
            {
                Console.WriteLine("Data service ==== error adding to stock element list" + e.StackTrace);
                return(false);
            }
        }
コード例 #3
0
        private void _validate(object obj)
        {
            try
            {
                var q = (float)_restService.GetARTDEPOTbyDepid(article.ARTID.ToString(), selectedDepot.DEPID.ToString()).Result.ARDSTOCKREEL;
            }
            catch
            {
                _dialogService.ShowMessage("ce produit n'existe pas dans ce depo", true);
                return;
            }

            try
            {
                reelQuantity = (float)_restService.GetARTDEPOTbyDepid(article.ARTID.ToString(), selectedDepot.DEPID.ToString()).Result.ARDSTOCKREEL;
                if (string.IsNullOrEmpty(Quantity))
                {
                    _dialogService.ShowMessage("Erreur : quantite doit être supérieur à 0 ", true);
                    return;
                }


                if (Quantity.Equals(null))
                {
                    _dialogService.ShowMessage("Erreur : veillez saisir un code valid ", true);
                    return;
                }
                if (int.Parse(Quantity) < 0)
                {
                    _dialogService.ShowMessage("Erreur : quantite doit être supérieur à 0 ", true);
                    return;
                }
                if (int.Parse(Quantity) > reelQuantity)
                {
                    _dialogService.ShowMessage("Erreur : quantite doit être supérieur à  " + reelQuantity, true);
                    return;
                }
                if (int.Parse(pht) < 0)
                {
                    _dialogService.ShowMessage("Erreur : prix doit être supérieur à 0 ", true);
                    return;
                }
            }
            catch
            {
                _dialogService.ShowMessage("Erreur  ", true);
            }
            var comp = _restService.getPieceDiversNumber().Result + numligne;

            numeroPiece = numauto.NUMSOUCHE + "000" + comp;
            numligne++;
            StockLigne stockLigne = new StockLigne
            {
                code            = code,
                designation     = designation,
                quantite        = Quantity,
                prix            = pht,
                depin           = null,
                depout          = selectedDepot,
                sense           = -1,
                article         = article,
                artfamilles_cpt = artfamilles_cpt,
                artarifligne    = artarifligne,
                numpiece        = numeroPiece,
                numauto         = numauto,
                pIECE_NATURE    = selectednature
            };

            Task.Run(async() =>
            {
                if (await _dataServices.addStockLigneMSAsync(stockLigne))
                {
                    _dialogService.ShowMessage("article " + code + " ajouter list avec succes", false);
                    MessagingCenter.Send(this, "MS");
                }
                else
                {
                    _dialogService.ShowMessage("error", true);
                }
            });
        }