Beispiel #1
0
        private void BtnRedeem_Click(object sender, EventArgs e)
        {
            if (!Util.Func.IsUserAllowed(User, Util.PermissionAlertType.Message, this))
            {
                return;
            }

            Blur blur = new Blur(this, UIConstants.ThirdFormBlurOpacity);

            blur.Show();

            //Edit Customer
            RedeemCustomer redeemCustomer = new RedeemCustomer
            {
                Customer = Customer,
                Currency = Currency,
                TopMost  = true,
            };

            // Update If Updated
            var formResponse = redeemCustomer.ShowWithResponse();

            if (formResponse.ActionDialog == Enums.ActionDialog.Redeem)
            {
                ActionDialog = Enums.ActionDialog.Updated;
                Customer     = (Backend.Objects.Customer)formResponse.Data;

                //Force Update
                this.Initialize();
            }

            blur.Close();
        }
Beispiel #2
0
        void UpdateCustomer()
        {
            if (!IsInputValid())
            {
                return;
            }

            if (QueryController.Customers.Customer.IsValid(customer))
            {
                SetCustomerProperties();
                var response = QueryController.Customers.Customer.Update(customer);
                if (response.StatusCode == 204)
                {
                    ActionDialog = Enums.ActionDialog.Updated;
                    this.Close();
                    Util.MessageParser.Alert("Customer", Util.AlertParserType.Updated);
                }
                else
                {
                    ActionDialog = Enums.ActionDialog.Error;
                    Util.MessageParser.Alert("Customer", Util.AlertParserType.ErrorUpdating);
                }
            }
            else
            {
                Util.MessageParser.Alert("Customer", Util.AlertParserType.ErrorDeleting);
            }
        }
Beispiel #3
0
        private void BtnDelete_Click(object sender, EventArgs e)
        {
            if (!Util.Func.IsUserAllowed(user, Util.PermissionAlertType.Message, this))
            {
                return;
            }

            Blur blur = new Blur(this, UIConstants.MinBlurOpacity);

            blur.Show();

            MessageDialog messageDialog = new MessageDialog
            {
                DialogButtonsIndex = MessageDialog.DialogButtons.Two,
                DialogIconIndex    = MessageDialog.DialogIcon.Sorry,
                SecondBtnText      = "No",
                ThirdBtnText       = "Yes",
                ThirdBtnColor      = Color.Tomato,
                Title   = "Are you sure ?",
                Message = $"Are you sure you want to permanently delete { customer.FirstName }, this customer will be deleted immediately. You can't undo this action.",
                TopMost = true,
            };

            var dialogResult = messageDialog.ShowWithEvent();

            if (dialogResult == MessageDialog.OnClickEvent.ThirdButton)
            {
                ActionDialog = Enums.ActionDialog.Deleted;
                //Delete
                DeleteCustomer();
            }

            blur.Close();
        }
Beispiel #4
0
        private void BtnEditProduct_Click(object sender, EventArgs e)
        {
            Blur blur = new Blur(this, UIConstants.FormBlurOpacity);

            blur.Show();

            Product product = new Product
            {
                ProductObject = Product,
                Task          = Enums.Task.Update,
                TopMost       = true
            };

            // Update If Updated
            var formResponse = product.ShowWithResponse();

            if (formResponse.ActionDialog == Enums.ActionDialog.Updated)
            {
                ActionDialog = Enums.ActionDialog.Updated;
                Product      = (Backend.Objects.Product)formResponse.Data;

                //Force Update
                this.Initialize();
            }
            else if (formResponse.ActionDialog == Enums.ActionDialog.Deleted)
            {
                // Close -> Nothing to show
                ActionDialog = Enums.ActionDialog.Deleted;
                this.Close();
            }

            blur.Close();
        }
Beispiel #5
0
        void DeleteProduct()
        {
            if (QueryController.Products.Product.IsValid(Product))
            {
                // Delete Product Image
                DeleteProductImage();

                var response = QueryController.Products.Product.Delete(Product);
                if (response.StatusCode == 204)
                {
                    ActionDialog = Enums.ActionDialog.Deleted;
                    this.Close();

                    Alert.Show("Product Deleted", $"{ Product.Name } was successfully deleted", Alert.AlertType.Success);
                }
                else
                {
                    Alert.Show("Unable to delete Product", $"An Error occured while trying to delete { Product.Name } ",
                               Alert.AlertType.Error);
                }
            }
            else
            {
                Alert.Show("Unknown Product", $"The Supplier you're trying to Delete doesn't exist ", Alert.AlertType.Warning);
            }
        }
Beispiel #6
0
        void UpdateBrand()
        {
            if (!IsInputValid())
            {
                imgValidInput.Image = Validation.GetValidityImage(false);
                return;
            }

            brand.Name        = txtBrandName.Text;
            brand.Description = rtxtBrandDescription.Text;
            if (QueryController.Products.Brand.IsValid(brand))
            {
                var response = QueryController.Products.Brand.Update(brand);
                if (response.StatusCode == 204)
                {
                    ActionDialog = Enums.ActionDialog.Updated;
                    Util.MessageParser.Alert("Brand", Util.AlertParserType.Updated);
                }
                else
                {
                    Util.MessageParser.Alert("Brand", Util.AlertParserType.ErrorUpdating);
                }
            }
            else
            {
                Util.MessageParser.Alert("Brand", Util.AlertParserType.NotFound);
            }
        }
Beispiel #7
0
        private void BtnSave_Click(object sender, EventArgs e)
        {
            SetCustomerGroup();

            if (Task == Enums.Task.Update || Task == Enums.Task.Get)
            {
                ActionDialog = Enums.ActionDialog.Updated;
                UpdateCustomer();
            }
            else if (Task == Enums.Task.Create)
            {
                ActionDialog = Enums.ActionDialog.Created;
                CreateCustomer();
                this.OnCreate(customer, e);
            }
            this.Close();
        }
Beispiel #8
0
        void Redeem(decimal amount)
        {
            var response = QueryController.Customers.Customer.Redeem(Customer, amount);

            if (response.StatusCode == 204)
            {
                ActionDialog = Enums.ActionDialog.Redeem;
                Customer     = (Backend.Objects.Customer)response.Data;

                // Print Receipt
                PrintReceipt(amount, Customer.StoreCredit);
                this.Close();
            }
            else
            {
                Util.MessageParser.Alert("Error", Util.AlertParserType.RedeemFailed);
            }
        }