Ejemplo n.º 1
0
        public static List <LICHHOC> GetLichHoc(LOPHOCPHAN lopHocPhan, THOIKHOABIEU thoiKhoaBieu)
        {
            using (var db = new UMS_HUSCEntities())
            {
                var ngayBatDauHoc  = lopHocPhan.NgayBatDauHoc;
                var ngayKetThucHoc = lopHocPhan.NgayKetThucHoc;
                var ngayTrongTuan  = thoiKhoaBieu.NgayTrongTuan - 1;
                var lichHoc        = new List <LICHHOC>();

                for (var index = ngayBatDauHoc; index <= ngayKetThucHoc; index = index.AddHours(24))
                {
                    if (index.DayOfWeek.GetHashCode() == ngayTrongTuan)
                    {
                        var item = new LICHHOC()
                        {
                            MaLopHocPhan   = lopHocPhan.MaLopHocPhan,
                            PhongHoc       = thoiKhoaBieu.PhongHoc,
                            TietHocBatDau  = thoiKhoaBieu.TietHocBatDau,
                            TietHocKetThuc = thoiKhoaBieu.TietHocKetThuc,
                            NgayHoc        = index
                        };
                        lichHoc.Add(item);
                    }
                }
                return(lichHoc);
            }
        }
        public ActionResult DeleteConfirmed(string id)
        {
            THOIKHOABIEU tHOIKHOABIEU = db.THOIKHOABIEUx.Find(id);

            db.THOIKHOABIEUx.Remove(tHOIKHOABIEU);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        // GET: THOIKHOABIEUx/Create
        public ActionResult Create()
        {
            ViewBag.CANBO_CB_MA   = new SelectList(db.CANBOes, "CB_MA", "CB_HOTEN");
            ViewBag.HOCKY_HK_MA   = new SelectList(db.HOCKies, "HK_MA", "HK_TEN");
            ViewBag.LOP_LOP_MA    = new SelectList(db.LOPs, "LOP_MA", "LOP_TEN");
            ViewBag.MONHOC_MH_MA  = new SelectList(db.MONHOCs, "MH_MA", "MH_TEN");
            ViewBag.THU_THU_MA    = new SelectList(db.THUs, "THU_MA", "THU_TEN");
            ViewBag.TIETHOC_TH_MA = new SelectList(db.TIETHOCs, "TH_MA", "TH_TEN");
            THOIKHOABIEU obj = new THOIKHOABIEU();

            obj.TKB_MA = CreateID.CreateID_ByteText();
            return(View(obj));
        }
        // GET: THOIKHOABIEUx/Details/5
        public ActionResult Details(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            THOIKHOABIEU tHOIKHOABIEU = db.THOIKHOABIEUx.Find(id);

            if (tHOIKHOABIEU == null)
            {
                return(HttpNotFound());
            }
            return(View(tHOIKHOABIEU));
        }
 public ActionResult Edit([Bind(Include = "TKB_MA,LOP_LOP_MA,MONHOC_MH_MA,THU_THU_MA,TIETHOC_TH_MA,CANBO_CB_MA,HOCKY_HK_MA")] THOIKHOABIEU tHOIKHOABIEU)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tHOIKHOABIEU).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.CANBO_CB_MA   = new SelectList(db.CANBOes, "CB_MA", "CB_HOTEN", tHOIKHOABIEU.CANBO_CB_MA);
     ViewBag.HOCKY_HK_MA   = new SelectList(db.HOCKies, "HK_MA", "HK_TEN", tHOIKHOABIEU.HOCKY_HK_MA);
     ViewBag.LOP_LOP_MA    = new SelectList(db.LOPs, "LOP_MA", "LOP_TEN", tHOIKHOABIEU.LOP_LOP_MA);
     ViewBag.MONHOC_MH_MA  = new SelectList(db.MONHOCs, "MH_MA", "MH_TEN", tHOIKHOABIEU.MONHOC_MH_MA);
     ViewBag.THU_THU_MA    = new SelectList(db.THUs, "THU_MA", "THU_TEN", tHOIKHOABIEU.THU_THU_MA);
     ViewBag.TIETHOC_TH_MA = new SelectList(db.TIETHOCs, "TH_MA", "TH_TEN", tHOIKHOABIEU.TIETHOC_TH_MA);
     return(View(tHOIKHOABIEU));
 }
