コード例 #1
0
        public ActionResult Grades(grades obj, HttpPostedFileBase gradefile)
        {
            try
            {
                string PhotoPath      = Server.MapPath("~/Docs/Images/");
                string PhotoName      = Guid.NewGuid() + Path.GetFileName(gradefile.FileName); //3l4an lw atb3t tokins m3 asm l swra y4lha
                string FinalPhotoPath = Path.Combine(PhotoPath, PhotoName);
                gradefile.SaveAs(FinalPhotoPath);
                if (ModelState.IsValid)
                {
                    obj.gradefile = PhotoName;
                    db.grades.Add(obj);
                    db.SaveChanges();
                    ModelState.Clear();
                    return(RedirectToAction("Attendance"));
                }
                return(View(obj));
            }

            catch (Exception ex)
            {
                ViewBag.GradeType = new SelectList(db.gradetype, "id", "TypeOfGrade");
                return(View(obj));
            }
        }
コード例 #2
0
        /// <summary>
        /// edit the student details against id
        /// </summary>
        /// <param name="id">contained a filed of id</param>
        /// <param name="student">contained a filed of students model</param>
        /// <returns></returns>
        public HttpResponseMessage PutStudent(int id, Student student)
        {
            if (ModelState.IsValid && id == student.studentID)
            {
                db.Entry(student).State = EntityState.Modified;
                try
                {
                    db.SaveChanges();
                }

                catch (DbUpdateConcurrencyException)

                {
                    return(Request.CreateResponse(HttpStatusCode.NotFound));
                }

                return(Request.CreateResponse(HttpStatusCode.OK));
            }

            else

            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }
        }
コード例 #3
0
 internal static int DeleteAllRoomsInSchool(int schoolID)
 {
     using (schoolEntities dbContext = new schoolEntities())
     {
         dbContext.Rooms.RemoveRange(dbContext.Rooms.Where(f => f.SchoolId == schoolID));
         dbContext.SaveChanges();
         return(dbContext.SaveChanges());
     }
 }
コード例 #4
0
        public ActionResult Create([Bind(Include = "id_class,class_name")] Class @class)
        {
            if (ModelState.IsValid)
            {
                db.Classes.Add(@class);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(@class));
        }
コード例 #5
0
        public ActionResult Create([Bind(Include = "id_teacher,fio,specialty")] Teacher teacher)
        {
            if (ModelState.IsValid)
            {
                db.Teachers.Add(teacher);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(teacher));
        }
コード例 #6
0
        public ActionResult Create([Bind(Include = "id,name,year")] subject subject)
        {
            if (ModelState.IsValid)
            {
                db.subject.Add(subject);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(subject));
        }
コード例 #7
0
        public ActionResult Create([Bind(Include = "id,fio,specialism,r_date,v_date")] teacher teacher)
        {
            if (ModelState.IsValid)
            {
                db.teacher.Add(teacher);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(teacher));
        }
