Exemplo n.º 1
0
        public void loadproduct()
        {
            flowLayoutPanel1.Controls.Clear();
            DataTable a = ProductDAO.Instance.Productlist();

            for (int i = 0; i < a.Rows.Count; i++)
            {
                UC_ItemProduct item    = new UC_ItemProduct(this);
                int            ton_tai = int.Parse(a.Rows[i]["ton_tai"].ToString());
                if (ton_tai == 1)
                {
                    item.masp    = a.Rows[i]["masp"].ToString();
                    item.tensp   = a.Rows[i]["ten_sp"].ToString();
                    item.loaisp  = a.Rows[i]["loai_sp"].ToString();
                    item.soluong = int.Parse(a.Rows[i]["so_luong"].ToString());
                    item.gianhap = double.Parse(a.Rows[i]["gia_nhap"].ToString());
                    item.giaban  = double.Parse(a.Rows[i]["gia_ban"].ToString());
                    item.img     = a.Rows[i]["img"].ToString();
                    item.set_UC();
                    if (d == 0)
                    {
                        flowLayoutPanel1.Controls.Add(item);
                    }
                    if (d == 2 && item.loaisp != "Linh kiện")
                    {
                        flowLayoutPanel1.Controls.Add(item);
                    }
                    if (d == 1 && item.loaisp == "Linh kiện")
                    {
                        flowLayoutPanel1.Controls.Add(item);
                    }
                }
            }
        }
Exemplo n.º 2
0
 private void guna2TextBox1_TextChanged(object sender, EventArgs e)
 {
     if (tb_search.Text == "")
     {
         loadproduct();
     }
     else
     {
         flowLayoutPanel1.Controls.Clear();
         DataTable a = ProductDAO.Instance.search_product_by_name(tb_search.Text);
         for (int i = 0; i < a.Rows.Count; i++)
         {
             UC_ItemProduct item    = new UC_ItemProduct(this);
             int            ton_tai = int.Parse(a.Rows[i]["ton_tai"].ToString());
             if (ton_tai == 1)
             {
                 item.masp    = a.Rows[i]["masp"].ToString();
                 item.tensp   = a.Rows[i]["ten_sp"].ToString();
                 item.loaisp  = a.Rows[i]["loai_sp"].ToString();
                 item.soluong = int.Parse(a.Rows[i]["so_luong"].ToString());
                 item.gianhap = double.Parse(a.Rows[i]["gia_nhap"].ToString());
                 item.giaban  = double.Parse(a.Rows[i]["gia_ban"].ToString());
                 item.img     = a.Rows[i]["img"].ToString();
                 item.set_UC();
                 //flowLayoutPanel1.Controls.Add(item);
                 if (d == 0)
                 {
                     flowLayoutPanel1.Controls.Add(item);
                 }
                 if (d == 2 && item.loaisp != "Linh kiện")
                 {
                     flowLayoutPanel1.Controls.Add(item);
                 }
                 if (d == 1 && item.loaisp == "Linh kiện")
                 {
                     flowLayoutPanel1.Controls.Add(item);
                 }
             }
         }
     }
 }