コード例 #1
0
        public int Xoa(string mSMonHoc)
        {
            MonHocModel mh = new MonHocModel();

            mh.MSHOCPHAN = int.Parse(mSMonHoc);
            return(mh.Xoa());
        }
コード例 #2
0
        public ActionResult FirstLogin(int ID)
        {
            using (ELearningDB db = new ELearningDB())
            {
                GiangVien gv = db.GiangViens.Find(ID);
                if (gv.HoVaTen != null)
                {
                    Session.Abandon();
                    return(RedirectToAction("Index", "Login", new { area = "" }));
                }
                HocVienModel hocvien = new HocVienModel();

                GiangVienModel giangvien = new GiangVienModel();
                giangvien.ID = gv.ID;
                var lstMonHoc = db.MonHocs;
                List <MonHocModel> MonHocs = new List <MonHocModel>();
                foreach (var item in lstMonHoc)
                {
                    MonHocModel mh = new MonHocModel();
                    mh.MaMonHoc  = item.MaMonHoc;
                    mh.TenMonHoc = item.TenMonHoc;
                    MonHocs.Add(mh);
                }
                SelectList lstMon = new SelectList(MonHocs, "MaMonHoc", "TenMonHoc");
                ViewBag.ListMonHoc = lstMon;
                return(View(giangvien));
            }
        }
コード例 #3
0
 public ActionResult FirstLogin(GiangVienModel gv)
 {
     using (ELearningDB db = new ELearningDB())
     {
         if (ModelState.IsValid)
         {
             GiangVien giangvien = db.GiangViens.Find(gv.ID);
             TaiKhoan  tk        = db.TaiKhoans.Find(gv.ID);
             giangvien.HoVaTen     = gv.HoVaTen;
             giangvien.Email       = gv.Email;
             giangvien.GioiTinh    = gv.GioiTinh;
             giangvien.MaMonHoc    = gv.MaMonHoc;
             giangvien.SoDienThoai = gv.SDT;
             tk.Password           = Encryptor.MD5Hash(gv.NewPass);
             db.SaveChanges();
             return(RedirectToAction("TrangChu", "HomeGV", new { area = "GV" }));
         }
         var lstMonHoc = db.MonHocs;
         List <MonHocModel> MonHocs = new List <MonHocModel>();
         foreach (var item in lstMonHoc)
         {
             MonHocModel mh = new MonHocModel();
             mh.MaMonHoc  = item.MaMonHoc;
             mh.TenMonHoc = item.TenMonHoc;
             MonHocs.Add(mh);
         }
         SelectList lstMon = new SelectList(MonHocs, "MaMonHoc", "TenMonHoc");
         ViewBag.ListMonHoc = lstMon;
         return(View(gv));
     }
 }
コード例 #4
0
        public ActionResult GetMonHocList()
        {
            var         list  = k.getAll();
            MonHocModel model = new MonHocModel();

            model.list_MonHoc = list;
            return(Json(model, JsonRequestBehavior.AllowGet));
        }
コード例 #5
0
        public int KiemTra(string maBacDaoTao, string maMonHoc, string tenMonHoc)
        {
            MonHocModel mh = new MonHocModel();

            mh.MAHOCPHAN   = maMonHoc;
            mh.MSBACDAOTAO = int.Parse(maBacDaoTao);
            mh.TENHOCPHAN  = tenMonHoc;
            return(mh.KiemTraMonHoc().Count);
        }
コード例 #6
0
        public string MonHocTheoBacDaoTaoJson(string maBacDaoTao)
        {
            MonHocModel mh = new MonHocModel();

            mh.MSBACDAOTAO = int.Parse(maBacDaoTao);
            return(JsonConvert.SerializeObject(
                       mh.DanhSach()
                       ));
        }
コード例 #7
0
        public int Them(string maBacDaoTao, string maHocPhan, string tenMonHoc, string lyThuyet, string thucHanh)
        {
            MonHocModel mh = new MonHocModel();

            mh.MSBACDAOTAO = int.Parse(maBacDaoTao);
            mh.MAHOCPHAN   = maHocPhan;
            mh.TENHOCPHAN  = tenMonHoc;
            mh.LYTHUYET    = int.Parse(lyThuyet);
            mh.THUCHANH    = int.Parse(thucHanh);
            return(mh.Them());
        }
コード例 #8
0
        public int CapNhat(string maBacDaoTao, string mSMonHoc,
                           string maMonHoc, string tenMonHoc, string lyThuyet, string thucHanh)
        {
            MonHocModel mh = new MonHocModel();

            mh.MSHOCPHAN   = int.Parse(mSMonHoc);
            mh.MSBACDAOTAO = int.Parse(maBacDaoTao);
            mh.MAHOCPHAN   = maMonHoc;
            mh.TENHOCPHAN  = tenMonHoc;
            mh.LYTHUYET    = int.Parse(lyThuyet);
            mh.THUCHANH    = int.Parse(thucHanh);
            return(mh.CapNhat());
        }
コード例 #9
0
ファイル: LopController.cs プロジェクト: mrhuy3200/ELearning
 public JsonResult GetListMonHoc()
 {
     using (ELearningDB db = new ELearningDB())
     {
         var lstMonHoc = db.MonHocs;
         List <MonHocModel> MonHocs = new List <MonHocModel>();
         foreach (var item in lstMonHoc)
         {
             MonHocModel monhoc = new MonHocModel();
             monhoc.MaMonHoc  = item.MaMonHoc;
             monhoc.TenMonHoc = item.TenMonHoc;
             MonHocs.Add(monhoc);
         }
         return(Json(MonHocs, JsonRequestBehavior.AllowGet));
     }
 }