Ejemplo n.º 6
0
        public static void AddLopHocPhan(string maHocPhan, int stt, int maHocKy, int maGiaoVien, DateTime ngayHetHanDK, DateTime ngayBDHoc, DateTime ngayKTHoc,
                                         int phongHoc, int ngayTrongTuan, int tietHocBD, int tietHocKT)
        {
            using (var db = new UMS_HUSCEntities())
            {
                var sttStr = stt < 10 ? "00" + stt : "" + stt;
                sttStr = (stt > 10) && (stt < 99) ? "0" + stt : "" + sttStr;
                var hocKy   = db.VHocKies.FirstOrDefault(i => i.MaHocKy == maHocKy);
                var hocPhan = db.HOCPHANs.FirstOrDefault(i => i.MaHocPhan.Equals(maHocPhan));

                var lopHocPhan = new LOPHOCPHAN()
                {
                    MaLopHocPhan      = hocKy.NamBatDau + "-" + hocKy.NamKetThuc + "." + hocKy.TenHocKy + "." + maHocPhan + "." + sttStr,
                    MaHocPhan         = maHocPhan,
                    TenLopHocPhan     = hocPhan.TenHocPhan + " - Nhóm " + stt,
                    SoThuTuLop        = stt,
                    HocKy             = maHocKy,
                    GiangVienPhuTrach = maGiaoVien,
                    NgayHetHanDangKy  = ngayHetHanDK,
                    NgayBatDauHoc     = ngayBDHoc,
                    NgayKetThucHoc    = ngayKTHoc,
                    HinhThucHoc       = 1,
                    TrangThaiHoatDong = 1,
                    GIANGVIEN         = null,
                    THOIKHOABIEUx     = null,
                    LICHHOCs          = null
                };

                var thoiKhoaBieu = new THOIKHOABIEU()
                {
                    MaLopHocPhan   = lopHocPhan.MaLopHocPhan,
                    PhongHoc       = phongHoc,
                    NgayTrongTuan  = ngayTrongTuan,
                    TietHocBatDau  = tietHocBD,
                    TietHocKetThuc = tietHocKT,
                    PHONGHOC1      = null,
                    LOPHOCPHAN     = lopHocPhan
                };
                lopHocPhan.THOIKHOABIEUx = new List <THOIKHOABIEU> {
                    thoiKhoaBieu
                };
                lopHocPhan.LICHHOCs = GetLichHoc(lopHocPhan, thoiKhoaBieu);
                db.LOPHOCPHANs.Add(lopHocPhan);
                db.SaveChanges();
            }
        }
        // GET: THOIKHOABIEUx/Edit/5
        public ActionResult Edit(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            THOIKHOABIEU tHOIKHOABIEU = db.THOIKHOABIEUx.Find(id);

            if (tHOIKHOABIEU == null)
            {
                return(HttpNotFound());
            }
            ViewBag.CANBO_CB_MA   = new SelectList(db.CANBOes, "CB_MA", "CB_HOTEN", tHOIKHOABIEU.CANBO_CB_MA);
            ViewBag.HOCKY_HK_MA   = new SelectList(db.HOCKies, "HK_MA", "HK_TEN", tHOIKHOABIEU.HOCKY_HK_MA);
            ViewBag.LOP_LOP_MA    = new SelectList(db.LOPs, "LOP_MA", "LOP_TEN", tHOIKHOABIEU.LOP_LOP_MA);
            ViewBag.MONHOC_MH_MA  = new SelectList(db.MONHOCs, "MH_MA", "MH_TEN", tHOIKHOABIEU.MONHOC_MH_MA);
            ViewBag.THU_THU_MA    = new SelectList(db.THUs, "THU_MA", "THU_TEN", tHOIKHOABIEU.THU_THU_MA);
            ViewBag.TIETHOC_TH_MA = new SelectList(db.TIETHOCs, "TH_MA", "TH_TEN", tHOIKHOABIEU.TIETHOC_TH_MA);
            return(View(tHOIKHOABIEU));
        }