using ClassLibrary;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace CollectionBinding
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }

        public ObservableCollection<Product> products;
        public IEnumerable<Product> matches;

        private void btnGetProducts_Click_1(object sender, RoutedEventArgs e)
        {
            decimal min = Convert.ToDecimal(txtMinUniCost.Text);
            products = StoreDB.GetProducts();
            matches = from p in products where p.UnitCost > min select p;
            lstProducts.ItemsSource = matches;
            lstProducts.DisplayMemberPath = "ModelName";
        }

        private void btnDelete_Click_1(object sender, RoutedEventArgs e)
        {
            Product p = (Product)lstProducts.SelectedItem;
            products.Remove(p);
            StoreDB.DeleteProductByID(p.ProductID);
        }

        private void btnInsert_Click_1(object sender, RoutedEventArgs e)
        {
            int categoryID = Convert.ToInt32(txtCategoryID.Text);
            decimal unitCost = Convert.ToDecimal(txtUnitCost.Text);

            Product p = new Product() { CategoryID = categoryID, ModelNumber = txtModelNumber.Text, ModelName = txtModelName.Text, ProductImage = txtProductImage.Text, UnitCost = unitCost, Description = txtDescription.Text };
            StoreDB.InsertProduct(p);
            products.Add(p);
        }

    }
}

最新文章

  1. junit测试,使用classpath和file 加载文件的区别
  2. Java多线程系列--“JUC集合”09之 LinkedBlockingDeque
  3. SQLSERVER吞噬内存解决记录
  4. C特殊浮点值NaN
  5. 剑指offer系列52---约瑟夫环问题
  6. Unity3D 使用 Editor 脚本,自定义 脚本的属性面板
  7. Uber将在泰国首推&quot;优步摩托&quot;服务
  8. Maximum Product Subarray动态规划思想
  9. 访问taotao-portal 中controller中返回taotaoresult 测试httppost方法 出现406错误
  10. 【学习笔记】Hibernate 一对一关联映射 组件映射 二级缓存 集合缓存
  11. SQL 收缩数据库日志的几种办法 (2005与2008 略有区别)
  12. 托管C++线程锁实现
  13. Leetcode 34 Find First and Last Position of Element in Sorted Array 解题思路 (python)
  14. 剑指offer--3.从头打印链表
  15. bzoj1106 树状数组
  16. day9--队列queue
  17. 使用Sqlserver事务发布实现数据同步(sql2008)_Mssq l数据库教程
  18. [UE4]优先级与相关性
  19. 单例模式——java设计模式
  20. SDUT 1269-走迷宫(DFS打印路径)

热门文章

  1. EChats+Ajax之柱状图的数据交互
  2. IT增值服务-客户案例(三):合肥薪火科技,Java和P2P网络借贷系统开发指导
  3. [Angular] Using directive to create a simple Credit card validator
  4. LUOGU 1525 关押罪犯 - 并查集拆点(对立点) / 二分+二分图染色
  5. MySql批量drop table
  6. HTML5移动开发实战必备知识——本地存储(1)
  7. Hibernate中的配置文件
  8. java十五个常用类学习及方法举例
  9. XMPP之ios即时通讯客户端开发-创建工程添加XMPPFramework及其他框架(三)
  10. 学习鸟哥的Linux私房菜笔记(15)——文件系统