public MainWindow() { InitializeComponent(); Login login = new Login(); if (login.ShowDialog() != true) { this.Close(); return; } else { isLoggedIn = true; currentAccount = login.account; } searchTypeTicked = new bool[3]; db = DatabaseHandler.getInstance(); db.connection.Open(); //string SQLSelect = "Select * From SANPHAM"; //SqlCommand cmd = new SqlCommand(SQLSelect, db.connection); //SqlDataReader dr = cmd.ExecuteReader(); //DataTable dt = new DataTable(); //dt.Load(dr); //db.connection.Close(); //for (int i = 0; i < dt.Rows.Count; i++) //{ // Product product = new Product() // { // ProductID = dt.Rows[i][0].ToString(), // ProductName = dt.Rows[i][1].ToString(), // }; //} //SqlCommand cmd = new SqlCommand("SP_DanhSachSP", db.connection); //cmd.CommandType = CommandType.StoredProcedure; //SqlDataReader dr = cmd.ExecuteReader(); //DataTable dt = new DataTable(); //dt.Load(dr); //DataListView.SetBinding(ItemsControl.ItemsSourceProperty, new Binding { Source = dt }); productList = new List <Product>(); StatisticList = new List <Order>(); currentOrder = new Order(); SqlCommand cmd = new SqlCommand("SP_DanhSachSP", db.connection); cmd.CommandType = CommandType.StoredProcedure; SqlDataReader dr = cmd.ExecuteReader(); DataTable dt = new DataTable(); dt.Load(dr); Binding orderSumBinding = new Binding("OrderSum"); orderSumBinding.Source = currentOrder; // Bind the new data source to the myText TextBlock control's Text dependency property. totalAmountDue.SetBinding(TextBlock.TextProperty, orderSumBinding); Binding ChangeBinding = new Binding("Change"); ChangeBinding.Source = currentOrder; // Bind the new data source to the myText TextBlock control's Text dependency property. changeAmount.SetBinding(TextBlock.TextProperty, ChangeBinding); Binding QuantityBinding = new Binding("Quantity"); QuantityBinding.Source = currentOrder; // Bind the new data source to the myText TextBlock control's Text dependency property. //QuantityTextBlock.SetBinding(TextBlock.TextProperty, QuantityBinding); /*Binding curNumberBinding = new Binding(); * curNumberBinding.Source = currentNumber; * txtBoxCurrentNumber.SetBinding(TextBlock.TextProperty, curNumberBinding);*/ setSearchProductList(dt); db.connection.Close(); }