public static int UpdateStudent(Student Obj_Student_Update)
 {
     try
     {
         using (EducationalInstituteEntities db = new EducationalInstituteEntities())
         {
             //Lambda expression
             Student c = db.Students.SingleOrDefault(x => x.ID == Obj_Student_Update.ID);
             c.Name       = Obj_Student_Update.Name;
             c.FatherName = Obj_Student_Update.FatherName;
             c.Address    = Obj_Student_Update.Address;
             c.Email      = Obj_Student_Update.Email;
             c.Mobile     = Obj_Student_Update.Mobile;
             c.DOB        = Obj_Student_Update.DOB;
             c.CourseID   = Obj_Student_Update.CourseID;
             c.TeacherID  = Obj_Student_Update.TeacherID;
             db.SaveChanges();
             return(Obj_Student_Update.ID);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Пример #2
0
 public static void SaveTeachers(Teacher Obj_Teacher_Save)//This is Add method.
 {
     try
     {
         using (EducationalInstituteEntities db = new EducationalInstituteEntities())
         {
             db.Teachers.Add(Obj_Teacher_Save);
             db.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public static void SaveCourses(Course Obj_Course_Save)//This is Add method.
 {
     try
     {
         using (EducationalInstituteEntities db = new EducationalInstituteEntities())
         {
             db.Courses.Add(Obj_Course_Save);
             db.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public static void SaveStudents(Student Obj_Student_Save)//This is Add method.
 {
     try
     {
         using (EducationalInstituteEntities db = new EducationalInstituteEntities())
         {
             db.Students.Add(Obj_Student_Save);
             db.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        public static int UpdateCourse(Course Obj_Course_Update)
        {
            try
            {
                using (EducationalInstituteEntities db = new EducationalInstituteEntities())
                {
                    //Lambda expression

                    Course c = db.Courses.SingleOrDefault(x => x.ID == Obj_Course_Update.ID);
                    c.CourseName = Obj_Course_Update.CourseName;
                    db.SaveChanges();
                    return(Obj_Course_Update.ID);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #6
0
 public static void DeleteTeacher(string Obj_Teacher_Delete)
 {
     try
     {
         using (EducationalInstituteEntities db = new EducationalInstituteEntities())
         {
             //Lambda expression
             Teacher c = db.Teachers.SingleOrDefault(x => x.ID.ToString().Trim() == Obj_Teacher_Delete.Trim());
             if (c != null)
             {
                 db.Teachers.Remove(c);
                 db.SaveChanges();
             }
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Пример #7
0
        public static int UpdateTeacher(Teacher Obj_Teacher_Update)
        {
            try
            {
                using (EducationalInstituteEntities db = new EducationalInstituteEntities())
                {
                    //Lambda expression

                    Teacher c = db.Teachers.SingleOrDefault(x => x.ID == Obj_Teacher_Update.ID);
                    c.Name       = Obj_Teacher_Update.Name;
                    c.FatherName = Obj_Teacher_Update.FatherName;
                    c.Address    = Obj_Teacher_Update.Address;
                    c.Email      = Obj_Teacher_Update.Email;
                    c.Mobile     = Obj_Teacher_Update.Mobile;
                    db.SaveChanges();
                    return(Obj_Teacher_Update.ID);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }