private void LuuThuocTinhSanPham() { ThuocTinhSanPham ttsp = new ThuocTinhSanPham(); int SanPhamID = int.Parse(ViewState["ID"].ToString()); ttsp.DeleteBySanPhamID(SanPhamID); foreach (ListItem li in lbiThuocTinh.Items) { if (li.Selected) { ttsp.InsertFields(SanPhamID, int.Parse(li.Value), null); } } }
private void LoadThuocTinhSanPham(int sanphamid) { int thuoctinhid = 0; int thuoctinhchaid = 0; ThuocTinhSanPham ttsp = new ThuocTinhSanPham(); DataSet ds = ttsp.SelectBySanPhamID(sanphamid); if (ds.Tables[0].Rows.Count > 0) { thuoctinhid = int.Parse(ds.Tables[0].Rows[0]["ThuocTinhID"].ToString()); ThuocTinh tt = new ThuocTinh(); DataSet dstt = tt.SelectByID(thuoctinhid); if (dstt.Tables[0].Rows.Count > 0) { thuoctinhchaid = int.Parse(dstt.Tables[0].Rows[0]["thuoctinhchaid"].ToString()); } } ddlThuocChinhCha.SelectedValue = thuoctinhchaid.ToString(); LoadThuocTinh(); foreach (DataRow dr in ds.Tables[0].Rows) { foreach (ListItem li in lbiThuocTinh.Items) { if (li.Value == dr["ThuocTinhID"].ToString()) li.Selected = true; } } }