public int add(SanPham_ChiTiet obj) { this._db.ds_sanpham_chitiet.Add(obj); this.save(); //return ma moi nhat return this._db.ds_sanpham_chitiet.Max(x => x.id); }
public Boolean delete(SanPham_ChiTiet obj) { try { obj = get_by_id(obj.id); this._db.ds_sanpham_chitiet.Remove(obj); return this.save(); } catch (Exception ex) { Debug.WriteLine(ex.ToString()); return false; } }
//method public void change(SanPham_ChiTiet spct) { this.active = spct.active; this.tonkho = spct.tonkho; this.mausac = spct.mausac; }
List<SanPham_ChiTiet> LayDanhSachSP() { List<SanPham_ChiTiet> list = new List<SanPham_ChiTiet>(); foreach (DataGridViewRow dtr in dtgvSanPham.Rows) { if (dtr.Cells["chon"].Value.ToString() == "True") { SanPham_ChiTiet spct = new SanPham_ChiTiet(); spct.id = Int32.Parse(dtr.Cells["id"].Value.ToString()); list.Add(spct); } } return list; }
private void btSuaChiTietSP_Click(object sender, EventArgs e) { if (dtgvChiTietSanPham.SelectedRows.Count == 0) return; SanPham_ChiTiet spct = (SanPham_ChiTiet)dtgvChiTietSanPham.SelectedRows[0].DataBoundItem; ThongTinFormSanPhamChiTiet = spct; gbThongTin.Enabled = true; btThemChiTietSP.Enabled = false; btXoaChiTietSP.Enabled = false; }