Beispiel #1
0
        //Command Execution for Order Clicked in KOTMainMenuPage
        public void ExecuteOrderCommand(M.MenuItem obj)
        {
            try
            {
                if (obj.SetQuantity == 0)
                {
                    DependencyService.Get <IMessage>().ShortAlert("Enter Quantity to Order");
                    return;
                }
                else
                {
                    var selected = SelectedItemsList.ToList().Find(x => x.MCODE == obj.MCODE);

                    var item    = OrderItemsList.ToList().Find(x => ((x.MCODE == obj.MCODE) && (x.SNO == 0)));
                    var KOTItem = M.MenuItem.MenuItemsToKOTProd(obj);

                    KOTItem.Quantity = (double)obj.SetQuantity;
                    OrderItemsList.Add(KOTItem);
                    DependencyService.Get <IMessage>().ShortAlert("Item added to Order List");

                    selected.SetQuantity = 0;

                    SelectedItemCount(obj);

                    //OrderItemsList = new ObservableCollection<KOTProd>(OrderItemsList);
                    //OrderItemsList.OrderBy(x => x.SNO);
                    DecreaseItemCount();
                }
            }catch (Exception ex)
            {
                DependencyService.Get <IMessage>().ShortAlert(ex.Message);
            }
        }
Beispiel #2
0
        public void ExecuteDecreaseMenuItemCommand(M.MenuItem menuItem)
        {
            if (menuItem.QUANTITY < 1)
            {
                DependencyService.Get <IMessage>().ShortAlert("Cannot decrease");
                return;
            }

            var items = OrderItemsList.ToList().Where(x => (x.MCODE == menuItem.MCODE && x.Quantity > 0));
            var obj   = items.ToList().Find(x => x.SNO == 0);

            if (obj == null)
            {
                DependencyService.Get <IMessage>().ShortAlert("Cannot decrease already Ordered Items from here");
                return;
                //decimal count = 0;
                //foreach (var item in items)
                //{
                //    count += (decimal)item.Quantity;
                //}
                //if (count > 1)
                //{
                //    obj = items.ToList().Find(x => (x.Quantity-x.DecQuantity) > 1);
                //}
                //else
                //{
                //    DependencyService.Get<IMessage>().ShortAlert("Cannot decrease");
                //    return;
                //}
            }
            ExecuteDecreaseOrderCommand(obj);
        }
Beispiel #3
0
        //Command Execution for New and Save KOT Button
        public async void ExecuteKOTCommand(string val)
        {
            try
            {
                var res = await App.Current.MainPage.DisplayAlert("Confirm", "Are you sure?", "Yes", "No");

                if (res)
                {
                    //New KOT
                    if (val == "1")
                    {
                        await App.Current.MainPage.Navigation.PopAsync();
                    }

                    //Save KOT
                    else if (val == "2")
                    {
                        if (OrderItemsList == null || OrderItemsList.Count == 0)
                        {
                            DependencyService.Get <IMessage>().ShortAlert("No Order Items");
                            return;
                        }

                        var items = OrderItemsList;
                        if (items != null)
                        {
                            KOTListTransfer KOTData = new KOTListTransfer();
                            KOTData.TABLENO = Helpers.Data.SelectedTable.TableNo;
                            KOTData.TRNUSER = Helpers.Constants.User.UserName;
                            KOTData.PAX     = Helpers.Data.PAX;

                            KOTData.KOTProdList = OrderItemsList.ToList();

                            LoadingMessage = "Please Wait! Saving KOT Items";
                            IsLoading      = true;

                            var result = await TableDataAccess.SaveKOTProdListAsync(KOTData);

                            if (result == "Success")
                            {
                                DependencyService.Get <IMessage>().ShortAlert("Order Saved Successfully");
                                App.Current.MainPage = new NavigationPage(new HomePage());
                            }
                            else
                            {
                                DependencyService.Get <IMessage>().ShortAlert(result);
                            }
                            IsLoading = false;
                        }
                    }
                }
            }catch (Exception ex)
            {
                DependencyService.Get <IMessage>().ShortAlert(ex.Message);
            }
        }
        public async void ExecuteSaveCommand()
        {
            try
            {
                var result = await App.Current.MainPage.DisplayAlert("Confirm", "Are you sure to save Split?", "Yes", "No");

                if (result)
                {
                    LoadingMessage = "Loading Please Wait!!!";
                    IsLoading      = true;
                    if (Helpers.Data.SelectedTable == null)
                    {
                        DependencyService.Get <IMessage>().ShortAlert("Data mismatch Error.");
                        IsLoading = false;
                        return;
                    }

                    var           list          = new List <KOTProd>(OrderItemsList);
                    var           recList       = new List <KOTProd>(Helpers.Data.OrderItemsList);
                    SplitTransfer SplitTransfer = new SplitTransfer();

                    SplitTransfer = new SplitTransfer()
                    {
                        TableNo      = Helpers.Data.SelectedTable.TableNo,
                        transferData = OrderItemsList.ToList(),
                        TRNUSER      = Helpers.Constants.User.UserName
                    };



                    SplitTransfer.transferData.ForEach(x => x.DispatchTime = null);
                    SplitTransfer.transferData.ForEach(x => x.TRNDATE      = null);

                    var res = await TableTransferAccess.GetSplitTableAsync(SplitTransfer);

                    if (res.ToLower() == "success")
                    {
                        DependencyService.Get <IMessage>().ShortAlert("Split Successful");
                        await App.Current.MainPage.Navigation.PopModalAsync();
                    }
                    else
                    {
                        DependencyService.Get <IMessage>().ShortAlert(res);
                    }
                    IsLoading = false;
                }
            }
            catch (Exception e)
            {
                IsLoading = false;
                DependencyService.Get <IMessage>().ShortAlert(e.Message);
            }
        }
