public bool themCauHoi(string noiDungCH, int doKho, List <DapAn> lstDA) { CauHoi ch = new CauHoi(); DapAn da; ch.NoiDungCH = noiDungCH; ch.DoKho = doKho; ch.HinhThucCH = null; try { tnth.CauHois.InsertOnSubmit(ch); tnth.SubmitChanges(); for (int i = 0; i < lstDA.Count; i++) { da = new DapAn(); da.MaCH = ch.MaCH; da.NoiDungDA = lstDA[i].NoiDungDA; da.DungSai = lstDA[i].DungSai; tnth.DapAns.InsertOnSubmit(da); } tnth.SubmitChanges(); return(true); } catch { return(false); } }
partial void DeleteDapAn(DapAn instance);
partial void UpdateDapAn(DapAn instance);
partial void InsertDapAn(DapAn instance);
private void detach_DapAns(DapAn entity) { this.SendPropertyChanging(); entity.CauHoi = null; }
private void attach_DapAns(DapAn entity) { this.SendPropertyChanging(); entity.CauHoi = this; }
public DapAn getDapAnDung(int mach) { DapAn dapans = tnth.DapAns.Where(t => t.MaCH == mach && t.DungSai == true).FirstOrDefault(); return(dapans); }