Example #1
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);
        }
Example #2
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();
        }
Example #3
0
        public override bool Validate()
        {
            string  newMaHS = ControlToValidate.Text;
            TextBox textBox = (TextBox)ControlToValidate;

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

            textBox.Text = newMaHS;
            HocSinhRepository hocSinhRepository = new HocSinhRepository();
            HocSinh           hocSinh           = hocSinhRepository.FindByCondition(p => p.MaHS.Equals(newMaHS) && !p.MaHS.Equals(oldMaHS)).SingleOrDefault();

            if (hocSinh != null)
            {
                return(false);
            }
            return(true);
        }
Example #4
0
        public HocSinh LayThongTinHocSinh(int idNguoiDung)
        {
            HocSinhRepository hocSinhRepository = new HocSinhRepository();

            return(hocSinhRepository.FindByCondition(p => p.NguoiDungID.Equals(idNguoiDung)).Single());
        }