public static int Update(STO_KhoVatTu kho, Entities db = null) { if (kho == null || kho.ID_kho == null || kho.Ten_kho == null) { return(0); } if (db == null) { db = new Entities(); } var entity = db.STO_KhoVatTu.FirstOrDefault(t => t.ID_kho == kho.ID_kho); if (entity == null) { return(0); } entity.Ten_kho = kho.Ten_kho; entity.Dia_diem = kho.Dia_diem; entity.Ma_kho = kho.Ma_kho; entity.Trang_thai = kho.Trang_thai; return(db.SaveChanges()); }
private void grvKhoVatTuCT_Load() { STO_KhoVatTu kho = (STO_KhoVatTu)grvKhoVatTu.GetFocusedRow(); if (kho != null) { KhoVatTuCTCtrl.LoadBindingSource(sTOKhoVatTuCTBindingSource, kho.ID_kho); } }
public static int Insert(STO_KhoVatTu kho, Entities db = null) { if (kho == null || kho.Ten_kho == null) { return(0); } if (db == null) { db = new Entities(); } db.STO_KhoVatTu.Add(kho); return(db.SaveChanges()); }