public List <TreeSelectListItem> GetUserMenu() { if (ConfigInfo.IsQuickDebug == true) { return(AllMenu.AsQueryable().GetTreeSelectListItems(null, null, x => x.PageName, null, x => x.ICon, x => x.Url, SortByName: false));; } else { var rv = AllMenu.Where(x => x.ShowOnMenu == true).AsQueryable().GetTreeSelectListItems(null, null, x => x.PageName, null, x => x.ICon, x => x.IsInside == true ? x.Url : "/_framework/outside?url=" + x.Url, SortByName: false); RemoveUnAccessableMenu(rv, LoginUserInfo); RemoveEmptyMenu(rv); return(rv); } }
void SetTotalDiscount() { DiscountModel currentDiscount = new DiscountModel(); if (TotalDiscount1) { currentDiscount = new DiscountModel { DiscountName = Discounts[0].DiscountName, Amount = Discounts[0].Amount, IsPercentage = Discounts[0].IsPercentage } } ; else if (TotalDiscount2) { currentDiscount = new DiscountModel { DiscountName = Discounts[1].DiscountName, Amount = Discounts[1].Amount, IsPercentage = Discounts[1].IsPercentage } } ; else if (TotalDiscount3) { currentDiscount = new DiscountModel { DiscountName = Discounts[2].DiscountName, Amount = Discounts[2].Amount, IsPercentage = Discounts[2].IsPercentage } } ; else if (TotalDiscount4) { currentDiscount = new DiscountModel { DiscountName = Discounts[3].DiscountName, Amount = Discounts[3].Amount, IsPercentage = Discounts[3].IsPercentage } } ; CurrentTotalDiscount = currentDiscount; } void OpenOption(ItemModel item) { CurrentItem = item; CurrentOption = new List <string>(); OptionList = new List <ItemOptionModel>(); if (!string.IsNullOrEmpty(item.Option1)) { OptionList.Add(new ItemOptionModel() { OptionName = item.Option1, Price = item.Option1Price }); } if (!string.IsNullOrEmpty(item.Option2)) { OptionList.Add(new ItemOptionModel() { OptionName = item.Option2, Price = item.Option2Price }); } if (!string.IsNullOrEmpty(item.Option3)) { OptionList.Add(new ItemOptionModel() { OptionName = item.Option3, Price = item.Option3Price }); } if (!string.IsNullOrEmpty(item.Option4)) { OptionList.Add(new ItemOptionModel() { OptionName = item.Option4, Price = item.Option4Price }); } foreach (var option in OptionList) { CurrentOption.Add(option.OptionName + " ( +" + option.Price.ToString("#,0.00") + " )"); } CurrentItemPrice = item.Price; if (item.Option2 == null && item.Option3 == null && item.Option4 == null) { if (!string.IsNullOrEmpty(item.Option1)) { OptionList.Add(new ItemOptionModel() { OptionName = item.Option1, Price = item.Option1Price }); } CurrentSelectedOptionIndex = 0; CurrentItemPrice = item.Price; SaveItemToTicket(); } else { PopupNavigation.PushAsync(new ItemPopup(this)); } } void SetItemMenu() { if (App.ListCategoryModels == null) { var getCate = _service.GetAllCategories(); if (!getCate.Result.IsError) { CategoriesList = getCate.Result.Categories; App.ListCategoryModels = CategoriesList; } } else { CategoriesList = App.ListCategoryModels; } if (CategoriesList == null) { CategoriesList = new List <CategoryModel>(); foreach (var category in CategoriesList) { AllMenu.Add(new MenuModel() { CategoryName = category.Name, Items = new ObservableCollection <ItemModel>() }); } } ItemsViewModel items; if (App.ItemsManuViewModel == null || App.ItemsManuViewModel.Items.Count == 0) { items = _service.GetItems(); App.ItemsManuViewModel = items; } else { items = App.ItemsManuViewModel; } if (items.Items == null || items.Items.Count == 0) { //Application.Current.MainPage.DisplayAlert("", "ไม่พบรายการอาหารในระบบ", "OK"); //PopupNavigation.PushAsync(new Error(new ErrorViewModel("ไม่พบรายการอาหารในระบบ"))); return; } foreach (var item in items.Items) { var isCatExist = AllMenu.Where(a => a.CategoryName == item.CategoryName).FirstOrDefault(); if (isCatExist == null) { AllMenu.Add(new MenuModel() { CategoryName = item.CategoryName, Items = new ObservableCollection <ItemModel>() });; } if (item.Color == null) { item.Color = "DDDDDD"; } AllMenu.Where(a => a.CategoryName == item.CategoryName).FirstOrDefault().Items.Add(item); } } void SaveTicket() { var maxNumber = 0; try { maxNumber = App.TicketList.Max(t => t.TicketNumber); } catch (Exception e) { } ReceiptViewModel receipt = new ReceiptViewModel() { ItemList = CurrentTicket.ToList(), Total = TotalPrice, TicketNumber = maxNumber + 1, CreateDateTime = DateTime.Now, }; App.TicketList.Add(receipt); ClearTicket(); } void OpenTicketList() { ClearTicket(); PopupNavigation.PushAsync(new OpenTicketsPopup(this)); TicketList = App.TicketList; } void ClearTicket() { CurrentTicket = new ObservableCollection <OrderItemModel>(); Quantity = 1; QuantityChangeCommand = new Command <string>((change) => QuantityChange(change)); SaveItemCommand = new Command(SaveItemToTicket); CurrentTicket = new ObservableCollection <OrderItemModel>(); CurrentTotalDiscount = new DiscountModel(); CurrentDiscountAmount = 0; TotalPrice = 0; ShowOpenButton = true; } void OpenTicket(int ticketNumber) { var ticket = App.TicketList.Where(t => t.TicketNumber == ticketNumber).FirstOrDefault(); if (ticket.ItemList == null || ticket.ItemList.Count == 0) { return; } foreach (var item in ticket.ItemList) { CurrentTicket.Add(item); TotalPrice += item.DiscountedPrice; } App.TicketList.Remove(ticket); PopupNavigation.PopAllAsync(); } void Charge() { if (CurrentTicket == null || CurrentTicket.Count == 0) { PopupNavigation.PushAsync(new Error(new ErrorViewModel("Please add item to ticket before proceeding"))); return; } decimal totalDiscount = 0; foreach (var item in CurrentTicket) { totalDiscount += item.ItemDiscount; } ReceiptViewModel receipt = new ReceiptViewModel() { ItemList = CurrentTicket.ToList(), Total = TotalPrice, CreateDateTime = DateTime.Now, TotalDiscount = totalDiscount + CurrentDiscountAmount, Discount = CurrentDiscountAmount, }; Application.Current.MainPage.Navigation.PushAsync(new ChargePage(receipt)); } void GetDiscount() { var discountVM = _service.GetDiscounts(); Discounts = discountVM.Discounts; if (Discounts.Count > 0) { DiscountName1 = Discounts[0].DiscountName; HasDiscount1 = true; Discount1 = false; } if (Discounts.Count > 1) { DiscountName2 = Discounts[1].DiscountName; HasDiscount2 = true; Discount2 = false; } if (Discounts.Count > 2) { DiscountName3 = Discounts[2].DiscountName; HasDiscount3 = true; Discount3 = false; } if (Discounts.Count > 3) { DiscountName4 = Discounts[3].DiscountName; HasDiscount4 = true; Discount4 = false; } } void DeleteItem(OrderItemModel model) { CurrentTicket.Remove(model); CalculateTotalAmount(); } void CloudsyncClick() { IsLoadding = true; var getCate = _service.GetAllCategories(); if (!getCate.Result.IsError) { CategoriesList = getCate.Result.Categories; App.ListCategoryModels = CategoriesList; } var items = _service.GetItems(); if (items.Items == null || items.Items.Count == 0) { //Application.Current.MainPage.DisplayAlert("", "ไม่พบรายการอาหารในระบบ", "OK"); //PopupNavigation.PushAsync(new Error(new ErrorViewModel("ไม่พบรายการอาหารในระบบ"))); return; } App.ItemsManuViewModel = items; Application.Current.MainPage = new NavigationPage(new Views.SaleView()); }