public int ThemHocSinh(HocSinhDTO hsa)
        {
            HocSinh hs = new HocSinh();

            //Hoc h = new Hoc();
            //LopHoc rs = (from lh in md.LopHocs
            // where lh.KhoaHocID == hsa.KhoaHocID
            //select lh).ToList().ElementAt(0);
            //int a = rs.LopHocID;
            hs.MaHS     = hsa.MaHS;
            hs.TenHS    = hsa.TenHS;
            hs.NgaySinh = hsa.NgaySinh;
            hs.GioiTinh = hsa.GioiTinh;
            hs.DiaChi   = hsa.DiaChi;
            hs.PhuHuynh = hsa.PhuHuynh;
            hs.SDT      = hsa.SDT;
            hs.UserName = hsa.UserName;
            hs.PassWord = hsa.PassWord;
            // h.LopHocID = a;
            //h.HocSinhID = hsa.HocSinhID;
            //md.HocSinhs.Add(hs);
            //md.Hocs.Add(h);
            md.HocSinhs.Add(hs);
            md.SaveChanges();

            return(hs.MaHS);
        }
Exemplo n.º 2
0
        public void Delete(int id)
        {
            var tan = tn.KetQuas.Find(id);

            tn.KetQuas.Remove(tan);
            tn.SaveChanges();
        }
Exemplo n.º 3
0
        public ActionResult StartContest(int id, BaiThiDTO collection)
        {
            int   socau    = tn.ch_db.Count(x => x.MaDe == id);
            float hesodiem = 100 / socau;
            float diem;
            int   bodem = 0;

            for (int i = 0; i < collection.ListQuiz.Count; i++)
            {
                var quizid = tn.CauHois.Find(collection.ListQuiz[i].MaCH);
                if (quizid.DapAn == collection.ListQuiz[i].GhiChu)
                {
                    bodem = bodem + 1;
                }
            }
            diem = bodem * hesodiem;
            int session = int.Parse(Session["MaHS"].ToString());

            //var session = (TracNghiemLTK.Common.ThiSinhInfo)Session[TracNghiemLTK.Common.CommonConstantsStudent.STUDENT_SESSION];
            //var ma = tn.KetQuas;
            tn.KetQuas.Add(new KetQua()
            {
                MaDe    = id,
                MaHS    = session,
                Diem    = diem,
                NgayThi = DateTime.Now
            });
            tn.SaveChanges();
            return(RedirectToAction("Index", "KetQuaBaiThi", new { @maThiSinh = Session["MaHS"], @maDe = id }));
            //return RedirectToAction("Index", "KetQuaBaiThi", new { @maDe = id });
        }
        public void DeleteCauHoiAdd(int id)
        {
            var tan = md.ch_db.Select(x => x.MaCH == id);
            var ten = md.ch_db.Find(tan);

            md.ch_db.Remove(ten);
            md.SaveChanges();
        }
        public int ThemBH(BaiHocDTO hsa)
        {
            BaiHoc bh = new BaiHoc();

            bh.MaBH       = hsa.MaBH;
            bh.TenBH      = hsa.TenBH;
            bh.ChuDe      = hsa.ChuDe;
            bh.AnhChuDe   = hsa.AnhChuDe;
            bh.NoiDung    = hsa.NoiDung;
            bh.NoiDungAnh = hsa.NoiDungAnh;
            bh.NghiaTu    = hsa.NghiaTu;
            bh.NghiaTu2   = hsa.NghiaTu2;
            md.BaiHocs.Add(bh);
            md.SaveChanges();

            return(bh.MaBH);
        }
 public long Insert(HocSinh entity)
 {
     mymd.HocSinhs.Add(entity);
     mymd.SaveChanges();
     return(entity.MaHS);
 }
Exemplo n.º 7
0
 public int Insert(DeThi entity)
 {
     tn.DeThis.Add(entity);
     tn.SaveChanges();
     return(entity.MaDe);
 }
 public int Insert(CauHoi entity)
 {
     tn.CauHois.Add(entity);
     tn.SaveChanges();
     return(entity.MaCH);
 }