public static void RefreshImportHistory() { ListBindingEntity = new List <ImportHistoryEntity>(); BaseDAO dao = new GoodsImportDAO(); ListGoodsImportEntity = dao.getAll(typeof(GoodsImportEntity)) as List <GoodsImportEntity>; dao = new ProductDAO(); ProductEntity product = new ProductEntity(); foreach (GoodsImportEntity entity in ListGoodsImportEntity) { product = dao.get(entity.ProductID) as ProductEntity; ListBindingEntity.Add(new ImportHistoryEntity() { ImportDate = entity.ImportDate, ProductID = entity.ProductID, ProductName = product.ProductName, Quantity = entity.Quantity }); } instance.listview.ItemsSource = ListBindingEntity; instance.listview.Items.Refresh(); }
private void btn_Update_Click(object sender, RoutedEventArgs e) { int oldQuantity = int.Parse(txt_Quantity.Text); int importQuantity = int.Parse(txt_ImportQuantity.Text); if (oldQuantity + importQuantity <= 5) { MessageBox.Show("Cần nhập nhiều hơn mức tồn tối thiểu (5 sản phẩm)", "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } GoodsImportEntity entity = new GoodsImportEntity() { ImportDate = DateTime.Now, ProductID = int.Parse(txt_Id.Text), Quantity = int.Parse(txt_ImportQuantity.Text) }; GoodsImportDAO importDAO = new GoodsImportDAO(); importDAO.insert(entity); products.RemoveAll(temp => temp.ProductID == int.Parse(txt_Id.Text)); CollectionViewSource.GetDefaultView(listBox.ItemsSource).Refresh(); MessageBox.Show("Nhập hàng thành công", "Info", MessageBoxButton.OK, MessageBoxImage.Information); txt_ImportQuantity.Clear(); listBox.SelectedIndex = 0; ImportHistory.RefreshImportHistory(); }