Пример #1
0
        private void btnSuaGV_Click(object sender, EventArgs e)
        {
            string oldGV = dgvGiaoVien.SelectedRows[0].Cells["MaGV"].Value.ToString();

            if (oldGV != txtMaGV.Text)
            {
                MessageBox.Show("Không thể chỉnh sửa mã giáo viên", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            GiaoVien gv = _giaoVienRepository.FindByCondition(p => p.MaGV.Equals(oldGV)).Single();

            gv.MaGV     = txtMaGV.Text;
            gv.HoTen    = txtHoTen.Text;
            gv.DiaChi   = txtDiaChi.Text;
            gv.NgaySinh = dtpNgaySinh.Value;
            gv.NguoiDung.TenTaiKhoan = txtTenTaiKhoan.Text;
            gv.NguoiDung.MatKhauHash = txtMatKhau.Text;

            _giaoVienRepository.Update();
            LoadGiaoVien();
        }
        public void LoadThongTinGiaoVien()
        {
            GiaoVien giaoVien = new GiaoVien();

            giaoVien = _giaoVienRepository.FindByCondition(p => p.NguoiDungID.Equals(_nguoiDung.IDNguoiDung)).SingleOrDefault();
            Binding binding = new Binding("Text", giaoVien, "HoTen");
            Binding bdmaGv  = new Binding("Text", giaoVien, "MaGV");
            Binding bdDchi  = new Binding("Text", giaoVien, "DiaChi");
            Binding bdNsgv  = new Binding("Text", giaoVien, "NgaySinh", true, DataSourceUpdateMode.OnPropertyChanged, true, "MM/dd/yyyy");

            lblHoTenGv.DataBindings.Add(binding);
            lblMaGV.DataBindings.Add(bdmaGv);
            lbDchiGv.DataBindings.Add(bdDchi);
            lblNsGv.DataBindings.Add(bdNsgv);
        }
Пример #3
0
        public override bool Validate()
        {
            string  newMaGV = ControlToValidate.Text;
            TextBox textBox = (TextBox)ControlToValidate;

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

            textBox.Text = newMaGV;
            GiaoVienRepository giaoVienRepository = new GiaoVienRepository();
            GiaoVien           giaoVien           = giaoVienRepository.FindByCondition(p => p.MaGV.Equals(newMaGV) && !p.MaGV.Equals(oldMaGV)).SingleOrDefault();

            if (giaoVien != null)
            {
                return(false);
            }
            return(true);
        }
Пример #4
0
        public GiaoVien LayThongTinGiaoVien(int idNguoiDung)
        {
            GiaoVienRepository giaoVienRepository = new GiaoVienRepository();

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