コード例 #10
0
 public JsonResult Create(MonHocModel mh)
 {
     try
     {
         ELearningDB db  = new ELearningDB();
         MonHoc      mon = new MonHoc();
         mon.TenMonHoc = mh.TenMonHoc;
         db.MonHocs.Add(mon);
         db.SaveChanges();
         return(Json(new { success = true }));
     }
     catch (Exception)
     {
         return(Json(new { success = false }));
     }
 }
コード例 #11
0
        public ActionResult DangKyHocPhan()
        {
            if (!isUserNameExist())
            {
                return(RedirectToAction("Index"));
            }
            MonHocModel monHoc = new MonHocModel();

            ViewBag.listMonHoc = monHoc.findAll();
            Account account = accountModel.find_username(Session[currentAccount].ToString());

            if (account.HocPhanDaDangKy != null)
            {
                return(View(account.HocPhanDaDangKy));
            }


            return(View());
        }
コード例 #12
0
        public ActionResult DangKyHocPhan(List <string> DanhSachHocPhan, List <string> MonHoc)
        {
            if (!isUserNameExist())
            {
                return(RedirectToAction("Index"));
            }
            //Create client connection to our MongoDB database
            var client = new MongoClient(new configWEB().connectionstring);

            //Create a session object that is used when leveraging transactions


            MonHocModel  monHocModel  = new MonHocModel();
            HocPhanModel hocPhanModel = new HocPhanModel();
            AccountModel accountModel = new AccountModel();
            Account      account      = new AccountModel().find_username(Session[currentAccount].ToString());

            List <string> HocPhanDaDangKy_OLD = account.HocPhanDaDangKy;
            List <bool>   trungID             = new List <bool>();

            for (int i = 0; i < HocPhanDaDangKy_OLD.Count(); i++)
            {
                if (HocPhanDaDangKy_OLD[i] == DanhSachHocPhan[i])
                {
                    trungID.Add(true);
                }
                else
                {
                    trungID.Add(false);
                }
            }
            string monHoc_Success = "";
            string monHoc_ThatBai = "";
            bool   isThatBai      = false;

            if (account != null)
            {
                using (var session = client.StartSession())
                {
                    account.Status = true;
                    accountModel.update(account);
                    session.StartTransaction(new TransactionOptions(
                                                 readConcern: ReadConcern.Snapshot,
                                                 writeConcern: WriteConcern.WMajority));
                    try
                    {
                        account.Status          = false;
                        account.HocPhanDaDangKy = DanhSachHocPhan;
                        accountModel.updateHocPhanDaDangKy(account, session);
                        for (int i = 0; i < DanhSachHocPhan.Count(); i++)
                        {
                            if (DanhSachHocPhan[i] != "")
                            {
                                while (monHocModel.getHocphan(MonHoc[i], account.HocPhanDaDangKy[i]).Status == true)
                                {
                                    if (monHocModel.getHocphan(MonHoc[i], account.HocPhanDaDangKy[i]).Status == false)
                                    {
                                        break;
                                    }
                                }
                                monHocModel.lockHocPhan(DanhSachHocPhan[i]);

                                if (monHocModel.ConLai(account.HocPhanDaDangKy[i],
                                                       monHocModel.getHocphan(MonHoc[i],
                                                                              account.HocPhanDaDangKy[i]).SiSo) > 0 || trungID[i] == true)
                                {
                                    monHoc_Success = monHoc_Success + ", " + monHocModel.find(MonHoc[i]).TenMonHoc + " ";
                                }
                                else
                                {
                                    monHoc_ThatBai = monHoc_ThatBai + ", " + monHocModel.find(MonHoc[i]).TenMonHoc + " ";
                                    isThatBai      = true;
                                }
                            }
                        }



                        Thread.Sleep(3000);



                        for (int i = 0; i < DanhSachHocPhan.Count(); i++)
                        {
                            if (DanhSachHocPhan[i] != "")
                            {
                                monHocModel.unlockHocPhan(DanhSachHocPhan[i]);
                            }
                        }

                        if (isThatBai)
                        {
                            ThongBao_Error("học phần môn " + monHoc_ThatBai + " đã hết chỗ , vui lòng chọn học phần khác");
                            session.AbortTransactionAsync();
                            ViewBag.listMonHoc  = monHocModel.findAll();
                            ViewBag.accountInfo = accountModel.find_username(Session[currentAccount].ToString());

                            account.Status          = false;
                            account.HocPhanDaDangKy = HocPhanDaDangKy_OLD;
                            accountModel.update(account);
                            return(View(HocPhanDaDangKy_OLD));
                        }
                        else
                        {
                            ThongBao_Success("Đăng ký học phần " + monHoc_Success + "  thành công!");
                            session.CommitTransaction();
                            ViewBag.listMonHoc  = monHocModel.findAll();
                            ViewBag.accountInfo = accountModel.find_username(Session[currentAccount].ToString());
                            return(View(DanhSachHocPhan));
                        }
                    }
                    catch (Exception e)
                    {
                        account.Status          = false;
                        account.HocPhanDaDangKy = HocPhanDaDangKy_OLD;
                        accountModel.update(account);

                        ThongBao_Error("Error writing to MongoDB: " + e.Message);
                        session.AbortTransaction();
                        ViewBag.listMonHoc  = monHocModel.findAll();
                        ViewBag.accountInfo = accountModel.find_username(Session[currentAccount].ToString());
                        return(View(HocPhanDaDangKy_OLD));
                    }
                }
            }



            ViewBag.listMonHoc  = monHocModel.findAll();
            ViewBag.accountInfo = accountModel.find_username(Session[currentAccount].ToString());
            return(View(DanhSachHocPhan));
        }