Esempio n. 1
0
        public ActionResult KiemTraDangNhap(string email, string pass)
        {
            Authentication authen     = new Authentication();
            string         checkLogin = authen.CheckLogin(email, pass);

            if (checkLogin == null)
            {
                ViewBag.Notifi = "Tên đăng nhập hoặc mật khẩu không chính xác!";
                return(RedirectToAction("Index"));
            }
            if (checkLogin.Split(':')[0].Equals("SINHVIEN"))
            {
                SinhVienBLL contextSV = new SinhVienBLL();
                SinhVien    sv        = contextSV.GetById(checkLogin.Split(':')[1].ToString().Trim());
                if (sv != null)
                {
                    Session["GiangVien"] = Session["MaGV"] = null;
                    Session["SinhVien"]  = sv.HoVaTenLot + " " + sv.TenSV;
                    Session["MaSV"]      = sv.MaSV;
                    return(RedirectToAction("Index", "SinhVien"));
                }
                return(RedirectToAction("Index"));
            }
            GiangVienBLL contextGV = new GiangVienBLL();
            GiangVien    gv        = contextGV.GetById(checkLogin.Split(':')[1].ToString().Trim());

            if (gv != null)
            {
                Session["SinhVien"]  = Session["MaSV"] = null;
                Session["GiangVien"] = gv.HoVaTenLot + " " + gv.TenGV;
                Session["MaGV"]      = gv.MaGV;
                return(RedirectToAction("Index", "GiangVien"));
            }
            return(RedirectToAction("Index"));
        }
