Exemple #1
0
        private void OrderDetail_MouseUp(object sender, MouseButtonEventArgs e)
        {
            TextBlock selected = sender as TextBlock;
            string    orderID  = selected.Text;

            db = DatabaseHandler.getInstance();

            db.connection.Open();

            StatisticList = new List <Order>();

            SqlCommand cmd = new SqlCommand("SP_ChiTietDonHang", db.connection);

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@id", SqlDbType.Char).Value = orderID;

            SqlDataReader dr  = cmd.ExecuteReader();
            DataTable     dts = new DataTable();

            dts.Load(dr);

            showOrderDetail(dts);

            db.connection.Close();
        }
Exemple #2
0
        private void SearchButton_Click(object sender, RoutedEventArgs e)
        {
            string pattern = txtBoxInputSearch.Text;

            searchTypeTicked[0] = (bool)chkBoxCourse.IsChecked;
            searchTypeTicked[1] = (bool)chkBoxDrink.IsChecked;
            searchTypeTicked[2] = (bool)chkBoxSnack.IsChecked;


            db = DatabaseHandler.getInstance();

            db.connection.Open();

            SqlCommand cmd;

            if (String.IsNullOrEmpty(pattern))
            {
                cmd = new SqlCommand("SP_DanhSachSP", db.connection);
            }
            else
            {
                cmd = new SqlCommand("SP_TimKiemSP", db.connection);
                cmd.Parameters.AddWithValue("@str_query", SqlDbType.NVarChar).Value = pattern;
            }
            cmd.CommandType = CommandType.StoredProcedure;
            SqlDataReader dr = cmd.ExecuteReader();
            DataTable     dt = new DataTable();

            dt.Load(dr);

            setSearchResultProductList(dt);

            db.connection.Close();
        }
Exemple #3
0
        public Login()
        {
            InitializeComponent();
            bc = new BrushConverter();
            db = DatabaseHandler.getInstance();

            db.connection.Open();
        }
Exemple #4
0
        private void SearchStatisticButton_Click(object sender, RoutedEventArgs e)
        {
            db = DatabaseHandler.getInstance();

            db.connection.Open();

            StatisticList = new List <Order>();


            SqlCommand cmd = new SqlCommand("SP_DanhSachDonHang", db.connection);

            cmd.CommandType = CommandType.StoredProcedure;

            SqlDataReader dr  = cmd.ExecuteReader();
            DataTable     dts = new DataTable();

            dts.Load(dr);

            setSearchResultStatisticList(dts);

            db.connection.Close();
        }
Exemple #5
0
        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();
        }