Exemplo n.º 1
0
        void NapSanPham()
        {
            listView1.Columns.Clear();
            listView1.Items.Clear();

            listView1.Columns.Add("Mã SP", 0);
            listView1.Columns.Add("Tên SP", 140);
            listView1.Columns.Add("Đơn vị", 80);
            listView1.Columns.Add("Đơn giá", 80);
            listView1.Columns.Add("Số tồn", 80);

            DataTable dt = new DataTable();

            bus = new BUS_SanPham();

            dt = bus.selectdata(cboLoaiSP.SelectedValue.ToString());
            foreach (DataRow dr in dt.Rows)
            {
                ListViewItem listitem = new ListViewItem(dr["MaSP"].ToString());
                listitem.SubItems.Add(dr["TenSP"].ToString());
                listitem.SubItems.Add(dr["DonViTinh"].ToString());
                listitem.SubItems.Add(dr["DonGiaMua"].ToString());
                listitem.SubItems.Add(dr["SoTon"].ToString());
                listView1.Items.Add(listitem);
            }
            listView1.View          = View.Details;
            listView1.GridLines     = true;
            listView1.FullRowSelect = true;
        }
Exemplo n.º 2
0
        void NapLoaiSP()
        {
            cboLoaiSP.Items.Clear();

            DataTable dt = new DataTable();

            bus = new BUS_SanPham();

            dt = bus.showdata();

            var item = new Dictionary <string, string>();

            foreach (DataRow dr in dt.Rows)
            {
                item.Add(dr["MaLoai"].ToString(), dr["TenLoai"].ToString());
            }
            cboLoaiSP.DataSource    = new BindingSource(item, null);
            cboLoaiSP.DisplayMember = "Value";
            cboLoaiSP.ValueMember   = "Key";
        }