public void checkTeacher() { int tid = Convert.ToInt32(txtLibTeacherId.Text); var teacher = lbManageEntity.tbl_TeacherLogin.Where(x => x.TeacherId == tid).FirstOrDefault(); if (teacher != null) { lbManageEntity.AddTotbl_TeacherLogin(teacherLib); lbManageEntity.SaveChanges(); CleanAll(); } else { lblMessafe.Text = "Incorrect Teacher ID Pleace cofirm your id"; } }