Пример #1
0
 public Home()
 {
     InitializeComponent();
     Image  = Productdatabase.GetImageProductByID("JK002").Image_product;
     Image1 = Productdatabase.GetImageProductByID("JK003").Image_product;
     Image2 = Productdatabase.GetImageProductByID("SHI001").Image_product;
 }
Пример #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;
        }
Пример #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 + "";
        }
Пример #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;
            }
        }
Пример #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 + "";
     };
 }
Пример #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);
            }
        }
Пример #7
0
 public void GetProduct()
 {
     listproduct = Productdatabase.GetProductByType(Type);
     lvDataBinding.ItemsSource = listproduct;
 }