コード例 #8
0
        public ActionResult Create([Bind(Include = "id,fio,id_class,p_year")] disciple disciple)
        {
            if (ModelState.IsValid)
            {
                db.disciple.Add(disciple);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.id_class = new SelectList(db.classrooms, "id", "name", disciple.id_class);
            return(View(disciple));
        }
コード例 #9
0
        public ActionResult Create([Bind(Include = "id,name,y_year,id_teacher")] classrooms classrooms)
        {
            if (ModelState.IsValid)
            {
                db.classrooms.Add(classrooms);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.id_teacher = new SelectList(db.teacher, "id", "fio", classrooms.id_teacher);
            return(View(classrooms));
        }
コード例 #10
0
        public ActionResult Create([Bind(Include = "id_student,fio,id_class")] Student student)
        {
            if (ModelState.IsValid)
            {
                db.Students.Add(student);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.id_class = new SelectList(db.Classes, "id_class", "class_name", student.id_class);
            return(View(student));
        }
コード例 #11
0
        public ActionResult Create([Bind(Include = "id,id_subject,id_teacher,cabinet,time")] schedule schedule)
        {
            if (ModelState.IsValid)
            {
                db.schedule.Add(schedule);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.id_subject = new SelectList(db.subject, "id", "name", schedule.id_subject);
            ViewBag.id_teacher = new SelectList(db.teacher, "id", "fio", schedule.id_teacher);
            return(View(schedule));
        }
コード例 #12
0
        public ActionResult Create([Bind(Include = "id_journal,id_lesson,grade,id_student")] Journal journal)
        {
            if (ModelState.IsValid)
            {
                db.Journals.Add(journal);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.id_lesson  = new SelectList(db.Lessons, "id_lesson", "id_lesson", journal.id_lesson);
            ViewBag.id_student = new SelectList(db.Students, "id_student", "fio", journal.id_student);
            return(View(journal));
        }
コード例 #13
0
        public ActionResult Create([Bind(Include = "id_lesson,id_subject,id_class,id_teacher,data")] Lesson lesson)
        {
            if (ModelState.IsValid)
            {
                db.Lessons.Add(lesson);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.id_class   = new SelectList(db.Classes, "id_class", "class_name", lesson.id_class);
            ViewBag.id_subject = new SelectList(db.Subjects, "id_subject", "subject_name", lesson.id_subject);
            ViewBag.id_teacher = new SelectList(db.Teachers, "id_teacher", "fio", lesson.id_teacher);
            return(View(lesson));
        }
コード例 #14
0
 public ActionResult Report(reports obj)
 {
     try
     {
         if (ModelState.IsValid)
         {
             db.reports.Add(obj);
             db.SaveChanges();
             ModelState.Clear();
             return(View());
         }
         return(View(obj));
     }
     catch (Exception ex)
     {
         return(View(obj));
     }
 }
コード例 #15
0
 // Method to modify a school name
 internal static int ModifySchoolName(int id, string newName)
 {
     using (schoolEntities dbContext = new schoolEntities())
     {
         Schools renamedSchool = dbContext.Schools.FirstOrDefault(f => f.Id == id);
         renamedSchool.Name = newName;
         return(dbContext.SaveChanges());
     }
 }
コード例 #16
0
 internal static int DeleteRoomByName(int schoolID, string roomName)
 {
     using (schoolEntities dbContext = new schoolEntities())
     {
         Rooms roomToDelete;
         roomToDelete = dbContext.Rooms.FirstOrDefault(f => f.SchoolId == schoolID && f.Number == roomName);
         dbContext.Rooms.Remove(roomToDelete);
         return(dbContext.SaveChanges());
     }
 }
コード例 #17
0
 internal static int ModifyRoomName(int schoolID, int roomID, string newRoomName)
 {
     using (schoolEntities dbContext = new schoolEntities())
     {
         Rooms roomToRename;
         roomToRename        = dbContext.Rooms.FirstOrDefault(f => f.SchoolId == schoolID && f.Id == roomID);
         roomToRename.Number = newRoomName;
         return(dbContext.SaveChanges());
     }
 }
コード例 #18
0
 internal static int InsertRoom(int schoolID, string roomName)
 {
     using (schoolEntities dbContext = new schoolEntities())
     {
         dbContext.Rooms.Add(new Rooms {
             SchoolId = schoolID, Number = roomName
         });
         return(dbContext.SaveChanges());
     }
 }
コード例 #19
0
 // Method to insert a school in DB
 internal static int InsertSchool(string name)
 {
     using (schoolEntities dbContext = new schoolEntities())
     {
         dbContext.Schools.Add(new Schools {
             Name = name
         });
         return(dbContext.SaveChanges());
     }
 }
コード例 #20
0
 // Method to delete a school by ID
 internal static int DeleteSchool(int id)
 {
     using (schoolEntities dbContext = new schoolEntities())
     {
         Schools deletedSchool;
         deletedSchool = dbContext.Schools.FirstOrDefault(f => f.Id == id);
         dbContext.Schools.Remove(deletedSchool);
         return(dbContext.SaveChanges());
     }
 }
コード例 #21
0
 // Method to delete a school by Name
 internal static int DeleteSchool(string name)
 {
     using (schoolEntities dbContext = new schoolEntities())
     {
         Schools deletedSchool = new Schools();
         deletedSchool = dbContext.Schools.FirstOrDefault(f => f.Name == name);
         dbContext.Schools.Remove(deletedSchool);
         return(dbContext.SaveChanges());
     }
 }
コード例 #22
0
 public ActionResult AdminRegistration(admin ad)
 {
     try
     {
         if (ModelState.IsValid)
         {
             db.Configuration.ProxyCreationEnabled = false;
             db.admin.Add(ad);
             Membership.CreateUser(ad.email, ad.pass);
             //Roles.AddUserToRole(ad.email, "AdminRole");
             db.SaveChanges();
             ModelState.Clear();
             return(RedirectToAction("Login", "Account"));
         }
         return(View());
     }
     catch (Exception ex)
     {
         return(View(ad));
     }
 }
コード例 #23
0
        public ActionResult Course(course obj)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    db.course.Add(obj);
                    db.SaveChanges();
                    ModelState.Clear();
                    return(RedirectToAction("HomeWork"));
                }
                ViewBag.CourseSemester = new SelectList(db.Schoolsemester, "id", "semester");

                return(View(obj));
            }
            catch (Exception ex)
            {
                ViewBag.CourseSemester = new SelectList(db.Schoolsemester, "id", "semester");
                return(View(obj));
            }
        }
コード例 #24
0
 private void SaveB_Click(object sender, RoutedEventArgs e)
 {
     _db.SaveChanges();
 }