Ejemplo n.º 1
0
        public static List <cProducts> GetListProducts()
        {
            List <cProducts> listProducts = new List <cProducts>();

            DataTable data = DataProvider.ExecuteQuery("SELECT dbo.Products.ProductName, dbo.Products.Price FROM dbo.Products");

            foreach (DataRow item in data.Rows)
            {
                cProducts Products = new cProducts(item);
                listProducts.Add(Products);
            }

            return(listProducts);
        }
Ejemplo n.º 2
0
        public static List <cProducts> GetListProductsByCategory(string name)
        {
            List <cProducts> a = new List <cProducts>();

            DataTable data = DataProvider.ExecuteQuery("SELECT dbo.Products.ProductName, dbo.Products.Price FROM dbo.Products WHERE dbo.Products.Category = N'" + name + "'");

            foreach (DataRow item in data.Rows)
            {
                cProducts Products = new cProducts(item);
                a.Add(Products);
            }

            return(a);
        }
Ejemplo n.º 3
0
        public static List <cProducts> GetListProductsByTable(int id)
        {
            List <cProducts> listProducts = new List <cProducts>();

            DataTable data = DataProvider.ExecuteQuery("SELECT dbo.Products.ProductName, dbo.Products.Price, dbo.BillInfo.Amount, dbo.Products.Price * dbo.BillInfo.Amount AS totalPrice FROM dbo.Products, dbo.BillInfo, dbo.Bill WHERE dbo.Products.id = dbo.BillInfo.idProduct AND dbo.BillInfo.idBill = dbo.Bill.id AND dbo.Bill.BillStatus = N'Chưa thanh toán' AND dbo.Bill.idDiningTable = " + id);

            foreach (DataRow item in data.Rows)
            {
                cProducts Products = new cProducts(item);
                listProducts.Add(Products);
            }

            return(listProducts);
        }
Ejemplo n.º 4
0
        public static List <cProducts> GetListCategory(bool b)
        {
            List <cProducts> listProducts = new List <cProducts>();

            DataTable data = DataProvider.ExecuteQuery("SELECT DISTINCT dbo.Products.Category FROM dbo.Products");

            if (b)
            {
                DataRow dr = data.NewRow();
                dr["Category"] = "Tất cả";
                data.Rows.InsertAt(dr, 0);
            }

            foreach (DataRow item in data.Rows)
            {
                cProducts Products = new cProducts(item);
                listProducts.Add(Products);
            }

            return(listProducts);
        }
Ejemplo n.º 5
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            lsvMenu.Items.Clear();

            List <cProducts> listMenu = new List <cProducts>();

            DataTable data = DataProvider.ExecuteQuery("SELECT dbo.Products.ProductName, dbo.Products.Price FROM dbo.Products WHERE dbo.Products.ProductName LIKE N'%" + tbxSearch.text + "%'");

            foreach (DataRow item in data.Rows)
            {
                cProducts menu = new cProducts(item);
                listMenu.Add(menu);
            }

            foreach (cProducts item in listMenu)
            {
                ListViewItem lsvItem = new ListViewItem(item.ProductName.ToString());
                lsvItem.SubItems.Add(item.Price.ToString());

                lsvMenu.Items.Add(lsvItem);
            }

            cbxCategory.SelectedIndex = 0;
        }