Exemple #1
0
        private void luyệnThiThửToolStripMenuItem_Click(object sender, EventArgs e)
        {
            HocSinh      hocSinh      = _hocSinhRepository.FindByCondition(p => p.NguoiDungID.Equals(_nguoiDung.IDNguoiDung)).SingleOrDefault();
            LuaChonKiThi luaChonKiThi = new LuaChonKiThi(hocSinh);

            luaChonKiThi.ShowDialog();
        }
Exemple #2
0
        private void btnThemHS_Click(object sender, EventArgs e)
        {
            if (_hocSinhRepository.FindByCondition(p => p.MaHS.Equals(txtMaHS.Text)).SingleOrDefault() != null)
            {
                MessageBox.Show("Mã học sinh này đã tồn tại", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (_nguoiDungRepository.FindByCondition(p => p.TenTaiKhoan.Equals(txtTenTaiKhoanHS.Text)).SingleOrDefault() != null)
            {
                MessageBox.Show("Tên tài khoản này đã tồn tại", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            NguoiDung nd = new NguoiDung();

            nd.TenTaiKhoan = txtTenTaiKhoanHS.Text;
            nd.MatKhauHash = txtMatKhauHS.Text;
            nd.Quyen       = 3;
            _nguoiDungRepository.Create(nd);
            _nguoiDungRepository.Update();

            HocSinh hs = new HocSinh();

            hs.MaHS        = txtMaHS.Text;
            hs.Lop         = txtLop.Text;
            hs.HoTen       = txtHoTenHS.Text;
            hs.DiaChi      = txtDiaChiHS.Text;
            hs.NgaySinh    = dtpNgaySinhHS.Value;
            hs.NguoiDungID = nd.IDNguoiDung;
            _hocSinhRepository.Create(hs);
            _hocSinhRepository.Update();
            LoadHocSinh();
        }
Exemple #3
0
        private void btnXoaHS_Click(object sender, EventArgs e)
        {
            string  oldHS       = dgvHocSinh.SelectedRows[0].Cells["MaHS"].Value.ToString();
            HocSinh hs          = _hocSinhRepository.FindByCondition(p => p.MaHS.Equals(oldHS)).Single();
            int     nguoiDungID = hs.NguoiDungID;

            _hocSinhRepository.Delete(hs);
            _hocSinhRepository.Update();

            NguoiDung nguoiDung = _nguoiDungRepository.FindByCondition(p => p.IDNguoiDung.Equals(nguoiDungID)).Single();

            _nguoiDungRepository.Delete(nguoiDung);
            _nguoiDungRepository.Update();

            LoadHocSinh();
        }
Exemple #4
0
        public void LoadThongTinHocSinh()
        {
            HocSinh hocSinh = new HocSinh();

            hocSinh = _hocSinhRepository.FindByCondition(p => p.NguoiDungID.Equals(_nguoiDung.IDNguoiDung)).SingleOrDefault();


            Binding bindingHoTen = new Binding("Text", hocSinh, "HoTen");

            lblHoTen.DataBindings.Add(bindingHoTen);
            Binding bindingLop = new Binding("Text", hocSinh, "Lop");

            lblLop.DataBindings.Add(bindingLop);
            Binding bindingMaHS = new Binding("Text", hocSinh, "MaHS");

            lblMaHS.DataBindings.Add(bindingMaHS);
            Binding bindingNgaySinh = new Binding("Text", hocSinh, "NgaySinh", true, DataSourceUpdateMode.OnPropertyChanged, true, "MM/dd/yyyy");

            lblNgaySinh.DataBindings.Add(bindingNgaySinh);
        }
Exemple #5
0
        private void btnSuaHS_Click(object sender, EventArgs e)
        {
            string oldHS = dgvHocSinh.SelectedRows[0].Cells["MaHS"].Value.ToString();

            if (oldHS != txtMaHS.Text)
            {
                MessageBox.Show("Không thể chỉnh sửa mã học sinh", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            HocSinh hs = _hocSinhRepository.FindByCondition(p => p.MaHS.Equals(oldHS)).Single();

            hs.MaHS     = txtMaHS.Text;
            hs.Lop      = txtLop.Text;
            hs.HoTen    = txtHoTenHS.Text;
            hs.DiaChi   = txtDiaChiHS.Text;
            hs.NgaySinh = dtpNgaySinhHS.Value;
            hs.NguoiDung.TenTaiKhoan = txtTenTaiKhoanHS.Text;
            hs.NguoiDung.MatKhauHash = txtMatKhauHS.Text;

            _hocSinhRepository.Update();
            LoadHocSinh();
        }