Beispiel #5
0
 private void DecreaseItemCount()
 {
     try
     {
         OrderItemsList.ToList().ForEach(x => x.DecQuantity = 0);
         foreach (var item in OrderItemsList)
         {
             if (item.Quantity < 0)
             {
                 var found = OrderItemsList.ToList().Find(x => x.SNO == item.REFSNO);
                 if (found != null)
                 {
                     found.DecQuantity += item.Quantity;
                 }
             }
         }
     }catch (Exception ex)
     {
         DependencyService.Get <IMessage>().ShortAlert(ex.Message);
     }
 }
        public void ExecuteSplitOkCommand()
        {
            try
            {
                var sno   = TransferItemsList.FirstOrDefault().SNO;
                var found = OrderItemsList.ToList().Find(x => x.SNO == sno);
                if (found != null)
                {
                    OrderItemsList.Remove(found);
                }

                //var count = OrderItemsList.ToList().MaxBy(x => x.SNO);
                var items = OrderItemsList.Select(i => i.SNO).ToList();
                var count = 0;
                if (items.Count > 0)
                {
                    count = items.Max();
                }

                foreach (var i in TransferItemsList)
                {
                    count++;
                    i.SNO = count;
                }

                foreach (var i in TransferItemsList)
                {
                    var newItem = new KOTProd(i);
                    newItem.Quantity = i.Quantity;
                    OrderItemsList.Add(newItem);
                }
                IsSplit = false;
            }catch (Exception ex)
            {
                IsSplit = false;
                DependencyService.Get <IMessage>().ShortAlert(ex.Message);
            }
        }
Beispiel #7
0
        //Command Execution for Increasing Quantity
        public void ExecuteIncreaseCommand(M.MenuItem obj)
        {
            try
            {
                var selected = SelectedItemsList.ToList().Find(x => x.MCODE == obj.MCODE);
                selected.SetQuantity += 1;
                var item = OrderItemsList.ToList().Find(x => ((x.MCODE == obj.MCODE) && (x.SNO == 0)));

                var KOTItem = M.MenuItem.MenuItemsToKOTProd(obj);
                if (item == null)
                {
                    KOTItem.Quantity = 1;
                    OrderItemsList.Add(KOTItem);
                }
                else
                {
                    item.Quantity += 1;
                    if (item.Quantity > 0)
                    {
                        item.REFSNO = 0;
                    }
                    else if (item.Quantity == 0)
                    {
                        OrderItemsList.Remove(item);
                    }
                }

                SelectedItemCount(obj);

                //OrderItemsList = new List<KOTProd>(OrderItemsList);
                //OrderItemsList.OrderBy(x => x.SNO);
                DecreaseItemCount();
            }
            catch (Exception ex)
            {
                DependencyService.Get <IMessage>().ShortAlert(ex.Message);
            }
        }
Beispiel #8
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);
            }
        }