Example #1
0
 private async void Sure_Click(object sender, RoutedEventArgs e)
 {
     if (string.IsNullOrEmpty(BookIDBox.Text) || string.IsNullOrEmpty(SaleNumberBox.Text))
     {
         return;
     }
     Models.Stock stock = StockUtil.QueryStock(BookIDBox.Text);
     if (stock != null)
     {
         int n = int.Parse(SaleNumberBox.Text);
         SaleNumberBox.Text = "";
         if (n < 0)
         {
             await new MessageDialog("还书的数值不正确!").ShowAsync();
             return;
         }
         // 库存记录
         StockViewModel.GetInstance().UpdateStock(stock.Book.BId, n);
         // 还书记录
         Models.Return @return = new Models.Return {
             Book = stock.Book, Number = n, Time = DateTimeOffset.Now, TotalPrice = stock.SalePrice * n
         };
         ReturnUtil.AddReturn(@return);
         await new MessageDialog("归还成功!").ShowAsync();
     }
     else
     {
         await new MessageDialog("本店没有进过这种书,不必归还到此!").ShowAsync();
     }
     BookIDBox.Text = "";
 }
Example #2
0
 public Statistics()
 {
     this.InitializeComponent();
     // MonthSales month = new MonthSales { Month = 7, TotalSaleNum = 20, TotalSales = 34.5f };
     // monthSales.Add(month);
     // Sale sale = new Sale { Book = new Book { BId = 1, BAuthor = "a", BName = "b" }, Number = 12, TotalPrice = 23.4f };
     // monthSalesDetail.Add(sale);
     SalesUtil.GetAllMonthSales().ForEach(p => monthSales.Add(p));
     SalesUtil.GetAllSales().ForEach(p => sales.Add(p));
     ReturnUtil.GetAllReturns().ForEach(p => returns.Add(p));
     PurchaseUtil.GetAllPurchases().ForEach(p => purchases.Add(p));
 }