Ejemplo n.º 1
0
 public Home()
 {
     InitializeComponent();
     Image  = Productdatabase.GetImageProductByID("JK002").Image_product;
     Image1 = Productdatabase.GetImageProductByID("JK003").Image_product;
     Image2 = Productdatabase.GetImageProductByID("SHI001").Image_product;
 }
Ejemplo n.º 2
0
        private void initProductDetail()
        {
            ProductDetailModel productDetail = Productdatabase.GetDetailProductByID(IdProduct);

            ImageMain       = productDetail.Image_product;
            ImageSub1       = productDetail.Image_product1;
            ImageSub2       = productDetail.Image_product2;
            NameProduct     = productDetail.Name_product;
            CategoryProduct = productDetail.Category_product;
        }
Ejemplo n.º 3
0
        public void GetCart()
        {
            listCart           = Productdatabase.GetProductInHistory(Phone);
            lvCart.ItemsSource = listCart;
            int sumMoney = 0;

            foreach (History item in listCart)
            {
                sumMoney += item.Price_product;
            }
            tbPriceSumAll.Text = sumMoney + "";
        }
Ejemplo n.º 4
0
        private void delCart_Click(object sender, RoutedEventArgs e)
        {
            Button           button  = sender as Button;
            History          history = button.DataContext as History;
            MessageBoxResult result  = MessageBox.Show("Are you sure ?", "Notify", MessageBoxButton.YesNo);

            switch (result)
            {
            case MessageBoxResult.Yes:
                Productdatabase.DeleteToHistory(history.Id_product);
                MainWindow mainWindow = (MainWindow)Window.GetWindow(this);
                mainWindow.HomeLayout.Children.Clear();
                mainWindow.HomeLayout.Children.Add(new Cart(mainWindow.PhoneNumber));
                break;
            }
        }
Ejemplo n.º 5
0
 private void operationsProduct()
 {
     btnPlus.Click += delegate(object sender, RoutedEventArgs e)
     {
         ProductDetailModel productDetail = Productdatabase.GetDetailProductByID(IdProduct);
         int temp = convertStringToInt(tbNumOfPro.Text) + 1;
         tbNumOfPro.Text = temp + "";
         tbPrice.Text    = productDetail.Price_product * temp + "";
     };
     btnMinus.Click += delegate(object sender, RoutedEventArgs e)
     {
         ProductDetailModel productDetail = Productdatabase.GetDetailProductByID(IdProduct);
         int temp = convertStringToInt(tbNumOfPro.Text) - 1;
         if (temp < 0)
         {
             temp = 0;
         }
         tbNumOfPro.Text = temp + "";
         tbPrice.Text    = productDetail.Price_product * temp + "";
     };
 }
Ejemplo n.º 6
0
        private void btnAddToHistory_Click(object sender, RoutedEventArgs e)
        {
            string     id     = IdProduct;
            byte       status = 0;
            MainWindow main   = (MainWindow)Window.GetWindow(this);
            string     phone  = main.PhoneNumber;

            try
            {
                int    price = convertStringToInt(tbPrice.Text);
                string size  = cbSize.SelectionBoxItem.ToString();
                if (size == null)
                {
                    MessageBox.Show("Please choose the size", "ERROR", MessageBoxButton.OK, MessageBoxImage.Error);
                }
                else
                {
                    string quantityText = tbNumOfPro.Text;
                    int    quantity     = convertStringToInt(quantityText);
                    if (quantity > 0)
                    {
                        if (Productdatabase.InsertToHistory(id, phone, status, size, quantity, price))
                        {
                            MessageBox.Show("Add to cart successfully~", "NOTIFY", MessageBoxButton.OK, MessageBoxImage.Information);
                        }
                        else
                        {
                            MessageBox.Show("Add to cart failure!", "ERROR", MessageBoxButton.OK, MessageBoxImage.Error);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Please choose quantity" + ex.Message, "ERROR", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Ejemplo n.º 7
0
 public void GetProduct()
 {
     listproduct = Productdatabase.GetProductByType(Type);
     lvDataBinding.ItemsSource = listproduct;
 }