Ejemplo n.º 1
0
        public ActionResult Edit(GiaoVien giaoVien)
        {
            try
            {
                // TODO: Add insert logic here
                if (ModelState.IsValid)
                {
                    var _daoGiaoVien = new GiaoVienDao();

                    var res = _daoGiaoVien.Update(giaoVien);
                    if (res)
                    {
                        return(RedirectToAction("Index", "GiaoVien"));
                    }
                    else
                    {
                        ModelState.AddModelError("", "Cập nhật lỗi");
                    }
                }
                return(View(giaoVien));
            }
            catch
            {
                return(RedirectToAction("Index", "GiaoVien"));
            }
        }
Ejemplo n.º 2
0
        public ActionResult GetCourseByTeacher(int id)
        {
            var list = new GiaoVienDao().getListCourseByTeacher(id);

            var model = new GiaoVienDao().ViewDetail(id);

            ViewBag.TenGiaoVien    = model.TenGiaoVien;
            ViewBag.LuongHangThang = model.MucLuong.Value.ToString("#,##").Replace(',', '.');


            return(View(list));
        }
Ejemplo n.º 3
0
        public ActionResult testListAllPagingOrderByDescending(string searchString, int page = 1, int pageSize = 10)
        {
            ViewBag.TongGiaoVien  = db.GiaoViens.Count();
            ViewBag.NhanVienNam   = db.GiaoViens.Where(x => x.GioiTinh == "Nam").Count();
            ViewBag.NhanVienNu    = db.GiaoViens.Where(x => x.GioiTinh == "Nữ").Count();
            ViewBag.TongTienLuong = db.GiaoViens.Sum(x => x.MucLuong).ToString();

            var _daoGiaoVien   = new GiaoVienDao();
            var _modelGiaoVien = _daoGiaoVien.ListAllOrderByDescending(searchString, page, pageSize);

            return(View(_modelGiaoVien));
        }
Ejemplo n.º 4
0
        public ActionResult testSearchByBirthDay(string searchStringBirthDay, int page, int pageSize)
        {
            ViewBag.TongGiaoVien  = db.GiaoViens.Count();
            ViewBag.NhanVienNam   = db.GiaoViens.Where(x => x.GioiTinh == "Nam").Count();
            ViewBag.NhanVienNu    = db.GiaoViens.Where(x => x.GioiTinh == "Nữ").Count();
            ViewBag.TongTienLuong = db.GiaoViens.Sum(x => x.MucLuong).ToString();

            var _daoGiaoVien   = new GiaoVienDao();
            var _modelGiaoVien = _daoGiaoVien.ListAllPagingByEmail(searchStringBirthDay, page, pageSize);

            ViewBag.SearchStringByBirthDay = searchStringBirthDay;
            return(View(_modelGiaoVien));
        }
Ejemplo n.º 5
0
        // GET: GiaoVien
        public ActionResult Index(string searchString, int page = 1, int pageSize = 10)
        {
            var _daoGiaoVien   = new GiaoVienDao();
            var _modelGiaoVien = _daoGiaoVien.ListAllPaging(searchString, page, pageSize);

            ViewBag.SearchString = searchString;
            //ViewBag.GiaoVien = db.GiaoViens.Count();// return tổng số giáo viên
            ViewBag.TongGiaoVien  = db.GiaoViens.Count();
            ViewBag.NhanVienNam   = db.GiaoViens.Where(x => x.GioiTinh == "Nam").Count();
            ViewBag.NhanVienNu    = db.GiaoViens.Where(x => x.GioiTinh == "Nữ").Count();
            ViewBag.TongTienLuong = db.GiaoViens.Sum(x => x.MucLuong).Value.ToString("#,##").Replace(',', '.');
            return(View(_modelGiaoVien));
        }
