Exemplo n.º 1
0
        public CustomerWindow(Boolean logIn, String userEmail)
        {
            InitializeComponent();

            UniversalFunctions.setUpWindow(this);
            this.isUserSignedIn = false;

            DataGridProducts.DataContext = ServiceProducts.getProductsToDisplay().DefaultView;
            btnShowProducts.Visibility   = Visibility.Hidden;
            btnShowCart.IsEnabled        = isUserSignedIn;
            btnOrderHistory.IsEnabled    = isUserSignedIn;

            this.isUserSignedIn = logIn;
            currentUserEmail    = userEmail;
            if (this.isUserSignedIn)
            {
                btnCustomerLogInMenu.Visibility = Visibility.Hidden;
                lblSingedInAs.Content           = "Signed in as " + ServiceCustomer.getNameFromEmail(userEmail);
                btnShowCart.IsEnabled           = isUserSignedIn;
                btnOrderHistory.IsEnabled       = isUserSignedIn;
            }
            else
            {
                lblSingedInAs.Content = "Login Failed";
            }
        }
Exemplo n.º 2
0
 private void btnShowProducts_Click(object sender, RoutedEventArgs e)
 {
     dgOrderHistory.Visibility    = Visibility.Hidden;
     DataGridProducts.Visibility  = Visibility.Visible;
     DataGridProducts.DataContext = ServiceProducts.getProductsToDisplay().DefaultView;
     btnShowCart.Visibility       = Visibility.Visible;
     btnConfirmOrder.Visibility   = Visibility.Hidden;
     btnShowProducts.Visibility   = Visibility.Hidden;
 }
        public QuantityPopUpWindow(CustomerWindow toCallBack, Button btn, int productCode)
        {
            InitializeComponent();
            quantity         = 1;
            txtQuantity.Text = quantity.ToString();
            cb       = toCallBack;
            this.btn = btn;

            this.topQuantity = ServiceProducts.getAvailableProductQuantity(productCode);
            Console.WriteLine(" top quantity " + topQuantity);
        }
Exemplo n.º 4
0
        public static Boolean discountProduct(String produkt, String discount, String start_date, String end_date)
        {
            int    produktCode = ServiceProducts.getProduktCodeFromName(produkt);
            String cmd         = "Insert into activeDiscounts (ProductCode,Discount,start_date,end_date) values (('" + produktCode + "'), ('" + discount + "'),('" + start_date + "'),('" + end_date + "'))";

            if (dbConnection.insertQuery(cmd) == 1)
            {
                return(true);
            }

            return(false);
        }
Exemplo n.º 5
0
 public DiscountsWindow()
 {
     InitializeComponent();
     UniversalFunctions.setUpWindow(this);
     String[] products = ServiceProducts.getAllProductsName();
     loadDiscounts();
     for (int i = 0; i < products.Length; i++)
     {
         cmboxProduct.Items.Add(products[i]);
         System.Diagnostics.Debug.WriteLine("suppliers??? " + products[i]);
     }
     DataDiscountHistory.DataContext = ServiceDiscount.getAllDiscountHistoryToDisplay().DefaultView;
 }
        private void btn_UpdateQuantity(object sender, RoutedEventArgs e)
        {
            Boolean isSuccessFull = ServiceProducts.updateQuantity(productCode, int.Parse(tbxQuantity.Text));

            if (isSuccessFull)
            {
                clearInputs();
            }
            else
            {
                Console.WriteLine("Something went wrong when updating quantity");
            }
        }
Exemplo n.º 7
0
        public CustomerWindow()
        {
            InitializeComponent();

            UniversalFunctions.setUpWindow(this);

            this.isUserSignedIn = false;

            btnShowProducts.Visibility   = Visibility.Hidden;
            btnShowCart.IsEnabled        = isUserSignedIn;
            btnOrderHistory.IsEnabled    = isUserSignedIn;
            DataGridProducts.DataContext = ServiceProducts.getProductsToDisplay().DefaultView;
        }
Exemplo n.º 8
0
        public static List <String[]> searchingForAdmin(String search)
        {
            Console.WriteLine("Testar" + search);
            String cmd;

            if (search == "")
            {
                return(ServiceProducts.getAllProducts());
            }
            else
            {
                cmd = "SELECT P.code, P.name, P.price, P.supplier from Products as P where name like " + "'%" + search + "%' or Supplier like " + "'%" + search + "%' or Code like " + "'%" + search + "%' ";
                return(dbConnection.selectMultipleRows(cmd));
            }
        }
Exemplo n.º 9
0
        public static List <String[]> searching(String search)
        {
            Console.WriteLine("Testar" + search);
            String cmd;

            if (search == "")
            {
                return(ServiceProducts.getAllProductsIncludingDiscount());
            }
            else
            {
                cmd = "SELECT P.code, P.name, P.price, P.supplier, Discount.Precentage from Products as P FULL OUTER JOIN ActiveDiscounts on p.code = ActiveDiscounts.productCode FULL OUTER join Discount on discount.reason = ActiveDiscounts.discount where name like " + "'%" + search + "%' or Supplier like " + "'%" + search + "%' or Code like " + "'%" + search + "%' or Price like " + "'%" + search + "%'";
                return(dbConnection.selectMultipleRows(cmd));
            }
        }
Exemplo n.º 10
0
        private void BtnShowCart_Click(object sender, RoutedEventArgs e)
        {
            DataView  data         = (DataView)DataGridProducts.ItemsSource;
            DataTable shoppingCart = ServiceProducts.getShoppingListFromSelectedProducts(data.ToTable());

            DataGridProducts.DataContext = shoppingCart.DefaultView;

            double totalPriceOfCart = ServiceProducts.getTotalPriceOfCart(shoppingCart);

            lblTotalPrice.Content = "Total price: " + totalPriceOfCart.ToString();

            btnShowCart.Visibility     = Visibility.Hidden;
            btnConfirmOrder.Visibility = Visibility.Visible;
            btnShowProducts.Visibility = Visibility.Visible;
        }
 private void BtnAddProduct_Click(object sender, RoutedEventArgs e)
 {
     if (sender == btnAddProduct)
     {
         Console.WriteLine("Clicking AddProduct Button");
         Console.WriteLine(tbxQuantity.Text + tbxPrice.Text + "\n" + cmboxSuppliers.Text);
         Boolean isSuccessful = ServiceProducts.addProduct(tbxProductName.Text, cmboxSuppliers.Text, int.Parse(tbxQuantity.Text), int.Parse(tbxPrice.Text));
         if (isSuccessful)
         {
             clearInputs();
         }
         else
         {
             Console.WriteLine("Something went wrong");
         }
     }
 }
 private void BtnDeleteProduct_Click(object sender, RoutedEventArgs e)
 {
     if (ServiceOrders.isProductOrederd(productCode))
     {
         MessageBox.Show("can not delete an ordered product", "info", MessageBoxButton.OK, MessageBoxImage.Information);
     }
     else
     {
         if (productCode != -1 && ServiceProducts.deleteProduct(productCode))
         {
             loadProductsToDataGrid();
             clearInputs();
         }
         else
         {
             MessageBox.Show("something went wrong deleting a product", "info", MessageBoxButton.OK, MessageBoxImage.Information);
         }
     }
 }
 private void loadProductsToDataGrid()
 {
     dgProducts.DataContext = ServiceProducts.getProductsToDisplayAdmin().DefaultView;
 }