public string addTheLoaiSach(decimal masach, byte matl) { bool done = false; try { CTTL ct = db.CTTLs.FirstOrDefault(x => x.MaSach == masach && x.MaTL == matl) ?? null; if (ct == null) { db.CTTLs.InsertOnSubmit(new CTTL { MaSach = masach, MaTL = matl }); db.SubmitChanges(); done = true; } else { done = false; } } catch (Exception ex) { done = false; } return(new JavaScriptSerializer().Serialize(done)); }
public string deleteCTTLSach(int masach, int matheloai) { bool done; try { CTTL ct = db.CTTLs.First(x => x.MaSach == masach && x.MaTL == matheloai); db.CTTLs.DeleteOnSubmit(ct); db.SubmitChanges(); done = true; } catch (Exception) { done = false; } return(new JavaScriptSerializer().Serialize(done)); }
public string deleteTheLoaiSach(decimal masach, byte matl) { bool done; try { CTTL ct = db.CTTLs.FirstOrDefault(x => x.MaSach == masach && x.MaTL == matl); db.CTTLs.DeleteOnSubmit(ct); db.SubmitChanges(); done = true; } catch (Exception ex) { done = false; } return(new JavaScriptSerializer().Serialize(done)); }