コード例 #1
0
 private void btnThem_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
 {
     if (gvMain.GetFocusedRowCellValue("ID") == null)
     {
     }
     else
     {
         int?idsv = (int)gvMain.GetFocusedRowCellValue("ID");
         if (idsv == null)
         {
             return;
         }
         if ((from a in db.SinhVien_LopMonHocs where a.IDSinhVien == (int)idsv && a.IDLopMonHoc == ID select a).Count() > 0)
         {
             return;
         }
         SinhVien_LopMonHoc obj = new SinhVien_LopMonHoc();
         obj.IDSinhVien  = idsv;
         obj.IDLopMonHoc = ID;
         db.SinhVien_LopMonHocs.InsertOnSubmit(obj);
         try
         {
             db.SubmitChanges();
         }
         catch (Exception)
         {}
         loadMain();
     }
 }
コード例 #2
0
        private void btnLoai_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            int idsv = (int)gvMain.GetFocusedRowCellValue("ID");

            if ((from a in db.SinhVien_LopMonHocs where a.IDSinhVien == (int)idsv && a.IDLopMonHoc == ID select a).Count() == 0)
            {
                return;
            }
            SinhVien_LopMonHoc obj = (from a in db.SinhVien_LopMonHocs where a.IDSinhVien == (int)idsv && a.IDLopMonHoc == ID select a).Single();

            db.SinhVien_LopMonHocs.DeleteOnSubmit(obj);
            try
            {
                db.SubmitChanges();
            }
            catch (Exception)
            { }
            loadMain();
        }