Esempio n. 1
0
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     // check if quantity is valid
     if (bllDetail.checkQuantity(textBoxQuantity.Text))
     {
         textBlockTotalQuantity.Text = bllDetail.ShowTotalProCate(this.CusID).ToString();
     }
     else
     {
         MessageBox.Show("Invalid quantity!");
         return;
     }
     // check if customer has a order oncart yet?
     if (bllDetail.CheckOrderExistBLL(this.CusID))
     {
         // if yes, work on this order
         int x = Int32.Parse(textBoxQuantity.Text);
         bllDetail.UpdatePPartOf(this.proID, x, this.CusID);
         textBlockTotalQuantity.Text = bllDetail.ShowTotalProCate(this.CusID).ToString();
         MessageBox.Show("Add product successfully!");
     }
     else
     {
         // otherwise, create a new order
         int x = Int32.Parse(textBoxQuantity.Text);
         bllDetail.InsertPPartOf(this.proID, x, this.CusID);
         textBlockTotalQuantity.Text = bllDetail.ShowTotalProCate(this.CusID).ToString();
         MessageBox.Show("Add product successfully!");
     }
 }
Esempio n. 2
0
 public MainUIWindow(string role, int cusID)
 {
     InitializeComponent();
     bll = new MainUIBLL();
     this.role = role;
     this.cusID = cusID;
     DetailBLL bllDetail = new DetailBLL();
     textBlockTotalQuantity.Text = bllDetail.ShowTotalProCate(this.cusID).ToString();
     List<Book> bookList = new List<Book>();
     List<Magazine> magaList = new List<Magazine>();
     bookList = bll.getallBookUI();
     magaList = bll.getallMagaUI();
     Separator separator = new Separator();
     separator.Width = 795;
     DisplayBookUI.Children.Add(separator);
     List<ProductDisplay> proList = new List<ProductDisplay>();
     proList = getAllProduct(bookList, magaList);
     proList.Sort(
         delegate (ProductDisplay p1, ProductDisplay p2)
         {
             return p2.Date.CompareTo(p1.Date);
         }
     );
     if (this.role == "Manager")
     {
         manage.Visibility = Visibility.Visible;
         manage.IsEnabled = true;
     }
     getallProUI(proList, "All");
     ProType.SelectionChanged += ProType_SelectionChanged;
     Instock.SelectionChanged += Instock_SelectionChanged;
     Search.Click += Search_click;
     ProSort.SelectionChanged += ProSort_SelectionChanged;
     SearchTaskBar.KeyDown += Search_KeyDown;
 }