Exemple #1
0
        public bool suaCauHoi(int maCH, string noiDungCH, int doKho, List <DapAn> lstDA)
        {
            CauHoi ch = tnth.CauHois.Where(t => t.MaCH == maCH).FirstOrDefault();

            ch.NoiDungCH = noiDungCH;
            ch.DoKho     = doKho;

            List <int> lst = getMaDapAn(maCH);
            DapAn      da;

            try
            {
                for (int i = 0; i < lst.Count; i++)
                {
                    da           = tnth.DapAns.Where(t => t.MaDA == lst[i]).FirstOrDefault();
                    da.NoiDungDA = lstDA[i].NoiDungDA;
                    da.DungSai   = lstDA[i].DungSai;
                }

                tnth.SubmitChanges();
                return(true);
            }
            catch
            {
                return(false);
            }
        }
Exemple #2
0
        public bool xoaCauHoi(int maCH)
        {
            CauHoi xoaCH  = tnth.CauHois.Where(t => t.MaCH == maCH).FirstOrDefault();
            var    dapans = from da in tnth.DapAns
                            where da.MaCH == maCH
                            select da;
            List <DapAn> lstDA = dapans.ToList <DapAn>();

            try
            {
                tnth.CauHois.DeleteOnSubmit(xoaCH);
                for (int i = 0; i < lstDA.Count; i++)
                {
                    tnth.DapAns.DeleteOnSubmit(lstDA[i]);
                }

                tnth.CauHois.DeleteOnSubmit(xoaCH);
                tnth.SubmitChanges();
                return(true);
            }
            catch
            {
                return(false);
            }
        }
Exemple #3
0
        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); }
        }
Exemple #4
0
 partial void DeleteCauHoi(CauHoi instance);
Exemple #5
0
 partial void UpdateCauHoi(CauHoi instance);
Exemple #6
0
 partial void InsertCauHoi(CauHoi instance);