Exemple #1
0
        private void btnTK_Click(object sender, EventArgs e)
        {
            if (txtTK.Text != "")
            {
                DataLopHPDataContext db = new DataLopHPDataContext();
                var Lst = from hp in db.tblLopHPs
                          join gv in db.tblGiaoViens on hp.maGV equals gv.maGV
                          where hp.tenLHP.Contains(txtTK.Text)
                          select new
                {
                    maLHP = hp.maLHP,
                    hp.maHP,
                    maHK   = hp.maHK,
                    tenLHP = hp.tenLHP,
                    maGV   = gv.hoTen,
                    sSDK   = hp.sSDK,
                    sSMax  = hp.sSMax
                };

                dtgLopHP.DataSource = Lst.ToList();
            }
            else
            {
                LoadData();
            }
        }
Exemple #2
0
        private void LoadData()
        {
            DataLopHPDataContext db = new DataLopHPDataContext();
            var Lst = from hp in db.tblLopHPs
                      join gv in db.tblGiaoViens on hp.maGV equals gv.maGV
                      select new
            {
                maLHP = hp.maLHP,
                hp.maHP,
                maHK   = hp.maHK,
                tenLHP = hp.tenLHP,
                maGV   = gv.hoTen,
                sSDK   = hp.sSDK,
                sSMax  = hp.sSMax
            };

            dtgLopHP.DataSource = Lst.ToList();
            txtMaHK.DataBindings.Clear();
            txtMaHP.DataBindings.Clear();
            txtMaLHP.DataBindings.Clear();
            txtGV.DataBindings.Clear();
            txtSSDK.DataBindings.Clear();
            txtSSMax.DataBindings.Clear();
            txtTenLHP.DataBindings.Clear();
        }
Exemple #3
0
 private void btnXoa_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("Bạn có chắc chắn muốn xoá lớp học phần này?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
     {
         DataLopHPDataContext db = new DataLopHPDataContext();
         try
         {
             var r = from hp in db.tblLopHPs
                     where hp.maLHP.ToString().Contains(txtMaLHP.Text.ToString())
                     select hp;
             db.tblLopHPs.DeleteAllOnSubmit(r);
             db.SubmitChanges();
             LoadData();
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
         }
     }
 }
Exemple #4
0
 private void btnThem_Click(object sender, EventArgs e)
 {
     try
     {
         DataLopHPDataContext db = new DataLopHPDataContext();
         lhp.maHP   = txtMaHP.Text;
         lhp.maLHP  = txtMaLHP.Text;
         lhp.tenLHP = txtTenLHP.Text;
         lhp.maGV   = txtGV.Text;
         lhp.maHK   = int.Parse(txtMaHK.Text);
         lhp.sSMax  = int.Parse(txtSSMax.Text);
         lhp.sSDK   = int.Parse(txtSSDK.Text);
         db.tblLopHPs.InsertOnSubmit(lhp);
         db.SubmitChanges();
         MessageBox.Show("Đã thêm");
         LoadData();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Exemple #5
0
 private void btnSua_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("Bạn có muốn sửa lớp học phần này?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
     {
         try
         {
             DataLopHPDataContext db = new DataLopHPDataContext();
             lhp        = db.tblLopHPs.Where(s => s.maLHP == txtMaLHP.Text.ToString()).Single();
             lhp.maHP   = txtMaHP.Text;
             lhp.tenLHP = txtTenLHP.Text;
             lhp.maHK   = int.Parse(txtMaHK.Text);
             lhp.sSMax  = int.Parse(txtSSMax.Text);
             lhp.sSDK   = int.Parse(txtSSDK.Text);
             db.SubmitChanges();
             LoadData();
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
         }
     }
 }