Esempio n. 2
0
        // thêm sinh viên
        private void btnthemsv_Click(object sender, EventArgs e)
        {
            try
            {
                SinhVien SV = new SinhVien();
                SV.MSSV     = tbxmssv.Text.Trim();
                SV.HoTen    = tbxtensv.Text.Trim();
                SV.NgaySinh = dtpngaysinh.Value;
                SV.Phai     = cbxGTSV.Text.Trim();
                SV.Khoa     = tbxkhoa.Text.Trim();
                SV.SDT      = tbxsdtsv.Text.Trim();
                SV.Email    = tbxemailsv.Text.Trim();

                SinhVienBLL SVBLL = new SinhVienBLL();
                string      _MSSV = tbxmssv.Text.Trim();
                if (!(SVBLL.CheckID(_MSSV)))
                {
                    SVBLL.Insert(SV);
                    LoadDataSinhVien();
                }
                else
                {
                    MessageBox.Show("Mã sinh viên " + _MSSV.ToString() + "đã tồn tại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Thêm bị lỗi: " + ex.Message.ToString(), "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Esempio n. 3
0
        private void btnthem_Click(object sender, EventArgs e)
        {
            // Kiểm tra tính hợp lệ của dữ liệ
            if (txthoten.Text == "" || txtdiachi.Text == "")
            {
                MessageBox.Show("Vui lòng nhập dữ liệu.", "Thông báo!"); return;
            }
            // Khởi tạo đối tượng sinh viên DTO
            HocSinhDTO svDTO = new HocSinhDTO();

            svDTO.SHoTen = txthoten.Text;
            if (radnam.Checked == true)
            {
                svDTO.SGioiTinh = "Nam";
            }
            else
            {
                svDTO.SGioiTinh = "Nữ";
            }
            svDTO.DtNgaySinh = DateTime.Parse(dtpngaysinh.Text);
            svDTO.SDiaChi    = txtdiachi.Text;
            svDTO.IMaLop     = int.Parse(cblop.SelectedValue.ToString());
            // Gọi lớp nghiệp vụ SinhVienBLL
            if (SinhVienBLL.ThemSinhVien(svDTO) == true)
            {
                MessageBox.Show("Thêm thành công.", "Thông báo!");
                // Load lại dữ liệu
                LoadSinhVien();
                return;
            }
            MessageBox.Show("Thêm thất bại.", "Thông báo!");
        }
Esempio n. 4
0
        private void btnOK_Click_1(object sender, EventArgs e)
        {
            try
            {
                SinhVienBLL sinhvienBLL = new SinhVienBLL();
                bool        rbGioiTinh;
                if (radioButtonMale.Checked)
                {
                    rbGioiTinh = true;
                }
                else
                {
                    rbGioiTinh = false;
                }

                SinhVien sinhvien = new SinhVien()
                {
                    maSinhVien      = txtMaSinhVien.Text.ToString(),
                    tenSinhVien     = txtTenSinhVien.Text.ToString(),
                    ngaySinh        = Convert.ToDateTime(dateTimePickerNgaySinh.Text.ToString()),
                    queQuan         = comboBoxQueQuan.Text.ToString(),
                    hoKhau          = txtHoKhau.Text.ToString(),
                    diemTrungBinhTL = (float)Convert.ToDouble(txtDiemTrungBinhTL.Text.ToString()),
                    maKhoa          = comboBoxKhoa.SelectedValue.ToString(),
                    gioiTinh        = rbGioiTinh
                };

                sinhvienBLL.addSinhVien(sinhvien);
                dlgAdd();
                Dispose();
            }catch (Exception e1)
            {
                MessageBox.Show("Ma Sinh Vien Da Ton Tai Hoac Du Lieu Ban Nhap Vao Khong Le");
            }
        }
        public JsonResult LocTKBTHeoTuan(string tuan)
        {
            if (Session["MaSV"] != null)
            {
                MonHocBLL           contextMH  = new MonHocBLL();
                SupportThoiKhoaBieu spTKB      = new SupportThoiKhoaBieu();
                SinhVienBLL         contextSV  = new SinhVienBLL();
                SinhVien            sv         = contextSV.GetById(Session["MaSV"].ToString().Trim());
                HeDaoTaoBLL         contextHDT = new HeDaoTaoBLL();
                List <SinhVien>     lstSV      = contextSV.GetAll();
                foreach (SinhVien sv1 in lstSV)
                {
                    if (sv1.MaSV == sv.MaSV)
                    {
                        sv = sv1;
                    }
                }
                ViewData["MaLop"] = sv.MaLop;
                ViewData["HDT"]   = contextHDT.GetById(sv.Lop.MaHDT).TenHDT;
                ViewData["Khoa"]  = sv.Lop.NienKhoa;

                List <SupportThoiKhoaBieu> lstSPTKB = spTKB.GetListSPTKB(tuan, sv.LopTinChis);
                return(Json(new { ListData = lstSPTKB }, JsonRequestBehavior.AllowGet));
            }
            return(Json(new { msg = "Bạn không có quyền xem thời khóa biểu!" }));
        }
Esempio n. 6
0
        // cập nhật sinh viên
        private void btncapnhatsv_Click(object sender, EventArgs e)
        {
            try
            {
                SinhVien SV = new SinhVien();
                SV.MSSV     = tbxmssv.Text.Trim();
                SV.HoTen    = tbxtensv.Text.Trim();
                SV.Phai     = cbxGTSV.Text.Trim();
                SV.NgaySinh = dtpngaysinh.Value;
                SV.Khoa     = tbxkhoa.Text.Trim();
                SV.SDT      = tbxsdtsv.Text.Trim();
                SV.Email    = tbxemailsv.Text.Trim();


                SinhVienBLL SVBLL = new SinhVienBLL();

                string _MSSV = tbxmssv.Text.Trim();
                SVBLL.Update(SV);

                LoadDataSinhVien();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Sửa bị lỗi: " + ex.Message.ToString(), "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Esempio n. 7
0
 public frmSinhVienTheoLop(Form f)
 {
     this.f      = f;
     sinhvienBLL = new SinhVienBLL();
     ds          = new DataSet();
     dssv        = new DataSet();
     InitializeComponent();
 }
Esempio n. 8
0
 public frmGVRieng(Form f)
 {
     sinhVienbll = new SinhVienBLL();
     lopbll      = new LopBLL();
     dssinhvien  = new DataSet();
     dslop       = new DataSet();
     dsidgv      = new DataSet();
     this.f      = f;
     InitializeComponent();
 }
Esempio n. 9
0
        public void viewResult(string content)
        {
            SinhVienBLL sinhvienBLL = new SinhVienBLL();

            var sinhviens = sinhvienBLL.getListSinhVien().Select(p => new { p.maSinhVien, p.tenSinhVien, p.ngaySinh, p.gioiTinh, p.diemTrungBinhTL, p.khoa.tenKhoa }).Where(p => p.maSinhVien.Contains(content) || p.tenSinhVien.Contains(content));

            dataGridView1.DataSource = sinhviens.ToList();
            for (int i = 0; i < dataGridView1.Rows.Count; i++)
            {
                dataGridView1.Rows[i].Cells["stt"].Value = (i + 1).ToString();
            }
        }
Esempio n. 10
0
        private void btntimkiem_Click(object sender, EventArgs e)
        {
            string            key   = txttimkiem.Text;
            List <HocSinhDTO> lstKQ = SinhVienBLL.TimKiemSinhVien(key);

            if (lstKQ == null)
            {
                MessageBox.Show("Không tìm thấy học sinh nào.", "Thông báo!");
                return;
            }
            dgvsinhvien.DataSource = lstKQ;
        }
Esempio n. 11
0
        private void LoadSinhVien()
        {
            List <HocSinhDTO> lstSinhVien = SinhVienBLL.LoadSinhVien();

            dgvsinhvien.DataSource = lstSinhVien;
            dgvsinhvien.Columns["IMaHS"].HeaderText      = "Mã học sinh";
            dgvsinhvien.Columns["SHoTen"].HeaderText     = "Tên học sinh";
            dgvsinhvien.Columns["SGioiTinh"].HeaderText  = "Giới tính";
            dgvsinhvien.Columns["DtNgaySinh"].HeaderText = "Ngày sinh";
            dgvsinhvien.Columns["SDiaChi"].HeaderText    = "Địa chỉ";
            dgvsinhvien.Columns["IMaLop"].Visible        = false;
            dgvsinhvien.Columns["STenLop"].HeaderText    = "Tên lớp";
        }
Esempio n. 12
0
        private void btnSort_Click(object sender, EventArgs e)
        {
            SinhVienBLL     sinhvienBLL = new SinhVienBLL();
            String          content     = comboBoxSort.Text;
            List <SinhVien> dssv        = sinhvienBLL.sortSinhVien(content);

            var sinhviens = dssv.Select(p => new { p.maSinhVien, p.tenSinhVien, p.ngaySinh, p.gioiTinh, p.diemTrungBinhTL, p.khoa.tenKhoa });

            dataGridView1.DataSource = sinhviens.ToList();
            for (int i = 0; i < dataGridView1.Rows.Count; i++)
            {
                dataGridView1.Rows[i].Cells["stt"].Value = (i + 1).ToString();
            }
        }
        private void btnSearchSV_Click(object sender, EventArgs e)
        {
            eSinhVien x = new SinhVienBLL().GetSinhVienByID(txtID.Text.Trim());

            if (x != null)
            {
                this.eSV    = x;
                txtTen.Text = x.HoVaTen.Trim();
            }
            else
            {
                MessageBox.Show("Sai mã sinh viên");
            }
        }
Esempio n. 14
0
 // xóa sinh viên
 private void btnxoasv_Click(object sender, EventArgs e)
 {
     try
     {
         string      _MSSV = tbxmssv.Text.Trim();
         SinhVienBLL SVBLL = new SinhVienBLL();
         SVBLL.Delete(_MSSV);
         LoadDataSinhVien();
     }
     catch (Exception ex)
     {
         MessageBox.Show("Xóa bị lỗi: " + ex.Message.ToString(), "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }
Esempio n. 15
0
        private void btnxoa_Click(object sender, EventArgs e)
        {
            if (txtmasv.Text == "")
            {
                MessageBox.Show("Hãy chọn sinh viên cần xóa.", "Thông báo!");
                return;
            }
            // Khởi tạo đối tượng sinh viên DTO
            HocSinhDTO svDTO = new HocSinhDTO();

            svDTO.IMaHS = int.Parse(txtmasv.Text);
            // Gọi lớp nghiệp vụ SinhVienBLL
            if (SinhVienBLL.XoaSinhVien(svDTO) == true)
            {
                MessageBox.Show("Xóa thành công.", "Thông báo!");
                // Load lại dữ liệu
                LoadSinhVien();
                return;
            }
            MessageBox.Show("Xóa thất bại.", "Thông báo!");
        }
Esempio n. 16
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            if (txtMaSinhVien.Text.Equals(""))
            {
                MessageBox.Show("Ban Chua Chon Doi Tuong Nao De Update");
                return;
            }
            SinhVienBLL sinhvienBLL = new SinhVienBLL();
            bool        rbGioiTinh;

            if (radioButtonMale.Checked)
            {
                rbGioiTinh = true;
            }
            else
            {
                rbGioiTinh = false;
            }

            SinhVien sinhvien = new SinhVien()
            {
                maSinhVien      = txtMaSinhVien.Text.ToString(),
                tenSinhVien     = txtTenSinhVien.Text.ToString(),
                ngaySinh        = Convert.ToDateTime(dateTimePickerNgaySinh.Text.ToString()),
                queQuan         = comboBoxQueQuan.Text.ToString(),
                hoKhau          = txtHoKhau.Text.ToString(),
                diemTrungBinhTL = (float)Convert.ToDouble(txtDiemTrungBinhTL.Text.ToString()),
                maKhoa          = comboBoxKhoa.SelectedValue.ToString(),
                gioiTinh        = rbGioiTinh
            };

            sinhvienBLL.updateSinhVien(sinhvien);
            loadSinhVien();

            txtDiemTrungBinhTL.Text = "";
            txtMaSinhVien.Text      = "";
            txtHoKhau.Text          = "";
            txtTenSinhVien.Text     = "";
            txtTimKiem.Text         = "";
        }
Esempio n. 17
0
 public frmSinhVien()
 {
     sinhVienBLL = new SinhVienBLL();
     dsSV        = new DataSet();
     InitializeComponent();
 }
Esempio n. 18
0
        private void LoadDataSinhVien()
        {
            SinhVienBLL Dt = new SinhVienBLL();

            dgvdsSV.DataSource = Dt.GetData();
        }
        public ActionResult Index()
        {
            HeDaoTaoBLL         contextHDT = new HeDaoTaoBLL();
            MonHocBLL           contextMH  = new MonHocBLL();
            ThoiKhoaBieuBLL     contextTKB = new ThoiKhoaBieuBLL();
            SinhVienBLL         contextSV  = new SinhVienBLL();
            SinhVien            sv         = contextSV.GetById(Session["MaSV"].ToString().Trim());
            SupportThoiKhoaBieu spTKB      = new SupportThoiKhoaBieu();
            List <SinhVien>     lstSV      = contextSV.GetAll();

            foreach (SinhVien sv1 in lstSV)
            {
                if (sv1.MaSV == sv.MaSV)
                {
                    sv = sv1;
                }
            }
            ViewData["MaLop"] = sv.MaLop;
            ViewData["HDT"]   = contextHDT.GetById(sv.Lop.MaHDT).TenHDT;
            ViewData["Khoa"]  = sv.Lop.NienKhoa;
            //sv.LopTinChis
            // lấy số tuần của năm và list ngày BD , KT của từng tuần lưu vào selectList
            Date          dt         = new Date();
            DateTime      dtNow      = DateTime.UtcNow;
            List <string> lstTuan    = dt.GetListDate(dtNow.Year);
            List <string> lstTuanNew = dt.GetListDate(dtNow.Year + 1);

            lstTuan.AddRange(lstTuanNew);
            //gán list các tuần vào selectList
            List <SelectListItem> weeks = lstTuan.Select(x => new SelectListItem()
            {
                Value = x, Text = x
            }).ToList();
            //Xem ngày hiện tại thuộc tuần nào trong năm
            int tuan = 0;

            for (int i = 0; i < lstTuan.Count; i++)
            {
                DateTime tempDTStart = new DateTime();
                DateTime tempDTEnd   = new DateTime();
                // Lấy datetime từ list Tuần và format về "dd/mm/yy"
                tempDTStart = DateTime.Parse(lstTuan[i].Split('-')[1], new CultureInfo("en-US"));
                tempDTEnd   = DateTime.Parse(lstTuan[i].Split('-')[3], new CultureInfo("en-US"));
                if (dtNow.DayOfYear >= tempDTStart.DayOfYear && dtNow.DayOfYear <= tempDTEnd.DayOfYear)
                {
                    tuan = i;
                    break;
                }
            }
            //Gán list tuần vào viewbag
            ViewBag.Weeks       = new SelectList(weeks, "Text", "Value", tuan);
            ViewBag.WeekCurrent = lstTuan[tuan];
            //lọc các lớp tín chỉ mở mới xem thời khóa biểu;
            LopTinChiBLL contextLTC = new LopTinChiBLL();

            sv.LopTinChis = contextLTC.GetListLTCOpen(sv.LopTinChis);
            //// lấy thời khóa biểu của tất cả các lớp mà sinh viên đã đăng ký cùng với môn học của lớp tín chỉ
            List <SupportThoiKhoaBieu> lstSPTKB = spTKB.GetListSPTKB(lstTuan[tuan], sv.LopTinChis);

            return(View(lstSPTKB));
        }