Ejemplo n.º 6
0
        public ActionResult testSearchByAddress(string searchStringAddress, int page = 1, int pageSize = 10)
        {
            ViewBag.TongGiaoVien  = db.GiaoViens.Count();
            ViewBag.NhanVienNam   = db.GiaoViens.Where(x => x.GioiTinh == "Nam").Count();
            ViewBag.NhanVienNu    = db.GiaoViens.Where(x => x.GioiTinh == "Nữ").Count();
            ViewBag.TongTienLuong = db.GiaoViens.Sum(x => x.MucLuong).ToString();

            var _daoGiaoVien   = new GiaoVienDao();
            var _modelGiaoVien = _daoGiaoVien.ListAllByAddress(searchStringAddress, page, pageSize);

            ViewBag.SearchStringByAddress = searchStringAddress;
            return(View(_modelGiaoVien));
        }
Ejemplo n.º 7
0
        public ActionResult Create(GiaoVien giaoVien, HttpPostedFileBase hinhAnh)
        {
            try
            {
                // TODO: Add insert logic here
                if (ModelState.IsValid)
                {
                    string path = "";
                    if (hinhAnh != null && hinhAnh.ContentLength > 0)
                    {
                        string extension = Path.GetExtension(hinhAnh.FileName);
                        if (extension.Equals(".jpg") || extension.Equals(".png") || extension.Equals(".jpeg"))
                        {
                            path = Path.Combine(Server.MapPath("~/Img/GiaoVien/"), hinhAnh.FileName);
                            hinhAnh.SaveAs(path);
                        }
                        giaoVien.HinhAnh = hinhAnh.FileName;
                        var _daoGiaoVien = new GiaoVienDao();
                        giaoVien.NgayDangKy = DateTime.Now;

                        if (string.IsNullOrEmpty(giaoVien.QuocTich))
                        {
                            giaoVien.QuocTich = "Việt Nam";
                        }
                        //giaoVien.QuocTich ??= "Việt Nam";


                        var encryptMd5Password = Encryptor.MD5Hash(giaoVien.MatKhau);
                        giaoVien.MatKhau = encryptMd5Password;

                        int _maGiaoVien = _daoGiaoVien.Insert(giaoVien);

                        if (_maGiaoVien > 0)
                        {
                            SetAlert("Thêm thành công", 1);
                            return(RedirectToAction("Index", "GiaoVien"));
                        }
                        else
                        {
                            SetAlert("Thêm thất bại", 3);
                            //ModelState.AddModelError("", "Thêm thất bại");
                        }
                    }
                }
                return(View(giaoVien));
            }
            catch
            {
                return(RedirectToAction("Index", "GiaoVien"));
            }
        }
Ejemplo n.º 8
0
        public ActionResult ThemMoiTrinhDo(TrinhDo trinhDo)
        {
            var trinhDoDao = new GiaoVienDao();

            //trinhDo.MaTrinhDo = maTrinhDo + 1;

            int _maTrinhDo = trinhDoDao.InsertTrinhDo(trinhDo);

            if (_maTrinhDo > 0)
            {
                SetAlert("Thêm thành công", 1);
                return(RedirectToAction("Index", "GiaoVien"));
            }
            else
            {
                SetAlert("Thêm thất bại", 3);
                //ModelState.AddModelError("", "Thêm thất bại");
            }

            return(View(trinhDo));
        }
Ejemplo n.º 9
0
        public void SetViewBagGVDetails(int?maGiaoVien = null)
        {
            var dao = new GiaoVienDao();

            ViewBag.MaGiaoVienDetails = new SelectList(dao.ListAll(), "MaGiaoVien", "TenGiaoVien", maGiaoVien);
        }
Ejemplo n.º 10
0
        public ActionResult Edit(int id)
        {
            var _giaoVien = new GiaoVienDao().ViewDetail(id);

            return(View(_giaoVien));
        }
Ejemplo n.º 11
0
        public ActionResult Details(int id)
        {
            var detailGiaoVien = new GiaoVienDao().ViewDetail(id);

            return(PartialView(detailGiaoVien));
        }