Beispiel #1
0
        public void showDSGiaoVien()
        {
            BindingSource   source     = new BindingSource();
            List <GiaoVien> dsGiaoVien = new List <GiaoVien>();

            if (this.admin == 1)
            {
                dsGiaoVien        = GiaoVienController.GetListGiaoVien();
                source.DataSource = dsGiaoVien;
            }
            else
            {
                GiaoVien gv = GiaoVienController.GetGV(this.currentGiaoVien);
                dsGiaoVien.Add(gv);
                source.DataSource = dsGiaoVien;
            }
            GiaoVien giaoVienRong = new GiaoVien();

            cbGiaoVien.DisplayMember = "HoTen";
            cbGiaoVien.Items.Add(giaoVienRong);
            foreach (GiaoVien gv in dsGiaoVien)
            {
                cbGiaoVien.Items.Add(gv);
            }
        }
Beispiel #2
0
        private void btnThemmoi_Click(object sender, EventArgs e)
        {
            int dem = 0;

            if (this.txtMaGV.Text.Trim().Length <= 0)
            {
                this.errorProvider1.SetError(this.txtMaGV, "Phải nhập mã giáo viên");
                dem++;
            }
            else
            {
                this.errorProvider1.SetError(this.txtMaGV, null);
            }
            if (this.txtHoTenGV.Text.Trim().Length <= 0)
            {
                this.errorProvider2.SetError(this.txtHoTenGV, "Phải nhập tên Giáo viên");
                dem++;
            }
            else
            {
                this.errorProvider2.SetError(this.txtHoTenGV, null);
            }
            if (this.txtEmailGV.Text.Trim().Length <= 0)
            {
                this.errorProvider3.SetError(this.txtEmailGV, "Phải nhập Email Giáo viên");
                dem++;
            }
            else
            {
                this.errorProvider3.SetError(this.txtEmailGV, null);
            }
            if (dem != 0)
            {
                return;
            }
            GiaoVien gv = new GiaoVien();

            gv.MaGV    = this.txtMaGV.Text.Trim();
            gv.TenGV   = this.txtHoTenGV.Text.Trim();
            gv.EmailGV = this.txtEmailGV.Text.Trim();
            if (GiaoVienController.AddGV(gv) == false)
            {
                MessageBox.Show("Mã giáo viên bị trùng");
                return;
            }
            GiaoVienController.AddGV(gv);
            BindingSource source = new BindingSource();

            source.DataSource             = GiaoVienController.GetGV();
            this.dataGridView1.DataSource = source;
        }
 public void showGV()
 {
     if (this.admin == 1)
     {
         BindingSource source = new BindingSource();
         source.DataSource          = GiaoVienController.GetListGiaoVien();
         this.dgvTeacher.DataSource = source;
     }
     else
     {
         BindingSource source = new BindingSource();
         source.DataSource          = GiaoVienController.GetGV(currentGiaoVien);
         this.dgvTeacher.DataSource = source;
     }
 }
Beispiel #4
0
        private void btnXoa_Click(object sender, EventArgs e)
        {
            if (this.dataGridView1.SelectedRows.Count <= 0)
            {
                MessageBox.Show("Hãy chọn dòng cần xóa!");
                return;
            }

            GiaoVien giaoVien = GiaoVienController.getGV(this.dataGridView1.SelectedRows[0].Cells[0].Value.ToString());

            GiaoVienController.DeleteGV(giaoVien);
            //Hiển thị
            BindingSource source = new BindingSource();

            source.DataSource             = GiaoVienController.GetGV();
            this.dataGridView1.DataSource = source;
        }
Beispiel #5
0
        public frmGiaoVien()
        {
            InitializeComponent();
            this.cMaGV.DataPropertyName  = nameof(GiaoVien.MaGV);
            this.cTenGV.DataPropertyName = nameof(GiaoVien.TenGV);
            this.cEmail.DataPropertyName = nameof(GiaoVien.EmailGV);
            this.helpProvider1.SetShowHelp(this.txtMaGV, true);
            this.helpProvider1.SetHelpString(this.txtMaGV, "Nhap Ma Giao Vien!");
            this.helpProvider1.SetShowHelp(this.txtHoTenGV, true);
            this.helpProvider1.SetHelpString(this.txtHoTenGV, "Nhap ho ten giao vien!");
            this.helpProvider1.SetShowHelp(this.txtEmailGV, true);
            this.helpProvider1.SetHelpString(this.txtEmailGV, "Nhap Email giao vien!");
            BindingSource source = new BindingSource();

            source.DataSource             = GiaoVienController.GetGV();
            this.dataGridView1.DataSource = source;
        }
        private void dgvTeacher_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (dgvTeacher.CurrentCell.ColumnIndex != 0)
            {
                return;
            }
            this.currentIDGV = Int32.Parse(dgvTeacher.CurrentRow.Cells[0].Value.ToString());
            GiaoVien task = GiaoVienController.GetGV(this.currentIDGV);

            this.txtEmail.Text        = task.Email.Trim();
            this.txtName.Text         = task.HoTen.Trim();
            this.Birthday.Value       = DateTime.Parse(task.NgaySinh.ToString());
            this.txtSDT.Text          = task.SDT.Trim();
            this.cbBomon.SelectedItem = task.BoMon.Trim();
            this.cbSex.SelectedItem   = task.GioiTinh.Trim();
            this.txtusername.Text     = task.username.Trim();
            this.txtpass.Text         = task.pass.Trim();
        }
Beispiel #7
0
        private void btnSua_Click(object sender, EventArgs e)
        {
            int dem = 0;

            if (this.txtMaGV.Text.Trim().Length <= 0)
            {
                this.errorProvider1.SetError(this.txtMaGV, "Phải nhập mã giáo viên");
                dem++;
            }
            else
            {
                this.errorProvider1.SetError(this.txtMaGV, null);
            }
            if (this.txtHoTenGV.Text.Trim().Length <= 0)
            {
                this.errorProvider2.SetError(this.txtHoTenGV, "Phải nhập tên Giáo viên");
                dem++;
            }
            else
            {
                this.errorProvider2.SetError(this.txtHoTenGV, null);
            }
            if (this.txtEmailGV.Text.Trim().Length <= 0)
            {
                this.errorProvider3.SetError(this.txtEmailGV, "Phải nhập Email Giáo viên");
                dem++;
            }
            else
            {
                this.errorProvider3.SetError(this.txtEmailGV, null);
            }
            if (dem != 0)
            {
                return;
            }
            if (flag == true)
            {
                try
                {
                    this.dataGridView1.SelectedCells[0].Value = this.txtMaGV.Text.Trim();
                    this.dataGridView1.SelectedCells[1].Value = this.txtHoTenGV.Text.Trim();
                    this.dataGridView1.SelectedCells[2].Value = this.txtEmailGV.Text.Trim();
                }
                catch
                {
                    MessageBox.Show("Hãy nhấn vào ô trống đầu tiên của mỗi dòng để chọn dòng cần cập nhật!");
                    return;
                }
            }
            GiaoVien gv = new GiaoVien();

            gv.MaGV    = this.txtMaGV.Text.Trim();
            gv.TenGV   = this.txtHoTenGV.Text.Trim();
            gv.EmailGV = this.txtEmailGV.Text.Trim();
            //update
            GiaoVienController.UpdateGV(gv);
            //hiển thị
            BindingSource source = new BindingSource();

            source.DataSource             = GiaoVienController.GetGV();
            this.dataGridView1.DataSource = source;
        }