public static IList <SoLuongTon> LaySoLuongTon() { SanPhamFactory f = new SanPhamFactory(); DataTable tbl = f.LaySoLuongTon(); IList <SoLuongTon> ds = new List <SoLuongTon>(); DonViTinhController ctrlDVT = new DonViTinhController(); foreach (DataRow row in tbl.Rows) { SoLuongTon slt = new SoLuongTon(); SanPham sp = new SanPham(); sp.Id = Convert.ToString(row["ID"]); sp.TenSanPham = Convert.ToString(row["TEN_SAN_PHAM"]); sp.SoLuong = Convert.ToInt32(row["SO_LUONG"]); sp.DonGiaNhap = Convert.ToInt64(row["DON_GIA_NHAP"]); sp.GiaBanLe = Convert.ToInt64(row["GIA_BAN_LE"]); sp.GiaBanSi = Convert.ToInt64(row["GIA_BAN_SI"]); sp.DonViTinh = ctrlDVT.LayDVT(Convert.ToInt32(row["ID_DON_VI_TINH"])); slt.SanPham = sp; slt.SoLuong = Convert.ToInt32(row["SO_LUONG_TON"]); ds.Add(slt); } return(ds); }
public SanPham LaySanPham(String id) { DataTable tbl = factory.LaySanPham(id); SanPham sp = new SanPham(); DonViTinhController ctrlDVT = new DonViTinhController(); if (tbl.Rows.Count > 0) { sp.Id = Convert.ToString(tbl.Rows[0]["ID"]); sp.TenSanPham = Convert.ToString(tbl.Rows[0]["TEN_SAN_PHAM"]); sp.SoLuong = Convert.ToInt32(tbl.Rows[0]["SO_LUONG"]); sp.DonGiaNhap = Convert.ToInt64(tbl.Rows[0]["DON_GIA_NHAP"]); sp.GiaBanLe = Convert.ToInt64(tbl.Rows[0]["GIA_BAN_LE"]); sp.GiaBanSi = Convert.ToInt64(tbl.Rows[0]["GIA_BAN_SI"]); sp.DonViTinh = ctrlDVT.LayDVT(Convert.ToInt32(tbl.Rows[0]["ID_DON_VI_TINH"])); } return(sp); }