Beispiel #1
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();
        }
Beispiel #2
0
        public NguoiDung DangNhap(string tenDangNhap, string matKhau)
        {
            NguoiDung nguoiDung = _nguoiDungRepository.FindByCondition(p => p.TenTaiKhoan.Equals(tenDangNhap) &&
                                                                       p.MatKhauHash.Equals(matKhau)).SingleOrDefault();

            return(nguoiDung);
        }
        public override bool Validate()
        {
            string  newNguoiDung = ControlToValidate.Text;
            TextBox textBox      = (TextBox)ControlToValidate;

            textBox.Undo();
            string oldNguoiDung = textBox.Text;

            textBox.Text = newNguoiDung;
            NguoiDungRepository nguoiDungRepository = new NguoiDungRepository();
            NguoiDung           tenTaiKhoang        = nguoiDungRepository.FindByCondition(p => p.TenTaiKhoan.Equals(newNguoiDung) && !p.TenTaiKhoan.Equals(oldNguoiDung)).SingleOrDefault();

            if (tenTaiKhoang != null)
            {
                return(false);
            }
            return(true);
        }