Ejemplo n.º 1
0
        public bool Delete(tblGIANG_VIEN model)
        {
            tblGIANG_VIEN dbEntry = context.tblGIANG_VIEN.Find(model.MaGV);

            if (dbEntry == null)
            {
                return(false);
            }
            context.tblGIANG_VIEN.Remove(dbEntry);
            context.SaveChanges();
            return(true);
        }
Ejemplo n.º 2
0
        public bool Insert(tblGIANG_VIEN model)
        {
            tblGIANG_VIEN dbEntry = context.tblGIANG_VIEN.Find(model.MaGV);

            if (dbEntry != null)
            {
                return(false);
            }
            context.tblGIANG_VIEN.Add(model);
            context.SaveChanges();
            return(true);
        }
Ejemplo n.º 3
0
        private void button3_Click(object sender, EventArgs e)
        {
            tblGIANG_VIEN g  = new tblGIANG_VIEN();
            GIANGVIENF    f  = new GIANGVIENF();
            string        id = txtMaGV.Text.Trim();

            if (MessageBox.Show(string.Format("Xóa giảng viên có mã '{0}'?", id), "", MessageBoxButtons.OKCancel) == DialogResult.OK)
            {
                g.MaGV       = txtMaGV.Text;
                g.TenGV      = txtHoTen.Text;
                g.Phone      = txtPhone.Text;
                g.NgaySInh   = dateNgaySinh.Value;
                g.PhanLoaiGV = cboPhanloai.Text;
                g.GioiTinh   = cboGioiTinh.Text;
                g.Email      = txtEmail.Text;
                f.Delete(g);
                dgrDSGV.DataSource = context.tblGIANG_VIEN.ToList();
            }
        }
Ejemplo n.º 4
0
        public bool Update(tblGIANG_VIEN model)
        {
            tblGIANG_VIEN dbEntry = context.tblGIANG_VIEN.Find(model.MaGV);

            if (dbEntry == null)
            {
                return(false);
            }
            dbEntry.MaGV       = model.MaGV;
            dbEntry.TenGV      = model.TenGV;
            dbEntry.NgaySInh   = model.NgaySInh;
            dbEntry.GioiTinh   = model.GioiTinh;
            dbEntry.Phone      = model.Phone;
            dbEntry.Email      = model.Email;
            dbEntry.PhanLoaiGV = model.PhanLoaiGV;


            context.SaveChanges();
            return(true);
        }
Ejemplo n.º 5
0
        private void button1_Click(object sender, EventArgs e)
        {
            GIANGVIENF    f = new GIANGVIENF();
            tblGIANG_VIEN g = new tblGIANG_VIEN();

            if (txtMaGV.Text.Trim() == "")
            {
                MessageBox.Show("Chưa nhập mã giảng viên", "Thông báo");
            }
            else
            {
                if (context.tblGIANG_VIEN.Find(txtMaGV.Text.Trim()) != null)
                {
                    MessageBox.Show("Mã giảng viên đã  tồn tại", "Thông báo");
                }
                else
                {
                    g.MaGV       = txtMaGV.Text;
                    g.TenGV      = txtHoTen.Text;
                    g.Phone      = txtPhone.Text;
                    g.NgaySInh   = dateNgaySinh.Value;
                    g.PhanLoaiGV = cboPhanloai.Text;
                    g.GioiTinh   = cboGioiTinh.Text;
                    g.Email      = txtEmail.Text;

                    f.Insert(g);

                    //dgrDSGV.DataSource = context.tblGIANG_VIEN.ToList();
                    dgrDSGV.DataSource = context.tblGIANG_VIEN.ToList();
                    txtMaGV.Clear();
                    txtHoTen.Clear();
                    txtEmail.Clear();
                    txtPhone.Clear();
                    cboGioiTinh.Text = "";
                    cboPhanloai.Text = "";
                }
            }
        }
Ejemplo n.º 6
0
        public tblGIANG_VIEN FindEntity(string ID)
        {
            tblGIANG_VIEN dbEntry = context.tblGIANG_VIEN.Find(ID);

            return(dbEntry);
        }