Пример #1
0
 public void CheckSetQuantity()
 {
     try
     {
         var newitems = OrderItemsList.Where(x => x.SNO == 0).ToList();
         foreach (var i in OrderItemsList)
         {
             var item = SelectedItemsList.ToList().Find(x => x.MCODE == i.MCODE);
             if (i.SNO == 0)
             {
                 if (item != null)
                 {
                     item.SetQuantity = (decimal)i.Quantity;
                 }
             }
             else
             {
                 if (item != null)
                 {
                     item.SetQuantity = 0;
                 }
             }
         }
     }catch (Exception ex)
     {
         DependencyService.Get <IMessage>().ShortAlert(ex.Message);
     }
 }
Пример #2
0
        //Function for viewing the change in KOTMainMenuPage
        public void SelectedItemCount(M.MenuItem obj)
        {
            try
            {
                var     selected = SelectedItemsList.ToList().Find(x => x.MCODE == obj.MCODE);
                var     items    = OrderItemsList.Where(x => x.MCODE == selected.MCODE).ToList();
                decimal count    = 0;
                foreach (var i in items)
                {
                    count = count + (decimal)i.Quantity;
                }
                selected.QUANTITY = count;

                decimal setCount = 0;
                var     newItems = items.Where(x => x.SNO == 0).ToList();
                if (newItems != null)
                {
                    foreach (var i in newItems)
                    {
                        setCount = setCount + (decimal)i.Quantity;
                    }
                    selected.SetQuantity = setCount;
                }
            }
            catch (Exception ex)
            {
                DependencyService.Get <IMessage>().ShortAlert(ex.Message);
            }
        }
Пример #3
0
        public void ExecuteRemarksOkCommand()
        {
            var found = OrderItemsList.Where(x => x.OrderSNO == SelectedOrderItem.OrderSNO).ToList();

            found.ForEach(x => x.Remarks = SelectedOrderItem.Remarks);
            IsRemarks = false;
        }
Пример #4
0
        public void ExecuteDecreaseOrderCommand(KOTProd obj)
        {
            try
            {
                //new KOTProd (SNO = 0 )
                if (obj.SNO == 0)
                {
                    if (obj.Quantity > 1)
                    {
                        var item = OrderItemsList.ToList().Find(x => (x.MCODE == obj.MCODE) && (x.SNO == 0));
                        item.Quantity -= 1;
                        OrderItemsList = new ObservableCollection <KOTProd>(OrderItemsList);
                        OrderItemsList.OrderBy(x => x.SNO);

                        M.MenuItem selectedObj = new M.MenuItem()
                        {
                            MCODE = obj.MCODE
                        };
                        SelectedItemCount(selectedObj);
                    }
                    else if (obj.Quantity == 1)
                    {
                        var item = OrderItemsList.ToList().Find(x => (x.MCODE == obj.MCODE) && (x.SNO == 0));
                        OrderItemsList.Remove(item);
                        M.MenuItem selectedObj = new M.MenuItem()
                        {
                            MCODE = obj.MCODE
                        };
                        SelectedItemCount(selectedObj);
                    }
                    else if (obj.Quantity < 1)
                    {
                        DependencyService.Get <IMessage>().ShortAlert("Cannot decrease");
                    }
                }

                //old saved KOTProd ( SNO > 0 )
                else
                {
                    //if quantity is negative return
                    if (obj.Quantity <= 1 || (obj.Quantity + obj.DecQuantity) <= 1)
                    {
                        DependencyService.Get <IMessage>().ShortAlert("Cannot Decrease. Only one Item left.Click Cancel");
                        return;
                    }

                    var items = OrderItemsList.Where(x => x.MCODE == obj.MCODE).ToList();

                    var    negativeItems = items.Where(x => x.REFSNO == obj.SNO);
                    double qty           = 0;
                    double negQty        = 0;
                    foreach (var i in negativeItems)
                    {
                        negQty += i.Quantity;
                    }

                    var match = items.Find(x => x.REFSNO == obj.SNO && x.SNO == 0);
                    if (match != null)
                    {
                        qty = obj.Quantity + negQty;
                        if (qty > 1)
                        {
                            obj.DecQuantity -= 1;
                            match.Quantity  -= 1;
                        }
                        else if (qty == 1)
                        {
                            SelectedOrderItem = obj;
                            IsCancel          = true;
                        }
                    }
                    else
                    {
                        obj.DecQuantity -= 1;
                        var item    = SubMenuList.Find(x => x.MCODE == obj.MCODE);
                        var KOTItem = M.MenuItem.MenuItemsToKOTProd(item);
                        KOTItem.Quantity = -1;
                        KOTItem.REFSNO   = obj.SNO;
                        OrderItemsList.Add(KOTItem);
                        DependencyService.Get <IMessage>().ShortAlert("Item added to Order List");
                    }

                    RefreshOrderItemsList();
                }
            }
            catch (Exception ex)
            {
                DependencyService.Get <IMessage>().ShortAlert(ex.Message);
            }
        }
Пример #5
0
        public async void ExecuteLoginCheckCommand()
        {
            try
            {
                LoadingMessage = "Loading!! Please wait a while";
                IsLoading      = true;
                if (CancelingUser == null)
                {
                    return;
                }
                if (string.IsNullOrEmpty(CancelingUser.UserName))
                {
                    DependencyService.Get <IMessage>().ShortAlert("UserName is empty");
                }
                else if (string.IsNullOrEmpty(CancelingUser.Password))
                {
                    DependencyService.Get <IMessage>().ShortAlert("Password is empty");
                }
                else
                {
                    var res = await LoginConnection.CheckAccessAsync(CancelingUser);

                    if (res.ToLower() == "success")
                    {
                        double qty       = 0;
                        double decreased = 0;
                        double left      = 0;

                        if (SelectedOrderItem.Quantity > 0)
                        {
                            var items = OrderItemsList.Where(x => x.REFSNO == SelectedOrderItem.SNO).ToList();
                            foreach (var i in items)
                            {
                                qty += i.Quantity;
                                if (i.SNO > 0)
                                {
                                    decreased += i.Quantity;
                                }
                            }
                        }

                        var neg = -(SelectedOrderItem.Quantity + qty);
                        if (neg < 0)
                        {
                            var items = OrderItemsList.Where(x => x.REFSNO == SelectedOrderItem.SNO).ToList();
                            foreach (var i in items)
                            {
                                if (i.SNO == 0)
                                {
                                    i.Quantity = -(SelectedOrderItem.Quantity - decreased);
                                    i.Remarks  = CancelingUser.Remarks;
                                    RefreshOrderItemsList();
                                    CancelingUser = new User();
                                    IsCancel      = false;
                                    IsLoading     = false;
                                    return;
                                }
                            }

                            var item    = SubMenuList.Find(x => x.MCODE == SelectedOrderItem.MCODE);
                            var KOTItem = M.MenuItem.MenuItemsToKOTProd(item);
                            KOTItem.Remarks  = CancelingUser.Remarks;
                            KOTItem.Quantity = neg;
                            KOTItem.REFSNO   = SelectedOrderItem.SNO;
                            OrderItemsList.Add(KOTItem);
                        }
                    }
                    else
                    {
                        DependencyService.Get <IMessage>().ShortAlert(res);
                    }
                }
                RefreshOrderItemsList();

                CancelingUser = new User();
                IsCancel      = false;
                IsLoading     = false;
            }catch (Exception ex)
            {
                IsCancel  = false;
                IsLoading = false;
                DependencyService.Get <IMessage>().ShortAlert(ex.Message);
            }
        }