Exemplo n.º 1
0
        private void DeleteMenu()
        {
            var currentMenu = bsMenu.Current as Menu;

            if (currentMenu == null)
            {
                return;
            }

            if (FlatMessageBox.Show("Are you sure?", "Delete", DialogButtons.YesNo, DialogType.Warning) ==
                DialogButton.Yes)
            {
                using (var context = UnitOfWork.Factory.Instance())
                {
                    var menu = context.Menus.GetById(currentMenu.Id);

                    menu.Flag = false;

                    context.SaveChanges();

                    FillMenus(true);

                    FlatMessageAlert.Show("Delete Successful.", alertType: AlertType.Delete);
                }
            }
        }
Exemplo n.º 2
0
        private void UpdateMenu()
        {
            var currentMenu = bsMenu.Current as Menu;

            if (currentMenu == null)
            {
                return;
            }

            if (!ValidateMenuOnUpdate(currentMenu))
            {
                return;
            }

            using (var context = UnitOfWork.Factory.Instance())
            {
                var menu = context.Menus.GetById(currentMenu.Id);

                menu.Name         = txtMenuName.Text;
                menu.Acronym      = txtMenuAcronym.Text.ToUpper();
                menu.CategoryId   = (int)cbCategory.SelectedValue;
                menu.Price        = decimal.TryParse(txtMenuPrice.Text, out var price) ? price : 0.00m;
                menu.MenuImage    = currentMenu.MenuImage;
                menu.Availability = cbMenuAvailability.Checked;

                context.SaveChanges();

                FillMenus(false);

                FlatMessageAlert.Show("Update Successful.", alertType: AlertType.Update);
            }
        }
Exemplo n.º 3
0
        private void CreateMenu()
        {
            if (!ValidateMenuOnCreate())
            {
                return;
            }

            using (var context = UnitOfWork.Factory.Instance())
            {
                var menu = new Menu
                {
                    Name         = txtMenuName.Text,
                    Acronym      = txtMenuAcronym.Text,
                    CategoryId   = (int)cbMenuCategory.SelectedValue,
                    MenuImage    = _image,
                    Availability = cbMenuAvailability.Checked,
                    Price        = decimal.TryParse(txtMenuDefaultPrice.Text, out var price)
                        ? price
                        : 0.00m,
                    Flag = true
                };

                context.Menus.Add(menu);

                context.SaveChanges();

                FlatMessageAlert.Show("Added Successfully.");

                this.Close();
            }
        }
Exemplo n.º 4
0
        private void CheckConnection()
        {
            if (UnitOfWork.Factory.Instance().TestConnection())
            {
                FlatMessageAlert.Show("Connected");

                EnableControls();
            }
            else
            {
                FlatMessageAlert.Show("Disconnected", alertType: AlertType.BadInfo);

                DisableControls();
            }

            this.Focus();
        }
Exemplo n.º 5
0
        private void ValidateQrCode()
        {
            var reader = new BarcodeReader();
            var result = reader.Decode((Bitmap)pbFrame.Image);

            try
            {
                var decodedValue = result.ToString().Trim();

                if (_registeredQrCode.Contains(decodedValue))
                {
                    tmrDecode.Stop();
                    this.Close();

                    FlatMessageAlert.Show(decodedValue);
                }
            }
            catch (Exception) { }
        }
Exemplo n.º 6
0
        private IEnumerable <ItemCardView> GetMenuCards()
        {
            var menus = GetMenus();

            foreach (var menu in menus)
            {
                var menuCard = new ItemCardView(menu);

                menuCard.CardClicked += (s, e) =>
                {
                    if (menuCard.GetMenu.Availability)
                    {
                        SelectMenu(menu);
                    }
                    else
                    {
                        FlatMessageAlert.Show($"{menuCard.GetMenu.Name} is not available", alertType: AlertType.BadInfo);
                    }
                };

                yield return(menuCard);
            }
        }
Exemplo n.º 7
0
 private void LoginErrorMessage()
 {
     FlatMessageAlert.Show("Invalid Credentials", "Error", alertType: AlertType.BadInfo);
 }